Resources support (#63)

* Resources support

* Ability to provide VM and worker resources via the CLI

* orchard dev: always listen on :6120

* orchard dev: support --resources

* REST API: provide resource defaults when creating VM

* OpenAPI: document "resources" field

* orchard dev: serve Swagger API documentation on /v1/

* Integration guide
This commit is contained in:
Nikolay Edigaryev
2023-03-27 17:30:54 +04:00
committed by GitHub
parent f42026824c
commit cb39836ee0
23 changed files with 647 additions and 96 deletions
+16 -1
View File
@@ -4,12 +4,14 @@ import (
"context"
"crypto/subtle"
"errors"
"github.com/cirruslabs/orchard/api"
storepkg "github.com/cirruslabs/orchard/internal/controller/store"
"github.com/cirruslabs/orchard/internal/responder"
v1pkg "github.com/cirruslabs/orchard/pkg/resource/v1"
"github.com/cirruslabs/orchard/rpc"
"github.com/deckarep/golang-set/v2"
"github.com/gin-gonic/gin"
"github.com/go-openapi/runtime/middleware"
"google.golang.org/grpc/metadata"
"net/http"
)
@@ -29,9 +31,22 @@ func (controller *Controller) initAPI() *gin.Engine {
// A way to for the clients to check that the API is working
v1.GET("/", func(c *gin.Context) {
c.Status(http.StatusOK)
if controller.enableSwaggerDocs {
middleware.SwaggerUI(middleware.SwaggerUIOpts{
Path: "/v1",
SpecURL: "/v1/openapi.yaml",
}, nil).ServeHTTP(c.Writer, c.Request)
} else {
c.Status(http.StatusOK)
}
})
if controller.enableSwaggerDocs {
v1.GET("/openapi.yaml", func(c *gin.Context) {
c.Data(200, "text/yaml", api.Spec)
})
}
// Service accounts
v1.POST("/service-accounts", func(c *gin.Context) {
controller.createServiceAccount(c).Respond(c)