Skip to content

Commit

Permalink
Remove unused swagger since we are using another tool for doc (#14)
Browse files Browse the repository at this point in the history
* Remove unused swagger
* Fix trivy path for dockerfile

Signed-off-by: Nathalia <[email protected]>
  • Loading branch information
n-th authored Jul 27, 2022
1 parent d987216 commit c406d7d
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 239 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Build an image from Dockerfile
run: |
docker build -f dev/api/Dockerfile -t docker.io/my-organization/my-app:${{ github.sha }} .
docker build -f doc/api/Dockerfile -t docker.io/my-organization/my-app:${{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Server and Client Go code is generated from the OpenAPI definition by [oapi-code
Run the following command to generate the code, from the root folder:

```bash
oapi-codegen --config=oapi-codegen/schemas.cfg.yaml oapi-codegen/schemas.yaml
oapi-codegen --config=oapi-codegen/harvester.cfg.yaml oapi-codegen/harvester.yaml
oapi-codegen --config=oapi-codegen/server.cfg.yaml oapi-codegen/server.yaml
oapi-codegen --config=spec/api/schemas.cfg.yaml spec/api/schemas.yaml
oapi-codegen --config=spec/api/harvester.cfg.yaml spec/api/harvester.yaml
oapi-codegen --config=spec/api/management.cfg.yaml spec/api/management.yaml
```

Run the following command to have a live view of the API documentation:
Expand Down
18 changes: 2 additions & 16 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ package main
import (
"flag"
"fmt"
"os"

serverapi "github.com/HewlettPackard/Galadriel/pkg/server/api/server"
"github.com/deepmap/oapi-codegen/pkg/middleware"
"github.com/labstack/echo/v4"
echomiddleware "github.com/labstack/echo/v4/middleware"
)
Expand All @@ -27,30 +24,19 @@ func main() {
var port = flag.Int("port", 8080, "Port for HTTP Galadriel server")
flag.Parse()

swagger, err := serverapi.GetSwagger()
if err != nil {
fmt.Fprintf(os.Stderr, "Error loading swagger spec\n: %s", err)
os.Exit(1)
}

// Clear out the servers array in the swagger spec, that skips validating
// that server names match. We don't know how this thing will be run.
swagger.Servers = nil

galadriel_server := serverapi.MyDumbServer{}
// galadriel_server := management.MyDumbServer{}

// This is how you set up a basic Echo router
router := echo.New()

// Log all requests
router.Use(echomiddleware.Logger())

// Use our validation middleware to check all requests against the
// OpenAPI schema.
router.Use(middleware.OapiRequestValidator(swagger))

// We now register our store above as the handler for the interface
serverapi.RegisterHandlers(router, galadriel_server)
// management.RegisterHandlers(router, galadriel_server)

// And we serve HTTP until the world ends.
router.Logger.Fatal(router.Start(fmt.Sprintf("0.0.0.0:%d", *port)))
Expand Down
2 changes: 1 addition & 1 deletion dev/api/Dockerfile → doc/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EXPOSE 8000

WORKDIR /app

ADD dev/api/index.html /app/
ADD doc/api/index.html /app/

ENTRYPOINT [ "python" ]

Expand Down
File renamed without changes.
97 changes: 0 additions & 97 deletions pkg/server/api/harvester/harvester.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package server
package management

import (
"errors"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pkg/server/api/server/handler_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ generate:
echo-server: true
client: false
models: true
embedded-spec: true
embedded-spec: false
output: pkg/server/api/harvester/harvester.gen.go
output-options:
skip-prune: true
File renamed without changes.
6 changes: 3 additions & 3 deletions oapi-codegen/server.cfg.yaml → spec/api/management.cfg.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package: server
package: management
generate:
echo-server: true
client: false
models: true
embedded-spec: true
output: pkg/server/api/server/server.gen.go
embedded-spec: false
output: pkg/server/api/management/management.gen.go
output-options:
skip-prune: true
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c406d7d

Please sign in to comment.