From 33d5dbe80fb7345560ef42c07a43a46be3cd6850 Mon Sep 17 00:00:00 2001 From: Bengt Wegner <87223648+Petzys@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:48:41 +0200 Subject: [PATCH] Fix(api): Simplified URL and updated README (#8) Signed-off-by: Bengt Wegner --- README.md | 4 ++++ cmd/server.go | 2 +- openapi.yaml | 6 +++--- server/server.go | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9a29cfb..fc6f006 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Available Commands: dir Analyze cryptographic assets in a directory help Help about any command image Analyze cryptographic assets in a container image + server Start a server (port: 8080, see openapi.yaml) Flags: -b, --bom string BOM file to be verified and enriched @@ -113,7 +114,10 @@ Server: Docker Engine - Community ```shell docker build -t cbomkit-theia . +# CLI docker run cbomkit-theia [command] > enriched_CBOM.json +# Server +docker run -d -p 8080:8080 cbomkit-theia ``` ### Compiled diff --git a/cmd/server.go b/cmd/server.go index bf0a09f..02eb2cf 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -24,7 +24,7 @@ import ( var serverCmd = &cobra.Command{ Use: "server", - Short: "Start a server", + Short: "Start a server (port: 8080, see openapi.yaml)", Run: func(cmd *cobra.Command, args []string) { server.Serve() }, diff --git a/openapi.yaml b/openapi.yaml index 89b5638..2f9601b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -6,9 +6,9 @@ info: url: http://www.apache.org/licenses/LICENSE-2.0.html version: 0.0.1 paths: - /api/v1/image/get: + /api/v1/image: post: - summary: Generate CBOM from existing image + summary: Generate CBOM from a Container Image requestBody: required: true content: @@ -17,7 +17,7 @@ paths: type: object properties: image: - description: Identifier for Image + description: Identifier for the Container Image example: "nginx" type: string plugins: diff --git a/server/server.go b/server/server.go index edec866..586fc6e 100644 --- a/server/server.go +++ b/server/server.go @@ -50,7 +50,7 @@ func Serve() { r.SetTrustedProxies(nil) v1 := r.Group("/api/v1") { - v1.POST("/image/get", imageGet) + v1.POST("/image", imageGet) } r.Run(":8080") // listen and serve on 0.0.0.0:8080 }