Merge branch 'main' into release/v0.1

This commit is contained in:
Gabriel Adrian Samfira 2023-07-06 09:15:01 +03:00
commit a0a561155a
No known key found for this signature in database
GPG key ID: 7D073DCC2C074CB5
941 changed files with 113281 additions and 5596 deletions

View file

@ -120,7 +120,9 @@ Once you've configured your database, providers and github credentials, you'll n
At this point, you should be done. Have a look at the [running garm document](/doc/running_garm.md) for usage instructions and available features.
If you would like to use ```garm``` with a different IaaS than the ones already available, have a loot at the [writing an external provider](/doc/external_provider.md) page.
If you would like to use ```garm``` with a different IaaS than the ones already available, have a look at the [writing an external provider](/doc/external_provider.md) page.
If you like to optimize the startup time of new instance, take a look at the [performance considerations](/doc/performance_considerations.md) page.
## Security considerations

View file

@ -306,3 +306,17 @@ func (a *APIController) ListProviders(w http.ResponseWriter, r *http.Request) {
log.Printf("failed to encode response: %q", err)
}
}
func (a *APIController) ListAllJobs(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
jobs, err := a.r.ListAllJobs(ctx)
if err != nil {
handleError(w, err)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(jobs); err != nil {
log.Printf("failed to encode response: %q", err)
}
}

View file

@ -136,7 +136,7 @@ func (a *APIController) UpdateEnterpriseHandler(w http.ResponseWriter, r *http.R
return
}
var updatePayload runnerParams.UpdateRepositoryParams
var updatePayload runnerParams.UpdateEntityParams
if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil {
handleError(w, gErrors.ErrBadRequest)
return

View file

@ -54,6 +54,20 @@ func (a *APIController) ListPoolInstancesHandler(w http.ResponseWriter, r *http.
}
}
// swagger:route GET /instances/{instanceName} instances GetInstance
//
// Get runner instance by name.
//
// Parameters:
// + name: instanceName
// description: Runner instance name.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Instance
// default: APIErrorResponse
func (a *APIController) GetInstanceHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
@ -82,6 +96,19 @@ func (a *APIController) GetInstanceHandler(w http.ResponseWriter, r *http.Reques
}
}
// swagger:route DELETE /instances/{instanceName} instances DeleteInstance
//
// Delete runner instance by name.
//
// Parameters:
// + name: instanceName
// description: Runner instance name.
// type: string
// in: path
// required: true
//
// Responses:
// default: APIErrorResponse
func (a *APIController) DeleteInstanceHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
@ -107,6 +134,20 @@ func (a *APIController) DeleteInstanceHandler(w http.ResponseWriter, r *http.Req
w.WriteHeader(http.StatusOK)
}
// swagger:route GET /repositories/{repoID}/instances repositories instances ListRepoInstances
//
// List repository instances.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Instances
// default: APIErrorResponse
func (a *APIController) ListRepoInstancesHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
@ -191,6 +232,13 @@ func (a *APIController) ListEnterpriseInstancesHandler(w http.ResponseWriter, r
}
}
// swagger:route GET /instances instances ListInstances
//
// Get all runners' instances.
//
// Responses:
// 200: Instances
// default: APIErrorResponse
func (a *APIController) ListAllInstancesHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

View file

@ -136,7 +136,7 @@ func (a *APIController) UpdateOrgHandler(w http.ResponseWriter, r *http.Request)
return
}
var updatePayload runnerParams.UpdateRepositoryParams
var updatePayload runnerParams.UpdateEntityParams
if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil {
handleError(w, gErrors.ErrBadRequest)
return

View file

@ -26,6 +26,20 @@ import (
"github.com/gorilla/mux"
)
// swagger:route POST /repositories repositories CreateRepo
//
// Create repository with the parameters given.
//
// Parameters:
// + name: Body
// description: Parameters used when creating the repository.
// type: CreateRepoParams
// in: body
// required: true
//
// Responses:
// 200: Repository
// default: APIErrorResponse
func (a *APIController) CreateRepoHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -48,6 +62,13 @@ func (a *APIController) CreateRepoHandler(w http.ResponseWriter, r *http.Request
}
}
// swagger:route GET /repositories repositories ListRepos
//
// List repositories.
//
// Responses:
// 200: Repositories
// default: APIErrorResponse
func (a *APIController) ListReposHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -64,6 +85,20 @@ func (a *APIController) ListReposHandler(w http.ResponseWriter, r *http.Request)
}
}
// swagger:route GET /repositories/{repoID} repositories GetRepo
//
// Get repository by ID.
//
// Parameters:
// + name: repoID
// description: ID of the repository to fetch.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Repository
// default: APIErrorResponse
func (a *APIController) GetRepoByIDHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -93,6 +128,19 @@ func (a *APIController) GetRepoByIDHandler(w http.ResponseWriter, r *http.Reques
}
}
// swagger:route DELETE /repositories/{repoID} repositories DeleteRepo
//
// Delete repository by ID.
//
// Parameters:
// + name: repoID
// description: ID of the repository to delete.
// type: string
// in: path
// required: true
//
// Responses:
// default: APIErrorResponse
func (a *APIController) DeleteRepoHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -120,6 +168,26 @@ func (a *APIController) DeleteRepoHandler(w http.ResponseWriter, r *http.Request
}
// swagger:route PUT /repositories/{repoID} repositories UpdateRepo
//
// Update repository with the parameters given.
//
// Parameters:
// + name: repoID
// description: ID of the repository to update.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters used when updating the repository.
// type: UpdateEntityParams
// in: body
// required: true
//
// Responses:
// 200: Repository
// default: APIErrorResponse
func (a *APIController) UpdateRepoHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -136,7 +204,7 @@ func (a *APIController) UpdateRepoHandler(w http.ResponseWriter, r *http.Request
return
}
var updatePayload runnerParams.UpdateRepositoryParams
var updatePayload runnerParams.UpdateEntityParams
if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil {
handleError(w, gErrors.ErrBadRequest)
return
@ -155,6 +223,26 @@ func (a *APIController) UpdateRepoHandler(w http.ResponseWriter, r *http.Request
}
}
// swagger:route POST /repositories/{repoID}/pools repositories pools CreateRepoPool
//
// Create repository pool with the parameters given.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters used when creating the repository pool.
// type: CreatePoolParams
// in: body
// required: true
//
// Responses:
// 200: Pool
// default: APIErrorResponse
func (a *APIController) CreateRepoPoolHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -191,6 +279,20 @@ func (a *APIController) CreateRepoPoolHandler(w http.ResponseWriter, r *http.Req
}
}
// swagger:route GET /repositories/{repoID}/pools repositories pools ListRepoPools
//
// List repository pools.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Pools
// default: APIErrorResponse
func (a *APIController) ListRepoPoolsHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
@ -219,6 +321,26 @@ func (a *APIController) ListRepoPoolsHandler(w http.ResponseWriter, r *http.Requ
}
}
// swagger:route GET /repositories/{repoID}/pools/{poolID} repositories pools GetRepoPool
//
// Get repository pool by ID.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// + name: poolID
// description: Pool ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Pool
// default: APIErrorResponse
func (a *APIController) GetRepoPoolHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
@ -248,6 +370,25 @@ func (a *APIController) GetRepoPoolHandler(w http.ResponseWriter, r *http.Reques
}
}
// swagger:route DELETE /repositories/{repoID}/pools/{poolID} repositories pools DeleteRepoPool
//
// Delete repository pool by ID.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// + name: poolID
// description: ID of the repository pool to delete.
// type: string
// in: path
// required: true
//
// Responses:
// default: APIErrorResponse
func (a *APIController) DeleteRepoPoolHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
@ -276,6 +417,32 @@ func (a *APIController) DeleteRepoPoolHandler(w http.ResponseWriter, r *http.Req
}
// swagger:route PUT /repositories/{repoID}/pools/{poolID} repositories pools UpdateRepoPool
//
// Update repository pool with the parameters given.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// + name: poolID
// description: ID of the repository pool to update.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters used when updating the repository pool.
// type: UpdatePoolParams
// in: body
// required: true
//
// Responses:
// 200: Pool
// default: APIErrorResponse
func (a *APIController) UpdateRepoPoolHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

View file

@ -12,11 +12,44 @@
// License for the specific language governing permissions and limitations
// under the License.
// Package routers Garm API.
//
// The Garm API generated using go-swagger.
//
// BasePath: /api/v1
// Version: 1.0.0
// License: Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0
//
// Consumes:
// - application/json
//
// Produces:
// - application/json
//
// Security:
// - Bearer:
//
// SecurityDefinitions:
// Bearer:
// type: apiKey
// name: Authorization
// in: header
// description: >-
// The token with the `Bearer: ` prefix, e.g. "Bearer abcde12345".
//
// swagger:meta
package routers
//go:generate go run github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 generate spec --input=../swagger-models.yaml --output=../swagger.yaml --include="routers|controllers"
//go:generate go run github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 validate ../swagger.yaml
//go:generate rm -rf ../../client
//go:generate go run github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 generate client --target=../../ --spec=../swagger.yaml
import (
_ "expvar" // Register the expvar handlers
"io"
"net/http"
_ "net/http/pprof" // Register the pprof handlers
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
@ -40,6 +73,15 @@ func WithMetricsRouter(parentRouter *mux.Router, disableAuth bool, metricsMiddle
return parentRouter
}
func WithDebugServer(parentRouter *mux.Router) *mux.Router {
if parentRouter == nil {
return nil
}
parentRouter.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux)
return parentRouter
}
func NewAPIRouter(han *controllers.APIController, logWriter io.Writer, authMiddleware, initMiddleware, instanceMiddleware auth.Middleware) *mux.Router {
router := mux.NewRouter()
logMiddleware := util.NewLoggingMiddleware(logWriter)
@ -80,6 +122,13 @@ func NewAPIRouter(han *controllers.APIController, logWriter io.Writer, authMiddl
apiRouter.Handle("/metrics-token/", http.HandlerFunc(han.MetricsTokenHandler)).Methods("GET", "OPTIONS")
apiRouter.Handle("/metrics-token", http.HandlerFunc(han.MetricsTokenHandler)).Methods("GET", "OPTIONS")
//////////
// Jobs //
//////////
// List all jobs
apiRouter.Handle("/jobs/", http.HandlerFunc(han.ListAllJobs)).Methods("GET", "OPTIONS")
apiRouter.Handle("/jobs", http.HandlerFunc(han.ListAllJobs)).Methods("GET", "OPTIONS")
///////////
// Pools //
///////////

View file

@ -0,0 +1,82 @@
# NOTE: The purpose of these definitions is to reuse the existing golang
# types from GARM packages.
definitions:
Instances:
type: object
x-go-type:
type: Instances
import:
package: github.com/cloudbase/garm/params
alias: garm_params
Instance:
type: object
x-go-type:
type: Instance
import:
package: github.com/cloudbase/garm/params
alias: garm_params
Pools:
type: object
x-go-type:
type: Pools
import:
package: github.com/cloudbase/garm/params
alias: garm_params
Pool:
type: object
x-go-type:
type: Pool
import:
package: github.com/cloudbase/garm/params
alias: garm_params
Repositories:
type: array
x-go-type:
type: Repositories
import:
package: github.com/cloudbase/garm/params
alias: garm_params
items:
$ref: '#/definitions/Repository'
Repository:
type: object
x-go-type:
type: Repository
import:
package: github.com/cloudbase/garm/params
alias: garm_params
CreateRepoParams:
type: object
x-go-type:
type: CreateRepoParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
UpdateEntityParams:
type: object
x-go-type:
type: UpdateEntityParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
CreatePoolParams:
type: object
x-go-type:
type: CreatePoolParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
UpdatePoolParams:
type: object
x-go-type:
type: UpdatePoolParams
import:
package: github.com/cloudbase/garm/params
alias: garm_params
APIErrorResponse:
type: object
x-go-type:
type: APIErrorResponse
import:
package: github.com/cloudbase/garm/apiserver/params
alias: apiserver_params

413
apiserver/swagger.yaml Normal file
View file

@ -0,0 +1,413 @@
basePath: /api/v1
consumes:
- application/json
definitions:
APIErrorResponse:
type: object
x-go-type:
import:
alias: apiserver_params
package: github.com/cloudbase/garm/apiserver/params
type: APIErrorResponse
CreatePoolParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: CreatePoolParams
CreateRepoParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: CreateRepoParams
Instance:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Instance
Instances:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Instances
Pool:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Pool
Pools:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Pools
Repositories:
items:
$ref: '#/definitions/Repository'
type: array
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Repositories
Repository:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: Repository
UpdateEntityParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: UpdateEntityParams
UpdatePoolParams:
type: object
x-go-type:
import:
alias: garm_params
package: github.com/cloudbase/garm/params
type: UpdatePoolParams
info:
description: The Garm API generated using go-swagger.
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0
title: Garm API.
version: 1.0.0
paths:
/instances:
get:
operationId: ListInstances
responses:
"200":
description: Instances
schema:
$ref: '#/definitions/Instances'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Get all runners' instances.
tags:
- instances
/instances/{instanceName}:
delete:
operationId: DeleteInstance
parameters:
- description: Runner instance name.
in: path
name: instanceName
required: true
type: string
responses:
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Delete runner instance by name.
tags:
- instances
get:
operationId: GetInstance
parameters:
- description: Runner instance name.
in: path
name: instanceName
required: true
type: string
responses:
"200":
description: Instance
schema:
$ref: '#/definitions/Instance'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Get runner instance by name.
tags:
- instances
/repositories:
get:
operationId: ListRepos
responses:
"200":
description: Repositories
schema:
$ref: '#/definitions/Repositories'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List repositories.
tags:
- repositories
post:
operationId: CreateRepo
parameters:
- description: Parameters used when creating the repository.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/CreateRepoParams'
description: Parameters used when creating the repository.
type: object
responses:
"200":
description: Repository
schema:
$ref: '#/definitions/Repository'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Create repository with the parameters given.
tags:
- repositories
/repositories/{repoID}:
delete:
operationId: DeleteRepo
parameters:
- description: ID of the repository to delete.
in: path
name: repoID
required: true
type: string
responses:
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Delete repository by ID.
tags:
- repositories
get:
operationId: GetRepo
parameters:
- description: ID of the repository to fetch.
in: path
name: repoID
required: true
type: string
responses:
"200":
description: Repository
schema:
$ref: '#/definitions/Repository'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Get repository by ID.
tags:
- repositories
put:
operationId: UpdateRepo
parameters:
- description: ID of the repository to update.
in: path
name: repoID
required: true
type: string
- description: Parameters used when updating the repository.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/UpdateEntityParams'
description: Parameters used when updating the repository.
type: object
responses:
"200":
description: Repository
schema:
$ref: '#/definitions/Repository'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Update repository with the parameters given.
tags:
- repositories
/repositories/{repoID}/instances:
get:
operationId: ListRepoInstances
parameters:
- description: Repository ID.
in: path
name: repoID
required: true
type: string
responses:
"200":
description: Instances
schema:
$ref: '#/definitions/Instances'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List repository instances.
tags:
- repositories
- instances
/repositories/{repoID}/pools:
get:
operationId: ListRepoPools
parameters:
- description: Repository ID.
in: path
name: repoID
required: true
type: string
responses:
"200":
description: Pools
schema:
$ref: '#/definitions/Pools'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: List repository pools.
tags:
- repositories
- pools
post:
operationId: CreateRepoPool
parameters:
- description: Repository ID.
in: path
name: repoID
required: true
type: string
- description: Parameters used when creating the repository pool.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/CreatePoolParams'
description: Parameters used when creating the repository pool.
type: object
responses:
"200":
description: Pool
schema:
$ref: '#/definitions/Pool'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Create repository pool with the parameters given.
tags:
- repositories
- pools
/repositories/{repoID}/pools/{poolID}:
delete:
operationId: DeleteRepoPool
parameters:
- description: Repository ID.
in: path
name: repoID
required: true
type: string
- description: ID of the repository pool to delete.
in: path
name: poolID
required: true
type: string
responses:
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Delete repository pool by ID.
tags:
- repositories
- pools
get:
operationId: GetRepoPool
parameters:
- description: Repository ID.
in: path
name: repoID
required: true
type: string
- description: Pool ID.
in: path
name: poolID
required: true
type: string
responses:
"200":
description: Pool
schema:
$ref: '#/definitions/Pool'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Get repository pool by ID.
tags:
- repositories
- pools
put:
operationId: UpdateRepoPool
parameters:
- description: Repository ID.
in: path
name: repoID
required: true
type: string
- description: ID of the repository pool to update.
in: path
name: poolID
required: true
type: string
- description: Parameters used when updating the repository pool.
in: body
name: Body
required: true
schema:
$ref: '#/definitions/UpdatePoolParams'
description: Parameters used when updating the repository pool.
type: object
responses:
"200":
description: Pool
schema:
$ref: '#/definitions/Pool'
default:
description: APIErrorResponse
schema:
$ref: '#/definitions/APIErrorResponse'
summary: Update repository pool with the parameters given.
tags:
- repositories
- pools
produces:
- application/json
security:
- Bearer: []
securityDefinitions:
Bearer:
description: 'The token with the `Bearer: ` prefix, e.g. "Bearer abcde12345".'
in: header
name: Authorization
type: apiKey
swagger: "2.0"

117
client/garm_api_client.go Normal file
View file

@ -0,0 +1,117 @@
// Code generated by go-swagger; DO NOT EDIT.
package client
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/cloudbase/garm/client/instances"
"github.com/cloudbase/garm/client/repositories"
)
// Default garm API HTTP client.
var Default = NewHTTPClient(nil)
const (
// DefaultHost is the default Host
// found in Meta (info) section of spec file
DefaultHost string = "localhost"
// DefaultBasePath is the default BasePath
// found in Meta (info) section of spec file
DefaultBasePath string = "/api/v1"
)
// DefaultSchemes are the default schemes found in Meta (info) section of spec file
var DefaultSchemes = []string{"http"}
// NewHTTPClient creates a new garm API HTTP client.
func NewHTTPClient(formats strfmt.Registry) *GarmAPI {
return NewHTTPClientWithConfig(formats, nil)
}
// NewHTTPClientWithConfig creates a new garm API HTTP client,
// using a customizable transport config.
func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *GarmAPI {
// ensure nullable parameters have default
if cfg == nil {
cfg = DefaultTransportConfig()
}
// create transport and client
transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
return New(transport, formats)
}
// New creates a new garm API client
func New(transport runtime.ClientTransport, formats strfmt.Registry) *GarmAPI {
// ensure nullable parameters have default
if formats == nil {
formats = strfmt.Default
}
cli := new(GarmAPI)
cli.Transport = transport
cli.Instances = instances.New(transport, formats)
cli.Repositories = repositories.New(transport, formats)
return cli
}
// DefaultTransportConfig creates a TransportConfig with the
// default settings taken from the meta section of the spec file.
func DefaultTransportConfig() *TransportConfig {
return &TransportConfig{
Host: DefaultHost,
BasePath: DefaultBasePath,
Schemes: DefaultSchemes,
}
}
// TransportConfig contains the transport related info,
// found in the meta section of the spec file.
type TransportConfig struct {
Host string
BasePath string
Schemes []string
}
// WithHost overrides the default host,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
cfg.Host = host
return cfg
}
// WithBasePath overrides the default basePath,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
cfg.BasePath = basePath
return cfg
}
// WithSchemes overrides the default schemes,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
cfg.Schemes = schemes
return cfg
}
// GarmAPI is a client for garm API
type GarmAPI struct {
Instances instances.ClientService
Repositories repositories.ClientService
Transport runtime.ClientTransport
}
// SetTransport changes the transport on the client and all its subresources
func (c *GarmAPI) SetTransport(transport runtime.ClientTransport) {
c.Transport = transport
c.Instances.SetTransport(transport)
c.Repositories.SetTransport(transport)
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package instances
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewDeleteInstanceParams creates a new DeleteInstanceParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewDeleteInstanceParams() *DeleteInstanceParams {
return &DeleteInstanceParams{
timeout: cr.DefaultTimeout,
}
}
// NewDeleteInstanceParamsWithTimeout creates a new DeleteInstanceParams object
// with the ability to set a timeout on a request.
func NewDeleteInstanceParamsWithTimeout(timeout time.Duration) *DeleteInstanceParams {
return &DeleteInstanceParams{
timeout: timeout,
}
}
// NewDeleteInstanceParamsWithContext creates a new DeleteInstanceParams object
// with the ability to set a context for a request.
func NewDeleteInstanceParamsWithContext(ctx context.Context) *DeleteInstanceParams {
return &DeleteInstanceParams{
Context: ctx,
}
}
// NewDeleteInstanceParamsWithHTTPClient creates a new DeleteInstanceParams object
// with the ability to set a custom HTTPClient for a request.
func NewDeleteInstanceParamsWithHTTPClient(client *http.Client) *DeleteInstanceParams {
return &DeleteInstanceParams{
HTTPClient: client,
}
}
/*
DeleteInstanceParams contains all the parameters to send to the API endpoint
for the delete instance operation.
Typically these are written to a http.Request.
*/
type DeleteInstanceParams struct {
/* InstanceName.
Runner instance name.
*/
InstanceName string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the delete instance params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteInstanceParams) WithDefaults() *DeleteInstanceParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the delete instance params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteInstanceParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the delete instance params
func (o *DeleteInstanceParams) WithTimeout(timeout time.Duration) *DeleteInstanceParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the delete instance params
func (o *DeleteInstanceParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the delete instance params
func (o *DeleteInstanceParams) WithContext(ctx context.Context) *DeleteInstanceParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the delete instance params
func (o *DeleteInstanceParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the delete instance params
func (o *DeleteInstanceParams) WithHTTPClient(client *http.Client) *DeleteInstanceParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the delete instance params
func (o *DeleteInstanceParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithInstanceName adds the instanceName to the delete instance params
func (o *DeleteInstanceParams) WithInstanceName(instanceName string) *DeleteInstanceParams {
o.SetInstanceName(instanceName)
return o
}
// SetInstanceName adds the instanceName to the delete instance params
func (o *DeleteInstanceParams) SetInstanceName(instanceName string) {
o.InstanceName = instanceName
}
// WriteToRequest writes these params to a swagger request
func (o *DeleteInstanceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param instanceName
if err := r.SetPathParam("instanceName", o.InstanceName); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,103 @@
// Code generated by go-swagger; DO NOT EDIT.
package instances
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
)
// DeleteInstanceReader is a Reader for the DeleteInstance structure.
type DeleteInstanceReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DeleteInstanceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
result := NewDeleteInstanceDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
// NewDeleteInstanceDefault creates a DeleteInstanceDefault with default headers values
func NewDeleteInstanceDefault(code int) *DeleteInstanceDefault {
return &DeleteInstanceDefault{
_statusCode: code,
}
}
/*
DeleteInstanceDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type DeleteInstanceDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this delete instance default response has a 2xx status code
func (o *DeleteInstanceDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this delete instance default response has a 3xx status code
func (o *DeleteInstanceDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this delete instance default response has a 4xx status code
func (o *DeleteInstanceDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this delete instance default response has a 5xx status code
func (o *DeleteInstanceDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this delete instance default response a status code equal to that given
func (o *DeleteInstanceDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the delete instance default response
func (o *DeleteInstanceDefault) Code() int {
return o._statusCode
}
func (o *DeleteInstanceDefault) Error() string {
return fmt.Sprintf("[DELETE /instances/{instanceName}][%d] DeleteInstance default %+v", o._statusCode, o.Payload)
}
func (o *DeleteInstanceDefault) String() string {
return fmt.Sprintf("[DELETE /instances/{instanceName}][%d] DeleteInstance default %+v", o._statusCode, o.Payload)
}
func (o *DeleteInstanceDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *DeleteInstanceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package instances
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewGetInstanceParams creates a new GetInstanceParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewGetInstanceParams() *GetInstanceParams {
return &GetInstanceParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetInstanceParamsWithTimeout creates a new GetInstanceParams object
// with the ability to set a timeout on a request.
func NewGetInstanceParamsWithTimeout(timeout time.Duration) *GetInstanceParams {
return &GetInstanceParams{
timeout: timeout,
}
}
// NewGetInstanceParamsWithContext creates a new GetInstanceParams object
// with the ability to set a context for a request.
func NewGetInstanceParamsWithContext(ctx context.Context) *GetInstanceParams {
return &GetInstanceParams{
Context: ctx,
}
}
// NewGetInstanceParamsWithHTTPClient creates a new GetInstanceParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetInstanceParamsWithHTTPClient(client *http.Client) *GetInstanceParams {
return &GetInstanceParams{
HTTPClient: client,
}
}
/*
GetInstanceParams contains all the parameters to send to the API endpoint
for the get instance operation.
Typically these are written to a http.Request.
*/
type GetInstanceParams struct {
/* InstanceName.
Runner instance name.
*/
InstanceName string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get instance params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetInstanceParams) WithDefaults() *GetInstanceParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get instance params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetInstanceParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get instance params
func (o *GetInstanceParams) WithTimeout(timeout time.Duration) *GetInstanceParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get instance params
func (o *GetInstanceParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get instance params
func (o *GetInstanceParams) WithContext(ctx context.Context) *GetInstanceParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get instance params
func (o *GetInstanceParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get instance params
func (o *GetInstanceParams) WithHTTPClient(client *http.Client) *GetInstanceParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get instance params
func (o *GetInstanceParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithInstanceName adds the instanceName to the get instance params
func (o *GetInstanceParams) WithInstanceName(instanceName string) *GetInstanceParams {
o.SetInstanceName(instanceName)
return o
}
// SetInstanceName adds the instanceName to the get instance params
func (o *GetInstanceParams) SetInstanceName(instanceName string) {
o.InstanceName = instanceName
}
// WriteToRequest writes these params to a swagger request
func (o *GetInstanceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param instanceName
if err := r.SetPathParam("instanceName", o.InstanceName); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package instances
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// GetInstanceReader is a Reader for the GetInstance structure.
type GetInstanceReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetInstanceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetInstanceOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewGetInstanceDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewGetInstanceOK creates a GetInstanceOK with default headers values
func NewGetInstanceOK() *GetInstanceOK {
return &GetInstanceOK{}
}
/*
GetInstanceOK describes a response with status code 200, with default header values.
Instance
*/
type GetInstanceOK struct {
Payload garm_params.Instance
}
// IsSuccess returns true when this get instance o k response has a 2xx status code
func (o *GetInstanceOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get instance o k response has a 3xx status code
func (o *GetInstanceOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get instance o k response has a 4xx status code
func (o *GetInstanceOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get instance o k response has a 5xx status code
func (o *GetInstanceOK) IsServerError() bool {
return false
}
// IsCode returns true when this get instance o k response a status code equal to that given
func (o *GetInstanceOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the get instance o k response
func (o *GetInstanceOK) Code() int {
return 200
}
func (o *GetInstanceOK) Error() string {
return fmt.Sprintf("[GET /instances/{instanceName}][%d] getInstanceOK %+v", 200, o.Payload)
}
func (o *GetInstanceOK) String() string {
return fmt.Sprintf("[GET /instances/{instanceName}][%d] getInstanceOK %+v", 200, o.Payload)
}
func (o *GetInstanceOK) GetPayload() garm_params.Instance {
return o.Payload
}
func (o *GetInstanceOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetInstanceDefault creates a GetInstanceDefault with default headers values
func NewGetInstanceDefault(code int) *GetInstanceDefault {
return &GetInstanceDefault{
_statusCode: code,
}
}
/*
GetInstanceDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type GetInstanceDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this get instance default response has a 2xx status code
func (o *GetInstanceDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this get instance default response has a 3xx status code
func (o *GetInstanceDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this get instance default response has a 4xx status code
func (o *GetInstanceDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this get instance default response has a 5xx status code
func (o *GetInstanceDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this get instance default response a status code equal to that given
func (o *GetInstanceDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the get instance default response
func (o *GetInstanceDefault) Code() int {
return o._statusCode
}
func (o *GetInstanceDefault) Error() string {
return fmt.Sprintf("[GET /instances/{instanceName}][%d] GetInstance default %+v", o._statusCode, o.Payload)
}
func (o *GetInstanceDefault) String() string {
return fmt.Sprintf("[GET /instances/{instanceName}][%d] GetInstance default %+v", o._statusCode, o.Payload)
}
func (o *GetInstanceDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *GetInstanceDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package instances
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
)
// New creates a new instances API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
/*
Client for instances API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientOption is the option for Client methods
type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
DeleteInstance(params *DeleteInstanceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
GetInstance(params *GetInstanceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInstanceOK, error)
ListInstances(params *ListInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListInstancesOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
DeleteInstance deletes runner instance by name
*/
func (a *Client) DeleteInstance(params *DeleteInstanceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteInstanceParams()
}
op := &runtime.ClientOperation{
ID: "DeleteInstance",
Method: "DELETE",
PathPattern: "/instances/{instanceName}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &DeleteInstanceReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
_, err := a.transport.Submit(op)
if err != nil {
return err
}
return nil
}
/*
GetInstance gets runner instance by name
*/
func (a *Client) GetInstance(params *GetInstanceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInstanceOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetInstanceParams()
}
op := &runtime.ClientOperation{
ID: "GetInstance",
Method: "GET",
PathPattern: "/instances/{instanceName}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetInstanceReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetInstanceOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*GetInstanceDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListInstances gets all runners instances
*/
func (a *Client) ListInstances(params *ListInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListInstancesOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListInstancesParams()
}
op := &runtime.ClientOperation{
ID: "ListInstances",
Method: "GET",
PathPattern: "/instances",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListInstancesReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListInstancesOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListInstancesDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}

View file

@ -0,0 +1,128 @@
// Code generated by go-swagger; DO NOT EDIT.
package instances
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListInstancesParams creates a new ListInstancesParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListInstancesParams() *ListInstancesParams {
return &ListInstancesParams{
timeout: cr.DefaultTimeout,
}
}
// NewListInstancesParamsWithTimeout creates a new ListInstancesParams object
// with the ability to set a timeout on a request.
func NewListInstancesParamsWithTimeout(timeout time.Duration) *ListInstancesParams {
return &ListInstancesParams{
timeout: timeout,
}
}
// NewListInstancesParamsWithContext creates a new ListInstancesParams object
// with the ability to set a context for a request.
func NewListInstancesParamsWithContext(ctx context.Context) *ListInstancesParams {
return &ListInstancesParams{
Context: ctx,
}
}
// NewListInstancesParamsWithHTTPClient creates a new ListInstancesParams object
// with the ability to set a custom HTTPClient for a request.
func NewListInstancesParamsWithHTTPClient(client *http.Client) *ListInstancesParams {
return &ListInstancesParams{
HTTPClient: client,
}
}
/*
ListInstancesParams contains all the parameters to send to the API endpoint
for the list instances operation.
Typically these are written to a http.Request.
*/
type ListInstancesParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list instances params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListInstancesParams) WithDefaults() *ListInstancesParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list instances params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListInstancesParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list instances params
func (o *ListInstancesParams) WithTimeout(timeout time.Duration) *ListInstancesParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list instances params
func (o *ListInstancesParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list instances params
func (o *ListInstancesParams) WithContext(ctx context.Context) *ListInstancesParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list instances params
func (o *ListInstancesParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list instances params
func (o *ListInstancesParams) WithHTTPClient(client *http.Client) *ListInstancesParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list instances params
func (o *ListInstancesParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ListInstancesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package instances
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListInstancesReader is a Reader for the ListInstances structure.
type ListInstancesReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListInstancesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListInstancesOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListInstancesDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListInstancesOK creates a ListInstancesOK with default headers values
func NewListInstancesOK() *ListInstancesOK {
return &ListInstancesOK{}
}
/*
ListInstancesOK describes a response with status code 200, with default header values.
Instances
*/
type ListInstancesOK struct {
Payload garm_params.Instances
}
// IsSuccess returns true when this list instances o k response has a 2xx status code
func (o *ListInstancesOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list instances o k response has a 3xx status code
func (o *ListInstancesOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list instances o k response has a 4xx status code
func (o *ListInstancesOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list instances o k response has a 5xx status code
func (o *ListInstancesOK) IsServerError() bool {
return false
}
// IsCode returns true when this list instances o k response a status code equal to that given
func (o *ListInstancesOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list instances o k response
func (o *ListInstancesOK) Code() int {
return 200
}
func (o *ListInstancesOK) Error() string {
return fmt.Sprintf("[GET /instances][%d] listInstancesOK %+v", 200, o.Payload)
}
func (o *ListInstancesOK) String() string {
return fmt.Sprintf("[GET /instances][%d] listInstancesOK %+v", 200, o.Payload)
}
func (o *ListInstancesOK) GetPayload() garm_params.Instances {
return o.Payload
}
func (o *ListInstancesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListInstancesDefault creates a ListInstancesDefault with default headers values
func NewListInstancesDefault(code int) *ListInstancesDefault {
return &ListInstancesDefault{
_statusCode: code,
}
}
/*
ListInstancesDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListInstancesDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list instances default response has a 2xx status code
func (o *ListInstancesDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list instances default response has a 3xx status code
func (o *ListInstancesDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list instances default response has a 4xx status code
func (o *ListInstancesDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list instances default response has a 5xx status code
func (o *ListInstancesDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list instances default response a status code equal to that given
func (o *ListInstancesDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list instances default response
func (o *ListInstancesDefault) Code() int {
return o._statusCode
}
func (o *ListInstancesDefault) Error() string {
return fmt.Sprintf("[GET /instances][%d] ListInstances default %+v", o._statusCode, o.Payload)
}
func (o *ListInstancesDefault) String() string {
return fmt.Sprintf("[GET /instances][%d] ListInstances default %+v", o._statusCode, o.Payload)
}
func (o *ListInstancesDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListInstancesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewCreateRepoParams creates a new CreateRepoParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewCreateRepoParams() *CreateRepoParams {
return &CreateRepoParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateRepoParamsWithTimeout creates a new CreateRepoParams object
// with the ability to set a timeout on a request.
func NewCreateRepoParamsWithTimeout(timeout time.Duration) *CreateRepoParams {
return &CreateRepoParams{
timeout: timeout,
}
}
// NewCreateRepoParamsWithContext creates a new CreateRepoParams object
// with the ability to set a context for a request.
func NewCreateRepoParamsWithContext(ctx context.Context) *CreateRepoParams {
return &CreateRepoParams{
Context: ctx,
}
}
// NewCreateRepoParamsWithHTTPClient creates a new CreateRepoParams object
// with the ability to set a custom HTTPClient for a request.
func NewCreateRepoParamsWithHTTPClient(client *http.Client) *CreateRepoParams {
return &CreateRepoParams{
HTTPClient: client,
}
}
/*
CreateRepoParams contains all the parameters to send to the API endpoint
for the create repo operation.
Typically these are written to a http.Request.
*/
type CreateRepoParams struct {
/* Body.
Parameters used when creating the repository.
*/
Body garm_params.CreateRepoParams
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the create repo params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateRepoParams) WithDefaults() *CreateRepoParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the create repo params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateRepoParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the create repo params
func (o *CreateRepoParams) WithTimeout(timeout time.Duration) *CreateRepoParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create repo params
func (o *CreateRepoParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create repo params
func (o *CreateRepoParams) WithContext(ctx context.Context) *CreateRepoParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create repo params
func (o *CreateRepoParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create repo params
func (o *CreateRepoParams) WithHTTPClient(client *http.Client) *CreateRepoParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create repo params
func (o *CreateRepoParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create repo params
func (o *CreateRepoParams) WithBody(body garm_params.CreateRepoParams) *CreateRepoParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create repo params
func (o *CreateRepoParams) SetBody(body garm_params.CreateRepoParams) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *CreateRepoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewCreateRepoPoolParams creates a new CreateRepoPoolParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewCreateRepoPoolParams() *CreateRepoPoolParams {
return &CreateRepoPoolParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateRepoPoolParamsWithTimeout creates a new CreateRepoPoolParams object
// with the ability to set a timeout on a request.
func NewCreateRepoPoolParamsWithTimeout(timeout time.Duration) *CreateRepoPoolParams {
return &CreateRepoPoolParams{
timeout: timeout,
}
}
// NewCreateRepoPoolParamsWithContext creates a new CreateRepoPoolParams object
// with the ability to set a context for a request.
func NewCreateRepoPoolParamsWithContext(ctx context.Context) *CreateRepoPoolParams {
return &CreateRepoPoolParams{
Context: ctx,
}
}
// NewCreateRepoPoolParamsWithHTTPClient creates a new CreateRepoPoolParams object
// with the ability to set a custom HTTPClient for a request.
func NewCreateRepoPoolParamsWithHTTPClient(client *http.Client) *CreateRepoPoolParams {
return &CreateRepoPoolParams{
HTTPClient: client,
}
}
/*
CreateRepoPoolParams contains all the parameters to send to the API endpoint
for the create repo pool operation.
Typically these are written to a http.Request.
*/
type CreateRepoPoolParams struct {
/* Body.
Parameters used when creating the repository pool.
*/
Body garm_params.CreatePoolParams
/* RepoID.
Repository ID.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the create repo pool params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateRepoPoolParams) WithDefaults() *CreateRepoPoolParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the create repo pool params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *CreateRepoPoolParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the create repo pool params
func (o *CreateRepoPoolParams) WithTimeout(timeout time.Duration) *CreateRepoPoolParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create repo pool params
func (o *CreateRepoPoolParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create repo pool params
func (o *CreateRepoPoolParams) WithContext(ctx context.Context) *CreateRepoPoolParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create repo pool params
func (o *CreateRepoPoolParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create repo pool params
func (o *CreateRepoPoolParams) WithHTTPClient(client *http.Client) *CreateRepoPoolParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create repo pool params
func (o *CreateRepoPoolParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create repo pool params
func (o *CreateRepoPoolParams) WithBody(body garm_params.CreatePoolParams) *CreateRepoPoolParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create repo pool params
func (o *CreateRepoPoolParams) SetBody(body garm_params.CreatePoolParams) {
o.Body = body
}
// WithRepoID adds the repoID to the create repo pool params
func (o *CreateRepoPoolParams) WithRepoID(repoID string) *CreateRepoPoolParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the create repo pool params
func (o *CreateRepoPoolParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *CreateRepoPoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// CreateRepoPoolReader is a Reader for the CreateRepoPool structure.
type CreateRepoPoolReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateRepoPoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewCreateRepoPoolOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewCreateRepoPoolDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewCreateRepoPoolOK creates a CreateRepoPoolOK with default headers values
func NewCreateRepoPoolOK() *CreateRepoPoolOK {
return &CreateRepoPoolOK{}
}
/*
CreateRepoPoolOK describes a response with status code 200, with default header values.
Pool
*/
type CreateRepoPoolOK struct {
Payload garm_params.Pool
}
// IsSuccess returns true when this create repo pool o k response has a 2xx status code
func (o *CreateRepoPoolOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this create repo pool o k response has a 3xx status code
func (o *CreateRepoPoolOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this create repo pool o k response has a 4xx status code
func (o *CreateRepoPoolOK) IsClientError() bool {
return false
}
// IsServerError returns true when this create repo pool o k response has a 5xx status code
func (o *CreateRepoPoolOK) IsServerError() bool {
return false
}
// IsCode returns true when this create repo pool o k response a status code equal to that given
func (o *CreateRepoPoolOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the create repo pool o k response
func (o *CreateRepoPoolOK) Code() int {
return 200
}
func (o *CreateRepoPoolOK) Error() string {
return fmt.Sprintf("[POST /repositories/{repoID}/pools][%d] createRepoPoolOK %+v", 200, o.Payload)
}
func (o *CreateRepoPoolOK) String() string {
return fmt.Sprintf("[POST /repositories/{repoID}/pools][%d] createRepoPoolOK %+v", 200, o.Payload)
}
func (o *CreateRepoPoolOK) GetPayload() garm_params.Pool {
return o.Payload
}
func (o *CreateRepoPoolOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewCreateRepoPoolDefault creates a CreateRepoPoolDefault with default headers values
func NewCreateRepoPoolDefault(code int) *CreateRepoPoolDefault {
return &CreateRepoPoolDefault{
_statusCode: code,
}
}
/*
CreateRepoPoolDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type CreateRepoPoolDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this create repo pool default response has a 2xx status code
func (o *CreateRepoPoolDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this create repo pool default response has a 3xx status code
func (o *CreateRepoPoolDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this create repo pool default response has a 4xx status code
func (o *CreateRepoPoolDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this create repo pool default response has a 5xx status code
func (o *CreateRepoPoolDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this create repo pool default response a status code equal to that given
func (o *CreateRepoPoolDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the create repo pool default response
func (o *CreateRepoPoolDefault) Code() int {
return o._statusCode
}
func (o *CreateRepoPoolDefault) Error() string {
return fmt.Sprintf("[POST /repositories/{repoID}/pools][%d] CreateRepoPool default %+v", o._statusCode, o.Payload)
}
func (o *CreateRepoPoolDefault) String() string {
return fmt.Sprintf("[POST /repositories/{repoID}/pools][%d] CreateRepoPool default %+v", o._statusCode, o.Payload)
}
func (o *CreateRepoPoolDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *CreateRepoPoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// CreateRepoReader is a Reader for the CreateRepo structure.
type CreateRepoReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateRepoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewCreateRepoOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewCreateRepoDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewCreateRepoOK creates a CreateRepoOK with default headers values
func NewCreateRepoOK() *CreateRepoOK {
return &CreateRepoOK{}
}
/*
CreateRepoOK describes a response with status code 200, with default header values.
Repository
*/
type CreateRepoOK struct {
Payload garm_params.Repository
}
// IsSuccess returns true when this create repo o k response has a 2xx status code
func (o *CreateRepoOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this create repo o k response has a 3xx status code
func (o *CreateRepoOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this create repo o k response has a 4xx status code
func (o *CreateRepoOK) IsClientError() bool {
return false
}
// IsServerError returns true when this create repo o k response has a 5xx status code
func (o *CreateRepoOK) IsServerError() bool {
return false
}
// IsCode returns true when this create repo o k response a status code equal to that given
func (o *CreateRepoOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the create repo o k response
func (o *CreateRepoOK) Code() int {
return 200
}
func (o *CreateRepoOK) Error() string {
return fmt.Sprintf("[POST /repositories][%d] createRepoOK %+v", 200, o.Payload)
}
func (o *CreateRepoOK) String() string {
return fmt.Sprintf("[POST /repositories][%d] createRepoOK %+v", 200, o.Payload)
}
func (o *CreateRepoOK) GetPayload() garm_params.Repository {
return o.Payload
}
func (o *CreateRepoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewCreateRepoDefault creates a CreateRepoDefault with default headers values
func NewCreateRepoDefault(code int) *CreateRepoDefault {
return &CreateRepoDefault{
_statusCode: code,
}
}
/*
CreateRepoDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type CreateRepoDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this create repo default response has a 2xx status code
func (o *CreateRepoDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this create repo default response has a 3xx status code
func (o *CreateRepoDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this create repo default response has a 4xx status code
func (o *CreateRepoDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this create repo default response has a 5xx status code
func (o *CreateRepoDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this create repo default response a status code equal to that given
func (o *CreateRepoDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the create repo default response
func (o *CreateRepoDefault) Code() int {
return o._statusCode
}
func (o *CreateRepoDefault) Error() string {
return fmt.Sprintf("[POST /repositories][%d] CreateRepo default %+v", o._statusCode, o.Payload)
}
func (o *CreateRepoDefault) String() string {
return fmt.Sprintf("[POST /repositories][%d] CreateRepo default %+v", o._statusCode, o.Payload)
}
func (o *CreateRepoDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *CreateRepoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewDeleteRepoParams creates a new DeleteRepoParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewDeleteRepoParams() *DeleteRepoParams {
return &DeleteRepoParams{
timeout: cr.DefaultTimeout,
}
}
// NewDeleteRepoParamsWithTimeout creates a new DeleteRepoParams object
// with the ability to set a timeout on a request.
func NewDeleteRepoParamsWithTimeout(timeout time.Duration) *DeleteRepoParams {
return &DeleteRepoParams{
timeout: timeout,
}
}
// NewDeleteRepoParamsWithContext creates a new DeleteRepoParams object
// with the ability to set a context for a request.
func NewDeleteRepoParamsWithContext(ctx context.Context) *DeleteRepoParams {
return &DeleteRepoParams{
Context: ctx,
}
}
// NewDeleteRepoParamsWithHTTPClient creates a new DeleteRepoParams object
// with the ability to set a custom HTTPClient for a request.
func NewDeleteRepoParamsWithHTTPClient(client *http.Client) *DeleteRepoParams {
return &DeleteRepoParams{
HTTPClient: client,
}
}
/*
DeleteRepoParams contains all the parameters to send to the API endpoint
for the delete repo operation.
Typically these are written to a http.Request.
*/
type DeleteRepoParams struct {
/* RepoID.
ID of the repository to delete.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the delete repo params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteRepoParams) WithDefaults() *DeleteRepoParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the delete repo params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteRepoParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the delete repo params
func (o *DeleteRepoParams) WithTimeout(timeout time.Duration) *DeleteRepoParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the delete repo params
func (o *DeleteRepoParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the delete repo params
func (o *DeleteRepoParams) WithContext(ctx context.Context) *DeleteRepoParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the delete repo params
func (o *DeleteRepoParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the delete repo params
func (o *DeleteRepoParams) WithHTTPClient(client *http.Client) *DeleteRepoParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the delete repo params
func (o *DeleteRepoParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRepoID adds the repoID to the delete repo params
func (o *DeleteRepoParams) WithRepoID(repoID string) *DeleteRepoParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the delete repo params
func (o *DeleteRepoParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *DeleteRepoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewDeleteRepoPoolParams creates a new DeleteRepoPoolParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewDeleteRepoPoolParams() *DeleteRepoPoolParams {
return &DeleteRepoPoolParams{
timeout: cr.DefaultTimeout,
}
}
// NewDeleteRepoPoolParamsWithTimeout creates a new DeleteRepoPoolParams object
// with the ability to set a timeout on a request.
func NewDeleteRepoPoolParamsWithTimeout(timeout time.Duration) *DeleteRepoPoolParams {
return &DeleteRepoPoolParams{
timeout: timeout,
}
}
// NewDeleteRepoPoolParamsWithContext creates a new DeleteRepoPoolParams object
// with the ability to set a context for a request.
func NewDeleteRepoPoolParamsWithContext(ctx context.Context) *DeleteRepoPoolParams {
return &DeleteRepoPoolParams{
Context: ctx,
}
}
// NewDeleteRepoPoolParamsWithHTTPClient creates a new DeleteRepoPoolParams object
// with the ability to set a custom HTTPClient for a request.
func NewDeleteRepoPoolParamsWithHTTPClient(client *http.Client) *DeleteRepoPoolParams {
return &DeleteRepoPoolParams{
HTTPClient: client,
}
}
/*
DeleteRepoPoolParams contains all the parameters to send to the API endpoint
for the delete repo pool operation.
Typically these are written to a http.Request.
*/
type DeleteRepoPoolParams struct {
/* PoolID.
ID of the repository pool to delete.
*/
PoolID string
/* RepoID.
Repository ID.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the delete repo pool params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteRepoPoolParams) WithDefaults() *DeleteRepoPoolParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the delete repo pool params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeleteRepoPoolParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the delete repo pool params
func (o *DeleteRepoPoolParams) WithTimeout(timeout time.Duration) *DeleteRepoPoolParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the delete repo pool params
func (o *DeleteRepoPoolParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the delete repo pool params
func (o *DeleteRepoPoolParams) WithContext(ctx context.Context) *DeleteRepoPoolParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the delete repo pool params
func (o *DeleteRepoPoolParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the delete repo pool params
func (o *DeleteRepoPoolParams) WithHTTPClient(client *http.Client) *DeleteRepoPoolParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the delete repo pool params
func (o *DeleteRepoPoolParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithPoolID adds the poolID to the delete repo pool params
func (o *DeleteRepoPoolParams) WithPoolID(poolID string) *DeleteRepoPoolParams {
o.SetPoolID(poolID)
return o
}
// SetPoolID adds the poolId to the delete repo pool params
func (o *DeleteRepoPoolParams) SetPoolID(poolID string) {
o.PoolID = poolID
}
// WithRepoID adds the repoID to the delete repo pool params
func (o *DeleteRepoPoolParams) WithRepoID(repoID string) *DeleteRepoPoolParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the delete repo pool params
func (o *DeleteRepoPoolParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *DeleteRepoPoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param poolID
if err := r.SetPathParam("poolID", o.PoolID); err != nil {
return err
}
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,103 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
)
// DeleteRepoPoolReader is a Reader for the DeleteRepoPool structure.
type DeleteRepoPoolReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DeleteRepoPoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
result := NewDeleteRepoPoolDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
// NewDeleteRepoPoolDefault creates a DeleteRepoPoolDefault with default headers values
func NewDeleteRepoPoolDefault(code int) *DeleteRepoPoolDefault {
return &DeleteRepoPoolDefault{
_statusCode: code,
}
}
/*
DeleteRepoPoolDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type DeleteRepoPoolDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this delete repo pool default response has a 2xx status code
func (o *DeleteRepoPoolDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this delete repo pool default response has a 3xx status code
func (o *DeleteRepoPoolDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this delete repo pool default response has a 4xx status code
func (o *DeleteRepoPoolDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this delete repo pool default response has a 5xx status code
func (o *DeleteRepoPoolDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this delete repo pool default response a status code equal to that given
func (o *DeleteRepoPoolDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the delete repo pool default response
func (o *DeleteRepoPoolDefault) Code() int {
return o._statusCode
}
func (o *DeleteRepoPoolDefault) Error() string {
return fmt.Sprintf("[DELETE /repositories/{repoID}/pools/{poolID}][%d] DeleteRepoPool default %+v", o._statusCode, o.Payload)
}
func (o *DeleteRepoPoolDefault) String() string {
return fmt.Sprintf("[DELETE /repositories/{repoID}/pools/{poolID}][%d] DeleteRepoPool default %+v", o._statusCode, o.Payload)
}
func (o *DeleteRepoPoolDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *DeleteRepoPoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,103 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
)
// DeleteRepoReader is a Reader for the DeleteRepo structure.
type DeleteRepoReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DeleteRepoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
result := NewDeleteRepoDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
// NewDeleteRepoDefault creates a DeleteRepoDefault with default headers values
func NewDeleteRepoDefault(code int) *DeleteRepoDefault {
return &DeleteRepoDefault{
_statusCode: code,
}
}
/*
DeleteRepoDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type DeleteRepoDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this delete repo default response has a 2xx status code
func (o *DeleteRepoDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this delete repo default response has a 3xx status code
func (o *DeleteRepoDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this delete repo default response has a 4xx status code
func (o *DeleteRepoDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this delete repo default response has a 5xx status code
func (o *DeleteRepoDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this delete repo default response a status code equal to that given
func (o *DeleteRepoDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the delete repo default response
func (o *DeleteRepoDefault) Code() int {
return o._statusCode
}
func (o *DeleteRepoDefault) Error() string {
return fmt.Sprintf("[DELETE /repositories/{repoID}][%d] DeleteRepo default %+v", o._statusCode, o.Payload)
}
func (o *DeleteRepoDefault) String() string {
return fmt.Sprintf("[DELETE /repositories/{repoID}][%d] DeleteRepo default %+v", o._statusCode, o.Payload)
}
func (o *DeleteRepoDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *DeleteRepoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewGetRepoParams creates a new GetRepoParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewGetRepoParams() *GetRepoParams {
return &GetRepoParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetRepoParamsWithTimeout creates a new GetRepoParams object
// with the ability to set a timeout on a request.
func NewGetRepoParamsWithTimeout(timeout time.Duration) *GetRepoParams {
return &GetRepoParams{
timeout: timeout,
}
}
// NewGetRepoParamsWithContext creates a new GetRepoParams object
// with the ability to set a context for a request.
func NewGetRepoParamsWithContext(ctx context.Context) *GetRepoParams {
return &GetRepoParams{
Context: ctx,
}
}
// NewGetRepoParamsWithHTTPClient creates a new GetRepoParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetRepoParamsWithHTTPClient(client *http.Client) *GetRepoParams {
return &GetRepoParams{
HTTPClient: client,
}
}
/*
GetRepoParams contains all the parameters to send to the API endpoint
for the get repo operation.
Typically these are written to a http.Request.
*/
type GetRepoParams struct {
/* RepoID.
ID of the repository to fetch.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get repo params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetRepoParams) WithDefaults() *GetRepoParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get repo params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetRepoParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get repo params
func (o *GetRepoParams) WithTimeout(timeout time.Duration) *GetRepoParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get repo params
func (o *GetRepoParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get repo params
func (o *GetRepoParams) WithContext(ctx context.Context) *GetRepoParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get repo params
func (o *GetRepoParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get repo params
func (o *GetRepoParams) WithHTTPClient(client *http.Client) *GetRepoParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get repo params
func (o *GetRepoParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRepoID adds the repoID to the get repo params
func (o *GetRepoParams) WithRepoID(repoID string) *GetRepoParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the get repo params
func (o *GetRepoParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *GetRepoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewGetRepoPoolParams creates a new GetRepoPoolParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewGetRepoPoolParams() *GetRepoPoolParams {
return &GetRepoPoolParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetRepoPoolParamsWithTimeout creates a new GetRepoPoolParams object
// with the ability to set a timeout on a request.
func NewGetRepoPoolParamsWithTimeout(timeout time.Duration) *GetRepoPoolParams {
return &GetRepoPoolParams{
timeout: timeout,
}
}
// NewGetRepoPoolParamsWithContext creates a new GetRepoPoolParams object
// with the ability to set a context for a request.
func NewGetRepoPoolParamsWithContext(ctx context.Context) *GetRepoPoolParams {
return &GetRepoPoolParams{
Context: ctx,
}
}
// NewGetRepoPoolParamsWithHTTPClient creates a new GetRepoPoolParams object
// with the ability to set a custom HTTPClient for a request.
func NewGetRepoPoolParamsWithHTTPClient(client *http.Client) *GetRepoPoolParams {
return &GetRepoPoolParams{
HTTPClient: client,
}
}
/*
GetRepoPoolParams contains all the parameters to send to the API endpoint
for the get repo pool operation.
Typically these are written to a http.Request.
*/
type GetRepoPoolParams struct {
/* PoolID.
Pool ID.
*/
PoolID string
/* RepoID.
Repository ID.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the get repo pool params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetRepoPoolParams) WithDefaults() *GetRepoPoolParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the get repo pool params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *GetRepoPoolParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the get repo pool params
func (o *GetRepoPoolParams) WithTimeout(timeout time.Duration) *GetRepoPoolParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get repo pool params
func (o *GetRepoPoolParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get repo pool params
func (o *GetRepoPoolParams) WithContext(ctx context.Context) *GetRepoPoolParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get repo pool params
func (o *GetRepoPoolParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get repo pool params
func (o *GetRepoPoolParams) WithHTTPClient(client *http.Client) *GetRepoPoolParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get repo pool params
func (o *GetRepoPoolParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithPoolID adds the poolID to the get repo pool params
func (o *GetRepoPoolParams) WithPoolID(poolID string) *GetRepoPoolParams {
o.SetPoolID(poolID)
return o
}
// SetPoolID adds the poolId to the get repo pool params
func (o *GetRepoPoolParams) SetPoolID(poolID string) {
o.PoolID = poolID
}
// WithRepoID adds the repoID to the get repo pool params
func (o *GetRepoPoolParams) WithRepoID(repoID string) *GetRepoPoolParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the get repo pool params
func (o *GetRepoPoolParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *GetRepoPoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param poolID
if err := r.SetPathParam("poolID", o.PoolID); err != nil {
return err
}
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// GetRepoPoolReader is a Reader for the GetRepoPool structure.
type GetRepoPoolReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetRepoPoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetRepoPoolOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewGetRepoPoolDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewGetRepoPoolOK creates a GetRepoPoolOK with default headers values
func NewGetRepoPoolOK() *GetRepoPoolOK {
return &GetRepoPoolOK{}
}
/*
GetRepoPoolOK describes a response with status code 200, with default header values.
Pool
*/
type GetRepoPoolOK struct {
Payload garm_params.Pool
}
// IsSuccess returns true when this get repo pool o k response has a 2xx status code
func (o *GetRepoPoolOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get repo pool o k response has a 3xx status code
func (o *GetRepoPoolOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get repo pool o k response has a 4xx status code
func (o *GetRepoPoolOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get repo pool o k response has a 5xx status code
func (o *GetRepoPoolOK) IsServerError() bool {
return false
}
// IsCode returns true when this get repo pool o k response a status code equal to that given
func (o *GetRepoPoolOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the get repo pool o k response
func (o *GetRepoPoolOK) Code() int {
return 200
}
func (o *GetRepoPoolOK) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}/pools/{poolID}][%d] getRepoPoolOK %+v", 200, o.Payload)
}
func (o *GetRepoPoolOK) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}/pools/{poolID}][%d] getRepoPoolOK %+v", 200, o.Payload)
}
func (o *GetRepoPoolOK) GetPayload() garm_params.Pool {
return o.Payload
}
func (o *GetRepoPoolOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetRepoPoolDefault creates a GetRepoPoolDefault with default headers values
func NewGetRepoPoolDefault(code int) *GetRepoPoolDefault {
return &GetRepoPoolDefault{
_statusCode: code,
}
}
/*
GetRepoPoolDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type GetRepoPoolDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this get repo pool default response has a 2xx status code
func (o *GetRepoPoolDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this get repo pool default response has a 3xx status code
func (o *GetRepoPoolDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this get repo pool default response has a 4xx status code
func (o *GetRepoPoolDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this get repo pool default response has a 5xx status code
func (o *GetRepoPoolDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this get repo pool default response a status code equal to that given
func (o *GetRepoPoolDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the get repo pool default response
func (o *GetRepoPoolDefault) Code() int {
return o._statusCode
}
func (o *GetRepoPoolDefault) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}/pools/{poolID}][%d] GetRepoPool default %+v", o._statusCode, o.Payload)
}
func (o *GetRepoPoolDefault) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}/pools/{poolID}][%d] GetRepoPool default %+v", o._statusCode, o.Payload)
}
func (o *GetRepoPoolDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *GetRepoPoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// GetRepoReader is a Reader for the GetRepo structure.
type GetRepoReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetRepoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetRepoOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewGetRepoDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewGetRepoOK creates a GetRepoOK with default headers values
func NewGetRepoOK() *GetRepoOK {
return &GetRepoOK{}
}
/*
GetRepoOK describes a response with status code 200, with default header values.
Repository
*/
type GetRepoOK struct {
Payload garm_params.Repository
}
// IsSuccess returns true when this get repo o k response has a 2xx status code
func (o *GetRepoOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this get repo o k response has a 3xx status code
func (o *GetRepoOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this get repo o k response has a 4xx status code
func (o *GetRepoOK) IsClientError() bool {
return false
}
// IsServerError returns true when this get repo o k response has a 5xx status code
func (o *GetRepoOK) IsServerError() bool {
return false
}
// IsCode returns true when this get repo o k response a status code equal to that given
func (o *GetRepoOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the get repo o k response
func (o *GetRepoOK) Code() int {
return 200
}
func (o *GetRepoOK) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}][%d] getRepoOK %+v", 200, o.Payload)
}
func (o *GetRepoOK) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}][%d] getRepoOK %+v", 200, o.Payload)
}
func (o *GetRepoOK) GetPayload() garm_params.Repository {
return o.Payload
}
func (o *GetRepoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewGetRepoDefault creates a GetRepoDefault with default headers values
func NewGetRepoDefault(code int) *GetRepoDefault {
return &GetRepoDefault{
_statusCode: code,
}
}
/*
GetRepoDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type GetRepoDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this get repo default response has a 2xx status code
func (o *GetRepoDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this get repo default response has a 3xx status code
func (o *GetRepoDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this get repo default response has a 4xx status code
func (o *GetRepoDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this get repo default response has a 5xx status code
func (o *GetRepoDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this get repo default response a status code equal to that given
func (o *GetRepoDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the get repo default response
func (o *GetRepoDefault) Code() int {
return o._statusCode
}
func (o *GetRepoDefault) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}][%d] GetRepo default %+v", o._statusCode, o.Payload)
}
func (o *GetRepoDefault) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}][%d] GetRepo default %+v", o._statusCode, o.Payload)
}
func (o *GetRepoDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *GetRepoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListRepoInstancesParams creates a new ListRepoInstancesParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListRepoInstancesParams() *ListRepoInstancesParams {
return &ListRepoInstancesParams{
timeout: cr.DefaultTimeout,
}
}
// NewListRepoInstancesParamsWithTimeout creates a new ListRepoInstancesParams object
// with the ability to set a timeout on a request.
func NewListRepoInstancesParamsWithTimeout(timeout time.Duration) *ListRepoInstancesParams {
return &ListRepoInstancesParams{
timeout: timeout,
}
}
// NewListRepoInstancesParamsWithContext creates a new ListRepoInstancesParams object
// with the ability to set a context for a request.
func NewListRepoInstancesParamsWithContext(ctx context.Context) *ListRepoInstancesParams {
return &ListRepoInstancesParams{
Context: ctx,
}
}
// NewListRepoInstancesParamsWithHTTPClient creates a new ListRepoInstancesParams object
// with the ability to set a custom HTTPClient for a request.
func NewListRepoInstancesParamsWithHTTPClient(client *http.Client) *ListRepoInstancesParams {
return &ListRepoInstancesParams{
HTTPClient: client,
}
}
/*
ListRepoInstancesParams contains all the parameters to send to the API endpoint
for the list repo instances operation.
Typically these are written to a http.Request.
*/
type ListRepoInstancesParams struct {
/* RepoID.
Repository ID.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list repo instances params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListRepoInstancesParams) WithDefaults() *ListRepoInstancesParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list repo instances params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListRepoInstancesParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list repo instances params
func (o *ListRepoInstancesParams) WithTimeout(timeout time.Duration) *ListRepoInstancesParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list repo instances params
func (o *ListRepoInstancesParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list repo instances params
func (o *ListRepoInstancesParams) WithContext(ctx context.Context) *ListRepoInstancesParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list repo instances params
func (o *ListRepoInstancesParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list repo instances params
func (o *ListRepoInstancesParams) WithHTTPClient(client *http.Client) *ListRepoInstancesParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list repo instances params
func (o *ListRepoInstancesParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRepoID adds the repoID to the list repo instances params
func (o *ListRepoInstancesParams) WithRepoID(repoID string) *ListRepoInstancesParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the list repo instances params
func (o *ListRepoInstancesParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *ListRepoInstancesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListRepoInstancesReader is a Reader for the ListRepoInstances structure.
type ListRepoInstancesReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListRepoInstancesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListRepoInstancesOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListRepoInstancesDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListRepoInstancesOK creates a ListRepoInstancesOK with default headers values
func NewListRepoInstancesOK() *ListRepoInstancesOK {
return &ListRepoInstancesOK{}
}
/*
ListRepoInstancesOK describes a response with status code 200, with default header values.
Instances
*/
type ListRepoInstancesOK struct {
Payload garm_params.Instances
}
// IsSuccess returns true when this list repo instances o k response has a 2xx status code
func (o *ListRepoInstancesOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list repo instances o k response has a 3xx status code
func (o *ListRepoInstancesOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list repo instances o k response has a 4xx status code
func (o *ListRepoInstancesOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list repo instances o k response has a 5xx status code
func (o *ListRepoInstancesOK) IsServerError() bool {
return false
}
// IsCode returns true when this list repo instances o k response a status code equal to that given
func (o *ListRepoInstancesOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list repo instances o k response
func (o *ListRepoInstancesOK) Code() int {
return 200
}
func (o *ListRepoInstancesOK) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}/instances][%d] listRepoInstancesOK %+v", 200, o.Payload)
}
func (o *ListRepoInstancesOK) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}/instances][%d] listRepoInstancesOK %+v", 200, o.Payload)
}
func (o *ListRepoInstancesOK) GetPayload() garm_params.Instances {
return o.Payload
}
func (o *ListRepoInstancesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListRepoInstancesDefault creates a ListRepoInstancesDefault with default headers values
func NewListRepoInstancesDefault(code int) *ListRepoInstancesDefault {
return &ListRepoInstancesDefault{
_statusCode: code,
}
}
/*
ListRepoInstancesDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListRepoInstancesDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list repo instances default response has a 2xx status code
func (o *ListRepoInstancesDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list repo instances default response has a 3xx status code
func (o *ListRepoInstancesDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list repo instances default response has a 4xx status code
func (o *ListRepoInstancesDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list repo instances default response has a 5xx status code
func (o *ListRepoInstancesDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list repo instances default response a status code equal to that given
func (o *ListRepoInstancesDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list repo instances default response
func (o *ListRepoInstancesDefault) Code() int {
return o._statusCode
}
func (o *ListRepoInstancesDefault) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}/instances][%d] ListRepoInstances default %+v", o._statusCode, o.Payload)
}
func (o *ListRepoInstancesDefault) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}/instances][%d] ListRepoInstances default %+v", o._statusCode, o.Payload)
}
func (o *ListRepoInstancesDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListRepoInstancesDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListRepoPoolsParams creates a new ListRepoPoolsParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListRepoPoolsParams() *ListRepoPoolsParams {
return &ListRepoPoolsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListRepoPoolsParamsWithTimeout creates a new ListRepoPoolsParams object
// with the ability to set a timeout on a request.
func NewListRepoPoolsParamsWithTimeout(timeout time.Duration) *ListRepoPoolsParams {
return &ListRepoPoolsParams{
timeout: timeout,
}
}
// NewListRepoPoolsParamsWithContext creates a new ListRepoPoolsParams object
// with the ability to set a context for a request.
func NewListRepoPoolsParamsWithContext(ctx context.Context) *ListRepoPoolsParams {
return &ListRepoPoolsParams{
Context: ctx,
}
}
// NewListRepoPoolsParamsWithHTTPClient creates a new ListRepoPoolsParams object
// with the ability to set a custom HTTPClient for a request.
func NewListRepoPoolsParamsWithHTTPClient(client *http.Client) *ListRepoPoolsParams {
return &ListRepoPoolsParams{
HTTPClient: client,
}
}
/*
ListRepoPoolsParams contains all the parameters to send to the API endpoint
for the list repo pools operation.
Typically these are written to a http.Request.
*/
type ListRepoPoolsParams struct {
/* RepoID.
Repository ID.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list repo pools params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListRepoPoolsParams) WithDefaults() *ListRepoPoolsParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list repo pools params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListRepoPoolsParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list repo pools params
func (o *ListRepoPoolsParams) WithTimeout(timeout time.Duration) *ListRepoPoolsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list repo pools params
func (o *ListRepoPoolsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list repo pools params
func (o *ListRepoPoolsParams) WithContext(ctx context.Context) *ListRepoPoolsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list repo pools params
func (o *ListRepoPoolsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list repo pools params
func (o *ListRepoPoolsParams) WithHTTPClient(client *http.Client) *ListRepoPoolsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list repo pools params
func (o *ListRepoPoolsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRepoID adds the repoID to the list repo pools params
func (o *ListRepoPoolsParams) WithRepoID(repoID string) *ListRepoPoolsParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the list repo pools params
func (o *ListRepoPoolsParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *ListRepoPoolsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListRepoPoolsReader is a Reader for the ListRepoPools structure.
type ListRepoPoolsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListRepoPoolsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListRepoPoolsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListRepoPoolsDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListRepoPoolsOK creates a ListRepoPoolsOK with default headers values
func NewListRepoPoolsOK() *ListRepoPoolsOK {
return &ListRepoPoolsOK{}
}
/*
ListRepoPoolsOK describes a response with status code 200, with default header values.
Pools
*/
type ListRepoPoolsOK struct {
Payload garm_params.Pools
}
// IsSuccess returns true when this list repo pools o k response has a 2xx status code
func (o *ListRepoPoolsOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list repo pools o k response has a 3xx status code
func (o *ListRepoPoolsOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list repo pools o k response has a 4xx status code
func (o *ListRepoPoolsOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list repo pools o k response has a 5xx status code
func (o *ListRepoPoolsOK) IsServerError() bool {
return false
}
// IsCode returns true when this list repo pools o k response a status code equal to that given
func (o *ListRepoPoolsOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list repo pools o k response
func (o *ListRepoPoolsOK) Code() int {
return 200
}
func (o *ListRepoPoolsOK) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}/pools][%d] listRepoPoolsOK %+v", 200, o.Payload)
}
func (o *ListRepoPoolsOK) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}/pools][%d] listRepoPoolsOK %+v", 200, o.Payload)
}
func (o *ListRepoPoolsOK) GetPayload() garm_params.Pools {
return o.Payload
}
func (o *ListRepoPoolsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListRepoPoolsDefault creates a ListRepoPoolsDefault with default headers values
func NewListRepoPoolsDefault(code int) *ListRepoPoolsDefault {
return &ListRepoPoolsDefault{
_statusCode: code,
}
}
/*
ListRepoPoolsDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListRepoPoolsDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list repo pools default response has a 2xx status code
func (o *ListRepoPoolsDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list repo pools default response has a 3xx status code
func (o *ListRepoPoolsDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list repo pools default response has a 4xx status code
func (o *ListRepoPoolsDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list repo pools default response has a 5xx status code
func (o *ListRepoPoolsDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list repo pools default response a status code equal to that given
func (o *ListRepoPoolsDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list repo pools default response
func (o *ListRepoPoolsDefault) Code() int {
return o._statusCode
}
func (o *ListRepoPoolsDefault) Error() string {
return fmt.Sprintf("[GET /repositories/{repoID}/pools][%d] ListRepoPools default %+v", o._statusCode, o.Payload)
}
func (o *ListRepoPoolsDefault) String() string {
return fmt.Sprintf("[GET /repositories/{repoID}/pools][%d] ListRepoPools default %+v", o._statusCode, o.Payload)
}
func (o *ListRepoPoolsDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListRepoPoolsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,128 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewListReposParams creates a new ListReposParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewListReposParams() *ListReposParams {
return &ListReposParams{
timeout: cr.DefaultTimeout,
}
}
// NewListReposParamsWithTimeout creates a new ListReposParams object
// with the ability to set a timeout on a request.
func NewListReposParamsWithTimeout(timeout time.Duration) *ListReposParams {
return &ListReposParams{
timeout: timeout,
}
}
// NewListReposParamsWithContext creates a new ListReposParams object
// with the ability to set a context for a request.
func NewListReposParamsWithContext(ctx context.Context) *ListReposParams {
return &ListReposParams{
Context: ctx,
}
}
// NewListReposParamsWithHTTPClient creates a new ListReposParams object
// with the ability to set a custom HTTPClient for a request.
func NewListReposParamsWithHTTPClient(client *http.Client) *ListReposParams {
return &ListReposParams{
HTTPClient: client,
}
}
/*
ListReposParams contains all the parameters to send to the API endpoint
for the list repos operation.
Typically these are written to a http.Request.
*/
type ListReposParams struct {
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the list repos params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListReposParams) WithDefaults() *ListReposParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the list repos params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ListReposParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the list repos params
func (o *ListReposParams) WithTimeout(timeout time.Duration) *ListReposParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list repos params
func (o *ListReposParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list repos params
func (o *ListReposParams) WithContext(ctx context.Context) *ListReposParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list repos params
func (o *ListReposParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list repos params
func (o *ListReposParams) WithHTTPClient(client *http.Client) *ListReposParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list repos params
func (o *ListReposParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WriteToRequest writes these params to a swagger request
func (o *ListReposParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// ListReposReader is a Reader for the ListRepos structure.
type ListReposReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListReposReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListReposOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewListReposDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewListReposOK creates a ListReposOK with default headers values
func NewListReposOK() *ListReposOK {
return &ListReposOK{}
}
/*
ListReposOK describes a response with status code 200, with default header values.
Repositories
*/
type ListReposOK struct {
Payload garm_params.Repositories
}
// IsSuccess returns true when this list repos o k response has a 2xx status code
func (o *ListReposOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this list repos o k response has a 3xx status code
func (o *ListReposOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this list repos o k response has a 4xx status code
func (o *ListReposOK) IsClientError() bool {
return false
}
// IsServerError returns true when this list repos o k response has a 5xx status code
func (o *ListReposOK) IsServerError() bool {
return false
}
// IsCode returns true when this list repos o k response a status code equal to that given
func (o *ListReposOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the list repos o k response
func (o *ListReposOK) Code() int {
return 200
}
func (o *ListReposOK) Error() string {
return fmt.Sprintf("[GET /repositories][%d] listReposOK %+v", 200, o.Payload)
}
func (o *ListReposOK) String() string {
return fmt.Sprintf("[GET /repositories][%d] listReposOK %+v", 200, o.Payload)
}
func (o *ListReposOK) GetPayload() garm_params.Repositories {
return o.Payload
}
func (o *ListReposOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewListReposDefault creates a ListReposDefault with default headers values
func NewListReposDefault(code int) *ListReposDefault {
return &ListReposDefault{
_statusCode: code,
}
}
/*
ListReposDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type ListReposDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this list repos default response has a 2xx status code
func (o *ListReposDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this list repos default response has a 3xx status code
func (o *ListReposDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this list repos default response has a 4xx status code
func (o *ListReposDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this list repos default response has a 5xx status code
func (o *ListReposDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this list repos default response a status code equal to that given
func (o *ListReposDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the list repos default response
func (o *ListReposDefault) Code() int {
return o._statusCode
}
func (o *ListReposDefault) Error() string {
return fmt.Sprintf("[GET /repositories][%d] ListRepos default %+v", o._statusCode, o.Payload)
}
func (o *ListReposDefault) String() string {
return fmt.Sprintf("[GET /repositories][%d] ListRepos default %+v", o._statusCode, o.Payload)
}
func (o *ListReposDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *ListReposDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,465 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
)
// New creates a new repositories API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
return &Client{transport: transport, formats: formats}
}
/*
Client for repositories API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
// ClientOption is the option for Client methods
type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
CreateRepo(params *CreateRepoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateRepoOK, error)
CreateRepoPool(params *CreateRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateRepoPoolOK, error)
DeleteRepo(params *DeleteRepoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
DeleteRepoPool(params *DeleteRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error
GetRepo(params *GetRepoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRepoOK, error)
GetRepoPool(params *GetRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRepoPoolOK, error)
ListRepoInstances(params *ListRepoInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListRepoInstancesOK, error)
ListRepoPools(params *ListRepoPoolsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListRepoPoolsOK, error)
ListRepos(params *ListReposParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListReposOK, error)
UpdateRepo(params *UpdateRepoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateRepoOK, error)
UpdateRepoPool(params *UpdateRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateRepoPoolOK, error)
SetTransport(transport runtime.ClientTransport)
}
/*
CreateRepo creates repository with the parameters given
*/
func (a *Client) CreateRepo(params *CreateRepoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateRepoOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateRepoParams()
}
op := &runtime.ClientOperation{
ID: "CreateRepo",
Method: "POST",
PathPattern: "/repositories",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &CreateRepoReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*CreateRepoOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*CreateRepoDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
CreateRepoPool creates repository pool with the parameters given
*/
func (a *Client) CreateRepoPool(params *CreateRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateRepoPoolOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateRepoPoolParams()
}
op := &runtime.ClientOperation{
ID: "CreateRepoPool",
Method: "POST",
PathPattern: "/repositories/{repoID}/pools",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &CreateRepoPoolReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*CreateRepoPoolOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*CreateRepoPoolDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
DeleteRepo deletes repository by ID
*/
func (a *Client) DeleteRepo(params *DeleteRepoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteRepoParams()
}
op := &runtime.ClientOperation{
ID: "DeleteRepo",
Method: "DELETE",
PathPattern: "/repositories/{repoID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &DeleteRepoReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
_, err := a.transport.Submit(op)
if err != nil {
return err
}
return nil
}
/*
DeleteRepoPool deletes repository pool by ID
*/
func (a *Client) DeleteRepoPool(params *DeleteRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) error {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteRepoPoolParams()
}
op := &runtime.ClientOperation{
ID: "DeleteRepoPool",
Method: "DELETE",
PathPattern: "/repositories/{repoID}/pools/{poolID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &DeleteRepoPoolReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
_, err := a.transport.Submit(op)
if err != nil {
return err
}
return nil
}
/*
GetRepo gets repository by ID
*/
func (a *Client) GetRepo(params *GetRepoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRepoOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetRepoParams()
}
op := &runtime.ClientOperation{
ID: "GetRepo",
Method: "GET",
PathPattern: "/repositories/{repoID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetRepoReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetRepoOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*GetRepoDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
GetRepoPool gets repository pool by ID
*/
func (a *Client) GetRepoPool(params *GetRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRepoPoolOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetRepoPoolParams()
}
op := &runtime.ClientOperation{
ID: "GetRepoPool",
Method: "GET",
PathPattern: "/repositories/{repoID}/pools/{poolID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &GetRepoPoolReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*GetRepoPoolOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*GetRepoPoolDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListRepoInstances lists repository instances
*/
func (a *Client) ListRepoInstances(params *ListRepoInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListRepoInstancesOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListRepoInstancesParams()
}
op := &runtime.ClientOperation{
ID: "ListRepoInstances",
Method: "GET",
PathPattern: "/repositories/{repoID}/instances",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListRepoInstancesReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListRepoInstancesOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListRepoInstancesDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListRepoPools lists repository pools
*/
func (a *Client) ListRepoPools(params *ListRepoPoolsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListRepoPoolsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListRepoPoolsParams()
}
op := &runtime.ClientOperation{
ID: "ListRepoPools",
Method: "GET",
PathPattern: "/repositories/{repoID}/pools",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListRepoPoolsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListRepoPoolsOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListRepoPoolsDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
ListRepos lists repositories
*/
func (a *Client) ListRepos(params *ListReposParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListReposOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListReposParams()
}
op := &runtime.ClientOperation{
ID: "ListRepos",
Method: "GET",
PathPattern: "/repositories",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &ListReposReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ListReposOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*ListReposDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
UpdateRepo updates repository with the parameters given
*/
func (a *Client) UpdateRepo(params *UpdateRepoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateRepoOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUpdateRepoParams()
}
op := &runtime.ClientOperation{
ID: "UpdateRepo",
Method: "PUT",
PathPattern: "/repositories/{repoID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &UpdateRepoReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*UpdateRepoOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*UpdateRepoDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
/*
UpdateRepoPool updates repository pool with the parameters given
*/
func (a *Client) UpdateRepoPool(params *UpdateRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateRepoPoolOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewUpdateRepoPoolParams()
}
op := &runtime.ClientOperation{
ID: "UpdateRepoPool",
Method: "PUT",
PathPattern: "/repositories/{repoID}/pools/{poolID}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &UpdateRepoPoolReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*UpdateRepoPoolOK)
if ok {
return success, nil
}
// unexpected success response
unexpectedSuccess := result.(*UpdateRepoPoolDefault)
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}

View file

@ -0,0 +1,173 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewUpdateRepoParams creates a new UpdateRepoParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewUpdateRepoParams() *UpdateRepoParams {
return &UpdateRepoParams{
timeout: cr.DefaultTimeout,
}
}
// NewUpdateRepoParamsWithTimeout creates a new UpdateRepoParams object
// with the ability to set a timeout on a request.
func NewUpdateRepoParamsWithTimeout(timeout time.Duration) *UpdateRepoParams {
return &UpdateRepoParams{
timeout: timeout,
}
}
// NewUpdateRepoParamsWithContext creates a new UpdateRepoParams object
// with the ability to set a context for a request.
func NewUpdateRepoParamsWithContext(ctx context.Context) *UpdateRepoParams {
return &UpdateRepoParams{
Context: ctx,
}
}
// NewUpdateRepoParamsWithHTTPClient creates a new UpdateRepoParams object
// with the ability to set a custom HTTPClient for a request.
func NewUpdateRepoParamsWithHTTPClient(client *http.Client) *UpdateRepoParams {
return &UpdateRepoParams{
HTTPClient: client,
}
}
/*
UpdateRepoParams contains all the parameters to send to the API endpoint
for the update repo operation.
Typically these are written to a http.Request.
*/
type UpdateRepoParams struct {
/* Body.
Parameters used when updating the repository.
*/
Body garm_params.UpdateEntityParams
/* RepoID.
ID of the repository to update.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the update repo params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateRepoParams) WithDefaults() *UpdateRepoParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the update repo params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateRepoParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the update repo params
func (o *UpdateRepoParams) WithTimeout(timeout time.Duration) *UpdateRepoParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the update repo params
func (o *UpdateRepoParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the update repo params
func (o *UpdateRepoParams) WithContext(ctx context.Context) *UpdateRepoParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the update repo params
func (o *UpdateRepoParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the update repo params
func (o *UpdateRepoParams) WithHTTPClient(client *http.Client) *UpdateRepoParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the update repo params
func (o *UpdateRepoParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the update repo params
func (o *UpdateRepoParams) WithBody(body garm_params.UpdateEntityParams) *UpdateRepoParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the update repo params
func (o *UpdateRepoParams) SetBody(body garm_params.UpdateEntityParams) {
o.Body = body
}
// WithRepoID adds the repoID to the update repo params
func (o *UpdateRepoParams) WithRepoID(repoID string) *UpdateRepoParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the update repo params
func (o *UpdateRepoParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *UpdateRepoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,195 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
garm_params "github.com/cloudbase/garm/params"
)
// NewUpdateRepoPoolParams creates a new UpdateRepoPoolParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewUpdateRepoPoolParams() *UpdateRepoPoolParams {
return &UpdateRepoPoolParams{
timeout: cr.DefaultTimeout,
}
}
// NewUpdateRepoPoolParamsWithTimeout creates a new UpdateRepoPoolParams object
// with the ability to set a timeout on a request.
func NewUpdateRepoPoolParamsWithTimeout(timeout time.Duration) *UpdateRepoPoolParams {
return &UpdateRepoPoolParams{
timeout: timeout,
}
}
// NewUpdateRepoPoolParamsWithContext creates a new UpdateRepoPoolParams object
// with the ability to set a context for a request.
func NewUpdateRepoPoolParamsWithContext(ctx context.Context) *UpdateRepoPoolParams {
return &UpdateRepoPoolParams{
Context: ctx,
}
}
// NewUpdateRepoPoolParamsWithHTTPClient creates a new UpdateRepoPoolParams object
// with the ability to set a custom HTTPClient for a request.
func NewUpdateRepoPoolParamsWithHTTPClient(client *http.Client) *UpdateRepoPoolParams {
return &UpdateRepoPoolParams{
HTTPClient: client,
}
}
/*
UpdateRepoPoolParams contains all the parameters to send to the API endpoint
for the update repo pool operation.
Typically these are written to a http.Request.
*/
type UpdateRepoPoolParams struct {
/* Body.
Parameters used when updating the repository pool.
*/
Body garm_params.UpdatePoolParams
/* PoolID.
ID of the repository pool to update.
*/
PoolID string
/* RepoID.
Repository ID.
*/
RepoID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the update repo pool params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateRepoPoolParams) WithDefaults() *UpdateRepoPoolParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the update repo pool params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *UpdateRepoPoolParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the update repo pool params
func (o *UpdateRepoPoolParams) WithTimeout(timeout time.Duration) *UpdateRepoPoolParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the update repo pool params
func (o *UpdateRepoPoolParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the update repo pool params
func (o *UpdateRepoPoolParams) WithContext(ctx context.Context) *UpdateRepoPoolParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the update repo pool params
func (o *UpdateRepoPoolParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the update repo pool params
func (o *UpdateRepoPoolParams) WithHTTPClient(client *http.Client) *UpdateRepoPoolParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the update repo pool params
func (o *UpdateRepoPoolParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the update repo pool params
func (o *UpdateRepoPoolParams) WithBody(body garm_params.UpdatePoolParams) *UpdateRepoPoolParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the update repo pool params
func (o *UpdateRepoPoolParams) SetBody(body garm_params.UpdatePoolParams) {
o.Body = body
}
// WithPoolID adds the poolID to the update repo pool params
func (o *UpdateRepoPoolParams) WithPoolID(poolID string) *UpdateRepoPoolParams {
o.SetPoolID(poolID)
return o
}
// SetPoolID adds the poolId to the update repo pool params
func (o *UpdateRepoPoolParams) SetPoolID(poolID string) {
o.PoolID = poolID
}
// WithRepoID adds the repoID to the update repo pool params
func (o *UpdateRepoPoolParams) WithRepoID(repoID string) *UpdateRepoPoolParams {
o.SetRepoID(repoID)
return o
}
// SetRepoID adds the repoId to the update repo pool params
func (o *UpdateRepoPoolParams) SetRepoID(repoID string) {
o.RepoID = repoID
}
// WriteToRequest writes these params to a swagger request
func (o *UpdateRepoPoolParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
// path param poolID
if err := r.SetPathParam("poolID", o.PoolID); err != nil {
return err
}
// path param repoID
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// UpdateRepoPoolReader is a Reader for the UpdateRepoPool structure.
type UpdateRepoPoolReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *UpdateRepoPoolReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewUpdateRepoPoolOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewUpdateRepoPoolDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewUpdateRepoPoolOK creates a UpdateRepoPoolOK with default headers values
func NewUpdateRepoPoolOK() *UpdateRepoPoolOK {
return &UpdateRepoPoolOK{}
}
/*
UpdateRepoPoolOK describes a response with status code 200, with default header values.
Pool
*/
type UpdateRepoPoolOK struct {
Payload garm_params.Pool
}
// IsSuccess returns true when this update repo pool o k response has a 2xx status code
func (o *UpdateRepoPoolOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this update repo pool o k response has a 3xx status code
func (o *UpdateRepoPoolOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this update repo pool o k response has a 4xx status code
func (o *UpdateRepoPoolOK) IsClientError() bool {
return false
}
// IsServerError returns true when this update repo pool o k response has a 5xx status code
func (o *UpdateRepoPoolOK) IsServerError() bool {
return false
}
// IsCode returns true when this update repo pool o k response a status code equal to that given
func (o *UpdateRepoPoolOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the update repo pool o k response
func (o *UpdateRepoPoolOK) Code() int {
return 200
}
func (o *UpdateRepoPoolOK) Error() string {
return fmt.Sprintf("[PUT /repositories/{repoID}/pools/{poolID}][%d] updateRepoPoolOK %+v", 200, o.Payload)
}
func (o *UpdateRepoPoolOK) String() string {
return fmt.Sprintf("[PUT /repositories/{repoID}/pools/{poolID}][%d] updateRepoPoolOK %+v", 200, o.Payload)
}
func (o *UpdateRepoPoolOK) GetPayload() garm_params.Pool {
return o.Payload
}
func (o *UpdateRepoPoolOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewUpdateRepoPoolDefault creates a UpdateRepoPoolDefault with default headers values
func NewUpdateRepoPoolDefault(code int) *UpdateRepoPoolDefault {
return &UpdateRepoPoolDefault{
_statusCode: code,
}
}
/*
UpdateRepoPoolDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type UpdateRepoPoolDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this update repo pool default response has a 2xx status code
func (o *UpdateRepoPoolDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this update repo pool default response has a 3xx status code
func (o *UpdateRepoPoolDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this update repo pool default response has a 4xx status code
func (o *UpdateRepoPoolDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this update repo pool default response has a 5xx status code
func (o *UpdateRepoPoolDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this update repo pool default response a status code equal to that given
func (o *UpdateRepoPoolDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the update repo pool default response
func (o *UpdateRepoPoolDefault) Code() int {
return o._statusCode
}
func (o *UpdateRepoPoolDefault) Error() string {
return fmt.Sprintf("[PUT /repositories/{repoID}/pools/{poolID}][%d] UpdateRepoPool default %+v", o._statusCode, o.Payload)
}
func (o *UpdateRepoPoolDefault) String() string {
return fmt.Sprintf("[PUT /repositories/{repoID}/pools/{poolID}][%d] UpdateRepoPool default %+v", o._statusCode, o.Payload)
}
func (o *UpdateRepoPoolDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *UpdateRepoPoolDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package repositories
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
apiserver_params "github.com/cloudbase/garm/apiserver/params"
garm_params "github.com/cloudbase/garm/params"
)
// UpdateRepoReader is a Reader for the UpdateRepo structure.
type UpdateRepoReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *UpdateRepoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewUpdateRepoOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
result := NewUpdateRepoDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewUpdateRepoOK creates a UpdateRepoOK with default headers values
func NewUpdateRepoOK() *UpdateRepoOK {
return &UpdateRepoOK{}
}
/*
UpdateRepoOK describes a response with status code 200, with default header values.
Repository
*/
type UpdateRepoOK struct {
Payload garm_params.Repository
}
// IsSuccess returns true when this update repo o k response has a 2xx status code
func (o *UpdateRepoOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this update repo o k response has a 3xx status code
func (o *UpdateRepoOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this update repo o k response has a 4xx status code
func (o *UpdateRepoOK) IsClientError() bool {
return false
}
// IsServerError returns true when this update repo o k response has a 5xx status code
func (o *UpdateRepoOK) IsServerError() bool {
return false
}
// IsCode returns true when this update repo o k response a status code equal to that given
func (o *UpdateRepoOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the update repo o k response
func (o *UpdateRepoOK) Code() int {
return 200
}
func (o *UpdateRepoOK) Error() string {
return fmt.Sprintf("[PUT /repositories/{repoID}][%d] updateRepoOK %+v", 200, o.Payload)
}
func (o *UpdateRepoOK) String() string {
return fmt.Sprintf("[PUT /repositories/{repoID}][%d] updateRepoOK %+v", 200, o.Payload)
}
func (o *UpdateRepoOK) GetPayload() garm_params.Repository {
return o.Payload
}
func (o *UpdateRepoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewUpdateRepoDefault creates a UpdateRepoDefault with default headers values
func NewUpdateRepoDefault(code int) *UpdateRepoDefault {
return &UpdateRepoDefault{
_statusCode: code,
}
}
/*
UpdateRepoDefault describes a response with status code -1, with default header values.
APIErrorResponse
*/
type UpdateRepoDefault struct {
_statusCode int
Payload apiserver_params.APIErrorResponse
}
// IsSuccess returns true when this update repo default response has a 2xx status code
func (o *UpdateRepoDefault) IsSuccess() bool {
return o._statusCode/100 == 2
}
// IsRedirect returns true when this update repo default response has a 3xx status code
func (o *UpdateRepoDefault) IsRedirect() bool {
return o._statusCode/100 == 3
}
// IsClientError returns true when this update repo default response has a 4xx status code
func (o *UpdateRepoDefault) IsClientError() bool {
return o._statusCode/100 == 4
}
// IsServerError returns true when this update repo default response has a 5xx status code
func (o *UpdateRepoDefault) IsServerError() bool {
return o._statusCode/100 == 5
}
// IsCode returns true when this update repo default response a status code equal to that given
func (o *UpdateRepoDefault) IsCode(code int) bool {
return o._statusCode == code
}
// Code gets the status code for the update repo default response
func (o *UpdateRepoDefault) Code() int {
return o._statusCode
}
func (o *UpdateRepoDefault) Error() string {
return fmt.Sprintf("[PUT /repositories/{repoID}][%d] UpdateRepo default %+v", o._statusCode, o.Payload)
}
func (o *UpdateRepoDefault) String() string {
return fmt.Sprintf("[PUT /repositories/{repoID}][%d] UpdateRepo default %+v", o._statusCode, o.Payload)
}
func (o *UpdateRepoDefault) GetPayload() apiserver_params.APIErrorResponse {
return o.Payload
}
func (o *UpdateRepoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View file

@ -36,11 +36,11 @@ if [ -z "$METADATA_URL" ];then
echo "no token is available and METADATA_URL is not set"
exit 1
fi
GITHUB_TOKEN=$(curl --retry 5 --retry-max-time 5 --fail -s -X GET -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${METADATA_URL}/runner-registration-token/")
GITHUB_TOKEN=$(curl --retry 5 --retry-delay 5 --retry-connrefused --fail -s -X GET -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${METADATA_URL}/runner-registration-token/")
function call() {
PAYLOAD="$1"
curl --retry 5 --retry-max-time 5 --retry-all-errors --fail -s -X POST -d "${PAYLOAD}" -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${CALLBACK_URL}" || echo "failed to call home: exit code ($?)"
curl --retry 5 --retry-delay 5 --retry-connrefused --fail -s -X POST -d "${PAYLOAD}" -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${CALLBACK_URL}" || echo "failed to call home: exit code ($?)"
}
function sendStatus() {
@ -93,11 +93,11 @@ function downloadAndExtractRunner() {
if [ ! -z "{{ .TempDownloadToken }}" ]; then
TEMP_TOKEN="Authorization: Bearer {{ .TempDownloadToken }}"
fi
curl --retry 5 --retry-max-time 5 --retry-all-errors --fail -L -H "${TEMP_TOKEN}" -o "/home/{{ .RunnerUsername }}/{{ .FileName }}" "{{ .DownloadURL }}" || fail "failed to download tools"
mkdir -p /home/runner/actions-runner || fail "failed to create actions-runner folder"
curl --retry 5 --retry-delay 5 --retry-connrefused --fail -L -H "${TEMP_TOKEN}" -o "/home/{{ .RunnerUsername }}/{{ .FileName }}" "{{ .DownloadURL }}" || fail "failed to download tools"
mkdir -p /home/{{ .RunnerUsername }}/actions-runner || fail "failed to create actions-runner folder"
sendStatus "extracting runner"
tar xf "/home/{{ .RunnerUsername }}/{{ .FileName }}" -C /home/{{ .RunnerUsername }}/actions-runner/ || fail "failed to extract runner"
chown {{ .RunnerUsername }}:{{ .RunnerGroup }} -R /home/{{ .RunnerUsername }}/actions-runner/ || fail "failed to change owner"
# chown {{ .RunnerUsername }}:{{ .RunnerGroup }} -R /home/{{ .RunnerUsername }}/actions-runner/ || fail "failed to change owner"
}
TEMP_TOKEN=""
@ -119,8 +119,8 @@ if [ -z "$CACHED_RUNNER" ];then
else
sendStatus "using cached runner found in $CACHED_RUNNER"
sudo cp -a "$CACHED_RUNNER" "/home/{{ .RunnerUsername }}/actions-runner"
sudo chown {{ .RunnerUsername }}:{{ .RunnerGroup }} -R "/home/{{ .RunnerUsername }}/actions-runner" || fail "failed to change owner"
cd /home/{{ .RunnerUsername }}/actions-runner
chown {{ .RunnerUsername }}:{{ .RunnerGroup }} -R "/home/{{ .RunnerUsername }}/actions-runner" || fail "failed to change owner"
fi
@ -129,7 +129,7 @@ set +e
attempt=1
while true; do
ERROUT=$(mktemp)
sudo -u {{ .RunnerUsername }} -- ./config.sh --unattended --url "{{ .RepoURL }}" --token "$GITHUB_TOKEN" $RUNNER_GROUP_OPT --name "{{ .RunnerName }}" --labels "{{ .RunnerLabels }}" --ephemeral 2>$ERROUT
./config.sh --unattended --url "{{ .RepoURL }}" --token "$GITHUB_TOKEN" $RUNNER_GROUP_OPT --name "{{ .RunnerName }}" --labels "{{ .RunnerLabels }}" --ephemeral 2>$ERROUT
if [ $? -eq 0 ]; then
rm $ERROUT || true
sendStatus "runner successfully configured after $attempt attempt(s)"
@ -140,7 +140,7 @@ while true; do
# if the runner is already configured, remove it and try again. In the past configuring a runner
# managed to register it but timed out later, resulting in an error.
sudo -u {{ .RunnerUsername }} -- ./config.sh remove --token "$GITHUB_TOKEN" || true
./config.sh remove --token "$GITHUB_TOKEN" || true
if [ $attempt -gt 5 ];then
rm $ERROUT || true
@ -155,7 +155,7 @@ done
set -e
sendStatus "installing runner service"
./svc.sh install {{ .RunnerUsername }} || fail "failed to install service"
sudo ./svc.sh install {{ .RunnerUsername }} || fail "failed to install service"
if [ -e "/sys/fs/selinux" ];then
sudo chcon -h user_u:object_r:bin_t /home/runner/ || fail "failed to change selinux context"
@ -163,7 +163,7 @@ if [ -e "/sys/fs/selinux" ];then
fi
sendStatus "starting service"
./svc.sh start || fail "failed to start service"
sudo ./svc.sh start || fail "failed to start service"
set +e
AGENT_ID=$(grep "agentId" /home/{{ .RunnerUsername }}/actions-runner/.runner | tr -d -c 0-9)

View file

@ -183,6 +183,19 @@ func (c *Client) DeleteRunner(instanceName string) error {
return nil
}
func (c *Client) ListAllJobs() ([]params.Job, error) {
url := fmt.Sprintf("%s/api/v1/jobs", c.Config.BaseURL)
var response []params.Job
resp, err := c.client.R().
SetResult(&response).
Get(url)
if err != nil || resp.IsError() {
return response, c.handleError(err, resp)
}
return response, nil
}
func (c *Client) ListPoolInstances(poolID string) ([]params.Instance, error) {
url := fmt.Sprintf("%s/api/v1/pools/%s/instances", c.Config.BaseURL, poolID)

View file

@ -51,6 +51,24 @@ func (c *Client) CreateEnterprise(param params.CreateEnterpriseParams) (params.E
return response, nil
}
func (c *Client) UpdateEnterprise(enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error) {
url := fmt.Sprintf("%s/api/v1/enterprises/%s", c.Config.BaseURL, enterpriseID)
var response params.Enterprise
body, err := json.Marshal(param)
if err != nil {
return response, err
}
resp, err := c.client.R().
SetBody(body).
SetResult(&response).
Put(url)
if err := c.handleError(err, resp); err != nil {
return params.Enterprise{}, err
}
return response, nil
}
func (c *Client) GetEnterprise(enterpriseID string) (params.Enterprise, error) {
var response params.Enterprise
url := fmt.Sprintf("%s/api/v1/enterprises/%s", c.Config.BaseURL, enterpriseID)

View file

@ -51,6 +51,24 @@ func (c *Client) CreateOrganization(param params.CreateOrgParams) (params.Organi
return response, nil
}
func (c *Client) UpdateOrganization(orgID string, param params.UpdateEntityParams) (params.Organization, error) {
url := fmt.Sprintf("%s/api/v1/organizations/%s", c.Config.BaseURL, orgID)
var response params.Organization
body, err := json.Marshal(param)
if err != nil {
return response, err
}
resp, err := c.client.R().
SetBody(body).
SetResult(&response).
Put(url)
if err := c.handleError(err, resp); err != nil {
return params.Organization{}, err
}
return response, nil
}
func (c *Client) GetOrganization(orgID string) (params.Organization, error) {
var response params.Organization
url := fmt.Sprintf("%s/api/v1/organizations/%s", c.Config.BaseURL, orgID)

View file

@ -147,6 +147,24 @@ func (c *Client) UpdateRepoPool(repoID, poolID string, param params.UpdatePoolPa
return response, nil
}
func (c *Client) UpdateRepo(repoID string, param params.UpdateEntityParams) (params.Repository, error) {
url := fmt.Sprintf("%s/api/v1/repositories/%s", c.Config.BaseURL, repoID)
var response params.Repository
body, err := json.Marshal(param)
if err != nil {
return response, err
}
resp, err := c.client.R().
SetBody(body).
SetResult(&response).
Put(url)
if err := c.handleError(err, resp); err != nil {
return params.Repository{}, err
}
return response, nil
}
func (c *Client) ListRepoInstances(repoID string) ([]params.Instance, error) {
url := fmt.Sprintf("%s/api/v1/repositories/%s/instances", c.Config.BaseURL, repoID)

View file

@ -135,6 +135,37 @@ var enterpriseDeleteCmd = &cobra.Command{
},
}
var enterpriseUpdateCmd = &cobra.Command{
Use: "update",
Short: "Update enterprise",
Long: `Update enterprise credentials or webhook secret.`,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if needsInit {
return errNeedsInitError
}
if len(args) == 0 {
return fmt.Errorf("command requires a enterprise ID")
}
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}
enterpriseUpdateReq := params.UpdateEntityParams{
WebhookSecret: repoWebhookSecret,
CredentialsName: repoCreds,
}
enterprise, err := cli.UpdateEnterprise(args[0], enterpriseUpdateReq)
if err != nil {
return err
}
formatOneEnterprise(enterprise)
return nil
},
}
func init() {
enterpriseAddCmd.Flags().StringVar(&enterpriseName, "name", "", "The name of the enterprise")
@ -142,12 +173,15 @@ func init() {
enterpriseAddCmd.Flags().StringVar(&enterpriseCreds, "credentials", "", "Credentials name. See credentials list.")
enterpriseAddCmd.MarkFlagRequired("credentials") //nolint
enterpriseAddCmd.MarkFlagRequired("name") //nolint
enterpriseUpdateCmd.Flags().StringVar(&enterpriseWebhookSecret, "webhook-secret", "", "The webhook secret for this enterprise")
enterpriseUpdateCmd.Flags().StringVar(&enterpriseCreds, "credentials", "", "Credentials name. See credentials list.")
enterpriseCmd.AddCommand(
enterpriseListCmd,
enterpriseAddCmd,
enterpriseShowCmd,
enterpriseDeleteCmd,
enterpriseUpdateCmd,
)
rootCmd.AddCommand(enterpriseCmd)

79
cmd/garm-cli/cmd/jobs.go Normal file
View file

@ -0,0 +1,79 @@
// Copyright 2023 Cloudbase Solutions SRL
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package cmd
import (
"fmt"
"strings"
"github.com/cloudbase/garm/params"
"github.com/google/uuid"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"
)
// runnerCmd represents the runner command
var jobsCmd = &cobra.Command{
Use: "job",
SilenceUsage: true,
Short: "Information about jobs",
Long: `Query information about jobs.`,
Run: nil,
}
var jobsListCmd = &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
Short: "List jobs",
Long: `List all jobs currently recorded in the system.`,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if needsInit {
return errNeedsInitError
}
jobs, err := cli.ListAllJobs()
if err != nil {
return err
}
formatJobs(jobs)
return nil
},
}
func formatJobs(jobs []params.Job) {
t := table.NewWriter()
header := table.Row{"ID", "Name", "Status", "Conclusion", "Runner Name", "Repository", "Requested Labels", "Locked by"}
t.AppendHeader(header)
for _, job := range jobs {
lockedBy := ""
repo := fmt.Sprintf("%s/%s", job.RepositoryOwner, job.RepositoryName)
if job.LockedBy != uuid.Nil {
lockedBy = job.LockedBy.String()
}
t.AppendRow(table.Row{job.ID, job.Name, job.Status, job.Conclusion, job.RunnerName, repo, strings.Join(job.Labels, " "), lockedBy})
t.AppendSeparator()
}
fmt.Println(t.Render())
}
func init() {
jobsCmd.AddCommand(
jobsListCmd,
)
rootCmd.AddCommand(jobsCmd)
}

View file

@ -68,6 +68,37 @@ var orgAddCmd = &cobra.Command{
},
}
var orgUpdateCmd = &cobra.Command{
Use: "update",
Short: "Update organization",
Long: `Update organization credentials or webhook secret.`,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if needsInit {
return errNeedsInitError
}
if len(args) == 0 {
return fmt.Errorf("command requires a organization ID")
}
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}
orgUpdateReq := params.UpdateEntityParams{
WebhookSecret: repoWebhookSecret,
CredentialsName: orgCreds,
}
org, err := cli.UpdateOrganization(args[0], orgUpdateReq)
if err != nil {
return err
}
formatOneOrganization(org)
return nil
},
}
var orgListCmd = &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
@ -142,12 +173,15 @@ func init() {
orgAddCmd.Flags().StringVar(&orgCreds, "credentials", "", "Credentials name. See credentials list.")
orgAddCmd.MarkFlagRequired("credentials") //nolint
orgAddCmd.MarkFlagRequired("name") //nolint
orgUpdateCmd.Flags().StringVar(&orgWebhookSecret, "webhook-secret", "", "The webhook secret for this organization")
orgUpdateCmd.Flags().StringVar(&orgCreds, "credentials", "", "Credentials name. See credentials list.")
organizationCmd.AddCommand(
orgListCmd,
orgAddCmd,
orgShowCmd,
orgDeleteCmd,
orgUpdateCmd,
)
rootCmd.AddCommand(organizationCmd)

View file

@ -90,6 +90,37 @@ var repoListCmd = &cobra.Command{
},
}
var repoUpdateCmd = &cobra.Command{
Use: "update",
Short: "Update repository",
Long: `Update repository credentials or webhook secret.`,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if needsInit {
return errNeedsInitError
}
if len(args) == 0 {
return fmt.Errorf("command requires a repo ID")
}
if len(args) > 1 {
return fmt.Errorf("too many arguments")
}
repoUpdateReq := params.UpdateEntityParams{
WebhookSecret: repoWebhookSecret,
CredentialsName: repoCreds,
}
repo, err := cli.UpdateRepo(args[0], repoUpdateReq)
if err != nil {
return err
}
formatOneRepository(repo)
return nil
},
}
var repoShowCmd = &cobra.Command{
Use: "show",
Short: "Show details for one repository",
@ -146,12 +177,15 @@ func init() {
repoAddCmd.MarkFlagRequired("credentials") //nolint
repoAddCmd.MarkFlagRequired("owner") //nolint
repoAddCmd.MarkFlagRequired("name") //nolint
repoUpdateCmd.Flags().StringVar(&repoWebhookSecret, "webhook-secret", "", "The webhook secret for this repository")
repoUpdateCmd.Flags().StringVar(&repoCreds, "credentials", "", "Credentials name. See credentials list.")
repositoryCmd.AddCommand(
repoListCmd,
repoAddCmd,
repoShowCmd,
repoDeleteCmd,
repoUpdateCmd,
)
rootCmd.AddCommand(repositoryCmd)

View file

@ -198,11 +198,11 @@ func init() {
func formatInstances(param []params.Instance) {
t := table.NewWriter()
header := table.Row{"Name", "Status", "Runner Status", "Pool ID"}
header := table.Row{"Nr", "Name", "Status", "Runner Status", "Pool ID"}
t.AppendHeader(header)
for _, inst := range param {
t.AppendRow(table.Row{inst.Name, inst.Status, inst.RunnerStatus, inst.PoolID})
for idx, inst := range param {
t.AppendRow(table.Row{idx + 1, inst.Name, inst.Status, inst.RunnerStatus, inst.PoolID})
t.AppendSeparator()
}
fmt.Println(t.Render())

View file

@ -24,6 +24,7 @@ import (
"net/http"
"os"
"os/signal"
"syscall"
"time"
"github.com/cloudbase/garm/apiserver/controllers"
@ -37,6 +38,7 @@ import (
"github.com/cloudbase/garm/util"
"github.com/cloudbase/garm/util/appdefaults"
"github.com/cloudbase/garm/websocket"
lumberjack "gopkg.in/natefinch/lumberjack.v2"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
@ -82,6 +84,26 @@ func main() {
log.Fatalf("fetching log writer: %+v", err)
}
// rotate log file on SIGHUP
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGHUP)
go func() {
for {
select {
case <-ctx.Done():
// Daemon is exiting.
return
case <-ch:
// we got a SIGHUP. Rotate log file.
if logger, ok := logWriter.(*lumberjack.Logger); ok {
if err := logger.Rotate(); err != nil {
log.Printf("failed to rotate log file: %v", err)
}
}
}
}
}()
var writers []io.Writer = []io.Writer{
logWriter,
}
@ -107,7 +129,7 @@ func main() {
log.Fatal(err)
}
runner, err := runner.NewRunner(ctx, *cfg)
runner, err := runner.NewRunner(ctx, *cfg, db)
if err != nil {
log.Fatalf("failed to create controller: %+v", err)
}
@ -154,6 +176,11 @@ func main() {
router = routers.WithMetricsRouter(router, cfg.Metrics.DisableAuth, metricsMiddleware)
}
if cfg.Default.DebugServer {
log.Printf("setting up debug routes")
router = routers.WithDebugServer(router)
}
corsMw := mux.CORSMethodMiddleware(router)
router.Use(corsMw)

View file

@ -120,6 +120,7 @@ type Default struct {
// LogFile is the location of the log file.
LogFile string `toml:"log_file,omitempty" json:"log-file"`
EnableLogStreamer bool `toml:"enable_log_streamer"`
DebugServer bool `toml:"debug_server" json:"debug-server"`
}
func (d *Default) Validate() error {
@ -337,7 +338,7 @@ func (s *SQLite) Validate() error {
}
func (s *SQLite) ConnectionString() (string, error) {
return s.DBFile, nil
return fmt.Sprintf("%s?_journal_mode=WAL&_foreign_keys=ON", s.DBFile), nil
}
// MySQL is the config entry for the mysql section

View file

@ -412,7 +412,7 @@ func TestGormParams(t *testing.T) {
dbType, uri, err := cfg.GormParams()
require.Nil(t, err)
require.Equal(t, SQLiteBackend, dbType)
require.Equal(t, filepath.Join(dir, "garm.db"), uri)
require.Equal(t, filepath.Join(dir, "garm.db?_journal_mode=WAL&_foreign_keys=ON"), uri)
cfg.DbBackend = MySQLBackend
cfg.MySQL = getMySQLDefaultConfig()

View file

@ -5,6 +5,7 @@ After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/local/bin/garm -config /etc/garm/config.toml
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=5s
User=garm

View file

@ -26,7 +26,7 @@ type RepoStore interface {
GetRepositoryByID(ctx context.Context, repoID string) (params.Repository, error)
ListRepositories(ctx context.Context) ([]params.Repository, error)
DeleteRepository(ctx context.Context, repoID string) error
UpdateRepository(ctx context.Context, repoID string, param params.UpdateRepositoryParams) (params.Repository, error)
UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (params.Repository, error)
CreateRepositoryPool(ctx context.Context, repoId string, param params.CreatePoolParams) (params.Pool, error)
@ -45,7 +45,7 @@ type OrgStore interface {
GetOrganizationByID(ctx context.Context, orgID string) (params.Organization, error)
ListOrganizations(ctx context.Context) ([]params.Organization, error)
DeleteOrganization(ctx context.Context, orgID string) error
UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error)
UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (params.Organization, error)
CreateOrganizationPool(ctx context.Context, orgId string, param params.CreatePoolParams) (params.Pool, error)
GetOrganizationPool(ctx context.Context, orgID, poolID string) (params.Pool, error)
@ -63,7 +63,7 @@ type EnterpriseStore interface {
GetEnterpriseByID(ctx context.Context, enterpriseID string) (params.Enterprise, error)
ListEnterprises(ctx context.Context) ([]params.Enterprise, error)
DeleteEnterprise(ctx context.Context, enterpriseID string) error
UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error)
UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error)
CreateEnterprisePool(ctx context.Context, enterpriseID string, param params.CreatePoolParams) (params.Pool, error)
GetEnterprisePool(ctx context.Context, enterpriseID, poolID string) (params.Pool, error)
@ -86,6 +86,7 @@ type PoolStore interface {
PoolInstanceCount(ctx context.Context, poolID string) (int64, error)
GetPoolInstanceByName(ctx context.Context, poolID string, instanceName string) (params.Instance, error)
FindPoolsMatchingAllTags(ctx context.Context, entityType params.PoolType, entityID string, tags []string) ([]params.Pool, error)
}
type UserStore interface {
@ -111,6 +112,21 @@ type InstanceStore interface {
ListInstanceEvents(ctx context.Context, instanceID string, eventType params.EventType, eventLevel params.EventLevel) ([]params.StatusMessage, error)
}
type JobsStore interface {
CreateOrUpdateJob(ctx context.Context, job params.Job) (params.Job, error)
ListEntityJobsByStatus(ctx context.Context, entityType params.PoolType, entityID string, status params.JobStatus) ([]params.Job, error)
ListJobsByStatus(ctx context.Context, status params.JobStatus) ([]params.Job, error)
ListAllJobs(ctx context.Context) ([]params.Job, error)
GetJobByID(ctx context.Context, jobID int64) (params.Job, error)
DeleteJob(ctx context.Context, jobID int64) error
UnlockJob(ctx context.Context, jobID int64, entityID string) error
LockJob(ctx context.Context, jobID int64, entityID string) error
BreakLockJobIsQueued(ctx context.Context, jobID int64) error
DeleteCompletedJobs(ctx context.Context) error
}
//go:generate mockery --name=Store
type Store interface {
RepoStore
@ -119,6 +135,7 @@ type Store interface {
PoolStore
UserStore
InstanceStore
JobsStore
ControllerInfo() (params.ControllerInfo, error)
InitController() (params.ControllerInfo, error)

View file

@ -1,4 +1,4 @@
// Code generated by mockery v2.22.1. DO NOT EDIT.
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
package mocks
@ -28,6 +28,20 @@ func (_m *Store) AddInstanceEvent(ctx context.Context, instanceID string, event
return r0
}
// BreakLockJobIsQueued provides a mock function with given fields: ctx, jobID
func (_m *Store) BreakLockJobIsQueued(ctx context.Context, jobID int64) error {
ret := _m.Called(ctx, jobID)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
r0 = rf(ctx, jobID)
} else {
r0 = ret.Error(0)
}
return r0
}
// ControllerInfo provides a mock function with given fields:
func (_m *Store) ControllerInfo() (params.ControllerInfo, error) {
ret := _m.Called()
@ -124,6 +138,30 @@ func (_m *Store) CreateInstance(ctx context.Context, poolID string, param params
return r0, r1
}
// CreateOrUpdateJob provides a mock function with given fields: ctx, job
func (_m *Store) CreateOrUpdateJob(ctx context.Context, job params.Job) (params.Job, error) {
ret := _m.Called(ctx, job)
var r0 params.Job
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, params.Job) (params.Job, error)); ok {
return rf(ctx, job)
}
if rf, ok := ret.Get(0).(func(context.Context, params.Job) params.Job); ok {
r0 = rf(ctx, job)
} else {
r0 = ret.Get(0).(params.Job)
}
if rf, ok := ret.Get(1).(func(context.Context, params.Job) error); ok {
r1 = rf(ctx, job)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// CreateOrganization provides a mock function with given fields: ctx, name, credentialsName, webhookSecret
func (_m *Store) CreateOrganization(ctx context.Context, name string, credentialsName string, webhookSecret string) (params.Organization, error) {
ret := _m.Called(ctx, name, credentialsName, webhookSecret)
@ -244,6 +282,20 @@ func (_m *Store) CreateUser(ctx context.Context, user params.NewUserParams) (par
return r0, r1
}
// DeleteCompletedJobs provides a mock function with given fields: ctx
func (_m *Store) DeleteCompletedJobs(ctx context.Context) error {
ret := _m.Called(ctx)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
} else {
r0 = ret.Error(0)
}
return r0
}
// DeleteEnterprise provides a mock function with given fields: ctx, enterpriseID
func (_m *Store) DeleteEnterprise(ctx context.Context, enterpriseID string) error {
ret := _m.Called(ctx, enterpriseID)
@ -286,6 +338,20 @@ func (_m *Store) DeleteInstance(ctx context.Context, poolID string, instanceName
return r0
}
// DeleteJob provides a mock function with given fields: ctx, jobID
func (_m *Store) DeleteJob(ctx context.Context, jobID int64) error {
ret := _m.Called(ctx, jobID)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok {
r0 = rf(ctx, jobID)
} else {
r0 = ret.Error(0)
}
return r0
}
// DeleteOrganization provides a mock function with given fields: ctx, orgID
func (_m *Store) DeleteOrganization(ctx context.Context, orgID string) error {
ret := _m.Called(ctx, orgID)
@ -404,6 +470,32 @@ func (_m *Store) FindOrganizationPoolByTags(ctx context.Context, orgID string, t
return r0, r1
}
// FindPoolsMatchingAllTags provides a mock function with given fields: ctx, entityType, entityID, tags
func (_m *Store) FindPoolsMatchingAllTags(ctx context.Context, entityType params.PoolType, entityID string, tags []string) ([]params.Pool, error) {
ret := _m.Called(ctx, entityType, entityID, tags)
var r0 []params.Pool
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, params.PoolType, string, []string) ([]params.Pool, error)); ok {
return rf(ctx, entityType, entityID, tags)
}
if rf, ok := ret.Get(0).(func(context.Context, params.PoolType, string, []string) []params.Pool); ok {
r0 = rf(ctx, entityType, entityID, tags)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]params.Pool)
}
}
if rf, ok := ret.Get(1).(func(context.Context, params.PoolType, string, []string) error); ok {
r1 = rf(ctx, entityType, entityID, tags)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// FindRepositoryPoolByTags provides a mock function with given fields: ctx, repoID, tags
func (_m *Store) FindRepositoryPoolByTags(ctx context.Context, repoID string, tags []string) (params.Pool, error) {
ret := _m.Called(ctx, repoID, tags)
@ -524,6 +616,30 @@ func (_m *Store) GetInstanceByName(ctx context.Context, instanceName string) (pa
return r0, r1
}
// GetJobByID provides a mock function with given fields: ctx, jobID
func (_m *Store) GetJobByID(ctx context.Context, jobID int64) (params.Job, error) {
ret := _m.Called(ctx, jobID)
var r0 params.Job
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, int64) (params.Job, error)); ok {
return rf(ctx, jobID)
}
if rf, ok := ret.Get(0).(func(context.Context, int64) params.Job); ok {
r0 = rf(ctx, jobID)
} else {
r0 = ret.Get(0).(params.Job)
}
if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok {
r1 = rf(ctx, jobID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetOrganization provides a mock function with given fields: ctx, name
func (_m *Store) GetOrganization(ctx context.Context, name string) (params.Organization, error) {
ret := _m.Called(ctx, name)
@ -828,6 +944,32 @@ func (_m *Store) ListAllInstances(ctx context.Context) ([]params.Instance, error
return r0, r1
}
// ListAllJobs provides a mock function with given fields: ctx
func (_m *Store) ListAllJobs(ctx context.Context) ([]params.Job, error) {
ret := _m.Called(ctx)
var r0 []params.Job
var r1 error
if rf, ok := ret.Get(0).(func(context.Context) ([]params.Job, error)); ok {
return rf(ctx)
}
if rf, ok := ret.Get(0).(func(context.Context) []params.Job); ok {
r0 = rf(ctx)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]params.Job)
}
}
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
r1 = rf(ctx)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ListAllPools provides a mock function with given fields: ctx
func (_m *Store) ListAllPools(ctx context.Context) ([]params.Pool, error) {
ret := _m.Called(ctx)
@ -932,6 +1074,32 @@ func (_m *Store) ListEnterprises(ctx context.Context) ([]params.Enterprise, erro
return r0, r1
}
// ListEntityJobsByStatus provides a mock function with given fields: ctx, entityType, entityID, status
func (_m *Store) ListEntityJobsByStatus(ctx context.Context, entityType params.PoolType, entityID string, status params.JobStatus) ([]params.Job, error) {
ret := _m.Called(ctx, entityType, entityID, status)
var r0 []params.Job
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, params.PoolType, string, params.JobStatus) ([]params.Job, error)); ok {
return rf(ctx, entityType, entityID, status)
}
if rf, ok := ret.Get(0).(func(context.Context, params.PoolType, string, params.JobStatus) []params.Job); ok {
r0 = rf(ctx, entityType, entityID, status)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]params.Job)
}
}
if rf, ok := ret.Get(1).(func(context.Context, params.PoolType, string, params.JobStatus) error); ok {
r1 = rf(ctx, entityType, entityID, status)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ListInstanceEvents provides a mock function with given fields: ctx, instanceID, eventType, eventLevel
func (_m *Store) ListInstanceEvents(ctx context.Context, instanceID string, eventType params.EventType, eventLevel params.EventLevel) ([]params.StatusMessage, error) {
ret := _m.Called(ctx, instanceID, eventType, eventLevel)
@ -958,6 +1126,32 @@ func (_m *Store) ListInstanceEvents(ctx context.Context, instanceID string, even
return r0, r1
}
// ListJobsByStatus provides a mock function with given fields: ctx, status
func (_m *Store) ListJobsByStatus(ctx context.Context, status params.JobStatus) ([]params.Job, error) {
ret := _m.Called(ctx, status)
var r0 []params.Job
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, params.JobStatus) ([]params.Job, error)); ok {
return rf(ctx, status)
}
if rf, ok := ret.Get(0).(func(context.Context, params.JobStatus) []params.Job); ok {
r0 = rf(ctx, status)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]params.Job)
}
}
if rf, ok := ret.Get(1).(func(context.Context, params.JobStatus) error); ok {
r1 = rf(ctx, status)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ListOrgInstances provides a mock function with given fields: ctx, orgID
func (_m *Store) ListOrgInstances(ctx context.Context, orgID string) ([]params.Instance, error) {
ret := _m.Called(ctx, orgID)
@ -1140,6 +1334,20 @@ func (_m *Store) ListRepositories(ctx context.Context) ([]params.Repository, err
return r0, r1
}
// LockJob provides a mock function with given fields: ctx, jobID, entityID
func (_m *Store) LockJob(ctx context.Context, jobID int64, entityID string) error {
ret := _m.Called(ctx, jobID, entityID)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok {
r0 = rf(ctx, jobID, entityID)
} else {
r0 = ret.Error(0)
}
return r0
}
// PoolInstanceCount provides a mock function with given fields: ctx, poolID
func (_m *Store) PoolInstanceCount(ctx context.Context, poolID string) (int64, error) {
ret := _m.Called(ctx, poolID)
@ -1164,22 +1372,36 @@ func (_m *Store) PoolInstanceCount(ctx context.Context, poolID string) (int64, e
return r0, r1
}
// UnlockJob provides a mock function with given fields: ctx, jobID, entityID
func (_m *Store) UnlockJob(ctx context.Context, jobID int64, entityID string) error {
ret := _m.Called(ctx, jobID, entityID)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok {
r0 = rf(ctx, jobID, entityID)
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdateEnterprise provides a mock function with given fields: ctx, enterpriseID, param
func (_m *Store) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) {
func (_m *Store) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error) {
ret := _m.Called(ctx, enterpriseID, param)
var r0 params.Enterprise
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) (params.Enterprise, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) (params.Enterprise, error)); ok {
return rf(ctx, enterpriseID, param)
}
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) params.Enterprise); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) params.Enterprise); ok {
r0 = rf(ctx, enterpriseID, param)
} else {
r0 = ret.Get(0).(params.Enterprise)
}
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateRepositoryParams) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateEntityParams) error); ok {
r1 = rf(ctx, enterpriseID, param)
} else {
r1 = ret.Error(1)
@ -1237,21 +1459,21 @@ func (_m *Store) UpdateInstance(ctx context.Context, instanceID string, param pa
}
// UpdateOrganization provides a mock function with given fields: ctx, orgID, param
func (_m *Store) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error) {
func (_m *Store) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (params.Organization, error) {
ret := _m.Called(ctx, orgID, param)
var r0 params.Organization
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) (params.Organization, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) (params.Organization, error)); ok {
return rf(ctx, orgID, param)
}
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) params.Organization); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) params.Organization); ok {
r0 = rf(ctx, orgID, param)
} else {
r0 = ret.Get(0).(params.Organization)
}
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateRepositoryParams) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateEntityParams) error); ok {
r1 = rf(ctx, orgID, param)
} else {
r1 = ret.Error(1)
@ -1285,21 +1507,21 @@ func (_m *Store) UpdateOrganizationPool(ctx context.Context, orgID string, poolI
}
// UpdateRepository provides a mock function with given fields: ctx, repoID, param
func (_m *Store) UpdateRepository(ctx context.Context, repoID string, param params.UpdateRepositoryParams) (params.Repository, error) {
func (_m *Store) UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (params.Repository, error) {
ret := _m.Called(ctx, repoID, param)
var r0 params.Repository
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) (params.Repository, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) (params.Repository, error)); ok {
return rf(ctx, repoID, param)
}
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) params.Repository); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateEntityParams) params.Repository); ok {
r0 = rf(ctx, repoID, param)
} else {
r0 = ret.Get(0).(params.Repository)
}
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateRepositoryParams) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateEntityParams) error); ok {
r1 = rf(ctx, repoID, param)
} else {
r1 = ret.Error(1)
@ -1356,13 +1578,12 @@ func (_m *Store) UpdateUser(ctx context.Context, user string, param params.Updat
return r0, r1
}
type mockConstructorTestingTNewStore interface {
// NewStore creates a new instance of Store. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewStore(t interface {
mock.TestingT
Cleanup(func())
}
// NewStore creates a new instance of Store. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewStore(t mockConstructorTestingTNewStore) *Store {
}) *Store {
mock := &Store{}
mock.Mock.Test(t)

View file

@ -18,8 +18,8 @@ import (
runnerErrors "github.com/cloudbase/garm/errors"
"github.com/cloudbase/garm/params"
"github.com/google/uuid"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"gorm.io/gorm"
)
@ -42,7 +42,7 @@ func (s *sqlDatabase) InitController() (params.ControllerInfo, error) {
return params.ControllerInfo{}, runnerErrors.NewConflictError("controller already initialized")
}
newID, err := uuid.NewV4()
newID, err := uuid.NewRandom()
if err != nil {
return params.ControllerInfo{}, errors.Wrap(err, "generating UUID")
}

View file

@ -69,5 +69,6 @@ func (s *CtrlTestSuite) TestInitControllerAlreadyInitialized() {
}
func TestCtrlTestSuite(t *testing.T) {
t.Parallel()
suite.Run(t, new(CtrlTestSuite))
}

View file

@ -7,8 +7,8 @@ import (
"github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/util"
"github.com/google/uuid"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"gorm.io/datatypes"
"gorm.io/gorm"
)
@ -99,7 +99,7 @@ func (s *sqlDatabase) DeleteEnterprise(ctx context.Context, enterpriseID string)
return nil
}
func (s *sqlDatabase) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) {
func (s *sqlDatabase) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error) {
enterprise, err := s.getEnterpriseByID(ctx, enterpriseID)
if err != nil {
return params.Enterprise{}, errors.Wrap(err, "fetching enterprise")
@ -148,7 +148,7 @@ func (s *sqlDatabase) CreateEnterprisePool(ctx context.Context, enterpriseID str
Flavor: param.Flavor,
OSType: param.OSType,
OSArch: param.OSArch,
EnterpriseID: enterprise.ID,
EnterpriseID: &enterprise.ID,
Enabled: param.Enabled,
RunnerBootstrapTimeout: param.RunnerBootstrapTimeout,
}
@ -224,15 +224,15 @@ func (s *sqlDatabase) UpdateEnterprisePool(ctx context.Context, enterpriseID, po
}
func (s *sqlDatabase) FindEnterprisePoolByTags(ctx context.Context, enterpriseID string, tags []string) (params.Pool, error) {
pool, err := s.findPoolByTags(enterpriseID, "enterprise_id", tags)
pool, err := s.findPoolByTags(enterpriseID, params.EnterprisePool, tags)
if err != nil {
return params.Pool{}, errors.Wrap(err, "fetching pool")
}
return pool, nil
return pool[0], nil
}
func (s *sqlDatabase) ListEnterprisePools(ctx context.Context, enterpriseID string) ([]params.Pool, error) {
pools, err := s.getEnterprisePools(ctx, enterpriseID, "Tags", "Enterprise")
pools, err := s.listEntityPools(ctx, params.EnterprisePool, enterpriseID, "Tags", "Instances")
if err != nil {
return nil, errors.Wrap(err, "fetching pools")
}
@ -246,7 +246,7 @@ func (s *sqlDatabase) ListEnterprisePools(ctx context.Context, enterpriseID stri
}
func (s *sqlDatabase) ListEnterpriseInstances(ctx context.Context, enterpriseID string) ([]params.Instance, error) {
pools, err := s.getEnterprisePools(ctx, enterpriseID, "Instances")
pools, err := s.listEntityPools(ctx, params.EnterprisePool, enterpriseID, "Instances", "Tags")
if err != nil {
return nil, errors.Wrap(err, "fetching enterprise")
}
@ -274,7 +274,7 @@ func (s *sqlDatabase) getEnterprise(ctx context.Context, name string) (Enterpris
}
func (s *sqlDatabase) getEnterpriseByID(ctx context.Context, id string, preload ...string) (Enterprise, error) {
u, err := uuid.FromString(id)
u, err := uuid.Parse(id)
if err != nil {
return Enterprise{}, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}
@ -315,28 +315,3 @@ func (s *sqlDatabase) getEnterprisePoolByUniqueFields(ctx context.Context, enter
return pool[0], nil
}
func (s *sqlDatabase) getEnterprisePools(ctx context.Context, enterpriseID string, preload ...string) ([]Pool, error) {
_, err := s.getEnterpriseByID(ctx, enterpriseID)
if err != nil {
return nil, errors.Wrap(err, "fetching enterprise")
}
q := s.conn
if len(preload) > 0 {
for _, item := range preload {
q = q.Preload(item)
}
}
var pools []Pool
err = q.Model(&Pool{}).Where("enterprise_id = ?", enterpriseID).
Omit("extra_specs").
Find(&pools).Error
if err != nil {
return nil, errors.Wrap(err, "fetching pool")
}
return pools, nil
}

View file

@ -40,7 +40,7 @@ type EnterpriseTestFixtures struct {
CreateEnterpriseParams params.CreateEnterpriseParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
SQLMock sqlmock.Sqlmock
}
@ -142,7 +142,7 @@ func (s *EnterpriseTestSuite) SetupTest() {
Name: "test-instance-name",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-update-creds",
WebhookSecret: "test-update-repo-webhook-secret",
},
@ -671,7 +671,7 @@ func (s *EnterpriseTestSuite) TestListEnterprisePoolsInvalidEnterpriseID() {
_, err := s.Store.ListEnterprisePools(context.Background(), "dummy-enterprise-id")
s.Require().NotNil(err)
s.Require().Equal("fetching pools: fetching enterprise: parsing id: invalid request", err.Error())
s.Require().Equal("fetching pools: parsing id: invalid request", err.Error())
}
func (s *EnterpriseTestSuite) TestGetEnterprisePool() {
@ -785,7 +785,7 @@ func (s *EnterpriseTestSuite) TestListEnterpriseInstancesInvalidEnterpriseID() {
_, err := s.Store.ListEnterpriseInstances(context.Background(), "dummy-enterprise-id")
s.Require().NotNil(err)
s.Require().Equal("fetching enterprise: fetching enterprise: parsing id: invalid request", err.Error())
s.Require().Equal("fetching enterprise: parsing id: invalid request", err.Error())
}
func (s *EnterpriseTestSuite) TestUpdateEnterprisePool() {
@ -811,5 +811,6 @@ func (s *EnterpriseTestSuite) TestUpdateEnterprisePoolInvalidEnterpriseID() {
}
func TestEnterpriseTestSuite(t *testing.T) {
t.Parallel()
suite.Run(t, new(EnterpriseTestSuite))
}

View file

@ -16,12 +16,14 @@ package sql
import (
"context"
"encoding/json"
runnerErrors "github.com/cloudbase/garm/errors"
"github.com/cloudbase/garm/params"
"github.com/google/uuid"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"gorm.io/datatypes"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
@ -32,6 +34,14 @@ func (s *sqlDatabase) CreateInstance(ctx context.Context, poolID string, param p
return params.Instance{}, errors.Wrap(err, "fetching pool")
}
var labels datatypes.JSON
if len(param.AditionalLabels) > 0 {
labels, err = json.Marshal(param.AditionalLabels)
if err != nil {
return params.Instance{}, errors.Wrap(err, "marshalling labels")
}
}
newInstance := Instance{
Pool: pool,
Name: param.Name,
@ -42,6 +52,7 @@ func (s *sqlDatabase) CreateInstance(ctx context.Context, poolID string, param p
CallbackURL: param.CallbackURL,
MetadataURL: param.MetadataURL,
GitHubRunnerGroup: param.GitHubRunnerGroup,
AditionalLabels: labels,
}
q := s.conn.Create(&newInstance)
if q.Error != nil {
@ -52,7 +63,7 @@ func (s *sqlDatabase) CreateInstance(ctx context.Context, poolID string, param p
}
func (s *sqlDatabase) getInstanceByID(ctx context.Context, instanceID string) (Instance, error) {
u, err := uuid.FromString(instanceID)
u, err := uuid.Parse(instanceID)
if err != nil {
return Instance{}, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}
@ -248,7 +259,7 @@ func (s *sqlDatabase) UpdateInstance(ctx context.Context, instanceID string, par
}
func (s *sqlDatabase) ListPoolInstances(ctx context.Context, poolID string) ([]params.Instance, error) {
u, err := uuid.FromString(poolID)
u, err := uuid.Parse(poolID)
if err != nil {
return nil, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}

View file

@ -552,5 +552,6 @@ func (s *InstancesTestSuite) TestPoolInstanceCountDBCountErr() {
}
func TestInstTestSuite(t *testing.T) {
t.Parallel()
suite.Run(t, new(InstancesTestSuite))
}

337
database/sql/jobs.go Normal file
View file

@ -0,0 +1,337 @@
package sql
import (
"context"
"encoding/json"
"github.com/cloudbase/garm/database/common"
runnerErrors "github.com/cloudbase/garm/errors"
"github.com/cloudbase/garm/params"
"github.com/google/uuid"
"github.com/pkg/errors"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
var _ common.JobsStore = &sqlDatabase{}
func sqlWorkflowJobToParamsJob(job WorkflowJob) (params.Job, error) {
labels := []string{}
if job.Labels != nil {
if err := json.Unmarshal(job.Labels, &labels); err != nil {
return params.Job{}, errors.Wrap(err, "unmarshaling labels")
}
}
return params.Job{
ID: job.ID,
RunID: job.RunID,
Action: job.Action,
Status: job.Status,
Name: job.Name,
Conclusion: job.Conclusion,
StartedAt: job.StartedAt,
CompletedAt: job.CompletedAt,
GithubRunnerID: job.GithubRunnerID,
RunnerName: job.RunnerName,
RunnerGroupID: job.RunnerGroupID,
RunnerGroupName: job.RunnerGroupName,
RepositoryName: job.RepositoryName,
RepositoryOwner: job.RepositoryOwner,
RepoID: job.RepoID,
OrgID: job.OrgID,
EnterpriseID: job.EnterpriseID,
Labels: labels,
CreatedAt: job.CreatedAt,
UpdatedAt: job.UpdatedAt,
LockedBy: job.LockedBy,
}, nil
}
func paramsJobToWorkflowJob(job params.Job) (WorkflowJob, error) {
asJson, err := json.Marshal(job.Labels)
if err != nil {
return WorkflowJob{}, errors.Wrap(err, "marshaling labels")
}
return WorkflowJob{
ID: job.ID,
RunID: job.RunID,
Action: job.Action,
Status: job.Status,
Name: job.Name,
Conclusion: job.Conclusion,
StartedAt: job.StartedAt,
CompletedAt: job.CompletedAt,
GithubRunnerID: job.GithubRunnerID,
RunnerName: job.RunnerName,
RunnerGroupID: job.RunnerGroupID,
RunnerGroupName: job.RunnerGroupName,
RepositoryName: job.RepositoryName,
RepositoryOwner: job.RepositoryOwner,
RepoID: job.RepoID,
OrgID: job.OrgID,
EnterpriseID: job.EnterpriseID,
Labels: asJson,
LockedBy: job.LockedBy,
}, nil
}
func (s *sqlDatabase) DeleteJob(ctx context.Context, jobID int64) error {
q := s.conn.Delete(&WorkflowJob{}, jobID)
if q.Error != nil {
if errors.Is(q.Error, gorm.ErrRecordNotFound) {
return nil
}
return errors.Wrap(q.Error, "deleting job")
}
return nil
}
func (s *sqlDatabase) LockJob(ctx context.Context, jobID int64, entityID string) error {
entityUUID, err := uuid.Parse(entityID)
if err != nil {
return errors.Wrap(err, "parsing entity id")
}
var workflowJob WorkflowJob
q := s.conn.Clauses(clause.Locking{Strength: "UPDATE"}).Where("id = ?", jobID).First(&workflowJob)
if q.Error != nil {
if errors.Is(q.Error, gorm.ErrRecordNotFound) {
return runnerErrors.ErrNotFound
}
return errors.Wrap(q.Error, "fetching job")
}
if workflowJob.LockedBy.String() == entityID {
// Already locked by us.
return nil
}
if workflowJob.LockedBy != uuid.Nil {
return runnerErrors.NewConflictError("job is locked by another entity %s", workflowJob.LockedBy.String())
}
workflowJob.LockedBy = entityUUID
if err := s.conn.Save(&workflowJob).Error; err != nil {
return errors.Wrap(err, "saving job")
}
return nil
}
func (s *sqlDatabase) BreakLockJobIsQueued(ctx context.Context, jobID int64) error {
var workflowJob WorkflowJob
q := s.conn.Clauses(clause.Locking{Strength: "UPDATE"}).Where("id = ? and status = ?", jobID, params.JobStatusQueued).First(&workflowJob)
if q.Error != nil {
if errors.Is(q.Error, gorm.ErrRecordNotFound) {
return nil
}
return errors.Wrap(q.Error, "fetching job")
}
if workflowJob.LockedBy == uuid.Nil {
// Job is already unlocked.
return nil
}
workflowJob.LockedBy = uuid.Nil
if err := s.conn.Save(&workflowJob).Error; err != nil {
return errors.Wrap(err, "saving job")
}
return nil
}
func (s *sqlDatabase) UnlockJob(ctx context.Context, jobID int64, entityID string) error {
var workflowJob WorkflowJob
q := s.conn.Clauses(clause.Locking{Strength: "UPDATE"}).Where("id = ?", jobID).First(&workflowJob)
if q.Error != nil {
if errors.Is(q.Error, gorm.ErrRecordNotFound) {
return runnerErrors.ErrNotFound
}
return errors.Wrap(q.Error, "fetching job")
}
if workflowJob.LockedBy == uuid.Nil {
// Job is already unlocked.
return nil
}
if workflowJob.LockedBy != uuid.Nil && workflowJob.LockedBy.String() != entityID {
return runnerErrors.NewConflictError("job is locked by another entity %s", workflowJob.LockedBy.String())
}
workflowJob.LockedBy = uuid.Nil
if err := s.conn.Save(&workflowJob).Error; err != nil {
return errors.Wrap(err, "saving job")
}
return nil
}
func (s *sqlDatabase) CreateOrUpdateJob(ctx context.Context, job params.Job) (params.Job, error) {
var workflowJob WorkflowJob
q := s.conn.Clauses(clause.Locking{Strength: "UPDATE"}).Where("id = ?", job.ID).First(&workflowJob)
if q.Error != nil {
if !errors.Is(q.Error, gorm.ErrRecordNotFound) {
return params.Job{}, errors.Wrap(q.Error, "fetching job")
}
}
if workflowJob.ID != 0 {
// Update workflowJob with values from job.
workflowJob.Status = job.Status
workflowJob.Action = job.Action
workflowJob.Conclusion = job.Conclusion
workflowJob.StartedAt = job.StartedAt
workflowJob.CompletedAt = job.CompletedAt
workflowJob.GithubRunnerID = job.GithubRunnerID
workflowJob.RunnerGroupID = job.RunnerGroupID
workflowJob.RunnerGroupName = job.RunnerGroupName
if job.LockedBy != uuid.Nil {
workflowJob.LockedBy = job.LockedBy
}
if job.RunnerName != "" {
workflowJob.RunnerName = job.RunnerName
}
if job.RepoID != nil {
workflowJob.RepoID = job.RepoID
}
if job.OrgID != nil {
workflowJob.OrgID = job.OrgID
}
if job.EnterpriseID != nil {
workflowJob.EnterpriseID = job.EnterpriseID
}
if err := s.conn.Save(&workflowJob).Error; err != nil {
return params.Job{}, errors.Wrap(err, "saving job")
}
} else {
workflowJob, err := paramsJobToWorkflowJob(job)
if err != nil {
return params.Job{}, errors.Wrap(err, "converting job")
}
if err := s.conn.Create(&workflowJob).Error; err != nil {
return params.Job{}, errors.Wrap(err, "creating job")
}
}
return sqlWorkflowJobToParamsJob(workflowJob)
}
// ListJobsByStatus lists all jobs for a given status.
func (s *sqlDatabase) ListJobsByStatus(ctx context.Context, status params.JobStatus) ([]params.Job, error) {
var jobs []WorkflowJob
query := s.conn.Model(&WorkflowJob{}).Where("status = ?", status)
if err := query.Find(&jobs); err.Error != nil {
return nil, err.Error
}
ret := make([]params.Job, len(jobs))
for idx, job := range jobs {
jobParam, err := sqlWorkflowJobToParamsJob(job)
if err != nil {
return nil, errors.Wrap(err, "converting job")
}
ret[idx] = jobParam
}
return ret, nil
}
// ListEntityJobsByStatus lists all jobs for a given entity type and id.
func (s *sqlDatabase) ListEntityJobsByStatus(ctx context.Context, entityType params.PoolType, entityID string, status params.JobStatus) ([]params.Job, error) {
u, err := uuid.Parse(entityID)
if err != nil {
return nil, err
}
var jobs []WorkflowJob
query := s.conn.Model(&WorkflowJob{}).Where("status = ?", status)
switch entityType {
case params.OrganizationPool:
query = query.Where("org_id = ?", u)
case params.RepositoryPool:
query = query.Where("repo_id = ?", u)
case params.EnterprisePool:
query = query.Where("enterprise_id = ?", u)
}
if err := query.Find(&jobs); err.Error != nil {
if errors.Is(err.Error, gorm.ErrRecordNotFound) {
return []params.Job{}, nil
}
return nil, err.Error
}
ret := make([]params.Job, len(jobs))
for idx, job := range jobs {
jobParam, err := sqlWorkflowJobToParamsJob(job)
if err != nil {
return nil, errors.Wrap(err, "converting job")
}
ret[idx] = jobParam
}
return ret, nil
}
func (s *sqlDatabase) ListAllJobs(ctx context.Context) ([]params.Job, error) {
var jobs []WorkflowJob
query := s.conn.Model(&WorkflowJob{})
if err := query.Find(&jobs); err.Error != nil {
if errors.Is(err.Error, gorm.ErrRecordNotFound) {
return []params.Job{}, nil
}
return nil, err.Error
}
ret := make([]params.Job, len(jobs))
for idx, job := range jobs {
jobParam, err := sqlWorkflowJobToParamsJob(job)
if err != nil {
return nil, errors.Wrap(err, "converting job")
}
ret[idx] = jobParam
}
return ret, nil
}
// GetJobByID gets a job by id.
func (s *sqlDatabase) GetJobByID(ctx context.Context, jobID int64) (params.Job, error) {
var job WorkflowJob
query := s.conn.Model(&WorkflowJob{}).Where("id = ?", jobID)
if err := query.First(&job); err.Error != nil {
if errors.Is(err.Error, gorm.ErrRecordNotFound) {
return params.Job{}, runnerErrors.ErrNotFound
}
return params.Job{}, err.Error
}
return sqlWorkflowJobToParamsJob(job)
}
// DeleteCompletedJobs deletes all completed jobs.
func (s *sqlDatabase) DeleteCompletedJobs(ctx context.Context) error {
query := s.conn.Model(&WorkflowJob{}).Where("status = ?", params.JobStatusCompleted)
if err := query.Unscoped().Delete(&WorkflowJob{}); err.Error != nil {
if errors.Is(err.Error, gorm.ErrRecordNotFound) {
return nil
}
return err.Error
}
return nil
}

View file

@ -20,8 +20,8 @@ import (
"github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/runner/providers/common"
"github.com/google/uuid"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"gorm.io/datatypes"
"gorm.io/gorm"
)
@ -38,7 +38,7 @@ func (b *Base) BeforeCreate(tx *gorm.DB) error {
if b.ID != emptyId {
return nil
}
newID, err := uuid.NewV4()
newID, err := uuid.NewRandom()
if err != nil {
return errors.Wrap(err, "generating id")
}
@ -50,7 +50,7 @@ type Tag struct {
Base
Name string `gorm:"type:varchar(64);uniqueIndex"`
Pools []*Pool `gorm:"many2many:pool_tags;"`
Pools []*Pool `gorm:"many2many:pool_tags;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
}
type Pool struct {
@ -65,7 +65,7 @@ type Pool struct {
Flavor string `gorm:"index:idx_pool_type"`
OSType params.OSType
OSArch params.OSArch
Tags []*Tag `gorm:"many2many:pool_tags;"`
Tags []*Tag `gorm:"many2many:pool_tags;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
Enabled bool
// ExtraSpecs is an opaque json that gets sent to the provider
// as part of the bootstrap params for instances. It can contain
@ -73,13 +73,13 @@ type Pool struct {
ExtraSpecs datatypes.JSON
GitHubRunnerGroup string
RepoID uuid.UUID `gorm:"index"`
Repository Repository `gorm:"foreignKey:RepoID"`
RepoID *uuid.UUID `gorm:"index"`
Repository Repository `gorm:"foreignKey:RepoID;"`
OrgID uuid.UUID `gorm:"index"`
OrgID *uuid.UUID `gorm:"index"`
Organization Organization `gorm:"foreignKey:OrgID"`
EnterpriseID uuid.UUID `gorm:"index"`
EnterpriseID *uuid.UUID `gorm:"index"`
Enterprise Enterprise `gorm:"foreignKey:EnterpriseID"`
Instances []Instance `gorm:"foreignKey:PoolID"`
@ -92,7 +92,8 @@ type Repository struct {
Owner string `gorm:"index:idx_owner_nocase,unique,collate:nocase"`
Name string `gorm:"index:idx_owner_nocase,unique,collate:nocase"`
WebhookSecret []byte
Pools []Pool `gorm:"foreignKey:RepoID"`
Pools []Pool `gorm:"foreignKey:RepoID"`
Jobs []WorkflowJob `gorm:"foreignKey:RepoID;constraint:OnDelete:SET NULL"`
}
type Organization struct {
@ -101,7 +102,8 @@ type Organization struct {
CredentialsName string
Name string `gorm:"index:idx_org_name_nocase,collate:nocase"`
WebhookSecret []byte
Pools []Pool `gorm:"foreignKey:OrgID"`
Pools []Pool `gorm:"foreignKey:OrgID"`
Jobs []WorkflowJob `gorm:"foreignKey:OrgID;constraint:OnDelete:SET NULL"`
}
type Enterprise struct {
@ -110,7 +112,8 @@ type Enterprise struct {
CredentialsName string
Name string `gorm:"index:idx_ent_name_nocase,collate:nocase"`
WebhookSecret []byte
Pools []Pool `gorm:"foreignKey:EnterpriseID"`
Pools []Pool `gorm:"foreignKey:EnterpriseID"`
Jobs []WorkflowJob `gorm:"foreignKey:EnterpriseID;constraint:OnDelete:SET NULL"`
}
type Address struct {
@ -130,8 +133,8 @@ type InstanceStatusUpdate struct {
EventLevel params.EventLevel
Message string `gorm:"type:text"`
InstanceID uuid.UUID
Instance Instance `gorm:"foreignKey:InstanceID"`
InstanceID uuid.UUID `gorm:"index:idx_instance_status_updates_instance_id"`
Instance Instance `gorm:"foreignKey:InstanceID"`
}
type Instance struct {
@ -144,7 +147,7 @@ type Instance struct {
OSArch params.OSArch
OSName string
OSVersion string
Addresses []Address `gorm:"foreignKey:InstanceID"`
Addresses []Address `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
Status common.InstanceStatus
RunnerStatus common.RunnerStatus
CallbackURL string
@ -153,11 +156,12 @@ type Instance struct {
CreateAttempt int
TokenFetched bool
GitHubRunnerGroup string
AditionalLabels datatypes.JSON
PoolID uuid.UUID
Pool Pool `gorm:"foreignKey:PoolID"`
StatusMessages []InstanceStatusUpdate `gorm:"foreignKey:InstanceID"`
StatusMessages []InstanceStatusUpdate `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
}
type User struct {
@ -176,3 +180,59 @@ type ControllerInfo struct {
ControllerID uuid.UUID
}
type WorkflowJob struct {
// ID is the ID of the job.
ID int64 `gorm:"index"`
// RunID is the ID of the workflow run. A run may have multiple jobs.
RunID int64
// Action is the specific activity that triggered the event.
Action string `gorm:"type:varchar(254);index"`
// Conclusion is the outcome of the job.
// Possible values: "success", "failure", "neutral", "cancelled", "skipped",
// "timed_out", "action_required"
Conclusion string
// Status is the phase of the lifecycle that the job is currently in.
// "queued", "in_progress" and "completed".
Status string
// Name is the name if the job that was triggered.
Name string
StartedAt time.Time
CompletedAt time.Time
GithubRunnerID int64
RunnerName string
RunnerGroupID int64
RunnerGroupName string
// repository in which the job was triggered.
RepositoryName string
RepositoryOwner string
Labels datatypes.JSON
// The entity that received the hook.
//
// Webhooks may be configured on the repo, the org and/or the enterprise.
// If we only configure a repo to use garm, we'll only ever receive a
// webhook from the repo. But if we configure the parent org of the repo and
// the parent enterprise of the org to use garm, a webhook will be sent for each
// entity type, in response to one workflow event. Thus, we will get 3 webhooks
// with the same run_id and job id. Record all involved entities in the same job
// if we have them configured in garm.
RepoID *uuid.UUID `gorm:"index"`
Repository Repository `gorm:"foreignKey:RepoID"`
OrgID *uuid.UUID `gorm:"index"`
Organization Organization `gorm:"foreignKey:OrgID"`
EnterpriseID *uuid.UUID `gorm:"index"`
Enterprise Enterprise `gorm:"foreignKey:EnterpriseID"`
LockedBy uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}

View file

@ -22,8 +22,8 @@ import (
"github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/util"
"github.com/google/uuid"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"gorm.io/datatypes"
"gorm.io/gorm"
)
@ -103,7 +103,7 @@ func (s *sqlDatabase) DeleteOrganization(ctx context.Context, orgID string) erro
return nil
}
func (s *sqlDatabase) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error) {
func (s *sqlDatabase) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (params.Organization, error) {
org, err := s.getOrgByID(ctx, orgID)
if err != nil {
return params.Organization{}, errors.Wrap(err, "fetching org")
@ -165,7 +165,7 @@ func (s *sqlDatabase) CreateOrganizationPool(ctx context.Context, orgId string,
Flavor: param.Flavor,
OSType: param.OSType,
OSArch: param.OSArch,
OrgID: org.ID,
OrgID: &org.ID,
Enabled: param.Enabled,
RunnerBootstrapTimeout: param.RunnerBootstrapTimeout,
}
@ -212,7 +212,7 @@ func (s *sqlDatabase) CreateOrganizationPool(ctx context.Context, orgId string,
}
func (s *sqlDatabase) ListOrgPools(ctx context.Context, orgID string) ([]params.Pool, error) {
pools, err := s.getOrgPools(ctx, orgID, "Tags")
pools, err := s.listEntityPools(ctx, params.OrganizationPool, orgID, "Tags", "Instances")
if err != nil {
return nil, errors.Wrap(err, "fetching pools")
}
@ -246,15 +246,15 @@ func (s *sqlDatabase) DeleteOrganizationPool(ctx context.Context, orgID, poolID
}
func (s *sqlDatabase) FindOrganizationPoolByTags(ctx context.Context, orgID string, tags []string) (params.Pool, error) {
pool, err := s.findPoolByTags(orgID, "org_id", tags)
pool, err := s.findPoolByTags(orgID, params.OrganizationPool, tags)
if err != nil {
return params.Pool{}, errors.Wrap(err, "fetching pool")
}
return pool, nil
return pool[0], nil
}
func (s *sqlDatabase) ListOrgInstances(ctx context.Context, orgID string) ([]params.Instance, error) {
pools, err := s.getOrgPools(ctx, orgID, "Instances")
pools, err := s.listEntityPools(ctx, params.OrganizationPool, orgID, "Tags", "Instances")
if err != nil {
return nil, errors.Wrap(err, "fetching org")
}
@ -277,7 +277,7 @@ func (s *sqlDatabase) UpdateOrganizationPool(ctx context.Context, orgID, poolID
}
func (s *sqlDatabase) getPoolByID(ctx context.Context, poolID string, preload ...string) (Pool, error) {
u, err := uuid.FromString(poolID)
u, err := uuid.Parse(poolID)
if err != nil {
return Pool{}, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}
@ -300,34 +300,8 @@ func (s *sqlDatabase) getPoolByID(ctx context.Context, poolID string, preload ..
return pool, nil
}
func (s *sqlDatabase) getOrgPools(ctx context.Context, orgID string, preload ...string) ([]Pool, error) {
_, err := s.getOrgByID(ctx, orgID)
if err != nil {
return nil, errors.Wrap(err, "fetching org")
}
q := s.conn
if len(preload) > 0 {
for _, item := range preload {
q = q.Preload(item)
}
}
var pools []Pool
err = q.Model(&Pool{}).
Where("org_id = ?", orgID).
Omit("extra_specs").
Find(&pools).Error
if err != nil {
return nil, errors.Wrap(err, "fetching pool")
}
return pools, nil
}
func (s *sqlDatabase) getOrgByID(ctx context.Context, id string, preload ...string) (Organization, error) {
u, err := uuid.FromString(id)
u, err := uuid.Parse(id)
if err != nil {
return Organization{}, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}

View file

@ -39,7 +39,7 @@ type OrgTestFixtures struct {
CreateOrgParams params.CreateOrgParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
SQLMock sqlmock.Sqlmock
}
@ -141,7 +141,7 @@ func (s *OrgTestSuite) SetupTest() {
Name: "test-instance-name",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-update-creds",
WebhookSecret: "test-update-repo-webhook-secret",
},
@ -670,7 +670,7 @@ func (s *OrgTestSuite) TestListOrgPoolsInvalidOrgID() {
_, err := s.Store.ListOrgPools(context.Background(), "dummy-org-id")
s.Require().NotNil(err)
s.Require().Equal("fetching pools: fetching org: parsing id: invalid request", err.Error())
s.Require().Equal("fetching pools: parsing id: invalid request", err.Error())
}
func (s *OrgTestSuite) TestGetOrganizationPool() {
@ -784,7 +784,7 @@ func (s *OrgTestSuite) TestListOrgInstancesInvalidOrgID() {
_, err := s.Store.ListOrgInstances(context.Background(), "dummy-org-id")
s.Require().NotNil(err)
s.Require().Equal("fetching org: fetching org: parsing id: invalid request", err.Error())
s.Require().Equal("fetching org: parsing id: invalid request", err.Error())
}
func (s *OrgTestSuite) TestUpdateOrganizationPool() {
@ -810,5 +810,6 @@ func (s *OrgTestSuite) TestUpdateOrganizationPoolInvalidOrgID() {
}
func TestOrgTestSuite(t *testing.T) {
t.Parallel()
suite.Run(t, new(OrgTestSuite))
}

View file

@ -21,8 +21,8 @@ import (
runnerErrors "github.com/cloudbase/garm/errors"
"github.com/cloudbase/garm/params"
"github.com/google/uuid"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"gorm.io/gorm"
)
@ -73,7 +73,7 @@ func (s *sqlDatabase) getEntityPool(ctx context.Context, entityType params.PoolT
return Pool{}, errors.Wrap(runnerErrors.ErrBadRequest, "missing entity id")
}
u, err := uuid.FromString(poolID)
u, err := uuid.Parse(poolID)
if err != nil {
return Pool{}, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}
@ -112,3 +112,109 @@ func (s *sqlDatabase) getEntityPool(ctx context.Context, entityType params.PoolT
return pool, nil
}
func (s *sqlDatabase) listEntityPools(ctx context.Context, entityType params.PoolType, entityID string, preload ...string) ([]Pool, error) {
if _, err := uuid.Parse(entityID); err != nil {
return nil, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}
q := s.conn
if len(preload) > 0 {
for _, item := range preload {
q = q.Preload(item)
}
}
var fieldName string
switch entityType {
case params.RepositoryPool:
fieldName = "repo_id"
case params.OrganizationPool:
fieldName = "org_id"
case params.EnterprisePool:
fieldName = "enterprise_id"
default:
return nil, fmt.Errorf("invalid entityType: %v", entityType)
}
var pools []Pool
condition := fmt.Sprintf("%s = ?", fieldName)
err := q.Model(&Pool{}).
Where(condition, entityID).
Omit("extra_specs").
Find(&pools).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return []Pool{}, nil
}
return nil, errors.Wrap(err, "fetching pool")
}
return pools, nil
}
func (s *sqlDatabase) findPoolByTags(id string, poolType params.PoolType, tags []string) ([]params.Pool, error) {
if len(tags) == 0 {
return nil, runnerErrors.NewBadRequestError("missing tags")
}
u, err := uuid.Parse(id)
if err != nil {
return nil, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}
var fieldName string
switch poolType {
case params.RepositoryPool:
fieldName = "repo_id"
case params.OrganizationPool:
fieldName = "org_id"
case params.EnterprisePool:
fieldName = "enterprise_id"
default:
return nil, fmt.Errorf("invalid poolType: %v", poolType)
}
var pools []Pool
where := fmt.Sprintf("tags.name in ? and %s = ? and enabled = true", fieldName)
q := s.conn.Joins("JOIN pool_tags on pool_tags.pool_id=pools.id").
Joins("JOIN tags on tags.id=pool_tags.tag_id").
Group("pools.id").
Preload("Tags").
Having("count(1) = ?", len(tags)).
Where(where, tags, u).Find(&pools)
if q.Error != nil {
if errors.Is(q.Error, gorm.ErrRecordNotFound) {
return nil, runnerErrors.ErrNotFound
}
return nil, errors.Wrap(q.Error, "fetching pool")
}
if len(pools) == 0 {
return nil, runnerErrors.ErrNotFound
}
ret := make([]params.Pool, len(pools))
for idx, val := range pools {
ret[idx] = s.sqlToCommonPool(val)
}
return ret, nil
}
func (s *sqlDatabase) FindPoolsMatchingAllTags(ctx context.Context, entityType params.PoolType, entityID string, tags []string) ([]params.Pool, error) {
if len(tags) == 0 {
return nil, runnerErrors.NewBadRequestError("missing tags")
}
pools, err := s.findPoolByTags(entityID, entityType, tags)
if err != nil {
if errors.Is(err, runnerErrors.ErrNotFound) {
return []params.Pool{}, nil
}
return nil, errors.Wrap(err, "fetching pools")
}
return pools, nil
}

View file

@ -186,5 +186,6 @@ func (s *PoolsTestSuite) TestDeletePoolByIDDBRemoveErr() {
}
func TestPoolsTestSuite(t *testing.T) {
t.Parallel()
suite.Run(t, new(PoolsTestSuite))
}

View file

@ -22,8 +22,8 @@ import (
"github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/util"
"github.com/google/uuid"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"gorm.io/datatypes"
"gorm.io/gorm"
)
@ -103,7 +103,7 @@ func (s *sqlDatabase) DeleteRepository(ctx context.Context, repoID string) error
return nil
}
func (s *sqlDatabase) UpdateRepository(ctx context.Context, repoID string, param params.UpdateRepositoryParams) (params.Repository, error) {
func (s *sqlDatabase) UpdateRepository(ctx context.Context, repoID string, param params.UpdateEntityParams) (params.Repository, error) {
repo, err := s.getRepoByID(ctx, repoID)
if err != nil {
return params.Repository{}, errors.Wrap(err, "fetching repo")
@ -165,7 +165,7 @@ func (s *sqlDatabase) CreateRepositoryPool(ctx context.Context, repoId string, p
Flavor: param.Flavor,
OSType: param.OSType,
OSArch: param.OSArch,
RepoID: repo.ID,
RepoID: &repo.ID,
Enabled: param.Enabled,
RunnerBootstrapTimeout: param.RunnerBootstrapTimeout,
}
@ -212,7 +212,7 @@ func (s *sqlDatabase) CreateRepositoryPool(ctx context.Context, repoId string, p
}
func (s *sqlDatabase) ListRepoPools(ctx context.Context, repoID string) ([]params.Pool, error) {
pools, err := s.getRepoPools(ctx, repoID, "Tags")
pools, err := s.listEntityPools(ctx, params.RepositoryPool, repoID, "Tags", "Instances")
if err != nil {
return nil, errors.Wrap(err, "fetching pools")
}
@ -246,15 +246,15 @@ func (s *sqlDatabase) DeleteRepositoryPool(ctx context.Context, repoID, poolID s
}
func (s *sqlDatabase) FindRepositoryPoolByTags(ctx context.Context, repoID string, tags []string) (params.Pool, error) {
pool, err := s.findPoolByTags(repoID, "repo_id", tags)
pool, err := s.findPoolByTags(repoID, params.RepositoryPool, tags)
if err != nil {
return params.Pool{}, errors.Wrap(err, "fetching pool")
}
return pool, nil
return pool[0], nil
}
func (s *sqlDatabase) ListRepoInstances(ctx context.Context, repoID string) ([]params.Instance, error) {
pools, err := s.getRepoPools(ctx, repoID, "Instances")
pools, err := s.listEntityPools(ctx, params.RepositoryPool, repoID, "Tags", "Instances")
if err != nil {
return nil, errors.Wrap(err, "fetching repo")
}
@ -294,38 +294,6 @@ func (s *sqlDatabase) getRepo(ctx context.Context, owner, name string) (Reposito
return repo, nil
}
func (s *sqlDatabase) findPoolByTags(id, poolType string, tags []string) (params.Pool, error) {
if len(tags) == 0 {
return params.Pool{}, runnerErrors.NewBadRequestError("missing tags")
}
u, err := uuid.FromString(id)
if err != nil {
return params.Pool{}, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}
var pools []Pool
where := fmt.Sprintf("tags.name in ? and %s = ? and enabled = true", poolType)
q := s.conn.Joins("JOIN pool_tags on pool_tags.pool_id=pools.id").
Joins("JOIN tags on tags.id=pool_tags.tag_id").
Group("pools.id").
Preload("Tags").
Having("count(1) = ?", len(tags)).
Where(where, tags, u).Find(&pools)
if q.Error != nil {
if errors.Is(q.Error, gorm.ErrRecordNotFound) {
return params.Pool{}, runnerErrors.ErrNotFound
}
return params.Pool{}, errors.Wrap(q.Error, "fetching pool")
}
if len(pools) == 0 {
return params.Pool{}, runnerErrors.ErrNotFound
}
return s.sqlToCommonPool(pools[0]), nil
}
func (s *sqlDatabase) getRepoPoolByUniqueFields(ctx context.Context, repoID string, provider, image, flavor string) (Pool, error) {
repo, err := s.getRepoByID(ctx, repoID)
if err != nil {
@ -345,32 +313,8 @@ func (s *sqlDatabase) getRepoPoolByUniqueFields(ctx context.Context, repoID stri
return pool[0], nil
}
func (s *sqlDatabase) getRepoPools(ctx context.Context, repoID string, preload ...string) ([]Pool, error) {
_, err := s.getRepoByID(ctx, repoID)
if err != nil {
return nil, errors.Wrap(err, "fetching repo")
}
q := s.conn
if len(preload) > 0 {
for _, item := range preload {
q = q.Preload(item)
}
}
var pools []Pool
err = q.Model(&Pool{}).Where("repo_id = ?", repoID).
Omit("extra_specs").
Find(&pools).Error
if err != nil {
return nil, errors.Wrap(err, "fetching pool")
}
return pools, nil
}
func (s *sqlDatabase) getRepoByID(ctx context.Context, id string, preload ...string) (Repository, error) {
u, err := uuid.FromString(id)
u, err := uuid.Parse(id)
if err != nil {
return Repository{}, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id")
}

View file

@ -38,7 +38,7 @@ type RepoTestFixtures struct {
CreateRepoParams params.CreateRepoParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
SQLMock sqlmock.Sqlmock
}
@ -153,7 +153,7 @@ func (s *RepoTestSuite) SetupTest() {
Name: "test-instance",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-update-creds",
WebhookSecret: "test-update-webhook-secret",
},
@ -707,7 +707,7 @@ func (s *RepoTestSuite) TestListRepoPoolsInvalidRepoID() {
_, err := s.Store.ListRepoPools(context.Background(), "dummy-repo-id")
s.Require().NotNil(err)
s.Require().Equal("fetching pools: fetching repo: parsing id: invalid request", err.Error())
s.Require().Equal("fetching pools: parsing id: invalid request", err.Error())
}
func (s *RepoTestSuite) TestGetRepositoryPool() {
@ -820,7 +820,7 @@ func (s *RepoTestSuite) TestListRepoInstancesInvalidRepoID() {
_, err := s.Store.ListRepoInstances(context.Background(), "dummy-repo-id")
s.Require().NotNil(err)
s.Require().Equal("fetching repo: fetching repo: parsing id: invalid request", err.Error())
s.Require().Equal("fetching repo: parsing id: invalid request", err.Error())
}
func (s *RepoTestSuite) TestUpdateRepositoryPool() {
@ -846,5 +846,6 @@ func (s *RepoTestSuite) TestUpdateRepositoryPoolInvalidRepoID() {
}
func TestRepoTestSuite(t *testing.T) {
t.Parallel()
suite.Run(t, new(RepoTestSuite))
}

View file

@ -16,7 +16,9 @@ package sql
import (
"context"
"fmt"
"log"
"strings"
"github.com/pkg/errors"
"gorm.io/driver/mysql"
@ -79,6 +81,115 @@ type sqlDatabase struct {
cfg config.Database
}
var renameTemplate = `
PRAGMA foreign_keys = OFF;
BEGIN TRANSACTION;
ALTER TABLE %s RENAME TO %s_old;
COMMIT;
`
var restoreNameTemplate = `
PRAGMA foreign_keys = OFF;
BEGIN TRANSACTION;
DROP TABLE IF EXISTS %s;
ALTER TABLE %s_old RENAME TO %s;
COMMIT;
`
var copyContentsTemplate = `
PRAGMA foreign_keys = OFF;
BEGIN TRANSACTION;
INSERT INTO %s SELECT * FROM %s_old;
DROP TABLE %s_old;
COMMIT;
`
func (s *sqlDatabase) cascadeMigrationSQLite(model interface{}, name string, justDrop bool) error {
if !s.conn.Migrator().HasTable(name) {
return nil
}
defer s.conn.Exec("PRAGMA foreign_keys = ON;")
var data string
var indexes []string
if err := s.conn.Raw(fmt.Sprintf("select sql from sqlite_master where type='table' and tbl_name='%s'", name)).Scan(&data).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
return fmt.Errorf("failed to get table %s: %w", name, err)
}
}
if err := s.conn.Raw(fmt.Sprintf("SELECT name FROM sqlite_master WHERE type == 'index' AND tbl_name == '%s' and name not like 'sqlite_%%'", name)).Scan(&indexes).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
return fmt.Errorf("failed to get table indexes %s: %w", name, err)
}
}
if strings.Contains(data, "ON DELETE") {
return nil
}
if justDrop {
if err := s.conn.Migrator().DropTable(model); err != nil {
return fmt.Errorf("failed to drop table %s: %w", name, err)
}
return nil
}
for _, index := range indexes {
if err := s.conn.Migrator().DropIndex(model, index); err != nil {
return fmt.Errorf("failed to drop index %s: %w", index, err)
}
}
err := s.conn.Exec(fmt.Sprintf(renameTemplate, name, name)).Error
if err != nil {
return fmt.Errorf("failed to rename table %s: %w", name, err)
}
if model != nil {
if err := s.conn.Migrator().AutoMigrate(model); err != nil {
if err := s.conn.Exec(fmt.Sprintf(restoreNameTemplate, name, name, name)).Error; err != nil {
log.Printf("failed to restore table %s: %s", name, err)
}
return fmt.Errorf("failed to create table %s: %w", name, err)
}
}
err = s.conn.Exec(fmt.Sprintf(copyContentsTemplate, name, name, name)).Error
if err != nil {
return fmt.Errorf("failed to copy contents to table %s: %w", name, err)
}
return nil
}
func (s *sqlDatabase) cascadeMigration() error {
switch s.cfg.DbBackend {
case config.SQLiteBackend:
if err := s.cascadeMigrationSQLite(&Address{}, "addresses", true); err != nil {
return fmt.Errorf("failed to drop table addresses: %w", err)
}
if err := s.cascadeMigrationSQLite(&InstanceStatusUpdate{}, "instance_status_updates", true); err != nil {
return fmt.Errorf("failed to drop table instance_status_updates: %w", err)
}
if err := s.cascadeMigrationSQLite(&Tag{}, "pool_tags", false); err != nil {
return fmt.Errorf("failed to migrate addresses: %w", err)
}
if err := s.cascadeMigrationSQLite(&WorkflowJob{}, "workflow_jobs", false); err != nil {
return fmt.Errorf("failed to migrate addresses: %w", err)
}
case config.MySQLBackend:
return nil
default:
return fmt.Errorf("invalid db backend: %s", s.cfg.DbBackend)
}
return nil
}
func (s *sqlDatabase) migrateDB() error {
if s.conn.Migrator().HasIndex(&Organization{}, "idx_organizations_name") {
if err := s.conn.Migrator().DropIndex(&Organization{}, "idx_organizations_name"); err != nil {
@ -91,6 +202,25 @@ func (s *sqlDatabase) migrateDB() error {
log.Printf("failed to drop index idx_owner: %s", err)
}
}
if err := s.cascadeMigration(); err != nil {
return errors.Wrap(err, "running cascade migration")
}
if s.conn.Migrator().HasTable(&Pool{}) {
if err := s.conn.Exec("update pools set repo_id=NULL where repo_id='00000000-0000-0000-0000-000000000000'").Error; err != nil {
return errors.Wrap(err, "updating pools")
}
if err := s.conn.Exec("update pools set org_id=NULL where org_id='00000000-0000-0000-0000-000000000000'").Error; err != nil {
return errors.Wrap(err, "updating pools")
}
if err := s.conn.Exec("update pools set enterprise_id=NULL where enterprise_id='00000000-0000-0000-0000-000000000000'").Error; err != nil {
return errors.Wrap(err, "updating pools")
}
}
if err := s.conn.AutoMigrate(
&Tag{},
&Pool{},
@ -102,6 +232,7 @@ func (s *sqlDatabase) migrateDB() error {
&Instance{},
&ControllerInfo{},
&User{},
&WorkflowJob{},
); err != nil {
return errors.Wrap(err, "running auto migrate")
}

View file

@ -22,7 +22,6 @@ import (
"github.com/cloudbase/garm/util"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"gorm.io/datatypes"
"gorm.io/gorm"
)
@ -32,6 +31,9 @@ func (s *sqlDatabase) sqlToParamsInstance(instance Instance) params.Instance {
if instance.ProviderID != nil {
id = *instance.ProviderID
}
var labels []string
_ = json.Unmarshal(instance.AditionalLabels, &labels)
ret := params.Instance{
ID: instance.ID.String(),
ProviderID: id,
@ -51,6 +53,7 @@ func (s *sqlDatabase) sqlToParamsInstance(instance Instance) params.Instance {
UpdatedAt: instance.UpdatedAt,
TokenFetched: instance.TokenFetched,
GitHubRunnerGroup: instance.GitHubRunnerGroup,
AditionalLabels: labels,
}
if len(instance.ProviderFault) > 0 {
@ -148,19 +151,19 @@ func (s *sqlDatabase) sqlToCommonPool(pool Pool) params.Pool {
GitHubRunnerGroup: pool.GitHubRunnerGroup,
}
if pool.RepoID != uuid.Nil {
if pool.RepoID != nil {
ret.RepoID = pool.RepoID.String()
if pool.Repository.Owner != "" && pool.Repository.Name != "" {
ret.RepoName = fmt.Sprintf("%s/%s", pool.Repository.Owner, pool.Repository.Name)
}
}
if pool.OrgID != uuid.Nil && pool.Organization.Name != "" {
if pool.OrgID != nil && pool.Organization.Name != "" {
ret.OrgID = pool.OrgID.String()
ret.OrgName = pool.Organization.Name
}
if pool.EnterpriseID != uuid.Nil && pool.Enterprise.Name != "" {
if pool.EnterpriseID != nil && pool.Enterprise.Name != "" {
ret.EnterpriseID = pool.EnterpriseID.String()
ret.EnterpriseName = pool.Enterprise.Name
}

17
doc/logging.md Normal file
View file

@ -0,0 +1,17 @@
# Logging
By default, GARM is logging only on standard output.
If you would like GARM to use a logging file instead, you can use the `log_file` configuration option:
```toml
[default]
# Use this if you'd like to log to a file instead of standard output.
log_file = "/tmp/runner-manager.log"
```
## Rotating log files
If GARM uses a log file, by default it will rotate it when it reaches 500MB or 28 days, whichever comes first.
However, if you want to manually rotate the log file, you can send a `SIGHUP` signal to the GARM process.

View file

@ -0,0 +1,82 @@
# Performance considerations
Performance is often important when running GitHub action runners with garm. This document shows some ways to improve the creation time of a GitHub action runner.
## garm specific performance considerations
### Bundle the GitHub action runner
When a new instance is created by garm, it usually downloads the latest available GitHub action runner binary, installs the requirements and starts it afterwards. This can be a time consuming task that quickly adds up when alot of instances are created by garm throughout the day. Therefore it is recommended to include the GitHub action runner binary inside of the used image.
There are two ways to do that:
1. Add the extracted runner to `/opt/cache/actions-runner/latest` in which case, garm won't do any version checking and will blindly trust that whatever you put there is indeed the latest. This is useful if you want to run a pre-release of the runner or have your own patches applied to it. Also GitHub runners have an auto-update mechanism. When it detects that a new version is available, it updates itself to the latest version.
2. Add the extracted runner to `/opt/cache/actions-runner/$VERSION` where `$VERSION` is the version of the runner. In this case, if what garm fetches from GitHub is different than what you bundled in the image, it will download and install the version indicated by GitHub.
Note, when bundling the runner with your image, you will have to download it, extract it to one of the above mentioned locations and also run the `./bin/installdependencies.sh` inside the extracted folder. All dependencies needed to run the runner must be pre-installed when bundling.
Example steps:
```bash
# Create a temporary instance from your base image
lxc launch <BASE_IMAGE> temp
# Enter bash inside the container
lxc exec temp -- bash
# Get and install the runner
mkdir -p /opt/cache/actions-runner/latest
cd /opt/cache/actions-runner/latest
curl -o actions-runner-linux-x64-2.305.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.305.0/actions-runner-linux-x64-2.305.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.305.0.tar.gz
./bin/installdependencies.sh
# Exit the container
exit
# Stop the instance and publish it as a new image
lxc stop temp
lxc publish temp --alias BASE_IMAGE-2.305.0
# Delete the temporary instance
lxc delete temp
# Update garm to use the new image
garm-cli pool update <POOL_ID> \
--image=BASE_IMAGE-2.305.0
```
### Disable updates
By default garm configures the `cloud-init` process of a new instance to update packages on startup. To prevent this from happening (and therefore reduce the time needed to start an instance) garm can be configured accordingly.
Example to disable this on LXD provider:
```bash
garm-cli pool update <POOL_ID> \
--extra-specs='{"disable_updates": true}'
```
## LXD specific performance considerations
### Storage driver
LXD supports various [storage drivers](https://linuxcontainers.org/lxd/docs/latest/reference/storage_drivers/) out of the box. These storage drivers support different features which influence the creation time of a new instance. Most notably check if the driver supports `Optimized image storage` and `Optimized instance creation` as these have the biggest impact on instance creation time.
If you're not sure which storage driver is currently used, check your storages with `lxc storage list`.
### Use shiftfs/idmapped mounts
Whenever a new unprivileged instance is started on LXD, its filesystem gets remapped. This is a time consuming task which depends on the image size that's being used. For large images this can easily take over a minute to complete. There are two ways to get around this: `shiftfs` or `idmapped mounts`. While the latter is the preferred one, not all filesystems currently support it, so in most cases enabling `shiftfs` show a significant performance improvement.
Example on how to enable it on a snap installed LXD:
```bash
snap set lxd shiftfs.enable=true
systemctl reload snap.lxd.daemon
```
Some details and discussions around `shiftfs` can be found [here](https://discuss.linuxcontainers.org/t/trying-out-shiftfs/5155).
Note: When `shiftfs` is used, mounting between host and container might need some extra steps to be secure. See [here](https://discuss.linuxcontainers.org/t/share-folders-and-volumes-between-host-and-containers/7735) for details.

View file

@ -29,8 +29,9 @@ var (
// ErrBadRequest is returned is a malformed request is sent
ErrBadRequest = NewBadRequestError("invalid request")
// ErrTimeout is returned when a timeout occurs.
ErrTimeout = fmt.Errorf("timed out")
ErrUnprocessable = fmt.Errorf("cannot process request")
ErrTimeout = fmt.Errorf("timed out")
ErrUnprocessable = fmt.Errorf("cannot process request")
ErrNoPoolsAvailable = fmt.Errorf("no pools available")
)
type baseError struct {

34
go.mod
View file

@ -4,9 +4,12 @@ go 1.20
require (
github.com/BurntSushi/toml v1.2.1
github.com/go-openapi/errors v0.20.4
github.com/go-openapi/runtime v0.26.0
github.com/go-openapi/strfmt v0.21.7
github.com/go-resty/resty/v2 v2.7.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/go-github/v48 v48.2.0
github.com/google/go-github/v53 v53.2.0
github.com/google/uuid v1.3.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
@ -20,14 +23,13 @@ require (
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.2
github.com/teris-io/shortid v0.0.0-20220617161101-71ec9f2aa569
golang.org/x/crypto v0.7.0
golang.org/x/oauth2 v0.6.0
golang.org/x/oauth2 v0.8.0
golang.org/x/sync v0.1.0
golang.org/x/sys v0.6.0
golang.org/x/sys v0.8.0
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
@ -38,21 +40,34 @@ require (
)
require (
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 // indirect
github.com/frankban/quicktest v1.14.3 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-macaroon-bakery/macaroon-bakery/v3 v3.0.1 // indirect
github.com/go-macaroon-bakery/macaroonpb v1.0.0 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/juju/errors v1.0.0 // indirect
github.com/juju/testing v1.0.2 // indirect
github.com/juju/webbrowser v1.0.0 // indirect
@ -60,9 +75,13 @@ require (
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pkg/sftp v1.13.5 // indirect
github.com/pkg/xattr v0.4.9 // indirect
@ -76,8 +95,11 @@ require (
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/term v0.6.0 // indirect
go.mongodb.org/mongo-driver v1.11.3 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/term v0.8.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/errgo.v1 v1.0.1 // indirect

189
go.sum
View file

@ -2,8 +2,16 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@ -17,6 +25,9 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -35,14 +46,79 @@ github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03D
github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y=
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-macaroon-bakery/macaroon-bakery/v3 v3.0.1 h1:uvQJoKTHrFFu8zxoaopNKedRzwdy3+8H72we4T/5cGs=
github.com/go-macaroon-bakery/macaroon-bakery/v3 v3.0.1/go.mod h1:H59IYeChwvD1po3dhGUPvq5na+4NVD7SJlbhGKvslr0=
github.com/go-macaroon-bakery/macaroonpb v1.0.0 h1:It9exBaRMZ9iix1iJ6gwzfwsDE6ExNuwtAJ9e09v6XE=
github.com/go-macaroon-bakery/macaroonpb v1.0.0/go.mod h1:UzrGOcbiwTXISFP2XDLDPjfhMINZa+fX/7A2lMd31zc=
github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY=
github.com/go-openapi/analysis v0.21.4 h1:ZDFLvSNxpDaomuCueM0BlSXxpANBlFYiBvr+GXrvIHc=
github.com/go-openapi/analysis v0.21.4/go.mod h1:4zQ35W4neeZTqh3ol0rv/O8JBbka9QyAgQRPp9y3pfo=
github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/errors v0.20.4 h1:unTcVm6PispJsMECE3zWgvG4xTiKda1LIR5rCRWLG6M=
github.com/go-openapi/errors v0.20.4/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk=
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns=
github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA=
github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo=
github.com/go-openapi/loads v0.21.1/go.mod h1:/DtAMXXneXFjbQMGEtbamCZb+4x7eGwkvZCvBmwUG+g=
github.com/go-openapi/loads v0.21.2 h1:r2a/xFIYeZ4Qd2TnGpWDIQNcP80dIaZgf704za8enro=
github.com/go-openapi/loads v0.21.2/go.mod h1:Jq58Os6SSGz0rzh62ptiu8Z31I+OTHqmULx5e/gJbNw=
github.com/go-openapi/runtime v0.26.0 h1:HYOFtG00FM1UvqrcxbEJg/SwvDRvYLQKGhw2zaQjTcc=
github.com/go-openapi/runtime v0.26.0/go.mod h1:QgRGeZwrUcSHdeh4Ka9Glvo0ug1LC5WyE+EV88plZrQ=
github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I=
github.com/go-openapi/spec v0.20.6/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA=
github.com/go-openapi/spec v0.20.8 h1:ubHmXNY3FCIOinT8RNrrPfGc9t7I1qhPtdOGoG2AxRU=
github.com/go-openapi/spec v0.20.8/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA=
github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg=
github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k=
github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg=
github.com/go-openapi/strfmt v0.21.7 h1:rspiXgNWgeUzhjo1YU01do6qsahtJNByjLVbPLNHb8k=
github.com/go-openapi/strfmt v0.21.7/go.mod h1:adeGTkxE44sPyLk0JV235VQAO/ZXUr8KAzYjclFs3ew=
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU=
github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-openapi/validate v0.22.1 h1:G+c2ub6q47kfX1sOBLwIQwzBVt8qmOAARyo/9Fqs9NU=
github.com/go-openapi/validate v0.22.1/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg=
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY=
github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg=
github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs=
github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI=
github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk=
github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28=
github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo=
github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk=
github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw=
github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360=
github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg=
github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE=
github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8=
github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0=
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
@ -63,6 +139,7 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@ -73,11 +150,12 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-github/v48 v48.2.0 h1:68puzySE6WqUY9KWmpOsDEQfDZsso98rT6pZcz9HqcE=
github.com/google/go-github/v48 v48.2.0/go.mod h1:dDlehKBDo850ZPvCTK0sEqTCVWcrGl2LcDiajkYi89Y=
github.com/google/go-github/v53 v53.2.0 h1:wvz3FyF53v4BK+AsnvCmeNhf8AkTaeh2SoYu/XUvTtI=
github.com/google/go-github/v53 v53.2.0/go.mod h1:XhFRObz+m/l+UCm9b7KSIC3lT3NWSXGt7mOsAWEloao=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
@ -86,6 +164,7 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
@ -104,6 +183,9 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/juju/clock v1.0.3 h1:yJHIsWXeU8j3QcBdiess09SzfiXRRrsjKPn2whnMeds=
github.com/juju/clock v1.0.3/go.mod h1:HIBvJ8kiV/n7UHwKuCkdYL4l/MDECztHR2sAvWDxxf0=
github.com/juju/errors v1.0.0 h1:yiq7kjCLll1BiaRuNY53MGI0+EQ3rF6GB+wvboZDefM=
@ -120,8 +202,13 @@ github.com/juju/webbrowser v1.0.0 h1:JLdmbFtCGY6Qf2jmS6bVaenJFGIFkdF1/BjUm76af78
github.com/juju/webbrowser v1.0.0/go.mod h1:RwVlbBcF91Q4vS+iwlkJ6bZTE3EwlrjbYlM3WMVD6Bc=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@ -135,8 +222,15 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lxc/lxd v0.0.0-20230325180147-8d608287b0ce h1:3zb1HRvOAHOMZ8VGTDEBkKpCUVlF28zalZcb7RFjMnE=
github.com/lxc/lxd v0.0.0-20230325180147-8d608287b0ce/go.mod h1:JJ1ShHzaOzMzU0B5TNcdI9+vq8Y45ijVeNYxE1wJ8zM=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
@ -148,12 +242,24 @@ github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE=
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6FxaNu/BnU2OAaLF86eTVhP2hjTB6iMvItA=
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw=
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18=
@ -180,23 +286,33 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM=
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
@ -205,11 +321,34 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/teris-io/shortid v0.0.0-20220617161101-71ec9f2aa569 h1:xzABM9let0HLLqFypcxvLmlvEciCHL7+Lv+4vwZqecI=
github.com/teris-io/shortid v0.0.0-20220617161101-71ec9f2aa569/go.mod h1:2Ly+NIftZN4de9zRmENdYbvPQeaVIYKWpLFStLFEBgI=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg=
go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng=
go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8=
go.mongodb.org/mongo-driver v1.11.3 h1:Ql6K6qYHEzB6xvu4+AU0BoRoqf9vFPcc4o7MUIdPW8Y=
go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY=
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -226,47 +365,67 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw=
golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw=
golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8=
golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220408201424-a24fb2fb8a0f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -299,6 +458,7 @@ gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 h1:FVCohIoYO7IJoDDVpV2pdq7SgrMH6wHnuTyrdr
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0/go.mod h1:OdE7CF6DbADk7lN8LIKRzRJTTZXIjtWgA5THM5lhBAw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/errgo.v1 v1.0.0/go.mod h1:CxwszS/Xz1C49Ucd2i6Zil5UToP1EmyrFhKaMVbg1mk=
@ -313,10 +473,15 @@ gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/datatypes v1.1.1 h1:XAjO7NNfUKVUvnS3+BkqMrPXxCAcxDlpOYbjnizxNCw=

View file

@ -21,8 +21,8 @@ import (
"github.com/cloudbase/garm/runner/providers/common"
"github.com/cloudbase/garm/util/appdefaults"
"github.com/google/go-github/v48/github"
uuid "github.com/satori/go.uuid"
"github.com/google/go-github/v53/github"
"github.com/google/uuid"
)
type (
@ -33,6 +33,7 @@ type (
OSType string
OSArch string
ProviderType string
JobStatus string
)
const (
@ -42,6 +43,12 @@ const (
ExternalProvider ProviderType = "external"
)
const (
JobStatusQueued JobStatus = "queued"
JobStatusInProgress JobStatus = "in_progress"
JobStatusCompleted JobStatus = "completed"
)
const (
RepositoryPool PoolType = "repository"
OrganizationPool PoolType = "organization"
@ -149,10 +156,11 @@ type Instance struct {
GitHubRunnerGroup string `json:"github-runner-group"`
// Do not serialize sensitive info.
CallbackURL string `json:"-"`
MetadataURL string `json:"-"`
CreateAttempt int `json:"-"`
TokenFetched bool `json:"-"`
CallbackURL string `json:"-"`
MetadataURL string `json:"-"`
CreateAttempt int `json:"-"`
TokenFetched bool `json:"-"`
AditionalLabels []string `json:"-"`
}
func (i Instance) GetName() string {
@ -163,6 +171,9 @@ func (i Instance) GetID() string {
return i.ID
}
// used by swagger client generated code
type Instances []Instance
type BootstrapInstance struct {
Name string `json:"name"`
Tools []*github.RunnerApplicationDownload `json:"tools"`
@ -285,6 +296,9 @@ func (p *Pool) PoolType() PoolType {
return ""
}
// used by swagger client generated code
type Pools []Pool
type Internal struct {
OAuth2Token string `json:"oauth2"`
ControllerID string `json:"controller_id"`
@ -315,6 +329,9 @@ func (r Repository) GetID() string {
return r.ID
}
// used by swagger client generated code
type Repositories []Repository
type Organization struct {
ID string `json:"id"`
Name string `json:"name"`
@ -391,7 +408,8 @@ type Provider struct {
}
type UpdatePoolStateParams struct {
WebhookSecret string
WebhookSecret string
InternalConfig *Internal
}
type PoolManagerStatus struct {
@ -414,3 +432,53 @@ func (p RunnerPrefix) GetRunnerPrefix() string {
}
return p.Prefix
}
type Job struct {
// ID is the ID of the job.
ID int64 `json:"id"`
// RunID is the ID of the workflow run. A run may have multiple jobs.
RunID int64 `json:"run_id"`
// Action is the specific activity that triggered the event.
Action string `json:"action"`
// Conclusion is the outcome of the job.
// Possible values: "success", "failure", "neutral", "cancelled", "skipped",
// "timed_out", "action_required"
Conclusion string `json:"conclusion"`
// Status is the phase of the lifecycle that the job is currently in.
// "queued", "in_progress" and "completed".
Status string `json:"status"`
// Name is the name if the job that was triggered.
Name string `json:"name"`
StartedAt time.Time
CompletedAt time.Time
GithubRunnerID int64 `json:"runner_id"`
RunnerName string `json:"runner_name"`
RunnerGroupID int64 `json:"runner_group_id"`
RunnerGroupName string `json:"runner_group_name"`
// repository in which the job was triggered.
RepositoryName string
RepositoryOwner string
Labels []string
// The entity that received the hook.
//
// Webhooks may be configured on the repo, the org and/or the enterprise.
// If we only configure a repo to use garm, we'll only ever receive a
// webhook from the repo. But if we configure the parent org of the repo and
// the parent enterprise of the org to use garm, a webhook will be sent for each
// entity type, in response to one workflow event. Thus, we will get 3 webhooks
// with the same run_id and job id. Record all involved entities in the same job
// if we have them configured in garm.
RepoID *uuid.UUID `json:"repo_id,omitempty"`
OrgID *uuid.UUID `json:"org_id,omitempty"`
EnterpriseID *uuid.UUID `json:"enterprise_id,omitempty"`
LockedBy uuid.UUID
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View file

@ -136,6 +136,7 @@ type CreateInstanceParams struct {
// The runner group must be created by someone with access to the enterprise.
GitHubRunnerGroup string
CreateAttempt int `json:"-"`
AditionalLabels []string
}
type CreatePoolParams struct {
@ -226,7 +227,7 @@ func (p PasswordLoginParams) Validate() error {
return nil
}
type UpdateRepositoryParams struct {
type UpdateEntityParams struct {
CredentialsName string `json:"credentials_name"`
WebhookSecret string `json:"webhook_secret"`
}

View file

@ -1,11 +1,11 @@
// Code generated by mockery v2.22.1. DO NOT EDIT.
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
package mocks
import (
context "context"
github "github.com/google/go-github/v48/github"
github "github.com/google/go-github/v53/github"
mock "github.com/stretchr/testify/mock"
)
@ -311,13 +311,12 @@ func (_m *GithubClient) RemoveRunner(ctx context.Context, owner string, repo str
return r0, r1
}
type mockConstructorTestingTNewGithubClient interface {
// NewGithubClient creates a new instance of GithubClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewGithubClient(t interface {
mock.TestingT
Cleanup(func())
}
// NewGithubClient creates a new instance of GithubClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewGithubClient(t mockConstructorTestingTNewGithubClient) *GithubClient {
}) *GithubClient {
mock := &GithubClient{}
mock.Mock.Test(t)

View file

@ -1,11 +1,11 @@
// Code generated by mockery v2.22.1. DO NOT EDIT.
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
package mocks
import (
context "context"
github "github.com/google/go-github/v48/github"
github "github.com/google/go-github/v53/github"
mock "github.com/stretchr/testify/mock"
)
@ -145,13 +145,12 @@ func (_m *GithubEnterpriseClient) RemoveRunner(ctx context.Context, enterprise s
return r0, r1
}
type mockConstructorTestingTNewGithubEnterpriseClient interface {
// NewGithubEnterpriseClient creates a new instance of GithubEnterpriseClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewGithubEnterpriseClient(t interface {
mock.TestingT
Cleanup(func())
}
// NewGithubEnterpriseClient creates a new instance of GithubEnterpriseClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewGithubEnterpriseClient(t mockConstructorTestingTNewGithubEnterpriseClient) *GithubEnterpriseClient {
}) *GithubEnterpriseClient {
mock := &GithubEnterpriseClient{}
mock.Mock.Test(t)

View file

@ -1,4 +1,4 @@
// Code generated by mockery v2.22.1. DO NOT EDIT.
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
package mocks
@ -162,13 +162,12 @@ func (_m *PoolManager) WebhookSecret() string {
return r0
}
type mockConstructorTestingTNewPoolManager interface {
// NewPoolManager creates a new instance of PoolManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewPoolManager(t interface {
mock.TestingT
Cleanup(func())
}
// NewPoolManager creates a new instance of PoolManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewPoolManager(t mockConstructorTestingTNewPoolManager) *PoolManager {
}) *PoolManager {
mock := &PoolManager{}
mock.Mock.Test(t)

View file

@ -1,4 +1,4 @@
// Code generated by mockery v2.22.1. DO NOT EDIT.
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
package mocks
@ -158,13 +158,12 @@ func (_m *Provider) Stop(ctx context.Context, instance string, force bool) error
return r0
}
type mockConstructorTestingTNewProvider interface {
// NewProvider creates a new instance of Provider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewProvider(t interface {
mock.TestingT
Cleanup(func())
}
// NewProvider creates a new instance of Provider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewProvider(t mockConstructorTestingTNewProvider) *Provider {
}) *Provider {
mock := &Provider{}
mock.Mock.Test(t)

View file

@ -25,15 +25,14 @@ const (
PoolConsilitationInterval = 5 * time.Second
PoolReapTimeoutInterval = 5 * time.Minute
// Temporary tools download token is valid for 1 hour by default.
// Set this to 15 minutes. This should allow enough time even on slow
// clouds for the instance to spin up, download the tools and join gh.
PoolToolUpdateInterval = 15 * time.Minute
// There is no point in making an API call to get available tools, for every runner
// we spin up. We cache the tools for one minute. This should save us a lot of API calls
// in cases where we have a lot of runners spin up at the same time.
PoolToolUpdateInterval = 1 * time.Minute
// UnauthorizedBackoffTimer is the time we wait before making another request
// after getting an unauthorized error from github. It is unlikely that a second
// request will not receive the same error, unless the config is changed with new
// credentials and garm is restarted.
UnauthorizedBackoffTimer = 3 * time.Hour
// BackoffTimer is the time we wait before attempting to make another request
// to the github API.
BackoffTimer = 1 * time.Minute
)
//go:generate mockery --all

View file

@ -3,7 +3,7 @@ package common
import (
"context"
"github.com/google/go-github/v48/github"
"github.com/google/go-github/v53/github"
)
// GithubClient that describes the minimum list of functions we need to interact with github.

View file

@ -144,7 +144,7 @@ func (r *Runner) DeleteEnterprise(ctx context.Context, enterpriseID string) erro
return nil
}
func (r *Runner) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) {
func (r *Runner) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateEntityParams) (params.Enterprise, error) {
if !auth.IsAdmin(ctx) {
return params.Enterprise{}, runnerErrors.ErrUnauthorized
}
@ -169,21 +169,12 @@ func (r *Runner) UpdateEnterprise(ctx context.Context, enterpriseID string, para
return params.Enterprise{}, errors.Wrap(err, "updating enterprise")
}
poolMgr, err := r.poolManagerCtrl.GetEnterprisePoolManager(enterprise)
poolMgr, err := r.poolManagerCtrl.UpdateEnterprisePoolManager(r.ctx, enterprise)
if err != nil {
newState := params.UpdatePoolStateParams{
WebhookSecret: enterprise.WebhookSecret,
}
// stop the pool mgr
if err := poolMgr.RefreshState(newState); err != nil {
return params.Enterprise{}, errors.Wrap(err, "updating enterprise pool manager")
}
} else {
if _, err := r.poolManagerCtrl.CreateEnterprisePoolManager(r.ctx, enterprise, r.providers, r.store); err != nil {
return params.Enterprise{}, errors.Wrap(err, "creating enterprise pool manager")
}
return params.Enterprise{}, fmt.Errorf("failed to update enterprise pool manager: %w", err)
}
enterprise.PoolManagerStatus = poolMgr.Status()
return enterprise, nil
}

View file

@ -44,7 +44,7 @@ type EnterpriseTestFixtures struct {
CreateEnterpriseParams params.CreateEnterpriseParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
UpdatePoolStateParams params.UpdatePoolStateParams
ErrMock error
@ -124,7 +124,7 @@ func (s *EnterpriseTestSuite) SetupTest() {
Name: "test-instance-name",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-creds",
WebhookSecret: "test-update-repo-webhook-secret",
},
@ -290,8 +290,8 @@ func (s *EnterpriseTestSuite) TestDeleteEnterprisePoolMgrFailed() {
}
func (s *EnterpriseTestSuite) TestUpdateEnterprise() {
s.Fixtures.PoolMgrCtrlMock.On("GetEnterprisePoolManager", mock.AnythingOfType("params.Enterprise")).Return(s.Fixtures.PoolMgrMock, nil)
s.Fixtures.PoolMgrCtrlMock.On("CreateEnterprisePoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Enterprise"), s.Fixtures.Providers, s.Fixtures.Store).Return(s.Fixtures.PoolMgrMock, nil)
s.Fixtures.PoolMgrCtrlMock.On("UpdateEnterprisePoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Enterprise")).Return(s.Fixtures.PoolMgrMock, nil)
s.Fixtures.PoolMgrMock.On("Status").Return(params.PoolManagerStatus{IsRunning: true}, nil)
org, err := s.Runner.UpdateEnterprise(s.Fixtures.AdminContext, s.Fixtures.StoreEnterprises["test-enterprise-1"].ID, s.Fixtures.UpdateRepoParams)
@ -317,25 +317,21 @@ func (s *EnterpriseTestSuite) TestUpdateEnterpriseInvalidCreds() {
}
func (s *EnterpriseTestSuite) TestUpdateEnterprisePoolMgrFailed() {
s.Fixtures.PoolMgrCtrlMock.On("GetEnterprisePoolManager", mock.AnythingOfType("params.Enterprise")).Return(s.Fixtures.PoolMgrMock, s.Fixtures.ErrMock)
s.Fixtures.PoolMgrMock.On("RefreshState", s.Fixtures.UpdatePoolStateParams).Return(s.Fixtures.ErrMock)
s.Fixtures.PoolMgrCtrlMock.On("UpdateEnterprisePoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Enterprise")).Return(s.Fixtures.PoolMgrMock, s.Fixtures.ErrMock)
_, err := s.Runner.UpdateEnterprise(s.Fixtures.AdminContext, s.Fixtures.StoreEnterprises["test-enterprise-1"].ID, s.Fixtures.UpdateRepoParams)
s.Fixtures.PoolMgrMock.AssertExpectations(s.T())
s.Fixtures.PoolMgrCtrlMock.AssertExpectations(s.T())
s.Require().Equal(fmt.Sprintf("updating enterprise pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
s.Require().Equal(fmt.Sprintf("failed to update enterprise pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
}
func (s *EnterpriseTestSuite) TestUpdateEnterpriseCreateEnterprisePoolMgrFailed() {
s.Fixtures.PoolMgrCtrlMock.On("GetEnterprisePoolManager", mock.AnythingOfType("params.Enterprise")).Return(s.Fixtures.PoolMgrMock, nil)
s.Fixtures.PoolMgrCtrlMock.On("CreateEnterprisePoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Enterprise"), s.Fixtures.Providers, s.Fixtures.Store).Return(s.Fixtures.PoolMgrMock, s.Fixtures.ErrMock)
s.Fixtures.PoolMgrCtrlMock.On("UpdateEnterprisePoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Enterprise")).Return(s.Fixtures.PoolMgrMock, s.Fixtures.ErrMock)
_, err := s.Runner.UpdateEnterprise(s.Fixtures.AdminContext, s.Fixtures.StoreEnterprises["test-enterprise-1"].ID, s.Fixtures.UpdateRepoParams)
s.Fixtures.PoolMgrMock.AssertExpectations(s.T())
s.Fixtures.PoolMgrCtrlMock.AssertExpectations(s.T())
s.Require().Equal(fmt.Sprintf("creating enterprise pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
s.Require().Equal(fmt.Sprintf("failed to update enterprise pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
}
func (s *EnterpriseTestSuite) TestCreateEnterprisePool() {

View file

@ -24,6 +24,7 @@ import (
type RepoPoolManager interface {
CreateRepoPoolManager(ctx context.Context, repo params.Repository, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error)
UpdateRepoPoolManager(ctx context.Context, repo params.Repository) (common.PoolManager, error)
GetRepoPoolManager(repo params.Repository) (common.PoolManager, error)
DeleteRepoPoolManager(repo params.Repository) error
GetRepoPoolManagers() (map[string]common.PoolManager, error)
@ -31,6 +32,7 @@ type RepoPoolManager interface {
type OrgPoolManager interface {
CreateOrgPoolManager(ctx context.Context, org params.Organization, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error)
UpdateOrgPoolManager(ctx context.Context, org params.Organization) (common.PoolManager, error)
GetOrgPoolManager(org params.Organization) (common.PoolManager, error)
DeleteOrgPoolManager(org params.Organization) error
GetOrgPoolManagers() (map[string]common.PoolManager, error)
@ -38,6 +40,7 @@ type OrgPoolManager interface {
type EnterprisePoolManager interface {
CreateEnterprisePoolManager(ctx context.Context, enterprise params.Enterprise, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error)
UpdateEnterprisePoolManager(ctx context.Context, enterprise params.Enterprise) (common.PoolManager, error)
GetEnterprisePoolManager(enterprise params.Enterprise) (common.PoolManager, error)
DeleteEnterprisePoolManager(enterprise params.Enterprise) error
GetEnterprisePoolManagers() (map[string]common.PoolManager, error)

View file

@ -1,4 +1,4 @@
// Code generated by mockery v2.22.1. DO NOT EDIT.
// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
package mocks
@ -295,13 +295,90 @@ func (_m *PoolManagerController) GetRepoPoolManagers() (map[string]common.PoolMa
return r0, r1
}
type mockConstructorTestingTNewPoolManagerController interface {
mock.TestingT
Cleanup(func())
// UpdateEnterprisePoolManager provides a mock function with given fields: ctx, enterprise
func (_m *PoolManagerController) UpdateEnterprisePoolManager(ctx context.Context, enterprise params.Enterprise) (common.PoolManager, error) {
ret := _m.Called(ctx, enterprise)
var r0 common.PoolManager
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, params.Enterprise) (common.PoolManager, error)); ok {
return rf(ctx, enterprise)
}
if rf, ok := ret.Get(0).(func(context.Context, params.Enterprise) common.PoolManager); ok {
r0 = rf(ctx, enterprise)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(common.PoolManager)
}
}
if rf, ok := ret.Get(1).(func(context.Context, params.Enterprise) error); ok {
r1 = rf(ctx, enterprise)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UpdateOrgPoolManager provides a mock function with given fields: ctx, org
func (_m *PoolManagerController) UpdateOrgPoolManager(ctx context.Context, org params.Organization) (common.PoolManager, error) {
ret := _m.Called(ctx, org)
var r0 common.PoolManager
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, params.Organization) (common.PoolManager, error)); ok {
return rf(ctx, org)
}
if rf, ok := ret.Get(0).(func(context.Context, params.Organization) common.PoolManager); ok {
r0 = rf(ctx, org)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(common.PoolManager)
}
}
if rf, ok := ret.Get(1).(func(context.Context, params.Organization) error); ok {
r1 = rf(ctx, org)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UpdateRepoPoolManager provides a mock function with given fields: ctx, repo
func (_m *PoolManagerController) UpdateRepoPoolManager(ctx context.Context, repo params.Repository) (common.PoolManager, error) {
ret := _m.Called(ctx, repo)
var r0 common.PoolManager
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, params.Repository) (common.PoolManager, error)); ok {
return rf(ctx, repo)
}
if rf, ok := ret.Get(0).(func(context.Context, params.Repository) common.PoolManager); ok {
r0 = rf(ctx, repo)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(common.PoolManager)
}
}
if rf, ok := ret.Get(1).(func(context.Context, params.Repository) error); ok {
r1 = rf(ctx, repo)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// NewPoolManagerController creates a new instance of PoolManagerController. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewPoolManagerController(t mockConstructorTestingTNewPoolManagerController) *PoolManagerController {
// The first argument is typically a *testing.T value.
func NewPoolManagerController(t interface {
mock.TestingT
Cleanup(func())
}) *PoolManagerController {
mock := &PoolManagerController{}
mock.Mock.Test(t)

View file

@ -158,7 +158,7 @@ func (r *Runner) DeleteOrganization(ctx context.Context, orgID string) error {
return nil
}
func (r *Runner) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error) {
func (r *Runner) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (params.Organization, error) {
if !auth.IsAdmin(ctx) {
return params.Organization{}, runnerErrors.ErrUnauthorized
}
@ -183,21 +183,12 @@ func (r *Runner) UpdateOrganization(ctx context.Context, orgID string, param par
return params.Organization{}, errors.Wrap(err, "updating org")
}
poolMgr, err := r.poolManagerCtrl.GetOrgPoolManager(org)
poolMgr, err := r.poolManagerCtrl.UpdateOrgPoolManager(r.ctx, org)
if err != nil {
newState := params.UpdatePoolStateParams{
WebhookSecret: org.WebhookSecret,
}
// stop the pool mgr
if err := poolMgr.RefreshState(newState); err != nil {
return params.Organization{}, errors.Wrap(err, "updating org pool manager")
}
} else {
if _, err := r.poolManagerCtrl.CreateOrgPoolManager(r.ctx, org, r.providers, r.store); err != nil {
return params.Organization{}, errors.Wrap(err, "creating org pool manager")
}
return params.Organization{}, fmt.Errorf("updating org pool manager: %w", err)
}
org.PoolManagerStatus = poolMgr.Status()
return org, nil
}

View file

@ -44,7 +44,7 @@ type OrgTestFixtures struct {
CreateOrgParams params.CreateOrgParams
CreatePoolParams params.CreatePoolParams
CreateInstanceParams params.CreateInstanceParams
UpdateRepoParams params.UpdateRepositoryParams
UpdateRepoParams params.UpdateEntityParams
UpdatePoolParams params.UpdatePoolParams
UpdatePoolStateParams params.UpdatePoolStateParams
ErrMock error
@ -124,7 +124,7 @@ func (s *OrgTestSuite) SetupTest() {
Name: "test-instance-name",
OSType: "linux",
},
UpdateRepoParams: params.UpdateRepositoryParams{
UpdateRepoParams: params.UpdateEntityParams{
CredentialsName: "test-creds",
WebhookSecret: "test-update-repo-webhook-secret",
},
@ -290,8 +290,8 @@ func (s *OrgTestSuite) TestDeleteOrganizationPoolMgrFailed() {
}
func (s *OrgTestSuite) TestUpdateOrganization() {
s.Fixtures.PoolMgrCtrlMock.On("GetOrgPoolManager", mock.AnythingOfType("params.Organization")).Return(s.Fixtures.PoolMgrMock, nil)
s.Fixtures.PoolMgrCtrlMock.On("CreateOrgPoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Organization"), s.Fixtures.Providers, s.Fixtures.Store).Return(s.Fixtures.PoolMgrMock, nil)
s.Fixtures.PoolMgrCtrlMock.On("UpdateOrgPoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Organization")).Return(s.Fixtures.PoolMgrMock, nil)
s.Fixtures.PoolMgrMock.On("Status").Return(params.PoolManagerStatus{IsRunning: true}, nil)
org, err := s.Runner.UpdateOrganization(s.Fixtures.AdminContext, s.Fixtures.StoreOrgs["test-org-1"].ID, s.Fixtures.UpdateRepoParams)
@ -317,25 +317,21 @@ func (s *OrgTestSuite) TestUpdateOrganizationInvalidCreds() {
}
func (s *OrgTestSuite) TestUpdateOrganizationPoolMgrFailed() {
s.Fixtures.PoolMgrCtrlMock.On("GetOrgPoolManager", mock.AnythingOfType("params.Organization")).Return(s.Fixtures.PoolMgrMock, s.Fixtures.ErrMock)
s.Fixtures.PoolMgrMock.On("RefreshState", s.Fixtures.UpdatePoolStateParams).Return(s.Fixtures.ErrMock)
s.Fixtures.PoolMgrCtrlMock.On("UpdateOrgPoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Organization")).Return(s.Fixtures.PoolMgrMock, s.Fixtures.ErrMock)
_, err := s.Runner.UpdateOrganization(s.Fixtures.AdminContext, s.Fixtures.StoreOrgs["test-org-1"].ID, s.Fixtures.UpdateRepoParams)
s.Fixtures.PoolMgrMock.AssertExpectations(s.T())
s.Fixtures.PoolMgrCtrlMock.AssertExpectations(s.T())
s.Require().Equal(fmt.Sprintf("updating org pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
}
func (s *OrgTestSuite) TestUpdateOrganizationCreateOrgPoolMgrFailed() {
s.Fixtures.PoolMgrCtrlMock.On("GetOrgPoolManager", mock.AnythingOfType("params.Organization")).Return(s.Fixtures.PoolMgrMock, nil)
s.Fixtures.PoolMgrCtrlMock.On("CreateOrgPoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Organization"), s.Fixtures.Providers, s.Fixtures.Store).Return(s.Fixtures.PoolMgrMock, s.Fixtures.ErrMock)
s.Fixtures.PoolMgrCtrlMock.On("UpdateOrgPoolManager", s.Fixtures.AdminContext, mock.AnythingOfType("params.Organization")).Return(s.Fixtures.PoolMgrMock, s.Fixtures.ErrMock)
_, err := s.Runner.UpdateOrganization(s.Fixtures.AdminContext, s.Fixtures.StoreOrgs["test-org-1"].ID, s.Fixtures.UpdateRepoParams)
s.Fixtures.PoolMgrMock.AssertExpectations(s.T())
s.Fixtures.PoolMgrCtrlMock.AssertExpectations(s.T())
s.Require().Equal(fmt.Sprintf("creating org pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
s.Require().Equal(fmt.Sprintf("updating org pool manager: %s", s.Fixtures.ErrMock.Error()), err.Error())
}
func (s *OrgTestSuite) TestCreateOrgPool() {

View file

@ -13,7 +13,7 @@ import (
"github.com/cloudbase/garm/runner/common"
"github.com/cloudbase/garm/util"
"github.com/google/go-github/v48/github"
"github.com/google/go-github/v53/github"
"github.com/pkg/errors"
)
@ -26,6 +26,9 @@ func NewEnterprisePoolManager(ctx context.Context, cfg params.Enterprise, cfgInt
return nil, errors.Wrap(err, "getting github client")
}
wg := &sync.WaitGroup{}
keyMuxes := &keyMutex{}
helper := &enterprise{
cfg: cfg,
cfgInternal: cfgInternal,
@ -42,9 +45,10 @@ func NewEnterprisePoolManager(ctx context.Context, cfg params.Enterprise, cfgInt
providers: providers,
controllerID: cfgInternal.ControllerID,
quit: make(chan struct{}),
done: make(chan struct{}),
helper: helper,
credsDetails: cfgInternal.GithubCredentialsDetails,
wg: wg,
keyMux: keyMuxes,
}
return repo, nil
}
@ -61,6 +65,14 @@ type enterprise struct {
mux sync.Mutex
}
func (r *enterprise) GithubCLI() common.GithubClient {
return r.ghcli
}
func (e *enterprise) PoolType() params.PoolType {
return params.EnterprisePool
}
func (r *enterprise) GetRunnerInfoFromWorkflow(job params.WorkflowJob) (params.RunnerInfo, error) {
if err := r.ValidateOwner(job); err != nil {
return params.RunnerInfo{}, errors.Wrap(err, "validating owner")
@ -87,6 +99,9 @@ func (r *enterprise) UpdateState(param params.UpdatePoolStateParams) error {
defer r.mux.Unlock()
r.cfg.WebhookSecret = param.WebhookSecret
if param.InternalConfig != nil {
r.cfgInternal = *param.InternalConfig
}
ghc, ghcEnterprise, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails)
if err != nil {

View file

@ -16,8 +16,9 @@ package pool
import (
"github.com/cloudbase/garm/params"
"github.com/cloudbase/garm/runner/common"
"github.com/google/go-github/v48/github"
"github.com/google/go-github/v53/github"
)
type poolHelper interface {
@ -28,6 +29,8 @@ type poolHelper interface {
RemoveGithubRunner(runnerID int64) (*github.Response, error)
FetchTools() ([]*github.RunnerApplicationDownload, error)
GithubCLI() common.GithubClient
FetchDbInstances() ([]params.Instance, error)
ListPools() ([]params.Pool, error)
GithubURL() string
@ -41,4 +44,5 @@ type poolHelper interface {
UpdateState(param params.UpdatePoolStateParams) error
WebhookSecret() string
ID() string
PoolType() params.PoolType
}

View file

@ -27,7 +27,7 @@ import (
"github.com/cloudbase/garm/runner/common"
"github.com/cloudbase/garm/util"
"github.com/google/go-github/v48/github"
"github.com/google/go-github/v53/github"
"github.com/pkg/errors"
)
@ -40,6 +40,9 @@ func NewOrganizationPoolManager(ctx context.Context, cfg params.Organization, cf
return nil, errors.Wrap(err, "getting github client")
}
wg := &sync.WaitGroup{}
keyMuxes := &keyMutex{}
helper := &organization{
cfg: cfg,
cfgInternal: cfgInternal,
@ -55,9 +58,10 @@ func NewOrganizationPoolManager(ctx context.Context, cfg params.Organization, cf
providers: providers,
controllerID: cfgInternal.ControllerID,
quit: make(chan struct{}),
done: make(chan struct{}),
helper: helper,
credsDetails: cfgInternal.GithubCredentialsDetails,
wg: wg,
keyMux: keyMuxes,
}
return repo, nil
}
@ -73,6 +77,14 @@ type organization struct {
mux sync.Mutex
}
func (r *organization) GithubCLI() common.GithubClient {
return r.ghcli
}
func (o *organization) PoolType() params.PoolType {
return params.OrganizationPool
}
func (r *organization) GetRunnerInfoFromWorkflow(job params.WorkflowJob) (params.RunnerInfo, error) {
if err := r.ValidateOwner(job); err != nil {
return params.RunnerInfo{}, errors.Wrap(err, "validating owner")
@ -99,6 +111,9 @@ func (r *organization) UpdateState(param params.UpdatePoolStateParams) error {
defer r.mux.Unlock()
r.cfg.WebhookSecret = param.WebhookSecret
if param.InternalConfig != nil {
r.cfgInternal = *param.InternalConfig
}
ghc, _, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails)
if err != nil {

File diff suppressed because it is too large Load diff

View file

@ -27,7 +27,7 @@ import (
"github.com/cloudbase/garm/runner/common"
"github.com/cloudbase/garm/util"
"github.com/google/go-github/v48/github"
"github.com/google/go-github/v53/github"
"github.com/pkg/errors"
)
@ -40,6 +40,9 @@ func NewRepositoryPoolManager(ctx context.Context, cfg params.Repository, cfgInt
return nil, errors.Wrap(err, "getting github client")
}
wg := &sync.WaitGroup{}
keyMuxes := &keyMutex{}
helper := &repository{
cfg: cfg,
cfgInternal: cfgInternal,
@ -55,9 +58,10 @@ func NewRepositoryPoolManager(ctx context.Context, cfg params.Repository, cfgInt
providers: providers,
controllerID: cfgInternal.ControllerID,
quit: make(chan struct{}),
done: make(chan struct{}),
helper: helper,
credsDetails: cfgInternal.GithubCredentialsDetails,
wg: wg,
keyMux: keyMuxes,
}
return repo, nil
}
@ -75,6 +79,14 @@ type repository struct {
mux sync.Mutex
}
func (r *repository) GithubCLI() common.GithubClient {
return r.ghcli
}
func (r *repository) PoolType() params.PoolType {
return params.RepositoryPool
}
func (r *repository) GetRunnerInfoFromWorkflow(job params.WorkflowJob) (params.RunnerInfo, error) {
if err := r.ValidateOwner(job); err != nil {
return params.RunnerInfo{}, errors.Wrap(err, "validating owner")
@ -101,6 +113,9 @@ func (r *repository) UpdateState(param params.UpdatePoolStateParams) error {
defer r.mux.Unlock()
r.cfg.WebhookSecret = param.WebhookSecret
if param.InternalConfig != nil {
r.cfgInternal = *param.InternalConfig
}
ghc, _, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails)
if err != nil {

67
runner/pool/util.go Normal file
View file

@ -0,0 +1,67 @@
package pool
import (
"log"
"sort"
"strings"
"sync"
"sync/atomic"
runnerErrors "github.com/cloudbase/garm/errors"
"github.com/cloudbase/garm/params"
)
type poolRoundRobin struct {
pools []params.Pool
next uint32
}
func (p *poolRoundRobin) Next() (params.Pool, error) {
if len(p.pools) == 0 {
return params.Pool{}, runnerErrors.ErrNoPoolsAvailable
}
n := atomic.AddUint32(&p.next, 1)
return p.pools[(int(n)-1)%len(p.pools)], nil
}
func (p *poolRoundRobin) Len() int {
return len(p.pools)
}
func (p *poolRoundRobin) Reset() {
atomic.StoreUint32(&p.next, 0)
}
type poolsForTags struct {
pools sync.Map
}
func (p *poolsForTags) Get(tags []string) (*poolRoundRobin, bool) {
sort.Strings(tags)
key := strings.Join(tags, "^")
v, ok := p.pools.Load(key)
if !ok {
return nil, false
}
return v.(*poolRoundRobin), true
}
func (p *poolsForTags) Add(tags []string, pools []params.Pool) *poolRoundRobin {
sort.Strings(tags)
key := strings.Join(tags, "^")
poolRR := &poolRoundRobin{pools: pools}
v, _ := p.pools.LoadOrStore(key, poolRR)
return v.(*poolRoundRobin)
}
func (r *basePoolManager) log(msg string, args ...interface{}) {
msgArgs := []interface{}{
r.helper.String(),
}
msgArgs = append(msgArgs, args...)
log.Printf("[Pool mgr %s] "+msg, msgArgs...)
}

View file

@ -117,7 +117,7 @@ func (r *Runner) UpdatePoolByID(ctx context.Context, poolID string, param params
} else if pool.EnterpriseID != "" {
newPool, err = r.store.UpdateEnterprisePool(ctx, pool.EnterpriseID, poolID, param)
} else {
return params.Pool{}, fmt.Errorf("pool not bound to a repo, org or enterprise")
return params.Pool{}, fmt.Errorf("pool not found to a repo, org or enterprise")
}
if err != nil {
@ -125,3 +125,15 @@ func (r *Runner) UpdatePoolByID(ctx context.Context, poolID string, param params
}
return newPool, nil
}
func (r *Runner) ListAllJobs(ctx context.Context) ([]params.Job, error) {
if !auth.IsAdmin(ctx) {
return []params.Job{}, runnerErrors.ErrUnauthorized
}
jobs, err := r.store.ListAllJobs(ctx)
if err != nil {
return nil, errors.Wrap(err, "fetching jobs")
}
return jobs, nil
}

View file

@ -181,6 +181,16 @@ func (s *PoolTestSuite) TestDeletePoolByIDRunnersFailed() {
s.Require().Equal(runnerErrors.NewBadRequestError("pool has runners"), err)
}
func (s *PoolTestSuite) TestUpdatePoolByID() {
pool, err := s.Runner.UpdatePoolByID(s.Fixtures.AdminContext, s.Fixtures.Pools[0].ID, s.Fixtures.UpdatePoolParams)
s.Require().Nil(err)
s.Require().Equal(*s.Fixtures.UpdatePoolParams.MaxRunners, pool.MaxRunners)
s.Require().Equal(*s.Fixtures.UpdatePoolParams.MinIdleRunners, pool.MinIdleRunners)
s.Require().Equal(s.Fixtures.UpdatePoolParams.Image, pool.Image)
s.Require().Equal(s.Fixtures.UpdatePoolParams.Flavor, pool.Flavor)
}
func (s *PoolTestSuite) TestUpdatePoolByIDErrUnauthorized() {
_, err := s.Runner.UpdatePoolByID(context.Background(), "dummy-pool-id", s.Fixtures.UpdatePoolParams)

View file

@ -27,7 +27,7 @@ import (
"github.com/cloudbase/garm/runner/common"
"github.com/cloudbase/garm/util"
"github.com/google/go-github/v48/github"
"github.com/google/go-github/v53/github"
lxd "github.com/lxc/lxd/client"
"github.com/lxc/lxd/shared/api"
"github.com/pkg/errors"

Some files were not shown because too many files have changed in this diff Show more