From 8c1fd2a6ab84de502078aff03d125e694c27661c Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Sun, 21 Nov 2021 23:37:24 +0100 Subject: [PATCH 1/2] Fix makefile --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ed465a0..9861398 100644 --- a/Makefile +++ b/Makefile @@ -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/** From 3e29e04ac3266629f3d6578e6e72917235129c01 Mon Sep 17 00:00:00 2001 From: Theta-Dev Date: Thu, 2 Dec 2021 20:29:20 +0100 Subject: [PATCH 2/2] Add system info api definition --- .pre-commit-config.yaml | 5 + openapi.yml | 134 ++++++++++++++---- .../components/{Upload => Updater}/Alert.tsx | 0 .../components/{Upload => Updater}/Reboot.tsx | 0 .../{Upload => Updater}/Updater.scss | 0 .../{Upload => Updater}/Updater.tsx | 0 ui/src/components/app.tsx | 2 +- 7 files changed, 115 insertions(+), 26 deletions(-) rename ui/src/components/{Upload => Updater}/Alert.tsx (100%) rename ui/src/components/{Upload => Updater}/Reboot.tsx (100%) rename ui/src/components/{Upload => Updater}/Updater.scss (100%) rename ui/src/components/{Upload => Updater}/Updater.tsx (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf556ef..91ff3f8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/openapi.yml b/openapi.yml index a9332ce..f55550d 100644 --- a/openapi.yml +++ b/openapi.yml @@ -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 diff --git a/ui/src/components/Upload/Alert.tsx b/ui/src/components/Updater/Alert.tsx similarity index 100% rename from ui/src/components/Upload/Alert.tsx rename to ui/src/components/Updater/Alert.tsx diff --git a/ui/src/components/Upload/Reboot.tsx b/ui/src/components/Updater/Reboot.tsx similarity index 100% rename from ui/src/components/Upload/Reboot.tsx rename to ui/src/components/Updater/Reboot.tsx diff --git a/ui/src/components/Upload/Updater.scss b/ui/src/components/Updater/Updater.scss similarity index 100% rename from ui/src/components/Upload/Updater.scss rename to ui/src/components/Updater/Updater.scss diff --git a/ui/src/components/Upload/Updater.tsx b/ui/src/components/Updater/Updater.tsx similarity index 100% rename from ui/src/components/Upload/Updater.tsx rename to ui/src/components/Updater/Updater.tsx diff --git a/ui/src/components/app.tsx b/ui/src/components/app.tsx index ad564b9..4d0f547 100644 --- a/ui/src/components/app.tsx +++ b/ui/src/components/app.tsx @@ -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"