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
hooks:
- id: prettier
- repo: https://github.com/dudefellah/pre-commit-openapi
rev: "v0.0.1"
hooks:
- id: check-openapi
- repo: local
hooks:
- id: tsc

View file

@ -4,7 +4,6 @@ UI_DIR=./ui
VERSION=$(shell git tag --sort=-version:refname | head -n 1)
setup:
go get -t ./src/...
cd ${UI_DIR} && pnpm install
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/.
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:
title: SEBRAUC
version: "0.0.1"
version: 0.1.0
description: REST API for the SEBRAUC firmware updater
servers:
- url: http://localhost:8080/api
paths:
/status:
get:
operationId: getStatus
responses:
"200":
200:
description: OK
content:
"application/json":
application/json:
schema:
$ref: "#/components/schemas/RaucStatus"
default:
description: "Server error"
description: Server error
content:
"application/json":
application/json:
schema:
$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:
post:
operationId: startUpdate
requestBody:
content:
multipart/form-data:
@ -32,32 +53,33 @@ paths:
type: string
format: binary
responses:
"200":
description: "OK"
200:
description: OK
content:
"application/json":
application/json:
schema:
$ref: "#/components/schemas/StatusMessage"
default:
description: "Server error"
description: Server error
content:
"application/json":
application/json:
schema:
$ref: "#/components/schemas/StatusMessage"
/reboot:
post:
operationId: startReboot
responses:
"200":
description: "OK"
200:
description: OK
content:
"application/json":
application/json:
schema:
$ref: "#/components/schemas/StatusMessage"
default:
description: "Server error"
description: Server error
content:
"application/json":
application/json:
schema:
$ref: "#/components/schemas/StatusMessage"
@ -67,23 +89,23 @@ components:
type: object
properties:
installing:
description: "True if the installer is running"
description: True if the installer is running
type: boolean
percent:
description: "Installation progress"
description: Installation progress
type: integer
minimum: 0
maximum: 100
message:
description: "Current installation step"
description: Current installation step
type: string
example: "Copying image to rootfs.0"
example: Copying image to rootfs.0
last_error:
description: "Installation error message"
description: Installation error message
type: string
example: "Failed to check bundle identifier: Invalid identifier. Did you pass a valid RAUC bundle?"
log:
description: "Full command line output of the current installation"
description: Full command line output of the current installation
type: string
example: "0% Installing\n0% Determining slot states\n20% Determining slot states done.\n"
required:
@ -93,15 +115,77 @@ components:
- last_error
- 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:
type: object
properties:
success:
description: "Is operation successful"
description: Is operation successful
type: boolean
msg:
description: "Success message"
description: Success message
type: string
example: "Update started"
example: Update started
required:
- msg

View file

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