Compare commits

..

2 commits

Author SHA1 Message Date
3e29e04ac3 Add system info api definition
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-12-02 20:29:47 +01:00
8c1fd2a6ab Fix makefile 2021-12-02 20:29:47 +01:00
8 changed files with 119 additions and 27 deletions

View file

@ -10,6 +10,11 @@ repos:
rev: v2.4.1 rev: v2.4.1
hooks: hooks:
- id: prettier - id: prettier
- repo: https://github.com/dudefellah/pre-commit-openapi
rev: "v0.0.1"
hooks:
- id: check-openapi
- repo: local - repo: local
hooks: hooks:
- id: tsc - id: tsc

View file

@ -4,7 +4,6 @@ UI_DIR=./ui
VERSION=$(shell git tag --sort=-version:refname | head -n 1) VERSION=$(shell git tag --sort=-version:refname | head -n 1)
setup: setup:
go get -t ./src/...
cd ${UI_DIR} && pnpm install cd ${UI_DIR} && pnpm install
test: test:
@ -17,3 +16,7 @@ build-server:
go build -tags prod -ldflags "-s -w -X code.thetadev.de/TSGRain/SEBRAUC/src/util.version=${VERSION}" -o build/sebrauc ./src/. go build -tags prod -ldflags "-s -w -X code.thetadev.de/TSGRain/SEBRAUC/src/util.version=${VERSION}" -o build/sebrauc ./src/.
build: build-ui build-server build: build-ui build-server
clean:
rm -f build/*
rm -rf ${UI_DIR}/dist/**

View file

@ -1,27 +1,48 @@
openapi: "3.0.3" openapi: 3.0.3
info: info:
title: SEBRAUC title: SEBRAUC
version: "0.0.1" version: 0.1.0
description: REST API for the SEBRAUC firmware updater
servers: servers:
- url: http://localhost:8080/api - url: http://localhost:8080/api
paths: paths:
/status: /status:
get: get:
operationId: getStatus
responses: responses:
"200": 200:
description: OK description: OK
content: content:
"application/json": application/json:
schema: schema:
$ref: "#/components/schemas/RaucStatus" $ref: "#/components/schemas/RaucStatus"
default: default:
description: "Server error" description: Server error
content: content:
"application/json": application/json:
schema: schema:
$ref: "#/components/schemas/StatusMessage" $ref: "#/components/schemas/StatusMessage"
/info:
get:
operationId: getInfo
responses:
200:
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/SystemInfo"
default:
description: Server error
content:
application/json:
schema:
$ref: "#/components/schemas/StatusMessage"
/update: /update:
post: post:
operationId: startUpdate
requestBody: requestBody:
content: content:
multipart/form-data: multipart/form-data:
@ -32,32 +53,33 @@ paths:
type: string type: string
format: binary format: binary
responses: responses:
"200": 200:
description: "OK" description: OK
content: content:
"application/json": application/json:
schema: schema:
$ref: "#/components/schemas/StatusMessage" $ref: "#/components/schemas/StatusMessage"
default: default:
description: "Server error" description: Server error
content: content:
"application/json": application/json:
schema: schema:
$ref: "#/components/schemas/StatusMessage" $ref: "#/components/schemas/StatusMessage"
/reboot: /reboot:
post: post:
operationId: startReboot
responses: responses:
"200": 200:
description: "OK" description: OK
content: content:
"application/json": application/json:
schema: schema:
$ref: "#/components/schemas/StatusMessage" $ref: "#/components/schemas/StatusMessage"
default: default:
description: "Server error" description: Server error
content: content:
"application/json": application/json:
schema: schema:
$ref: "#/components/schemas/StatusMessage" $ref: "#/components/schemas/StatusMessage"
@ -67,23 +89,23 @@ components:
type: object type: object
properties: properties:
installing: installing:
description: "True if the installer is running" description: True if the installer is running
type: boolean type: boolean
percent: percent:
description: "Installation progress" description: Installation progress
type: integer type: integer
minimum: 0 minimum: 0
maximum: 100 maximum: 100
message: message:
description: "Current installation step" description: Current installation step
type: string type: string
example: "Copying image to rootfs.0" example: Copying image to rootfs.0
last_error: last_error:
description: "Installation error message" description: Installation error message
type: string type: string
example: "Failed to check bundle identifier: Invalid identifier. Did you pass a valid RAUC bundle?" example: "Failed to check bundle identifier: Invalid identifier. Did you pass a valid RAUC bundle?"
log: log:
description: "Full command line output of the current installation" description: Full command line output of the current installation
type: string type: string
example: "0% Installing\n0% Determining slot states\n20% Determining slot states done.\n" example: "0% Installing\n0% Determining slot states\n20% Determining slot states done.\n"
required: required:
@ -93,15 +115,77 @@ components:
- last_error - last_error
- log - log
SystemInfo:
type: object
properties:
os_name:
description: Name of the os distribution
type: string
example: "Poky"
os_version:
description: Operating system version
type: string
example: "1.0.2"
uptime:
description: System uptime in seconds
type: integer
example: 5832
rauc_compatible:
description: Compatible firmware name
type: string
example: "Poky"
rauc_variant:
description: Compatible firmware variant
type: string
example: "rpi-prod"
rauc_booted:
description: Currently booted rootfs
type: string
example: "rootfs.0"
rauc_boot_primary:
description: Primary rootfs to boot from
type: string
example: "rootfs.1"
rauc_rootfs:
description: List of RAUC root filesystems
type: object
additionalProperties:
$ref: "#/components/schemas/RaucFS"
RaucFS:
type: object
properties:
device:
description: Block device
type: string
example: "/dev/mmcblk0p2"
type:
description: Filesystem
type: string
example: ext4
state:
description: Current state of filesystem
type: string
enum: [active, inactive, booted]
example: booted
mountpoint:
description: Mount path (null when not mounted)
type: string
nullable: true
example: "/"
bootable:
description: "Is the filesystem bootable"
type: boolean
StatusMessage: StatusMessage:
type: object type: object
properties: properties:
success: success:
description: "Is operation successful" description: Is operation successful
type: boolean type: boolean
msg: msg:
description: "Success message" description: Success message
type: string type: string
example: "Update started" example: Update started
required: required:
- msg - msg

View file

@ -1,5 +1,5 @@
import {Component} from "preact" import {Component} from "preact"
import Updater from "./Upload/Updater" import Updater from "./Updater/Updater"
import logo from "../assets/logo.svg" import logo from "../assets/logo.svg"
import {version} from "../util/version" import {version} from "../util/version"