From 808c5e6ba4ca8574e3ba1621aa0bf2b67aaa23a5 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Mon, 5 Sep 2022 14:48:58 +0200 Subject: [PATCH 01/15] feat(api): add worker model and worker model template entities --- cli/cdsctl/experimental.go | 1 + .../experimental_worker-model-template.go | 69 +++++ cli/cdsctl/experimental_worker-model.go | 76 ++++++ engine/api/api_routes.go | 3 +- engine/api/entity/dao.go | 101 ++++++++ engine/api/entity/gorp_model.go | 23 ++ engine/api/v2_repository_analyze.go | 237 +++++++++++++----- engine/api/v2_repository_analyze_test.go | 10 +- engine/api/v2_worker_model.go | 62 +++++ engine/api/v2_worker_model_template.go | 62 +++++ engine/api/v2_worker_model_template_test.go | 123 +++++++++ engine/api/v2_worker_model_test.go | 126 ++++++++++ engine/sql/api/251_entity.sql | 19 ++ sdk/cdsclient/client_worker_model.go | 25 ++ sdk/cdsclient/client_worker_model_template.go | 35 +++ sdk/cdsclient/interface.go | 3 + .../mock_cdsclient/interface_mock.go | 128 ++++++++-- sdk/entity.go | 49 ++++ sdk/worker_model_template.go | 122 +++++++++ tests/08_v2_analyze.yml | 15 +- .../worker-model-template/tmpl-docker.yml | 6 + .../fixtures/worker-model/docker-debian9.yml | 9 + 22 files changed, 1214 insertions(+), 90 deletions(-) create mode 100644 cli/cdsctl/experimental_worker-model-template.go create mode 100644 cli/cdsctl/experimental_worker-model.go create mode 100644 engine/api/entity/dao.go create mode 100644 engine/api/entity/gorp_model.go create mode 100644 engine/api/v2_worker_model.go create mode 100644 engine/api/v2_worker_model_template.go create mode 100644 engine/api/v2_worker_model_template_test.go create mode 100644 engine/api/v2_worker_model_test.go create mode 100644 engine/sql/api/251_entity.sql create mode 100644 sdk/cdsclient/client_worker_model_template.go create mode 100644 sdk/entity.go create mode 100644 sdk/worker_model_template.go create mode 100644 tests/fixtures/worker-model-template/tmpl-docker.yml create mode 100644 tests/fixtures/worker-model/docker-debian9.yml diff --git a/cli/cdsctl/experimental.go b/cli/cdsctl/experimental.go index fea6a58009..072fdd37b0 100644 --- a/cli/cdsctl/experimental.go +++ b/cli/cdsctl/experimental.go @@ -17,6 +17,7 @@ func experimentalCommands() []*cobra.Command { return []*cobra.Command{ experimentalRbac(), experimentalProject(), + experimentalWorkerModel(), } } diff --git a/cli/cdsctl/experimental_worker-model-template.go b/cli/cdsctl/experimental_worker-model-template.go new file mode 100644 index 0000000000..fbb6b33cec --- /dev/null +++ b/cli/cdsctl/experimental_worker-model-template.go @@ -0,0 +1,69 @@ +package main + +import ( + "context" + "github.com/ovh/cds/sdk/cdsclient" + "github.com/spf13/cobra" + + "github.com/ovh/cds/cli" +) + +var experimentalWorkerModelTemplateCmd = cli.Command{ + Name: "template", + Aliases: []string{}, + Short: "CDS Experimental worker-model template commands", +} + +func experimentalWorkerModelTemplate() *cobra.Command { + return cli.NewCommand(experimentalWorkerModelTemplateCmd, nil, []*cobra.Command{ + cli.NewListCommand(wmTemplateListCmd, wmTemplateListFunc, nil, withAllCommandModifiers()...), + }) +} + +var wmTemplateListCmd = cli.Command{ + Name: "list", + Example: "cdsctl worker-model-template list", + Ctx: []cli.Arg{ + {Name: _ProjectKey}, + }, + Args: []cli.Arg{ + {Name: "vcs-name"}, + {Name: "repository"}, + }, + Flags: []cli.Flag{ + {Name: "branch", Usage: "Filter on a specific branch"}, + }, +} + +func wmTemplateListFunc(v cli.Values) (cli.ListResult, error) { + vcsName := v.GetString("vcs-name") + repositoryName := v.GetString("repository") + + branch := v.GetString("branch") + var filter *cdsclient.WorkerModelTemplateFilter + if branch != "" { + filter = &cdsclient.WorkerModelTemplateFilter{ + Branch: branch, + } + } + + tmpls, err := client.WorkerModelTemplateList(context.Background(), v.GetString(_ProjectKey), vcsName, repositoryName, filter) + if err != nil { + return nil, err + } + + type Result struct { + Name string `cli:"name"` + Type string `cli:"type"` + } + results := make([]Result, 0, len(tmpls)) + for _, t := range tmpls { + tmplType := "docker" + if t.VM != nil { + tmplType = "vm" + } + results = append(results, Result{Name: t.Name, Type: tmplType}) + } + + return cli.AsListResult(results), err +} diff --git a/cli/cdsctl/experimental_worker-model.go b/cli/cdsctl/experimental_worker-model.go new file mode 100644 index 0000000000..eb1fff9c85 --- /dev/null +++ b/cli/cdsctl/experimental_worker-model.go @@ -0,0 +1,76 @@ +package main + +import ( + "context" + "github.com/ovh/cds/sdk/cdsclient" + "github.com/spf13/cobra" + + "github.com/ovh/cds/cli" +) + +var experimentalWorkerModelCmd = cli.Command{ + Name: "worker-model", + Aliases: []string{"wm"}, + Short: "CDS Experimental worker model commands", +} + +func experimentalWorkerModel() *cobra.Command { + return cli.NewCommand(experimentalWorkerModelCmd, nil, []*cobra.Command{ + cli.NewListCommand(wmListCmd, workerModelListFunc, nil, withAllCommandModifiers()...), + experimentalWorkerModelTemplate(), + }) +} + +var wmListCmd = cli.Command{ + Name: "list", + Example: "cdsctl worker-model list", + Ctx: []cli.Arg{ + {Name: _ProjectKey}, + }, + Args: []cli.Arg{ + {Name: "vcs-name"}, + {Name: "repository"}, + }, + Flags: []cli.Flag{ + {Name: "branch", Usage: "Filter on a specific branch"}, + }, +} + +func workerModelListFunc(v cli.Values) (cli.ListResult, error) { + vcsName := v.GetString("vcs-name") + repositoryName := v.GetString("repository") + + branch := v.GetString("branch") + var filter *cdsclient.WorkerModelV2Filter + if branch != "" { + filter = &cdsclient.WorkerModelV2Filter{ + Branch: branch, + } + } + + wms, err := client.WorkerModelv2List(context.Background(), v.GetString(_ProjectKey), vcsName, repositoryName, filter) + if err != nil { + return nil, err + } + + type Result struct { + Name string `cli:"name"` + Type string `cli:"type"` + } + results := make([]Result, 0, len(wms)) + for _, t := range wms { + var modelType string + switch { + case t.Docker != nil: + modelType = "docker" + case t.VSphere != nil: + modelType = "vsphere" + case t.Openstack != nil: + modelType = "openstack" + default: + modelType = "unknown" + } + results = append(results, Result{Name: t.Name, Type: modelType}) + } + return cli.AsListResult(results), err +} diff --git a/engine/api/api_routes.go b/engine/api/api_routes.go index a4e1ae39ba..d5172acff8 100644 --- a/engine/api/api_routes.go +++ b/engine/api/api_routes.go @@ -446,7 +446,8 @@ func (api *API) InitRouter() { r.Handle("/v2/project/{projectKey}/vcs/{vcsIdentifier}/repository/{repositoryIdentifier}/analysis", nil, r.GETv2(api.getProjectRepositoryAnalysesHandler)) r.Handle("/v2/project/{projectKey}/vcs/{vcsIdentifier}/repository/{repositoryIdentifier}/analysis/{analysisID}", nil, r.GETv2(api.getProjectRepositoryAnalysisHandler)) r.Handle("/v2/project/{projectKey}/vcs/{vcsIdentifier}/repository/{repositoryIdentifier}/hook/regen", nil, r.POSTv2(api.postRepositoryHookRegenKeyHandler)) - + r.Handle("/v2/project/{projectKey}/vcs/{vcsIdentifier}/repository/{repositoryIdentifier}/workermodel", nil, r.GETv2(api.getWorkerModelsV2Handler)) + r.Handle("/v2/project/{projectKey}/vcs/{vcsIdentifier}/repository/{repositoryIdentifier}/workermodel/template", nil, r.GETv2(api.getWorkerModelTemplatesHandler)) r.Handle("/v2/user/gpgkey/{gpgKeyID}", Scope(sdk.AuthConsumerScopeUser), r.GETv2(api.getUserGPGKeyHandler)) r.Handle("/v2/user/{user}/gpgkey", Scope(sdk.AuthConsumerScopeUser), r.GETv2(api.getUserGPGKeysHandler), r.POSTv2(api.postUserGPGGKeyHandler)) r.Handle("/v2/user/{user}/gpgkey/{gpgKeyID}", Scope(sdk.AuthConsumerScopeUser), r.DELETEv2(api.deleteUserGPGKey)) diff --git a/engine/api/entity/dao.go b/engine/api/entity/dao.go new file mode 100644 index 0000000000..aa2757d38a --- /dev/null +++ b/engine/api/entity/dao.go @@ -0,0 +1,101 @@ +package entity + +import ( + "context" + "time" + + "github.com/go-gorp/gorp" + "github.com/rockbears/log" + + "github.com/ovh/cds/engine/api/database/gorpmapping" + "github.com/ovh/cds/engine/gorpmapper" + "github.com/ovh/cds/sdk" +) + +func getEntity(ctx context.Context, db gorp.SqlExecutor, query gorpmapping.Query, opts ...gorpmapping.GetOptionFunc) (*sdk.Entity, error) { + var res dbEntity + found, err := gorpmapping.Get(ctx, db, query, &res, opts...) + if err != nil { + return nil, err + } + if !found { + return nil, sdk.WithStack(sdk.ErrNotFound) + } + + isValid, err := gorpmapping.CheckSignature(res, res.Signature) + if err != nil { + return nil, err + } + if !isValid { + log.Error(ctx, "entity %d / %s data corrupted", res.ID, res.Name) + return nil, sdk.WithStack(sdk.ErrNotFound) + } + return &res.Entity, nil +} + +func getEntities(ctx context.Context, db gorp.SqlExecutor, query gorpmapping.Query, opts ...gorpmapping.GetOptionFunc) ([]sdk.Entity, error) { + var res []dbEntity + if err := gorpmapping.GetAll(ctx, db, query, &res, opts...); err != nil { + return nil, err + } + entities := make([]sdk.Entity, 0, len(res)) + for _, r := range res { + isValid, err := gorpmapping.CheckSignature(r, r.Signature) + if err != nil { + return nil, err + } + if !isValid { + log.Error(ctx, "entity %d / %s data corrupted", r.ID, r.Name) + continue + } + entities = append(entities, r.Entity) + } + return entities, nil +} + +func Insert(ctx context.Context, db gorpmapper.SqlExecutorWithTx, e *sdk.Entity) error { + if e.ID == "" { + e.ID = sdk.UUID() + } + e.LastUpdate = time.Now() + dbData := &dbEntity{Entity: *e} + if err := gorpmapping.InsertAndSign(ctx, db, dbData); err != nil { + return err + } + *e = dbData.Entity + return nil +} + +func Update(ctx context.Context, db gorpmapper.SqlExecutorWithTx, e *sdk.Entity) error { + e.LastUpdate = time.Now() + dbData := &dbEntity{Entity: *e} + if err := gorpmapping.UpdateAndSign(ctx, db, dbData); err != nil { + return err + } + *e = dbData.Entity + return nil +} + +// LoadByType loads an entity by his repository, type +func LoadByType(ctx context.Context, db gorp.SqlExecutor, projectRepositoryID string, t string, opts ...gorpmapping.GetOptionFunc) ([]sdk.Entity, error) { + query := gorpmapping.NewQuery(` + SELECT * from entity + WHERE project_repository_id = $1 AND type = $2`).Args(projectRepositoryID, t) + return getEntities(ctx, db, query, opts...) +} + +// LoadByTypeAndBranch loads an entity by his repository, type and branch +func LoadByTypeAndBranch(ctx context.Context, db gorp.SqlExecutor, projectRepositoryID string, t string, branch string, opts ...gorpmapping.GetOptionFunc) ([]sdk.Entity, error) { + query := gorpmapping.NewQuery(` + SELECT * from entity + WHERE project_repository_id = $1 AND type = $2 AND branch = $3`).Args(projectRepositoryID, t, branch) + return getEntities(ctx, db, query, opts...) +} + +// LoadByBranchTypeName loads an entity by his repository, branch, type and name +func LoadByBranchTypeName(ctx context.Context, db gorp.SqlExecutor, projectRepositoryID string, branch string, t string, name string, opts ...gorpmapping.GetOptionFunc) (*sdk.Entity, error) { + query := gorpmapping.NewQuery(` + SELECT * from entity + WHERE project_repository_id $1 AND branch = $2 AND type = $3 AND name = $4`).Args(projectRepositoryID, branch, t, name) + return getEntity(ctx, db, query, opts...) +} diff --git a/engine/api/entity/gorp_model.go b/engine/api/entity/gorp_model.go new file mode 100644 index 0000000000..8692dc4d10 --- /dev/null +++ b/engine/api/entity/gorp_model.go @@ -0,0 +1,23 @@ +package entity + +import ( + "github.com/ovh/cds/engine/api/database/gorpmapping" + "github.com/ovh/cds/engine/gorpmapper" + "github.com/ovh/cds/sdk" +) + +func init() { + gorpmapping.Register(gorpmapping.New(dbEntity{}, "entity", false, "id")) +} + +type dbEntity struct { + sdk.Entity + gorpmapper.SignedEntity +} + +func (v dbEntity) Canonical() gorpmapper.CanonicalForms { + _ = []interface{}{v.ID, v.Name, v.ProjectKey, v.ProjectRepositoryID, v.Type, v.Branch, v.Commit} + return []gorpmapper.CanonicalForm{ + "{{.ID}}{{.Name}}{{.ProjectKey}}{{.ProjectRepositoryID}}{{.Type}}{{.Branch}}{{.Commit}}", + } +} diff --git a/engine/api/v2_repository_analyze.go b/engine/api/v2_repository_analyze.go index f873839033..0d429eec42 100644 --- a/engine/api/v2_repository_analyze.go +++ b/engine/api/v2_repository_analyze.go @@ -2,8 +2,10 @@ package api import ( "archive/tar" + "bytes" "compress/gzip" "context" + "encoding/base64" "fmt" "io" "net/http" @@ -17,6 +19,7 @@ import ( "go.opencensus.io/trace" "github.com/ovh/cds/engine/api/database/gorpmapping" + "github.com/ovh/cds/engine/api/entity" "github.com/ovh/cds/engine/api/operation" "github.com/ovh/cds/engine/api/project" "github.com/ovh/cds/engine/api/rbac" @@ -270,31 +273,34 @@ func (api *API) analyzeRepository(ctx context.Context, projectRepoID string, ana return api.stopAnalysis(ctx, analysis, err) } + var keyID, analysisError string switch vcsProject.Type { case sdk.VCSTypeBitbucketServer, sdk.VCSTypeBitbucketCloud, sdk.VCSTypeGitlab, sdk.VCSTypeGerrit: - if err := api.analyzeCommitSignatureThroughOperation(ctx, analysis, *vcsProject, *repoWithSecret); err != nil { + keyID, analysisError, err = api.analyzeCommitSignatureThroughOperation(ctx, analysis, *vcsProject, *repoWithSecret) + if err != nil { return api.stopAnalysis(ctx, analysis, err) } case sdk.VCSTypeGitea, sdk.VCSTypeGithub: - if err := api.analyzeCommitSignatureThroughVcsAPI(ctx, analysis, *vcsProject, *repoWithSecret); err != nil { + keyID, analysisError, err = api.analyzeCommitSignatureThroughVcsAPI(ctx, analysis, *vcsProject, *repoWithSecret) + if err != nil { return api.stopAnalysis(ctx, analysis, err) } default: return api.stopAnalysis(ctx, analysis, sdk.NewErrorFrom(sdk.ErrInvalidData, "unable to analyze vcs type: %s", vcsProject.Type)) } + analysis.Data.SignKeyID = keyID + if analysisError != "" { + analysis.Status = sdk.RepositoryAnalysisStatusSkipped + analysis.Data.Error = analysisError + } // remove secret from repo repoWithSecret.Auth = sdk.ProjectRepositoryAuth{} - tx, err := api.mustDB().Begin() - if err != nil { - return api.stopAnalysis(ctx, analysis, sdk.WithStack(err)) - } - defer tx.Rollback() //nolint - + var filesContent map[string][]byte if analysis.Status == sdk.RepositoryAnalysisStatusInProgress { var cdsUser *sdk.AuthentifiedUser - gpgKey, err := user.LoadGPGKeyByKeyID(ctx, tx, analysis.Data.SignKeyID) + gpgKey, err := user.LoadGPGKeyByKeyID(ctx, api.mustDB(), analysis.Data.SignKeyID) if err != nil { if !sdk.ErrorIs(err, sdk.ErrNotFound) { return api.stopAnalysis(ctx, analysis, sdk.WrapError(err, "unable to find gpg key: %s", analysis.Data.SignKeyID)) @@ -304,7 +310,7 @@ func (api *API) analyzeRepository(ctx context.Context, projectRepoID string, ana } if gpgKey != nil { - cdsUser, err = user.LoadByID(ctx, tx, gpgKey.AuthentifiedUserID) + cdsUser, err = user.LoadByID(ctx, api.mustDB(), gpgKey.AuthentifiedUserID) if err != nil { if !sdk.ErrorIs(err, sdk.ErrNotFound) { return api.stopAnalysis(ctx, analysis, sdk.WrapError(err, "unable to find user %s", gpgKey.AuthentifiedUserID)) @@ -319,7 +325,7 @@ func (api *API) analyzeRepository(ctx context.Context, projectRepoID string, ana analysis.Data.CDSUserName = cdsUser.Username // Check user right - b, err := rbac.HasRoleOnProjectAndUserID(ctx, tx, sdk.RoleManage, cdsUser.ID, analysis.ProjectKey) + b, err := rbac.HasRoleOnProjectAndUserID(ctx, api.mustDB(), sdk.RoleManage, cdsUser.ID, analysis.ProjectKey) if err != nil { return api.stopAnalysis(ctx, analysis, err) } @@ -329,89 +335,147 @@ func (api *API) analyzeRepository(ctx context.Context, projectRepoID string, ana } if analysis.Status == sdk.RepositoryAnalysisStatusInProgress { - client, err := repositoriesmanager.AuthorizedClient(ctx, tx, api.Cache, analysis.ProjectKey, vcsProject.Name) - if err != nil { - return api.stopAnalysis(ctx, analysis, err) - } - switch vcsProject.Type { case sdk.VCSTypeBitbucketServer, sdk.VCSTypeBitbucketCloud: // get archive - err = api.getCdsArchiveFileOnRepo(ctx, client, *repoWithSecret, analysis) + filesContent, err = api.getCdsArchiveFileOnRepo(ctx, *repoWithSecret, analysis, vcsProject.Name) case sdk.VCSTypeGitlab, sdk.VCSTypeGithub, sdk.VCSTypeGitea: analysis.Data.Entities = make([]sdk.ProjectRepositoryDataEntity, 0) - err = api.getCdsFilesOnVCSDirectory(ctx, client, analysis, repoWithSecret.Name, analysis.Commit, ".cds") + filesContent, err = api.getCdsFilesOnVCSDirectory(ctx, analysis, vcsProject.Name, repoWithSecret.Name, analysis.Commit, ".cds") case sdk.VCSTypeGerrit: return sdk.WithStack(sdk.ErrNotImplemented) } + if err != nil { return api.stopAnalysis(ctx, analysis, err) - } else { - analysis.Status = sdk.RepositoryAnalysisStatusSucceed } } } } + tx, err := api.mustDB().Begin() + if err != nil { + return api.stopAnalysis(ctx, analysis, err) + } + defer tx.Rollback() // nolint + + if len(filesContent) == 0 && analysis.Status == sdk.RepositoryAnalysisStatusInProgress { + analysis.Status = sdk.RepositoryAnalysisStatusSkipped + analysis.Data.Error = "no cds files found" + } + + if analysis.Status != sdk.RepositoryAnalysisStatusInProgress { + if err := repository.UpdateAnalysis(ctx, tx, analysis); err != nil { + return sdk.WrapError(err, "unable to update analysis") + } + return sdk.WithStack(tx.Commit()) + } + + entities, err := api.handleEntitiesFiles(ctx, filesContent, *analysis) + if err != nil { + return api.stopAnalysis(ctx, analysis, err) + } + + for i := range entities { + e := &entities[i] + existingEntity, err := entity.LoadByBranchTypeName(ctx, tx, e.ProjectRepositoryID, e.Branch, e.Type, e.Name) + if err != nil && !sdk.ErrorIs(err, sdk.ErrNotFound) { + return api.stopAnalysis(ctx, analysis, err) + } + if existingEntity == nil { + if err := entity.Insert(ctx, tx, e); err != nil { + return api.stopAnalysis(ctx, analysis, sdk.WrapError(err, "unable to insert entity %s", e.Name)) + } + } else { + e.ID = existingEntity.ID + if err := entity.Update(ctx, tx, e); err != nil { + return api.stopAnalysis(ctx, analysis, sdk.WrapError(err, "unable to save entity %s/%s", e.ID, e.Name)) + } + } + } + analysis.Status = sdk.RepositoryAnalysisStatusSucceed + if err := repository.UpdateAnalysis(ctx, tx, analysis); err != nil { - return sdk.WrapError(err, "unable to failed analyze") + return sdk.WrapError(err, "unable to update analysis") } return sdk.WithStack(tx.Commit()) } -func (api *API) analyzeCommitSignatureThroughVcsAPI(ctx context.Context, analysis *sdk.ProjectRepositoryAnalysis, vcsProject sdk.VCSProject, repoWithSecret sdk.ProjectRepository) error { +func (api *API) handleEntitiesFiles(_ context.Context, filesContent map[string][]byte, analysis sdk.ProjectRepositoryAnalysis) ([]sdk.Entity, error) { + entities := make([]sdk.Entity, 0) + var err error + for filePath, content := range filesContent { + dir, fileName := filepath.Split(filePath) + fileName = strings.TrimSuffix(fileName, ".yml") + switch { + case strings.HasPrefix(filePath, "worker-model-templates"): + var tmpls []sdk.WorkerModelTemplate + entities, err = sdk.ReadEntityFile(dir, fileName, content, &tmpls, sdk.EntityTypeWorkerModelTemplate, analysis) + if err != nil { + return nil, err + } + case strings.HasPrefix(filePath, "worker-models"): + var wms []sdk.V2WorkerModel + entities, err = sdk.ReadEntityFile(dir, fileName, content, &wms, sdk.EntityTypeWorkerModel, analysis) + if err != nil { + return nil, err + } + } + } + return entities, nil +} + +// analyzeCommitSignatureThroughVcsAPI analyzes commit. +func (api *API) analyzeCommitSignatureThroughVcsAPI(ctx context.Context, analysis *sdk.ProjectRepositoryAnalysis, vcsProject sdk.VCSProject, repoWithSecret sdk.ProjectRepository) (string, string, error) { + var keyID, analyzesError string + ctx, next := telemetry.Span(ctx, "api.analyzeCommitSignatureThroughVcsAPI") defer next() tx, err := api.mustDB().Begin() if err != nil { - return sdk.WithStack(err) + return keyID, analyzesError, sdk.WithStack(err) } // Check commit signature client, err := repositoriesmanager.AuthorizedClient(ctx, tx, api.Cache, analysis.ProjectKey, vcsProject.Name) if err != nil { _ = tx.Rollback() // nolint - return err + return keyID, analyzesError, err } vcsCommit, err := client.Commit(ctx, repoWithSecret.Name, analysis.Commit) if err != nil { _ = tx.Rollback() // nolint - return err + return keyID, analyzesError, err } if err := tx.Commit(); err != nil { - return sdk.WithStack(err) + return keyID, analyzesError, sdk.WithStack(err) } if vcsCommit.Hash == "" { - analysis.Status = sdk.RepositoryAnalysisStatusError - analysis.Data.Error = fmt.Sprintf("commit %s not found", analysis.Commit) + return keyID, analyzesError, fmt.Errorf("commit %s not found", analysis.Commit) } else { if vcsCommit.Signature != "" { keyId, err := gpg.GetKeyIdFromSignature(vcsCommit.Signature) if err != nil { - log.ErrorWithStackTrace(ctx, err) - analysis.Status = sdk.RepositoryAnalysisStatusError - analysis.Data.Error = fmt.Sprintf("unable to extract keyID from signature: %v", err) + return keyID, analyzesError, fmt.Errorf("unable to extract keyID from signature: %v", err) } else { - analysis.Data.SignKeyID = keyId - analysis.Data.CommitCheck = true + keyID = keyId } } else { - analysis.Data.CommitCheck = false - analysis.Status = sdk.RepositoryAnalysisStatusSkipped - analysis.Data.Error = fmt.Sprintf("commit %s is not signed", vcsCommit.Hash) + analyzesError = fmt.Sprintf("commit %s is not signed", vcsCommit.Hash) } } - return nil + return keyID, analyzesError, nil } -func (api *API) analyzeCommitSignatureThroughOperation(ctx context.Context, analysis *sdk.ProjectRepositoryAnalysis, vcsProject sdk.VCSProject, repoWithSecret sdk.ProjectRepository) error { +func (api *API) analyzeCommitSignatureThroughOperation(ctx context.Context, analysis *sdk.ProjectRepositoryAnalysis, vcsProject sdk.VCSProject, repoWithSecret sdk.ProjectRepository) (string, string, error) { + var keyId, analyzeError string ctx, next := telemetry.Span(ctx, "api.analyzeCommitSignatureThroughOperation") defer next() if analysis.Data.OperationUUID == "" { proj, err := project.Load(ctx, api.mustDB(), analysis.ProjectKey) if err != nil { - return err + return keyId, analyzeError, err } ope := &sdk.Operation{ @@ -439,49 +503,59 @@ func (api *API) analyzeCommitSignatureThroughOperation(ctx context.Context, anal tx, err := api.mustDB().Begin() if err != nil { - return sdk.WithStack(err) + return keyId, analyzeError, sdk.WithStack(err) } if err := operation.PostRepositoryOperation(ctx, tx, *proj, ope, nil); err != nil { - return err + return keyId, analyzeError, err } analysis.Data.OperationUUID = ope.UUID if err := repository.UpdateAnalysis(ctx, tx, analysis); err != nil { - return err + return keyId, analyzeError, err } if err := tx.Commit(); err != nil { - return sdk.WithStack(err) + return keyId, analyzeError, sdk.WithStack(err) } } ope, err := operation.Poll(ctx, api.mustDB(), analysis.Data.OperationUUID) if err != nil { - return err + return keyId, analyzeError, err } if ope.Status == sdk.OperationStatusDone && ope.Setup.Checkout.Result.CommitVerified { - analysis.Data.CommitCheck = true - analysis.Data.SignKeyID = ope.Setup.Checkout.Result.SignKeyID + keyId = ope.Setup.Checkout.Result.SignKeyID } if ope.Status == sdk.OperationStatusDone && !ope.Setup.Checkout.Result.CommitVerified { analysis.Data.CommitCheck = false - analysis.Data.SignKeyID = ope.Setup.Checkout.Result.SignKeyID - analysis.Data.Error = ope.Setup.Checkout.Result.Msg - analysis.Status = sdk.RepositoryAnalysisStatusSkipped + keyId = ope.Setup.Checkout.Result.SignKeyID + analyzeError = ope.Setup.Checkout.Result.Msg } if ope.Status == sdk.OperationStatusError { - analysis.Data.Error = ope.Error.Message - analysis.Status = sdk.RepositoryAnalysisStatusError + return "", "", sdk.WithStack(fmt.Errorf("%s", ope.Error.Message)) } - return nil + return keyId, analyzeError, nil } -func (api *API) getCdsFilesOnVCSDirectory(ctx context.Context, client sdk.VCSAuthorizedClientService, analysis *sdk.ProjectRepositoryAnalysis, repoName, commit, directory string) error { +func (api *API) getCdsFilesOnVCSDirectory(ctx context.Context, analysis *sdk.ProjectRepositoryAnalysis, vcsName, repoName, commit, directory string) (map[string][]byte, error) { ctx, next := telemetry.Span(ctx, "api.getCdsFilesOnVCSDirectory") defer next() + + tx, err := api.mustDB().Begin() + if err != nil { + return nil, sdk.WithStack(err) + } + defer tx.Rollback() // nolint + + client, err := repositoriesmanager.AuthorizedClient(ctx, tx, api.Cache, analysis.ProjectKey, vcsName) + if err != nil { + return nil, sdk.WithStack(err) + } + + filesContent := make(map[string][]byte) contents, err := client.ListContent(ctx, repoName, commit, directory) if err != nil { - return sdk.WrapError(err, "unable to list content on commit [%s] in directory %s: %v", commit, directory, err) + return nil, sdk.WrapError(err, "unable to list content on commit [%s] in directory %s: %v", commit, directory, err) } for _, c := range contents { if c.IsFile && strings.HasSuffix(c.Name, ".yml") { @@ -489,28 +563,58 @@ func (api *API) getCdsFilesOnVCSDirectory(ctx context.Context, client sdk.VCSAut FileName: c.Name, Path: directory + "/", }) + filePath := directory + "/" + c.Name + vcsContent, err := client.GetContent(ctx, repoName, commit, filePath) + if err != nil { + return nil, err + } + contentBts, err := base64.StdEncoding.DecodeString(vcsContent.Content) + if err != nil { + return nil, sdk.WithStack(err) + } + filesContent[filePath] = contentBts } if c.IsDirectory { - if err := api.getCdsFilesOnVCSDirectory(ctx, client, analysis, repoName, commit, directory+"/"+c.Name); err != nil { - return err + contents, err := api.getCdsFilesOnVCSDirectory(ctx, analysis, vcsName, repoName, commit, directory+"/"+c.Name) + if err != nil { + return nil, err + } + for k, v := range contents { + filesContent[k] = v } } } - return nil + if err := tx.Commit(); err != nil { + return nil, sdk.WithStack(err) + } + return filesContent, nil } -func (api *API) getCdsArchiveFileOnRepo(ctx context.Context, client sdk.VCSAuthorizedClientService, repo sdk.ProjectRepository, analysis *sdk.ProjectRepositoryAnalysis) error { +func (api *API) getCdsArchiveFileOnRepo(ctx context.Context, repo sdk.ProjectRepository, analysis *sdk.ProjectRepositoryAnalysis, vcsName string) (map[string][]byte, error) { ctx, next := telemetry.Span(ctx, "api.getCdsArchiveFileOnRepo") defer next() + + tx, err := api.mustDB().Begin() + if err != nil { + return nil, sdk.WithStack(err) + } + defer tx.Rollback() // nolint + + client, err := repositoriesmanager.AuthorizedClient(ctx, tx, api.Cache, analysis.ProjectKey, vcsName) + if err != nil { + return nil, sdk.WithStack(err) + } + + filesContent := make(map[string][]byte) analysis.Data.Entities = make([]sdk.ProjectRepositoryDataEntity, 0) reader, _, err := client.GetArchive(ctx, repo.Name, ".cds", "tar.gz", analysis.Commit) if err != nil { - return err + return nil, err } gzf, err := gzip.NewReader(reader) if err != nil { - return sdk.WrapError(err, "unable to read gzip file") + return nil, sdk.WrapError(err, "unable to read gzip file") } tarReader := tar.NewReader(gzf) @@ -520,7 +624,7 @@ func (api *API) getCdsArchiveFileOnRepo(ctx context.Context, client sdk.VCSAutho break } if err != nil { - return sdk.NewErrorWithStack(err, sdk.NewErrorFrom(sdk.ErrWrongRequest, "unable to read tar file")) + return nil, sdk.NewErrorWithStack(err, sdk.NewErrorFrom(sdk.ErrWrongRequest, "unable to read tar file")) } dir, fileName := filepath.Split(hdr.Name) @@ -532,8 +636,17 @@ func (api *API) getCdsArchiveFileOnRepo(ctx context.Context, client sdk.VCSAutho analysis.Data.Entities = append(analysis.Data.Entities, entity) } + buff := new(bytes.Buffer) + if _, err := io.Copy(buff, tarReader); err != nil { + return nil, sdk.NewErrorWithStack(err, sdk.NewErrorFrom(sdk.ErrWrongRequest, "unable to read tar file")) + } + filesContent[dir+fileName] = buff.Bytes() + } - return nil + if err := tx.Commit(); err != nil { + return nil, sdk.WithStack(err) + } + return filesContent, nil } func (api *API) stopAnalysis(ctx context.Context, analysis *sdk.ProjectRepositoryAnalysis, originalError error) error { diff --git a/engine/api/v2_repository_analyze_test.go b/engine/api/v2_repository_analyze_test.go index cbf1d2d7eb..26d84a08ca 100644 --- a/engine/api/v2_repository_analyze_test.go +++ b/engine/api/v2_repository_analyze_test.go @@ -65,7 +65,7 @@ func TestCleanAnalysis(t *testing.T) { require.Len(t, analyses, 50) } -func TestAnalyzeBitbucketServerWithoutHash(t *testing.T) { +func TestAnalyzeGithubWithoutHash(t *testing.T) { api, db, _ := newTestAPI(t) ctx := context.TODO() @@ -136,7 +136,7 @@ func TestAnalyzeBitbucketServerWithoutHash(t *testing.T) { require.Equal(t, sdk.RepositoryAnalysisStatusError, analysisUpdated.Status) } -func TestAnalyzeBitbucketServerWrongSignature(t *testing.T) { +func TestAnalyzeGithubWrongSignature(t *testing.T) { api, db, _ := newTestAPI(t) ctx := context.TODO() @@ -208,7 +208,7 @@ func TestAnalyzeBitbucketServerWrongSignature(t *testing.T) { require.Contains(t, analysisUpdated.Data.Error, "unable to extract keyID from signature") } -func TestAnalyzeBitbucketServerGPGKeyNotFound(t *testing.T) { +func TestAnalyzeGithubGPGKeyNotFound(t *testing.T) { api, db, _ := newTestAPI(t) ctx := context.TODO() @@ -288,7 +288,7 @@ func TestAnalyzeBitbucketServerGPGKeyNotFound(t *testing.T) { require.Equal(t, "gpgkey F344BDDCE15F17D7 not found", analysisUpdated.Data.Error) } -func TestAnalyzeBitbucketServerUserNotEnoughPerm(t *testing.T) { +func TestAnalyzeGithubUserNotEnoughPerm(t *testing.T) { api, db, _ := newTestAPI(t) ctx := context.TODO() @@ -426,7 +426,7 @@ GDFkaTe3nUJdYV4= require.Contains(t, analysisUpdated.Data.Error, "doesn't have enough right on project") } -func TestAnalyzeBitbucketServerCommitNotSigned(t *testing.T) { +func TestAnalyzeGithubServerCommitNotSigned(t *testing.T) { api, db, _ := newTestAPI(t) ctx := context.TODO() diff --git a/engine/api/v2_worker_model.go b/engine/api/v2_worker_model.go new file mode 100644 index 0000000000..b6512b1b69 --- /dev/null +++ b/engine/api/v2_worker_model.go @@ -0,0 +1,62 @@ +package api + +import ( + "context" + "net/http" + "net/url" + + "github.com/gorilla/mux" + "github.com/rockbears/yaml" + + "github.com/ovh/cds/engine/api/entity" + "github.com/ovh/cds/engine/api/rbac" + "github.com/ovh/cds/engine/service" + "github.com/ovh/cds/sdk" +) + +func (api *API) getWorkerModelsV2Handler() ([]service.RbacChecker, service.Handler) { + return service.RBAC(rbac.ProjectRead), + func(ctx context.Context, w http.ResponseWriter, req *http.Request) error { + vars := mux.Vars(req) + pKey := vars["projectKey"] + vcsIdentifier, err := url.PathUnescape(vars["vcsIdentifier"]) + if err != nil { + return sdk.NewError(sdk.ErrWrongRequest, err) + } + repositoryIdentifier, err := url.PathUnescape(vars["repositoryIdentifier"]) + if err != nil { + return sdk.WithStack(err) + } + + branch := QueryString(req, "branch") + + vcsProject, err := api.getVCSByIdentifier(ctx, pKey, vcsIdentifier) + if err != nil { + return err + } + + repo, err := api.getRepositoryByIdentifier(ctx, vcsProject.ID, repositoryIdentifier) + if err != nil { + return err + } + + var entities []sdk.Entity + if branch == "" { + entities, err = entity.LoadByType(ctx, api.mustDB(), repo.ID, sdk.EntityTypeWorkerModel) + } else { + entities, err = entity.LoadByTypeAndBranch(ctx, api.mustDB(), repo.ID, sdk.EntityTypeWorkerModel, branch) + } + if err != nil { + return err + } + modelTemplates := make([]sdk.V2WorkerModel, 0, len(entities)) + for _, e := range entities { + var mt sdk.V2WorkerModel + if err := yaml.Unmarshal([]byte(e.Data), &mt); err != nil { + return sdk.WithStack(err) + } + modelTemplates = append(modelTemplates, mt) + } + return service.WriteJSON(w, modelTemplates, http.StatusOK) + } +} diff --git a/engine/api/v2_worker_model_template.go b/engine/api/v2_worker_model_template.go new file mode 100644 index 0000000000..8df40d17bc --- /dev/null +++ b/engine/api/v2_worker_model_template.go @@ -0,0 +1,62 @@ +package api + +import ( + "context" + "net/http" + "net/url" + + "github.com/gorilla/mux" + "github.com/rockbears/yaml" + + "github.com/ovh/cds/engine/api/entity" + "github.com/ovh/cds/engine/api/rbac" + "github.com/ovh/cds/engine/service" + "github.com/ovh/cds/sdk" +) + +func (api *API) getWorkerModelTemplatesHandler() ([]service.RbacChecker, service.Handler) { + return service.RBAC(rbac.ProjectRead), + func(ctx context.Context, w http.ResponseWriter, req *http.Request) error { + vars := mux.Vars(req) + pKey := vars["projectKey"] + vcsIdentifier, err := url.PathUnescape(vars["vcsIdentifier"]) + if err != nil { + return sdk.NewError(sdk.ErrWrongRequest, err) + } + repositoryIdentifier, err := url.PathUnescape(vars["repositoryIdentifier"]) + if err != nil { + return sdk.WithStack(err) + } + + branch := QueryString(req, "branch") + + vcsProject, err := api.getVCSByIdentifier(ctx, pKey, vcsIdentifier) + if err != nil { + return err + } + + repo, err := api.getRepositoryByIdentifier(ctx, vcsProject.ID, repositoryIdentifier) + if err != nil { + return err + } + + var entities []sdk.Entity + if branch == "" { + entities, err = entity.LoadByType(ctx, api.mustDB(), repo.ID, sdk.EntityTypeWorkerModelTemplate) + } else { + entities, err = entity.LoadByTypeAndBranch(ctx, api.mustDB(), repo.ID, sdk.EntityTypeWorkerModelTemplate, branch) + } + if err != nil { + return err + } + modelTemplates := make([]sdk.WorkerModelTemplate, 0, len(entities)) + for _, e := range entities { + var mt sdk.WorkerModelTemplate + if err := yaml.Unmarshal([]byte(e.Data), &mt); err != nil { + return sdk.WithStack(err) + } + modelTemplates = append(modelTemplates, mt) + } + return service.WriteJSON(w, modelTemplates, http.StatusOK) + } +} diff --git a/engine/api/v2_worker_model_template_test.go b/engine/api/v2_worker_model_template_test.go new file mode 100644 index 0000000000..5816858247 --- /dev/null +++ b/engine/api/v2_worker_model_template_test.go @@ -0,0 +1,123 @@ +package api + +import ( + "context" + "encoding/json" + "github.com/ovh/cds/engine/api/entity" + "github.com/ovh/cds/engine/api/repository" + "github.com/ovh/cds/engine/api/vcs" + "net/http/httptest" + "testing" + "time" + + "github.com/ovh/cds/engine/api/test" + "github.com/ovh/cds/engine/api/test/assets" + "github.com/ovh/cds/sdk" + "github.com/stretchr/testify/require" +) + +func TestGetWorkerModelTemplatesHandler(t *testing.T) { + api, db, _ := newTestAPI(t) + + p := assets.InsertTestProject(t, db, api.Cache, sdk.RandomString(10), sdk.RandomString(10)) + u, pass := assets.InsertAdminUser(t, db) + + vcsProject := &sdk.VCSProject{ + Name: "the-name", + Type: "github", + Auth: sdk.VCSAuthProject{Username: "the-username", Token: "the-token"}, + Description: "the-username", + ProjectID: p.ID, + } + + err := vcs.Insert(context.TODO(), db, vcsProject) + require.NoError(t, err) + require.NotEmpty(t, vcsProject.ID) + + repo := sdk.ProjectRepository{ + Name: "myrepo", + Auth: sdk.ProjectRepositoryAuth{ + Username: "myuser", + Token: "mytoken", + }, + Created: time.Now(), + VCSProjectID: vcsProject.ID, + CreatedBy: "me", + CloneURL: "myurl", + } + require.NoError(t, repository.Insert(context.TODO(), db, &repo)) + + e := sdk.Entity{ + Name: "tmpl1", + Commit: "123456", + Branch: "master", + Type: sdk.EntityTypeWorkerModelTemplate, + ProjectRepositoryID: repo.ID, + ProjectKey: p.Key, + Data: `name: docker-unix +docker: + cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker + shell: sh -c + envs: + MYVAR: toto`, + } + require.NoError(t, entity.Insert(context.TODO(), db, &e)) + + e2 := sdk.Entity{ + Name: "tmpl2", + Commit: "123456", + Branch: "openstack", + Type: sdk.EntityTypeWorkerModelTemplate, + ProjectRepositoryID: repo.ID, + ProjectKey: p.Key, + Data: `name: openstack-debian +vm: + pre_cmd: apt-get install docker-ce. + cmd: ./worker + post_cmd: sudo shutdown -h now`, + } + require.NoError(t, entity.Insert(context.TODO(), db, &e2)) + + vars := map[string]string{ + "projectKey": p.Key, + "vcsIdentifier": vcsProject.ID, + "repositoryIdentifier": repo.Name, + } + uri := api.Router.GetRouteV2("GET", api.getWorkerModelTemplatesHandler, vars) + test.NotEmpty(t, uri) + req := assets.NewAuthentifiedRequest(t, u, pass, "GET", uri, nil) + + w := httptest.NewRecorder() + api.Router.Mux.ServeHTTP(w, req) + require.Equal(t, 200, w.Code) + + body := w.Body.Bytes() + var tmpls []sdk.WorkerModelTemplate + require.NoError(t, json.Unmarshal(body, &tmpls)) + + t.Logf("%+v", tmpls) + require.Equal(t, 2, len(tmpls)) + + varsGetOne := map[string]string{ + "projectKey": p.Key, + "vcsIdentifier": vcsProject.ID, + "repositoryIdentifier": repo.Name, + } + uriOne := api.Router.GetRouteV2("GET", api.getWorkerModelTemplatesHandler, varsGetOne) + test.NotEmpty(t, uri) + reqOne := assets.NewAuthentifiedRequest(t, u, pass, "GET", uriOne+"?branch=master", nil) + + wOne := httptest.NewRecorder() + api.Router.Mux.ServeHTTP(wOne, reqOne) + require.Equal(t, 200, wOne.Code) + + bodyOne := wOne.Body.Bytes() + var tmplsOne []sdk.WorkerModelTemplate + require.NoError(t, json.Unmarshal(bodyOne, &tmplsOne)) + + require.Equal(t, 1, len(tmplsOne)) + require.NotNil(t, tmplsOne[0].Docker) + require.Equal(t, "curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker", tmplsOne[0].Docker.Cmd) + require.Equal(t, "sh -c", tmplsOne[0].Docker.Shell) + require.Equal(t, 1, len(tmplsOne[0].Docker.Envs)) +} diff --git a/engine/api/v2_worker_model_test.go b/engine/api/v2_worker_model_test.go new file mode 100644 index 0000000000..a2677404cb --- /dev/null +++ b/engine/api/v2_worker_model_test.go @@ -0,0 +1,126 @@ +package api + +import ( + "context" + "encoding/json" + "github.com/ovh/cds/engine/api/entity" + "github.com/ovh/cds/engine/api/repository" + "github.com/ovh/cds/engine/api/vcs" + "net/http/httptest" + "testing" + "time" + + "github.com/ovh/cds/engine/api/test" + "github.com/ovh/cds/engine/api/test/assets" + "github.com/ovh/cds/sdk" + "github.com/stretchr/testify/require" +) + +func TestGetV2WorkerModelsHandler(t *testing.T) { + api, db, _ := newTestAPI(t) + + p := assets.InsertTestProject(t, db, api.Cache, sdk.RandomString(10), sdk.RandomString(10)) + u, pass := assets.InsertAdminUser(t, db) + + vcsProject := &sdk.VCSProject{ + Name: "the-name", + Type: "github", + Auth: sdk.VCSAuthProject{Username: "the-username", Token: "the-token"}, + Description: "the-username", + ProjectID: p.ID, + } + + err := vcs.Insert(context.TODO(), db, vcsProject) + require.NoError(t, err) + require.NotEmpty(t, vcsProject.ID) + + repo := sdk.ProjectRepository{ + Name: "myrepo", + Auth: sdk.ProjectRepositoryAuth{ + Username: "myuser", + Token: "mytoken", + }, + Created: time.Now(), + VCSProjectID: vcsProject.ID, + CreatedBy: "me", + CloneURL: "myurl", + } + require.NoError(t, repository.Insert(context.TODO(), db, &repo)) + + e := sdk.Entity{ + Name: "tmpl1", + Commit: "123456", + Branch: "master", + Type: sdk.EntityTypeWorkerModel, + ProjectRepositoryID: repo.ID, + ProjectKey: p.Key, + Data: `name: docker-unix +docker: + image: monimage + cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker + shell: sh -c + envs: + MYVAR: toto`, + } + require.NoError(t, entity.Insert(context.TODO(), db, &e)) + + e2 := sdk.Entity{ + Name: "tmpl2", + Commit: "123456", + Branch: "openstack", + Type: sdk.EntityTypeWorkerModel, + ProjectRepositoryID: repo.ID, + ProjectKey: p.Key, + Data: `name: openstack-debian +vm: + image: monimage + flavor: maflavor + pre_cmd: apt-get install docker-ce. + cmd: ./worker + post_cmd: sudo shutdown -h now`, + } + require.NoError(t, entity.Insert(context.TODO(), db, &e2)) + + vars := map[string]string{ + "projectKey": p.Key, + "vcsIdentifier": vcsProject.ID, + "repositoryIdentifier": repo.Name, + } + uri := api.Router.GetRouteV2("GET", api.getWorkerModelsV2Handler, vars) + test.NotEmpty(t, uri) + req := assets.NewAuthentifiedRequest(t, u, pass, "GET", uri, nil) + + w := httptest.NewRecorder() + api.Router.Mux.ServeHTTP(w, req) + require.Equal(t, 200, w.Code) + + body := w.Body.Bytes() + var wms []sdk.V2WorkerModel + require.NoError(t, json.Unmarshal(body, &wms)) + + t.Logf("%+v", wms) + require.Equal(t, 2, len(wms)) + + varsGetOne := map[string]string{ + "projectKey": p.Key, + "vcsIdentifier": vcsProject.ID, + "repositoryIdentifier": repo.Name, + } + uriOne := api.Router.GetRouteV2("GET", api.getWorkerModelsV2Handler, varsGetOne) + test.NotEmpty(t, uri) + reqOne := assets.NewAuthentifiedRequest(t, u, pass, "GET", uriOne+"?branch=master", nil) + + wOne := httptest.NewRecorder() + api.Router.Mux.ServeHTTP(wOne, reqOne) + require.Equal(t, 200, wOne.Code) + + bodyOne := wOne.Body.Bytes() + var wm []sdk.V2WorkerModel + require.NoError(t, json.Unmarshal(bodyOne, &wm)) + + require.Equal(t, 1, len(wm)) + require.NotNil(t, wm[0].Docker) + require.Equal(t, "curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker", wm[0].Docker.Cmd) + require.Equal(t, "sh -c", wm[0].Docker.Shell) + require.Equal(t, 1, len(wm[0].Docker.Envs)) +} diff --git a/engine/sql/api/251_entity.sql b/engine/sql/api/251_entity.sql new file mode 100644 index 0000000000..a412d4a677 --- /dev/null +++ b/engine/sql/api/251_entity.sql @@ -0,0 +1,19 @@ +-- +migrate Up +CREATE TABLE IF NOT EXISTS "entity" ( + "id" uuid PRIMARY KEY, + "project_repository_id" uuid NOT NULL, + "project_key" TEXT NOT NULL, + "type" VARCHAR(255) NOT NULL, + "name" VARCHAR(255) NOT NULL, + "branch" VARCHAR(255) NOT NULL, + "commit" VARCHAR(255) NOT NULL, + "last_update" TIMESTAMP WITH TIME ZONE DEFAULT LOCALTIMESTAMP, + "data" TEXT NOT NULL, + "sig" BYTEA, + "signer" TEXT +); +SELECT create_unique_index('entity', 'idx_unq_repo_branch_type_name', 'project_repository_id,branch,type,name'); +SELECT create_foreign_key_idx_cascade('fk_entity_repository', 'entity', 'project_repository', 'project_repository_id', 'id'); + +-- +migrate Down +DROP TABLE entity; diff --git a/sdk/cdsclient/client_worker_model.go b/sdk/cdsclient/client_worker_model.go index 7bc2207238..5d1e1a6e54 100644 --- a/sdk/cdsclient/client_worker_model.go +++ b/sdk/cdsclient/client_worker_model.go @@ -132,3 +132,28 @@ func (c *client) WorkerModelSecretList(groupName, name string) (sdk.WorkerModelS } return secrets, nil } + +type WorkerModelV2Filter struct { + Branch string +} + +func (c *client) WorkerModelv2List(ctx context.Context, projKey string, vcsIdentifier string, repoIdentifier string, filter *WorkerModelV2Filter) ([]sdk.V2WorkerModel, error) { + var mods []RequestModifier + if filter != nil { + mods = []RequestModifier{ + func(req *http.Request) { + q := req.URL.Query() + if filter.Branch != "" { + q.Add("branch", url.QueryEscape(filter.Branch)) + } + req.URL.RawQuery = q.Encode() + }, + } + } + var models []sdk.V2WorkerModel + uri := fmt.Sprintf("/v2/project/%s/vcs/%s/repository/%s/workermodel", projKey, url.PathEscape(vcsIdentifier), url.PathEscape(repoIdentifier)) + if _, err := c.GetJSON(ctx, uri, &models, mods...); err != nil { + return nil, err + } + return models, nil +} diff --git a/sdk/cdsclient/client_worker_model_template.go b/sdk/cdsclient/client_worker_model_template.go new file mode 100644 index 0000000000..76a7814b5a --- /dev/null +++ b/sdk/cdsclient/client_worker_model_template.go @@ -0,0 +1,35 @@ +package cdsclient + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/ovh/cds/sdk" +) + +type WorkerModelTemplateFilter struct { + Branch string +} + +func (c *client) WorkerModelTemplateList(ctx context.Context, projKey string, vcsIdentifier string, repoIdentifier string, filter *WorkerModelTemplateFilter) ([]sdk.WorkerModelTemplate, error) { + var mods []RequestModifier + if filter != nil { + mods = []RequestModifier{ + func(req *http.Request) { + q := req.URL.Query() + if filter.Branch != "" { + q.Add("branch", url.QueryEscape(filter.Branch)) + } + req.URL.RawQuery = q.Encode() + }, + } + } + var modelTmpls []sdk.WorkerModelTemplate + uri := fmt.Sprintf("/v2/project/%s/vcs/%s/repository/%s/workermodel/template", projKey, url.PathEscape(vcsIdentifier), url.PathEscape(repoIdentifier)) + if _, err := c.GetJSON(ctx, uri, &modelTmpls, mods...); err != nil { + return nil, err + } + return modelTmpls, nil +} diff --git a/sdk/cdsclient/interface.go b/sdk/cdsclient/interface.go index 3291ee86b7..3821c31113 100644 --- a/sdk/cdsclient/interface.go +++ b/sdk/cdsclient/interface.go @@ -310,6 +310,9 @@ type WorkerClient interface { WorkerModelSecretList(groupName, name string) (sdk.WorkerModelSecrets, error) WorkerRegister(ctx context.Context, authToken string, form sdk.WorkerRegistrationForm) (*sdk.Worker, bool, error) WorkerSetStatus(ctx context.Context, status string) error + + WorkerModelv2List(ctx context.Context, projKey string, vcsIdentifier string, repoIdentifier string, filter *WorkerModelV2Filter) ([]sdk.V2WorkerModel, error) + WorkerModelTemplateList(ctx context.Context, projKey string, vcsIdentifier string, repoIdentifier string, filter *WorkerModelTemplateFilter) ([]sdk.WorkerModelTemplate, error) CDNClient } diff --git a/sdk/cdsclient/mock_cdsclient/interface_mock.go b/sdk/cdsclient/mock_cdsclient/interface_mock.go index ae4b5fd716..f1c04f0267 100644 --- a/sdk/cdsclient/mock_cdsclient/interface_mock.go +++ b/sdk/cdsclient/mock_cdsclient/interface_mock.go @@ -2894,31 +2894,31 @@ func (mr *MockProjectClientMockRecorder) VariableListEncrypt(projectKey interfac return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VariableListEncrypt", reflect.TypeOf((*MockProjectClient)(nil).VariableListEncrypt), projectKey) } -// MockRbacClient is a mock of RBACClient interface. -type MockRbacClient struct { +// MockRBACClient is a mock of RBACClient interface. +type MockRBACClient struct { ctrl *gomock.Controller - recorder *MockRbacClientMockRecorder + recorder *MockRBACClientMockRecorder } -// MockRbacClientMockRecorder is the mock recorder for MockRbacClient. -type MockRbacClientMockRecorder struct { - mock *MockRbacClient +// MockRBACClientMockRecorder is the mock recorder for MockRBACClient. +type MockRBACClientMockRecorder struct { + mock *MockRBACClient } -// NewMockRbacClient creates a new mock instance. -func NewMockRbacClient(ctrl *gomock.Controller) *MockRbacClient { - mock := &MockRbacClient{ctrl: ctrl} - mock.recorder = &MockRbacClientMockRecorder{mock} +// NewMockRBACClient creates a new mock instance. +func NewMockRBACClient(ctrl *gomock.Controller) *MockRBACClient { + mock := &MockRBACClient{ctrl: ctrl} + mock.recorder = &MockRBACClientMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockRbacClient) EXPECT() *MockRbacClientMockRecorder { +func (m *MockRBACClient) EXPECT() *MockRBACClientMockRecorder { return m.recorder } -// RbacImport mocks base method. -func (m *MockRbacClient) RBACImport(ctx context.Context, content io.Reader, mods ...cdsclient.RequestModifier) (sdk.RBAC, error) { +// RBACImport mocks base method. +func (m *MockRBACClient) RBACImport(ctx context.Context, content io.Reader, mods ...cdsclient.RequestModifier) (sdk.RBAC, error) { m.ctrl.T.Helper() varargs := []interface{}{ctx, content} for _, a := range mods { @@ -2930,11 +2930,11 @@ func (m *MockRbacClient) RBACImport(ctx context.Context, content io.Reader, mods return ret0, ret1 } -// RbacImport indicates an expected call of RbacImport. -func (mr *MockRbacClientMockRecorder) RbacImport(ctx, content interface{}, mods ...interface{}) *gomock.Call { +// RBACImport indicates an expected call of RBACImport. +func (mr *MockRBACClientMockRecorder) RBACImport(ctx, content interface{}, mods ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, content}, mods...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RBACImport", reflect.TypeOf((*MockRbacClient)(nil).RBACImport), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RBACImport", reflect.TypeOf((*MockRBACClient)(nil).RBACImport), varargs...) } // MockProjectKeysClient is a mock of ProjectKeysClient interface. @@ -3880,6 +3880,36 @@ func (mr *MockWorkerClientMockRecorder) WorkerModelSpawnError(groupName, name, i return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerModelSpawnError", reflect.TypeOf((*MockWorkerClient)(nil).WorkerModelSpawnError), groupName, name, info) } +// WorkerModelTemplateList mocks base method. +func (m *MockWorkerClient) WorkerModelTemplateList(ctx context.Context, projKey, vcsIdentifier, repoIdentifier string, filter *cdsclient.WorkerModelTemplateFilter) ([]sdk.WorkerModelTemplate, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WorkerModelTemplateList", ctx, projKey, vcsIdentifier, repoIdentifier, filter) + ret0, _ := ret[0].([]sdk.WorkerModelTemplate) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WorkerModelTemplateList indicates an expected call of WorkerModelTemplateList. +func (mr *MockWorkerClientMockRecorder) WorkerModelTemplateList(ctx, projKey, vcsIdentifier, repoIdentifier, filter interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerModelTemplateList", reflect.TypeOf((*MockWorkerClient)(nil).WorkerModelTemplateList), ctx, projKey, vcsIdentifier, repoIdentifier, filter) +} + +// WorkerModelv2List mocks base method. +func (m *MockWorkerClient) WorkerModelv2List(ctx context.Context, projKey, vcsIdentifier, repoIdentifier string, filter *cdsclient.WorkerModelV2Filter) ([]sdk.V2WorkerModel, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WorkerModelv2List", ctx, projKey, vcsIdentifier, repoIdentifier, filter) + ret0, _ := ret[0].([]sdk.V2WorkerModel) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WorkerModelv2List indicates an expected call of WorkerModelv2List. +func (mr *MockWorkerClientMockRecorder) WorkerModelv2List(ctx, projKey, vcsIdentifier, repoIdentifier, filter interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerModelv2List", reflect.TypeOf((*MockWorkerClient)(nil).WorkerModelv2List), ctx, projKey, vcsIdentifier, repoIdentifier, filter) +} + // WorkerRefresh mocks base method. func (m *MockWorkerClient) WorkerRefresh(ctx context.Context) error { m.ctrl.T.Helper() @@ -7551,7 +7581,7 @@ func (mr *MockInterfaceMockRecorder) QueueWorkflowRunResultsRelease(ctx, permJob return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueueWorkflowRunResultsRelease", reflect.TypeOf((*MockInterface)(nil).QueueWorkflowRunResultsRelease), ctx, permJobID, runResultIDs, from, to) } -// RbacImport mocks base method. +// RBACImport mocks base method. func (m *MockInterface) RBACImport(ctx context.Context, content io.Reader, mods ...cdsclient.RequestModifier) (sdk.RBAC, error) { m.ctrl.T.Helper() varargs := []interface{}{ctx, content} @@ -7564,8 +7594,8 @@ func (m *MockInterface) RBACImport(ctx context.Context, content io.Reader, mods return ret0, ret1 } -// RbacImport indicates an expected call of RbacImport. -func (mr *MockInterfaceMockRecorder) RbacImport(ctx, content interface{}, mods ...interface{}) *gomock.Call { +// RBACImport indicates an expected call of RBACImport. +func (mr *MockInterfaceMockRecorder) RBACImport(ctx, content interface{}, mods ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{ctx, content}, mods...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RBACImport", reflect.TypeOf((*MockInterface)(nil).RBACImport), varargs...) @@ -8497,6 +8527,36 @@ func (mr *MockInterfaceMockRecorder) WorkerModelSpawnError(groupName, name, info return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerModelSpawnError", reflect.TypeOf((*MockInterface)(nil).WorkerModelSpawnError), groupName, name, info) } +// WorkerModelTemplateList mocks base method. +func (m *MockInterface) WorkerModelTemplateList(ctx context.Context, projKey, vcsIdentifier, repoIdentifier string, filter *cdsclient.WorkerModelTemplateFilter) ([]sdk.WorkerModelTemplate, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WorkerModelTemplateList", ctx, projKey, vcsIdentifier, repoIdentifier, filter) + ret0, _ := ret[0].([]sdk.WorkerModelTemplate) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WorkerModelTemplateList indicates an expected call of WorkerModelTemplateList. +func (mr *MockInterfaceMockRecorder) WorkerModelTemplateList(ctx, projKey, vcsIdentifier, repoIdentifier, filter interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerModelTemplateList", reflect.TypeOf((*MockInterface)(nil).WorkerModelTemplateList), ctx, projKey, vcsIdentifier, repoIdentifier, filter) +} + +// WorkerModelv2List mocks base method. +func (m *MockInterface) WorkerModelv2List(ctx context.Context, projKey, vcsIdentifier, repoIdentifier string, filter *cdsclient.WorkerModelV2Filter) ([]sdk.V2WorkerModel, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WorkerModelv2List", ctx, projKey, vcsIdentifier, repoIdentifier, filter) + ret0, _ := ret[0].([]sdk.V2WorkerModel) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WorkerModelv2List indicates an expected call of WorkerModelv2List. +func (mr *MockInterfaceMockRecorder) WorkerModelv2List(ctx, projKey, vcsIdentifier, repoIdentifier, filter interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerModelv2List", reflect.TypeOf((*MockInterface)(nil).WorkerModelv2List), ctx, projKey, vcsIdentifier, repoIdentifier, filter) +} + // WorkerRefresh mocks base method. func (m *MockInterface) WorkerRefresh(ctx context.Context) error { m.ctrl.T.Helper() @@ -9898,6 +9958,36 @@ func (mr *MockWorkerInterfaceMockRecorder) WorkerModelSpawnError(groupName, name return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerModelSpawnError", reflect.TypeOf((*MockWorkerInterface)(nil).WorkerModelSpawnError), groupName, name, info) } +// WorkerModelTemplateList mocks base method. +func (m *MockWorkerInterface) WorkerModelTemplateList(ctx context.Context, projKey, vcsIdentifier, repoIdentifier string, filter *cdsclient.WorkerModelTemplateFilter) ([]sdk.WorkerModelTemplate, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WorkerModelTemplateList", ctx, projKey, vcsIdentifier, repoIdentifier, filter) + ret0, _ := ret[0].([]sdk.WorkerModelTemplate) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WorkerModelTemplateList indicates an expected call of WorkerModelTemplateList. +func (mr *MockWorkerInterfaceMockRecorder) WorkerModelTemplateList(ctx, projKey, vcsIdentifier, repoIdentifier, filter interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerModelTemplateList", reflect.TypeOf((*MockWorkerInterface)(nil).WorkerModelTemplateList), ctx, projKey, vcsIdentifier, repoIdentifier, filter) +} + +// WorkerModelv2List mocks base method. +func (m *MockWorkerInterface) WorkerModelv2List(ctx context.Context, projKey, vcsIdentifier, repoIdentifier string, filter *cdsclient.WorkerModelV2Filter) ([]sdk.V2WorkerModel, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WorkerModelv2List", ctx, projKey, vcsIdentifier, repoIdentifier, filter) + ret0, _ := ret[0].([]sdk.V2WorkerModel) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WorkerModelv2List indicates an expected call of WorkerModelv2List. +func (mr *MockWorkerInterfaceMockRecorder) WorkerModelv2List(ctx, projKey, vcsIdentifier, repoIdentifier, filter interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerModelv2List", reflect.TypeOf((*MockWorkerInterface)(nil).WorkerModelv2List), ctx, projKey, vcsIdentifier, repoIdentifier, filter) +} + // WorkerRefresh mocks base method. func (m *MockWorkerInterface) WorkerRefresh(ctx context.Context) error { m.ctrl.T.Helper() diff --git a/sdk/entity.go b/sdk/entity.go new file mode 100644 index 0000000000..447c8a9820 --- /dev/null +++ b/sdk/entity.go @@ -0,0 +1,49 @@ +package sdk + +import ( + "github.com/rockbears/yaml" + "time" +) + +const ( + EntityTypeWorkerModelTemplate = "WorkerModelTemplate" + EntityTypeWorkerModel = "WorkerModel" +) + +type Entity struct { + ID string `json:"id" db:"id"` + ProjectKey string `json:"project_key" db:"project_key"` + ProjectRepositoryID string `json:"project_repository_id" db:"project_repository_id"` + Type string `json:"type" db:"type"` + Name string `json:"name" db:"name"` + Branch string `json:"branch" db:"branch"` + Commit string `json:"commit" db:"commit"` + LastUpdate time.Time `json:"last_update" db:"last_update"` + Data string `json:"data" db:"data"` +} + +type Lintable interface { + Lint() error +} + +func ReadEntityFile[T Lintable](directory, fileName string, content []byte, out *[]T, t string, analysis ProjectRepositoryAnalysis) ([]Entity, error) { + if err := yaml.UnmarshalMultipleDocuments(content, out); err != nil { + return nil, WrapError(err, "unable to read %s%s", directory, fileName) + } + var entities []Entity + for _, o := range *out { + if err := o.Lint(); err != nil { + return nil, err + } + entities = append(entities, Entity{ + Data: string(content), + Name: fileName, + Branch: analysis.Branch, + Commit: analysis.Commit, + ProjectKey: analysis.ProjectKey, + ProjectRepositoryID: analysis.ProjectRepositoryID, + Type: t, + }) + } + return entities, nil +} diff --git a/sdk/worker_model_template.go b/sdk/worker_model_template.go new file mode 100644 index 0000000000..4db1bb5504 --- /dev/null +++ b/sdk/worker_model_template.go @@ -0,0 +1,122 @@ +package sdk + +import "fmt" + +type V2WorkerModel struct { + Name string `json:"name"` + From string `json:"from"` + Description string `json:"description,omitempty"` + Docker *WorkerModelDocker `json:"docker,omitempty"` + Openstack *WorkerModelOpenstack `json:"openstack,omitempty"` + VSphere *WorkerModelVSphere `json:"vsphere,omitempty"` +} + +func (wm V2WorkerModel) Lint() error { + if wm.Name == "" { + return WithStack(fmt.Errorf("missing worker model template name")) + } + if wm.VSphere != nil && (wm.Openstack != nil || wm.Docker != nil) || + wm.Docker != nil && (wm.Openstack != nil || wm.VSphere != nil) || + wm.Openstack != nil && (wm.Docker != nil || wm.VSphere != nil) { + return WithStack(fmt.Errorf("worker model cannot have multiple types")) + } + + switch { + case wm.Docker != nil: + if wm.Docker.Image == "" { + return WithStack(fmt.Errorf("missing image path")) + } + if wm.From != "" && (wm.Docker.Cmd != "" || wm.Docker.Shell != "" || len(wm.Docker.Envs) > 0) { + return WithStack(fmt.Errorf("you can't override worker model template (cmd,shell,envs)")) + } + case wm.Openstack != nil: + if wm.Openstack.Flavor == "" { + return WithStack(fmt.Errorf("missing flavor")) + } + if wm.Openstack.Image == "" { + return WithStack(fmt.Errorf("missing image")) + } + if wm.From != "" && (wm.Openstack.Cmd != "" || wm.Openstack.PreCmd != "" || wm.Openstack.PostCmd != "") { + return WithStack(fmt.Errorf("you can't override worker model template (cmd,pre_cmd,post_cmd)")) + } + case wm.VSphere != nil: + if wm.VSphere.Image == "" { + return WithStack(fmt.Errorf("missing image")) + } + if wm.VSphere.Username == "" || wm.VSphere.Password == "" { + return WithStack(fmt.Errorf("missing vm credentials")) + } + if wm.From != "" && (wm.VSphere.Cmd != "" || wm.VSphere.PreCmd != "" || wm.VSphere.PostCmd != "") { + return WithStack(fmt.Errorf("you can't override worker model template (cmd,pre_cmd,post_cmd)")) + } + } + return nil +} + +type WorkerModelDocker struct { + Image string `json:"image"` + Registry string `json:"registry,omitempty"` + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Cmd string `json:"cmd,omitempty"` + Shell string `json:"shell"` + Envs map[string]string `json:"envs"` +} + +type WorkerModelOpenstack struct { + Image string `json:"image"` + Flavor string `json:"flavor"` + Cmd string `json:"cmd,omitempty"` + PreCmd string `json:"pre_cmd"` + PostCmd string `json:"post_cmd"` +} + +type WorkerModelVSphere struct { + Image string `json:"image"` + Username string `json:"username"` + Password string `json:"password"` + Cmd string `json:"cmd,omitempty"` + PreCmd string `json:"pre_cmd"` + PostCmd string `json:"post_cmd"` +} + +type WorkerModelTemplate struct { + Name string `json:"name"` + Docker *WorkerModelTemplateDocker `json:"docker,omitempty"` + VM *WorkerModelTemplateVM `json:"vm,omitempty"` +} + +type WorkerModelTemplateDocker struct { + Cmd string `json:"cmd"` + Shell string `json:"shell"` + Envs map[string]string `json:"envs"` +} + +type WorkerModelTemplateVM struct { + Cmd string `json:"cmd"` + PreCmd string `json:"pre_cmd"` + PostCmd string `json:"post_cmd"` +} + +func (wmt WorkerModelTemplate) Lint() error { + if wmt.Name == "" { + return WithStack(fmt.Errorf("missing worker model template name")) + } + if wmt.Docker != nil { + if wmt.Docker.Cmd == "" { + return WithStack(fmt.Errorf("missing docker cmd")) + } + if wmt.Docker.Shell == "" { + return WithStack(fmt.Errorf("missing docker shell")) + } + } + if wmt.VM != nil { + if wmt.VM.Cmd == "" { + return WithStack(fmt.Errorf("missing vm cmd")) + } + if wmt.VM.PostCmd == "" { + return WithStack(fmt.Errorf("missing vm post_cmd to shutdown the VM")) + } + } + return nil +} diff --git a/tests/08_v2_analyze.yml b/tests/08_v2_analyze.yml index e986ab4a39..17725f340d 100644 --- a/tests/08_v2_analyze.yml +++ b/tests/08_v2_analyze.yml @@ -43,9 +43,11 @@ testcases: steps: - script: echo {{.repositoryProject.repoID}} - script: rm -Rf /tmp/myrepo && git clone "http://{{.git.user}}:{{.git.password}}@localhost:3000/{{.git.user}}/myrepo.git" /tmp/myrepo - - script: mkdir -p /tmp/myrepo/.cds/models && echo 'new file' > /tmp/myrepo/.cds/models/my-worker-model.yml + - script: mkdir -p /tmp/myrepo/.cds/worker-model-templates && mkdir -p /tmp/myrepo/.cds/worker-models + - script: cat ./fixtures/worker-model-template/tmpl-docker.yml > /tmp/myrepo/.cds/worker-model-templates/tmpl-docker.yml + - script: cat ./fixtures/worker-model/docker-debian9.yml > /tmp/myrepo/.cds/worker-models/docker-debian9.yml - script: cd /tmp/myrepo && git config user.email "{{.git.user}}@gitea.eu" && git config user.name "{{.git.user}}" - - script: cd /tmp/myrepo && git add /tmp/myrepo/.cds/models/my-worker-model.yml && git commit . --gpg-sign=2B74B3591CEFB2F534265465E027B500E97E52E7 -m "add file and sign" && git push + - script: cd /tmp/myrepo && git add /tmp/myrepo/.cds/worker-model-templates/tmpl-docker.yml && git commit . --gpg-sign=2B74B3591CEFB2F534265465E027B500E97E52E7 -m "add file and sign" && git push - script: {{.cdsctl}} -f {{.cdsctl.config}} experimental project repository hook-regen ITCLIPRJVCS my_vcs_server {{.git.user}}/myrepo --format json vars: hookSecret: @@ -75,7 +77,14 @@ testcases: - result.code ShouldEqual 0 - 'result.systemout ShouldContainSubstring "status: Success"' - 'result.systemout ShouldContainSubstring "key_sign_id: E027B500E97E52E7"' - + - script: {{.cdsctl}} -f {{.cdsctl.config}} experimental worker-model template list ITCLIPRJVCS my_vcs_server {{.git.user}}/myrepo + assertions: + - result.code ShouldEqual 0 + - result.systemoutjson.systemoutjson0.name ShouldEqual docker-unix + - script: {{.cdsctl}} -f {{.cdsctl.config}} experimental worker-model list ITCLIPRJVCS my_vcs_server {{.git.user}}/myrepo + assertions: + - result.code ShouldEqual 0 + - result.systemoutjson.systemoutjson0.name ShouldEqual docker-debian - name: delete repository on project steps: - script: {{.cdsctl}} -f {{.cdsctl.config}} experimental project repository delete ITCLIPRJVCS my_vcs_server {{.git.user}}/myrepo --force diff --git a/tests/fixtures/worker-model-template/tmpl-docker.yml b/tests/fixtures/worker-model-template/tmpl-docker.yml new file mode 100644 index 0000000000..30d82364f7 --- /dev/null +++ b/tests/fixtures/worker-model-template/tmpl-docker.yml @@ -0,0 +1,6 @@ +name: docker-unix +docker: + cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker + shell: sh -c + envs: + MYVAR: toto diff --git a/tests/fixtures/worker-model/docker-debian9.yml b/tests/fixtures/worker-model/docker-debian9.yml new file mode 100644 index 0000000000..8fcb7c09a5 --- /dev/null +++ b/tests/fixtures/worker-model/docker-debian9.yml @@ -0,0 +1,9 @@ +name: docker-debian +description: my debian worker model +docker: + image: myimage:1.1 + registry: http://my-registry:9000 + cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker + shell: sh -c + envs: + MYVAR: toto From 30ff2e9a6da865a0a279c7400247592e96ef2439 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Mon, 5 Sep 2022 14:55:44 +0200 Subject: [PATCH 02/15] fix(test): git add all files on .cds folder --- cli/cdsctl/experimental_worker-model-template.go | 3 ++- cli/cdsctl/experimental_worker-model.go | 3 ++- tests/08_v2_analyze.yml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cli/cdsctl/experimental_worker-model-template.go b/cli/cdsctl/experimental_worker-model-template.go index fbb6b33cec..cc3fbcf542 100644 --- a/cli/cdsctl/experimental_worker-model-template.go +++ b/cli/cdsctl/experimental_worker-model-template.go @@ -2,10 +2,11 @@ package main import ( "context" - "github.com/ovh/cds/sdk/cdsclient" + "github.com/spf13/cobra" "github.com/ovh/cds/cli" + "github.com/ovh/cds/sdk/cdsclient" ) var experimentalWorkerModelTemplateCmd = cli.Command{ diff --git a/cli/cdsctl/experimental_worker-model.go b/cli/cdsctl/experimental_worker-model.go index eb1fff9c85..da1e7c4c6c 100644 --- a/cli/cdsctl/experimental_worker-model.go +++ b/cli/cdsctl/experimental_worker-model.go @@ -2,10 +2,11 @@ package main import ( "context" - "github.com/ovh/cds/sdk/cdsclient" + "github.com/spf13/cobra" "github.com/ovh/cds/cli" + "github.com/ovh/cds/sdk/cdsclient" ) var experimentalWorkerModelCmd = cli.Command{ diff --git a/tests/08_v2_analyze.yml b/tests/08_v2_analyze.yml index 17725f340d..c8b69371ee 100644 --- a/tests/08_v2_analyze.yml +++ b/tests/08_v2_analyze.yml @@ -47,7 +47,7 @@ testcases: - script: cat ./fixtures/worker-model-template/tmpl-docker.yml > /tmp/myrepo/.cds/worker-model-templates/tmpl-docker.yml - script: cat ./fixtures/worker-model/docker-debian9.yml > /tmp/myrepo/.cds/worker-models/docker-debian9.yml - script: cd /tmp/myrepo && git config user.email "{{.git.user}}@gitea.eu" && git config user.name "{{.git.user}}" - - script: cd /tmp/myrepo && git add /tmp/myrepo/.cds/worker-model-templates/tmpl-docker.yml && git commit . --gpg-sign=2B74B3591CEFB2F534265465E027B500E97E52E7 -m "add file and sign" && git push + - script: cd /tmp/myrepo && git add /tmp/myrepo/.cds/* && git commit . --gpg-sign=2B74B3591CEFB2F534265465E027B500E97E52E7 -m "add file and sign" && git push - script: {{.cdsctl}} -f {{.cdsctl.config}} experimental project repository hook-regen ITCLIPRJVCS my_vcs_server {{.git.user}}/myrepo --format json vars: hookSecret: From 12897cac1354da8b6e1e22a9f047d60547bf72fb Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Mon, 5 Sep 2022 15:05:04 +0200 Subject: [PATCH 03/15] fix: update go sum --- contrib/grpcplugins/action/plugin-archive/go.mod | 1 + contrib/grpcplugins/action/plugin-archive/go.sum | 2 ++ .../action/plugin-artifactory-release-bundle-create/go.mod | 1 + .../action/plugin-artifactory-release-bundle-create/go.sum | 2 ++ .../action/plugin-artifactory-release-bundle-distribute/go.mod | 2 ++ .../action/plugin-artifactory-release-bundle-distribute/go.sum | 3 +++ contrib/grpcplugins/action/plugin-download/go.mod | 1 + contrib/grpcplugins/action/plugin-download/go.sum | 2 ++ contrib/grpcplugins/action/plugin-group-tmpl/go.mod | 2 ++ contrib/grpcplugins/action/plugin-group-tmpl/go.sum | 3 +++ contrib/grpcplugins/action/plugin-npm-audit-parser/go.mod | 2 ++ contrib/grpcplugins/action/plugin-npm-audit-parser/go.sum | 3 +++ contrib/grpcplugins/action/plugin-ssh-cmd/go.mod | 2 ++ contrib/grpcplugins/action/plugin-ssh-cmd/go.sum | 3 +++ contrib/grpcplugins/action/plugin-tmpl/go.mod | 2 ++ contrib/grpcplugins/action/plugin-tmpl/go.sum | 3 +++ contrib/grpcplugins/action/plugin-venom/go.mod | 1 + contrib/grpcplugins/action/plugin-venom/go.sum | 2 ++ tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod | 2 ++ tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum | 3 +++ 20 files changed, 42 insertions(+) diff --git a/contrib/grpcplugins/action/plugin-archive/go.mod b/contrib/grpcplugins/action/plugin-archive/go.mod index 3b610ae35f..830b511e9b 100644 --- a/contrib/grpcplugins/action/plugin-archive/go.mod +++ b/contrib/grpcplugins/action/plugin-archive/go.mod @@ -54,6 +54,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 // indirect github.com/sirupsen/logrus v1.8.1 // indirect diff --git a/contrib/grpcplugins/action/plugin-archive/go.sum b/contrib/grpcplugins/action/plugin-archive/go.sum index 2ffbda87b1..d8eef48d5b 100644 --- a/contrib/grpcplugins/action/plugin-archive/go.sum +++ b/contrib/grpcplugins/action/plugin-archive/go.sum @@ -271,6 +271,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= diff --git a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.mod b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.mod index 5f5d378e56..bf72df4f40 100644 --- a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.mod +++ b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.mod @@ -72,6 +72,7 @@ require ( github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 // indirect github.com/sirupsen/logrus v1.8.1 // indirect diff --git a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.sum b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.sum index 30a9582123..be8192c02b 100644 --- a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.sum +++ b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.sum @@ -425,6 +425,8 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= diff --git a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.mod b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.mod index 3f61359100..a026a16bd3 100644 --- a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.mod +++ b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.mod @@ -51,6 +51,7 @@ require ( github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 // indirect github.com/sirupsen/logrus v1.8.1 // indirect @@ -72,4 +73,5 @@ require ( google.golang.org/grpc v1.43.0 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.sum b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.sum index 23d0fc25cb..6a1845db3b 100644 --- a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.sum +++ b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.sum @@ -270,6 +270,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= @@ -671,6 +673,7 @@ 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-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= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/contrib/grpcplugins/action/plugin-download/go.mod b/contrib/grpcplugins/action/plugin-download/go.mod index 31b2f84444..7808850447 100644 --- a/contrib/grpcplugins/action/plugin-download/go.mod +++ b/contrib/grpcplugins/action/plugin-download/go.mod @@ -54,6 +54,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 // indirect github.com/sirupsen/logrus v1.8.1 // indirect diff --git a/contrib/grpcplugins/action/plugin-download/go.sum b/contrib/grpcplugins/action/plugin-download/go.sum index b5e6a9f324..9875bd54ea 100644 --- a/contrib/grpcplugins/action/plugin-download/go.sum +++ b/contrib/grpcplugins/action/plugin-download/go.sum @@ -269,6 +269,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= diff --git a/contrib/grpcplugins/action/plugin-group-tmpl/go.mod b/contrib/grpcplugins/action/plugin-group-tmpl/go.mod index 0909d131c3..116025f41b 100644 --- a/contrib/grpcplugins/action/plugin-group-tmpl/go.mod +++ b/contrib/grpcplugins/action/plugin-group-tmpl/go.mod @@ -51,6 +51,7 @@ require ( github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 // indirect github.com/sirupsen/logrus v1.8.1 // indirect @@ -72,4 +73,5 @@ require ( google.golang.org/grpc v1.43.0 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/grpcplugins/action/plugin-group-tmpl/go.sum b/contrib/grpcplugins/action/plugin-group-tmpl/go.sum index 9132a168c3..1562efd1ff 100644 --- a/contrib/grpcplugins/action/plugin-group-tmpl/go.sum +++ b/contrib/grpcplugins/action/plugin-group-tmpl/go.sum @@ -269,6 +269,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= @@ -670,6 +672,7 @@ 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-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= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/contrib/grpcplugins/action/plugin-npm-audit-parser/go.mod b/contrib/grpcplugins/action/plugin-npm-audit-parser/go.mod index 588c48ff33..439c195d41 100644 --- a/contrib/grpcplugins/action/plugin-npm-audit-parser/go.mod +++ b/contrib/grpcplugins/action/plugin-npm-audit-parser/go.mod @@ -51,6 +51,7 @@ require ( github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 // indirect github.com/sirupsen/logrus v1.8.1 // indirect @@ -72,4 +73,5 @@ require ( google.golang.org/grpc v1.43.0 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/grpcplugins/action/plugin-npm-audit-parser/go.sum b/contrib/grpcplugins/action/plugin-npm-audit-parser/go.sum index 9132a168c3..1562efd1ff 100644 --- a/contrib/grpcplugins/action/plugin-npm-audit-parser/go.sum +++ b/contrib/grpcplugins/action/plugin-npm-audit-parser/go.sum @@ -269,6 +269,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= @@ -670,6 +672,7 @@ 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-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= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/contrib/grpcplugins/action/plugin-ssh-cmd/go.mod b/contrib/grpcplugins/action/plugin-ssh-cmd/go.mod index 187e6c7606..66747db234 100644 --- a/contrib/grpcplugins/action/plugin-ssh-cmd/go.mod +++ b/contrib/grpcplugins/action/plugin-ssh-cmd/go.mod @@ -52,6 +52,7 @@ require ( github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 // indirect github.com/sirupsen/logrus v1.8.1 // indirect @@ -72,4 +73,5 @@ require ( google.golang.org/grpc v1.43.0 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/grpcplugins/action/plugin-ssh-cmd/go.sum b/contrib/grpcplugins/action/plugin-ssh-cmd/go.sum index 9132a168c3..1562efd1ff 100644 --- a/contrib/grpcplugins/action/plugin-ssh-cmd/go.sum +++ b/contrib/grpcplugins/action/plugin-ssh-cmd/go.sum @@ -269,6 +269,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= @@ -670,6 +672,7 @@ 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-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= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/contrib/grpcplugins/action/plugin-tmpl/go.mod b/contrib/grpcplugins/action/plugin-tmpl/go.mod index 4497ad3afb..44d9addd9e 100644 --- a/contrib/grpcplugins/action/plugin-tmpl/go.mod +++ b/contrib/grpcplugins/action/plugin-tmpl/go.mod @@ -51,6 +51,7 @@ require ( github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 // indirect github.com/sirupsen/logrus v1.8.1 // indirect @@ -72,4 +73,5 @@ require ( google.golang.org/grpc v1.43.0 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/grpcplugins/action/plugin-tmpl/go.sum b/contrib/grpcplugins/action/plugin-tmpl/go.sum index 9132a168c3..1562efd1ff 100644 --- a/contrib/grpcplugins/action/plugin-tmpl/go.sum +++ b/contrib/grpcplugins/action/plugin-tmpl/go.sum @@ -269,6 +269,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= @@ -670,6 +672,7 @@ 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-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= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/contrib/grpcplugins/action/plugin-venom/go.mod b/contrib/grpcplugins/action/plugin-venom/go.mod index f785d03046..846bdbaad5 100644 --- a/contrib/grpcplugins/action/plugin-venom/go.mod +++ b/contrib/grpcplugins/action/plugin-venom/go.mod @@ -79,6 +79,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/rubenv/sql-migrate v0.0.0-20160620083229-6f4757563362 // indirect github.com/sclevine/agouti v3.0.0+incompatible // indirect github.com/sergi/go-diff v1.1.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-venom/go.sum b/contrib/grpcplugins/action/plugin-venom/go.sum index 96e598a770..79485c113a 100644 --- a/contrib/grpcplugins/action/plugin-venom/go.sum +++ b/contrib/grpcplugins/action/plugin-venom/go.sum @@ -337,6 +337,8 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5X github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rubenv/sql-migrate v0.0.0-20160620083229-6f4757563362 h1:lmOdpLt3XS6QyVoY6xNfOOTNWE2xtUBees+OAO+HFOg= diff --git a/tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod b/tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod index 78a24e4055..408a4d7702 100644 --- a/tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod +++ b/tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod @@ -49,6 +49,7 @@ require ( github.com/pierrec/lz4/v4 v4.1.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rockbears/log v0.6.0 // indirect + github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 // indirect github.com/sirupsen/logrus v1.8.1 // indirect @@ -70,6 +71,7 @@ require ( google.golang.org/grpc v1.43.0 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) replace github.com/ovh/cds => ../../.. diff --git a/tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum b/tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum index 9132a168c3..1562efd1ff 100644 --- a/tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum +++ b/tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum @@ -269,6 +269,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rockbears/log v0.6.0 h1:Wzpu7nbrZFFJy14ku41jI2/UEh3d0CJwvIED9/FQZKQ= github.com/rockbears/log v0.6.0/go.mod h1:z46IOEOh914gJvg256Vm3F4s8K7D3ePaEAzuMYcfk98= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625 h1:HQAWw/D9RItCYSoWFs8E7IrGKrX9ivqAlCq47DM3IVU= +github.com/rockbears/yaml v0.1.1-0.20220901090137-13dadb408625/go.mod h1:8cDJx2PWQJMtfGgsRCvHVbIB61SV3dvy8o6EGv2cIpg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= @@ -670,6 +672,7 @@ 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-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= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 0466486cacd006562dde7e6c7aa19d1fa13e3ea4 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Mon, 5 Sep 2022 16:29:42 +0200 Subject: [PATCH 04/15] fix: use go 1.18 --- tests/fixtures/04SCWorkflowRunSimplePlugin/Makefile | 2 +- tests/fixtures/ITSCWRKFLW15/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fixtures/04SCWorkflowRunSimplePlugin/Makefile b/tests/fixtures/04SCWorkflowRunSimplePlugin/Makefile index 811dc52825..14a604cd50 100644 --- a/tests/fixtures/04SCWorkflowRunSimplePlugin/Makefile +++ b/tests/fixtures/04SCWorkflowRunSimplePlugin/Makefile @@ -16,6 +16,6 @@ build-plugin: --rm \ -e "GOOS=$(OS)" \ -e "GOARCH=$(ARCH)" \ - golang:1.17 \ + golang:1.18 \ /bin/bash -c \ "cd /go/src/github.com/ovh/cds/tests/fixtures/04SCWorkflowRunSimplePlugin && go version && CGO_ENABLED=0 go build -installsuffix cgo -ldflags '-extldflags "-static"' -o plugin-simple-$(OS)-$(ARCH) ." diff --git a/tests/fixtures/ITSCWRKFLW15/Makefile b/tests/fixtures/ITSCWRKFLW15/Makefile index 0839a4050a..4ddec391c0 100644 --- a/tests/fixtures/ITSCWRKFLW15/Makefile +++ b/tests/fixtures/ITSCWRKFLW15/Makefile @@ -16,6 +16,6 @@ build-plugin: --rm \ -e "GOOS=$(OS)" \ -e "GOARCH=$(ARCH)" \ - golang:1.17 \ + golang:1.18 \ /bin/bash -c \ "cd /go/src/github.com/ovh/cds/tests/fixtures/ITSCWRKFLW15 && go version && CGO_ENABLED=0 go build -installsuffix cgo -ldflags '-extldflags "-static"' -o plugin-simple-integ-$(OS)-$(ARCH) ." From 724b5d9a1bebbe3d5fe4ce3f84e68e48ac2b1261 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Mon, 5 Sep 2022 18:30:28 +0200 Subject: [PATCH 05/15] fix: directory prefix --- engine/api/entity/dao.go | 2 +- engine/api/v2_repository_analyze.go | 5 +- engine/api/v2_repository_analyze_test.go | 210 +++++++++++++++++++++++ sdk/entity.go | 3 +- sdk/v2_worker_model.go | 85 +++++++++ sdk/worker_model_template.go | 82 +-------- 6 files changed, 305 insertions(+), 82 deletions(-) create mode 100644 sdk/v2_worker_model.go diff --git a/engine/api/entity/dao.go b/engine/api/entity/dao.go index aa2757d38a..5b2296b8ee 100644 --- a/engine/api/entity/dao.go +++ b/engine/api/entity/dao.go @@ -96,6 +96,6 @@ func LoadByTypeAndBranch(ctx context.Context, db gorp.SqlExecutor, projectReposi func LoadByBranchTypeName(ctx context.Context, db gorp.SqlExecutor, projectRepositoryID string, branch string, t string, name string, opts ...gorpmapping.GetOptionFunc) (*sdk.Entity, error) { query := gorpmapping.NewQuery(` SELECT * from entity - WHERE project_repository_id $1 AND branch = $2 AND type = $3 AND name = $4`).Args(projectRepositoryID, branch, t, name) + WHERE project_repository_id = $1 AND branch = $2 AND type = $3 AND name = $4`).Args(projectRepositoryID, branch, t, name) return getEntity(ctx, db, query, opts...) } diff --git a/engine/api/v2_repository_analyze.go b/engine/api/v2_repository_analyze.go index 0d429eec42..81201092c6 100644 --- a/engine/api/v2_repository_analyze.go +++ b/engine/api/v2_repository_analyze.go @@ -408,13 +408,13 @@ func (api *API) handleEntitiesFiles(_ context.Context, filesContent map[string][ dir, fileName := filepath.Split(filePath) fileName = strings.TrimSuffix(fileName, ".yml") switch { - case strings.HasPrefix(filePath, "worker-model-templates"): + case strings.HasPrefix(filePath, ".cds/worker-model-templates/"): var tmpls []sdk.WorkerModelTemplate entities, err = sdk.ReadEntityFile(dir, fileName, content, &tmpls, sdk.EntityTypeWorkerModelTemplate, analysis) if err != nil { return nil, err } - case strings.HasPrefix(filePath, "worker-models"): + case strings.HasPrefix(filePath, ".cds/worker-models/"): var wms []sdk.V2WorkerModel entities, err = sdk.ReadEntityFile(dir, fileName, content, &wms, sdk.EntityTypeWorkerModel, analysis) if err != nil { @@ -423,6 +423,7 @@ func (api *API) handleEntitiesFiles(_ context.Context, filesContent map[string][ } } return entities, nil + } // analyzeCommitSignatureThroughVcsAPI analyzes commit. diff --git a/engine/api/v2_repository_analyze_test.go b/engine/api/v2_repository_analyze_test.go index 26d84a08ca..36192e129d 100644 --- a/engine/api/v2_repository_analyze_test.go +++ b/engine/api/v2_repository_analyze_test.go @@ -2,8 +2,10 @@ package api import ( "context" + "encoding/base64" "github.com/go-gorp/gorp" "github.com/golang/mock/gomock" + "github.com/ovh/cds/engine/api/entity" "github.com/ovh/cds/engine/api/repository" "github.com/ovh/cds/engine/api/services" "github.com/ovh/cds/engine/api/services/mock_services" @@ -495,3 +497,211 @@ func TestAnalyzeGithubServerCommitNotSigned(t *testing.T) { require.Equal(t, sdk.RepositoryAnalysisStatusSkipped, analysisUpdated.Status) require.Equal(t, "commit abcdef is not signed", analysisUpdated.Data.Error) } + +func TestAnalyzeGithubAddWorkerModel(t *testing.T) { + api, db, _ := newTestAPI(t) + ctx := context.TODO() + + // Create project + key1 := sdk.RandomString(10) + proj1 := assets.InsertTestProject(t, db, api.Cache, key1, key1) + + uk, err := user.LoadGPGKeyByKeyID(ctx, db, "F344BDDCE15F17D7") + if err != nil && !sdk.ErrorIs(err, sdk.ErrNotFound) { + require.NoError(t, err) + } + if uk != nil { + require.NoError(t, user.DeleteGPGKey(db, *uk)) + } + + u, _ := assets.InsertLambdaUser(t, db) + userKey := &sdk.UserGPGKey{ + KeyID: "F344BDDCE15F17D7", + PublicKey: `-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBFXv+IMBEADYp5xTZ0YKvUgXvvE0SSeXg+bo8mPTTq5clIYWfdmfVjS6NL8T +IYhnjj5MXXIoGs/Lyx+B0VUC9Jo5ObSVCViJRXGVwfHpMIW2+n4i251pGO4bUPPw +o7SpEbvEc1tqE4P3OU26BZhZoIv3AaslMXi+v2eZjJe5Qr4BSc6FLOo5pdAm9HAZ +7vkj7M/WKbbpoXKpfZF+DLmJsrWU/2/TVD2ZdLANAwiXSVLmLeJr0z/zVX+9o6b9 +Rz7HV3euPDCWb/t2fEI4yT8+e92QlxCtVcMpG7ZpxftQbl4z0U8kHASr38UqjTL5 +VtCHKUFD5KyrxHUxFEUingI+M8NstzObho65oK2yxzcoufHTQBo2sfL4xWqPmFj8 +hZeNSz3P6XPLQ+wdIganRGweEv+LSpbSMXIaWpiE2GjwFVRRTaffCgWvth1JRBti +deJI5rxe7UztytDTg8Ekt5MAqTBIoxqZ24zOdbxEef4EpEiYnaa5GXMg8EHH1bJr +aIc2nuY7Zfoz7uvqS8F5ohh69q/LbSv+gxw7aU36oogd13+8/MYPE29vfb+tIIwz +xen0PUcPkt83EQ0RdTbG7AnrvNMXDINp+ZGz3Oks3OXehezX/syPAe7BunPU/Zfy +wK/GDhpjsS9R+y/ZWDXX/LyQfHiHw5nIoX0m6I43BdshrQH5fyrTvJA02wARAQAB +tCxTdGV2ZW4gR3VpaGV1eCA8c3RldmVuLmd1aWhldXhAY29ycC5vdmguY29tPokC +OAQTAQIAIgUCVe/4gwIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQ80S9 +3OFfF9dDYw//VuE85jnUS6bFwdvkFtdbXPZxOsFDMX9tiCjYDdXfT+98AoGgZboC +Ya/E8T5NhFjG8yGC8WOsiZZhQ/DyFr7TT+CwLvZ2JmLarEKHpL//YNr5ACp7Q8lo +7PSAACEJx2J3s2qpEbpMrvXVOJkAbwiFUnSz8R14RMJZLCmgbA5CDKpYqCSM/1B1 +ED/WY8phhV6GknsqvG/cQiyQNQBg8PEdsyiNn79QWRGD8q5ZvWsxAuMMY7j/WSLy +VHZJ9wR9lBM9Lf3NJ+vDoVq56WaAH30vuVJ2LzGwHOULDKSFkQZ1JPodsu+7tDAZ +QDENAMaD1940GzmBANH/FOHD5T2VrOYMtPHMcyXJRSUOgw3MtvSuKJJliLMO0DNa +EZG14nCcdDP7xoS9da2JddMxDmqhzuCpsPk0IVH+JSjrAKOJ7r5YE3/vWcI2dQaU +nOYBhqST73RN2g6wF5xLt9Oi1DXYFBfdhz+oXJ1ck34MB3oPx5yzlY9Rp7N5F9a+ +gDiuE1Y1iqRX0uuoDq8b2EsZrQ4dSvpjZwWYRsDghjSATjiAcrhC70NjpG22Avwt +0x3SPG+HQYgzYs9idQMI6lpKqoFU9QUHMsWQKuBFE0ZXJs9Q9d+zjjUCebFZ7LjN +twZyhn8QXg5FUhLygfF6Pq8jnYMXMzAbKXm3NEC8X1/VGaZjB1Lszcq5Ag0EVe/4 +gwEQAMGVA4T9qs/a8zy10Tc8nSGAMdNzI26D0fhH2rRtjeNJs5BqGNMPu2Eg5DKR +7rStsw58fDvdKeB116ZPXq4Hoe66H+Pw83QIwDQk/vN965fPwqz9BIgDE/xTx09w +wVLvfKAHIFQF7znqqUYrES2gYpvirVD7knGKjVMMkB4Hil7TMcya6MTD2a9L32be +nMfZ5sA4311TJPS+kIEeEuG+SU2w3i6YRho+atUvsxkMNzmx92ow6JDznX8Kpbr/ +PVExZObUW0+379yMKlgaZLhrgqbcwm+IOCgsM5XSs/zGb2AFACADnOdqOYToRtIt +bdvH2Y/2fq3t3upuzbpM3fiUu0Vs2rVRe5w4luHt6ZpKdZo43blEL9MN/ZbQVYE0 +N/5/9SAizfyyOGmrNvB4EwPLpyImBre9MRcZJRvg22tFxcbnM2+SJGwfmD0FnPGe +gIRihPgsQxrx6BOCB1JzCUCOUqZ12gy2ul2RuopGEEX8YKLWNryNN8v0ooS+PU8D +Ii2biB9O9UYecXPVhxVP64gl48lN8psIFL+YSJ+svAErsQYGASApRF240Nor98+L +zgHm1+60JNU1i5gYQV6RzDMUML43XYWxsVqA21mTZZSJFwC/TcmLDl9yGyIOTNG4 +kFPT/c1xibi5MGBQE8gIxdwEwfrj9iqohMt8afJfIMhcfwdzABEBAAGJAh8EGAEC +AAkFAlXv+IMCGwwACgkQ80S93OFfF9ceWxAAprlvofJ8qkREkhNznF9YacuDru8n +8BfWINLHKMI8zmOaijcdZVjC/+5FxC7rIx/Bc+vJCmMTTAkud0RfF4zDBPAqEv0q +I+4lR/ATThkRmX3XJSBDeI62MJTOPHqZ13mPnof5fAdy9HFclc1vwMoBjOofJpq4 +DiQqchzR8eg0YXFDfaKptDrjvBGeffb14RjI7MeNwp5YIrEc4zZfQGZ3p3Q8oH84 +vMbWjiWp/OZH+ZBVixLWQVMrTu1jSE7Hj7FgbBJzaXGoH/NyYqTTWany06Mpltu7 ++71v/gJGgav+VxGcPoEzI83SCKdWdlLdtK5HjzpmqMixX1NaO5gfQblatmi7qLIT +f42j7Ul9tumMOLPtKQmiuloMJHO7mUmqOZDxmbrNmb47rAmIU3KRx5oNID9rLhxe +4tuAIsY8Lu2mU+PR5XQlgjG1J0aCunxUOZ4HhLUqJ6U+QWLUpRAq74zjPGocIv1e +GAH2qkfaNTarBQKytsA7k6vnzHmY7KYup3c9qQjMC8XzjuKBF5oJXl3yBU2VCPaw +qVWF89Lpz5nHVxmY2ejU/DvV7zUUAiqlVyzFmiOed5O66jVtPG4YM5x2EMwNvejk +e9rMe4DS8qoQg4er1Z3WNcb4JOAc33HDOol1LFOH1buNN5V+KrkUo0fPWMf4nQ97 +GDFkaTe3nUJdYV4= +=SNcy +-----END PGP PUBLIC KEY BLOCK-----`, + AuthentifiedUserID: u.ID, + } + require.NoError(t, user.InsertGPGKey(ctx, db, userKey)) + + assets.InsertRBAcProject(t, db, sdk.RoleManage, proj1.Key, *u) + + // Create VCS + vcsProject := assets.InsertTestVCSProject(t, db, proj1.ID, "vcs-server", "github") + + repo := sdk.ProjectRepository{ + Name: "myrepo", + Auth: sdk.ProjectRepositoryAuth{ + Username: "myuser", + Token: "mytoken", + }, + Created: time.Now(), + VCSProjectID: vcsProject.ID, + CreatedBy: "me", + } + require.NoError(t, repository.Insert(context.TODO(), db, &repo)) + + analysis := sdk.ProjectRepositoryAnalysis{ + ID: "", + Status: sdk.RepositoryAnalysisStatusInProgress, + Commit: "abcdef", + ProjectKey: proj1.Key, + ProjectRepositoryID: repo.ID, + Created: time.Now(), + LastModified: time.Now(), + Branch: "master", + VCSProjectID: vcsProject.ID, + } + require.NoError(t, repository.InsertAnalysis(ctx, db, &analysis)) + + // Mock VCS + s, _ := assets.InsertService(t, db, t.Name()+"_VCS", sdk.TypeVCS) + // Setup a mock for all services called by the API + ctrl := gomock.NewController(t) + defer ctrl.Finish() + servicesClients := mock_services.NewMockClient(ctrl) + services.NewClient = func(_ gorp.SqlExecutor, _ []sdk.Service) services.Client { + return servicesClients + } + defer func() { + _ = services.Delete(db, s) + services.NewClient = services.NewDefaultClient + }() + + model := `name: docker-debian +description: my debian worker model +docker: + image: myimage:1.1 + registry: http://my-registry:9000 + cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker + shell: sh -c + envs: + MYVAR: toto + +` + encodedModel := base64.StdEncoding.EncodeToString([]byte(model)) + + servicesClients.EXPECT(). + DoJSONRequest(gomock.Any(), "GET", "/vcs/vcs-server/repos/myrepo/commits/abcdef", gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn( + func(ctx context.Context, method, path string, in interface{}, out interface{}, _ interface{}) (http.Header, int, error) { + commit := &sdk.VCSCommit{ + Signature: "-----BEGIN PGP SIGNATURE-----\n\niQIzBAABCAAdFiEEfYJxMHx+E0DPuqaA80S93OFfF9cFAmME7aIACgkQ80S93OFf\nF9eFWBAAq5hOcZIx/A+8J6/NwRtXMs5OW+TJxzJb5siXdRC8Mjrm+fqwpTPPHqtB\nbb7iuiRnmY/HqCegULiw4qVxDyA3sswyDHPLcyUcfG4drJGylPW9ZYg3YeRslX2B\niQykYZyd4h3R/euYAuBKA9vMGoWnaU/Vh22A11Po1pXpPq623FTkiFOSAZrD8Hql\nEvmlhw26qHSPlhsdSKsR+/FPvpLUXlNUiYB5oq7W9qy0yOOafgwZ9r3vvxshzvkt\nvW5zG+R05thQ8icCyrWfEfIWp+TTtQX3asOopnQG9dFs2LRODLXXaHTRVRB/MWPa\nNVvUD/dIzBVyNimpik+2Uqq5jWNiXavQmqoxyL9n4A372AIH7Hu78NnfmAz7VnYo\nyVHRNBryiCcYNj5g0x/WnGsDuhQr7170ODw7QfEYJdCPxGgYuhdYovHdjcMcgWpF\ncWEtayj8bhuLTjjxEsqXTv+psxwB55N5OUvyXmNAaFLhJSEI+l1VHW14L3gZFdPT\n+VgPQtT9a1+GEjPqLvZ6wLVTcSI9uogK6NHowmyM261FtFQqLVdkOdUU8RCR8qLC\nekZWQaJutqicIZTolAQyBPBw8aQz0i+uBUgdWkoiHf/zEEudu0b06IpDq2oYFFVH\nVmCuZ3/AcXrW6T3XXcE5pu+Rvsi57O7iR8i7TIP0CaDTr2FfQWc=\n=/H7t\n-----END PGP SIGNATURE-----", + Verified: true, + Hash: "abcdef", + } + *(out.(*sdk.VCSCommit)) = *commit + return nil, 200, nil + }, + ).MaxTimes(1) + servicesClients.EXPECT(). + DoJSONRequest(gomock.Any(), "GET", "/vcs/vcs-server/repos/myrepo/contents/.cds?commit=abcdef", gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn( + func(ctx context.Context, method, path string, in interface{}, out interface{}, _ interface{}) (http.Header, int, error) { + contents := []sdk.VCSContent{ + { + IsDirectory: true, + Name: "worker-models", + }, + } + *(out.(*[]sdk.VCSContent)) = contents + return nil, 200, nil + }, + ).MaxTimes(1) + servicesClients.EXPECT(). + DoJSONRequest(gomock.Any(), "GET", "/vcs/vcs-server/repos/myrepo/contents/.cds%2Fworker-models?commit=abcdef", gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn( + func(ctx context.Context, method, path string, in interface{}, out interface{}, _ interface{}) (http.Header, int, error) { + contents := []sdk.VCSContent{ + { + IsDirectory: false, + IsFile: true, + Name: "mymodels.yml", + }, + } + *(out.(*[]sdk.VCSContent)) = contents + return nil, 200, nil + }, + ).MaxTimes(1) + servicesClients.EXPECT(). + DoJSONRequest(gomock.Any(), "GET", "/vcs/vcs-server/repos/myrepo/content/.cds%2Fworker-models%2Fmymodels.yml?commit=abcdef", gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn( + func(ctx context.Context, method, path string, in interface{}, out interface{}, _ interface{}) (http.Header, int, error) { + + content := sdk.VCSContent{ + IsDirectory: false, + IsFile: true, + Name: "mymodels.yml", + Content: encodedModel, + } + *(out.(*sdk.VCSContent)) = content + return nil, 200, nil + }, + ).MaxTimes(1) + + require.NoError(t, api.analyzeRepository(ctx, repo.ID, analysis.ID)) + + analysisUpdated, err := repository.LoadRepositoryAnalysisById(ctx, db, repo.ID, analysis.ID) + require.NoError(t, err) + require.Equal(t, sdk.RepositoryAnalysisStatusSucceed, analysisUpdated.Status) + + es, err := entity.LoadByType(context.TODO(), db, repo.ID, sdk.EntityTypeWorkerModel) + require.NoError(t, err) + + require.Equal(t, 1, len(es)) + require.Equal(t, model, es[0].Data) + t.Logf("%+v", es[0]) + + e, err := entity.LoadByBranchTypeName(context.TODO(), db, repo.ID, "master", sdk.EntityTypeWorkerModel, "docker-debian") + require.NoError(t, err) + require.Equal(t, model, e.Data) + +} diff --git a/sdk/entity.go b/sdk/entity.go index 447c8a9820..f260c99541 100644 --- a/sdk/entity.go +++ b/sdk/entity.go @@ -24,6 +24,7 @@ type Entity struct { type Lintable interface { Lint() error + GetName() string } func ReadEntityFile[T Lintable](directory, fileName string, content []byte, out *[]T, t string, analysis ProjectRepositoryAnalysis) ([]Entity, error) { @@ -37,7 +38,7 @@ func ReadEntityFile[T Lintable](directory, fileName string, content []byte, out } entities = append(entities, Entity{ Data: string(content), - Name: fileName, + Name: o.GetName(), Branch: analysis.Branch, Commit: analysis.Commit, ProjectKey: analysis.ProjectKey, diff --git a/sdk/v2_worker_model.go b/sdk/v2_worker_model.go new file mode 100644 index 0000000000..66783e31c3 --- /dev/null +++ b/sdk/v2_worker_model.go @@ -0,0 +1,85 @@ +package sdk + +import "fmt" + +type V2WorkerModel struct { + Name string `json:"name"` + From string `json:"from"` + Description string `json:"description,omitempty"` + Docker *WorkerModelDocker `json:"docker,omitempty"` + Openstack *WorkerModelOpenstack `json:"openstack,omitempty"` + VSphere *WorkerModelVSphere `json:"vsphere,omitempty"` +} + +func (wm V2WorkerModel) GetName() string { + return wm.Name +} + +func (wm V2WorkerModel) Lint() error { + if wm.Name == "" { + return WithStack(fmt.Errorf("missing worker model template name")) + } + if wm.VSphere != nil && (wm.Openstack != nil || wm.Docker != nil) || + wm.Docker != nil && (wm.Openstack != nil || wm.VSphere != nil) || + wm.Openstack != nil && (wm.Docker != nil || wm.VSphere != nil) { + return WithStack(fmt.Errorf("worker model cannot have multiple types")) + } + + switch { + case wm.Docker != nil: + if wm.Docker.Image == "" { + return WithStack(fmt.Errorf("missing image path")) + } + if wm.From != "" && (wm.Docker.Cmd != "" || wm.Docker.Shell != "" || len(wm.Docker.Envs) > 0) { + return WithStack(fmt.Errorf("you can't override worker model template (cmd,shell,envs)")) + } + case wm.Openstack != nil: + if wm.Openstack.Flavor == "" { + return WithStack(fmt.Errorf("missing flavor")) + } + if wm.Openstack.Image == "" { + return WithStack(fmt.Errorf("missing image")) + } + if wm.From != "" && (wm.Openstack.Cmd != "" || wm.Openstack.PreCmd != "" || wm.Openstack.PostCmd != "") { + return WithStack(fmt.Errorf("you can't override worker model template (cmd,pre_cmd,post_cmd)")) + } + case wm.VSphere != nil: + if wm.VSphere.Image == "" { + return WithStack(fmt.Errorf("missing image")) + } + if wm.VSphere.Username == "" || wm.VSphere.Password == "" { + return WithStack(fmt.Errorf("missing vm credentials")) + } + if wm.From != "" && (wm.VSphere.Cmd != "" || wm.VSphere.PreCmd != "" || wm.VSphere.PostCmd != "") { + return WithStack(fmt.Errorf("you can't override worker model template (cmd,pre_cmd,post_cmd)")) + } + } + return nil +} + +type WorkerModelDocker struct { + Image string `json:"image"` + Registry string `json:"registry,omitempty"` + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Cmd string `json:"cmd,omitempty"` + Shell string `json:"shell"` + Envs map[string]string `json:"envs"` +} + +type WorkerModelOpenstack struct { + Image string `json:"image"` + Flavor string `json:"flavor"` + Cmd string `json:"cmd,omitempty"` + PreCmd string `json:"pre_cmd"` + PostCmd string `json:"post_cmd"` +} + +type WorkerModelVSphere struct { + Image string `json:"image"` + Username string `json:"username"` + Password string `json:"password"` + Cmd string `json:"cmd,omitempty"` + PreCmd string `json:"pre_cmd"` + PostCmd string `json:"post_cmd"` +} diff --git a/sdk/worker_model_template.go b/sdk/worker_model_template.go index 4db1bb5504..7be00dba63 100644 --- a/sdk/worker_model_template.go +++ b/sdk/worker_model_template.go @@ -2,84 +2,6 @@ package sdk import "fmt" -type V2WorkerModel struct { - Name string `json:"name"` - From string `json:"from"` - Description string `json:"description,omitempty"` - Docker *WorkerModelDocker `json:"docker,omitempty"` - Openstack *WorkerModelOpenstack `json:"openstack,omitempty"` - VSphere *WorkerModelVSphere `json:"vsphere,omitempty"` -} - -func (wm V2WorkerModel) Lint() error { - if wm.Name == "" { - return WithStack(fmt.Errorf("missing worker model template name")) - } - if wm.VSphere != nil && (wm.Openstack != nil || wm.Docker != nil) || - wm.Docker != nil && (wm.Openstack != nil || wm.VSphere != nil) || - wm.Openstack != nil && (wm.Docker != nil || wm.VSphere != nil) { - return WithStack(fmt.Errorf("worker model cannot have multiple types")) - } - - switch { - case wm.Docker != nil: - if wm.Docker.Image == "" { - return WithStack(fmt.Errorf("missing image path")) - } - if wm.From != "" && (wm.Docker.Cmd != "" || wm.Docker.Shell != "" || len(wm.Docker.Envs) > 0) { - return WithStack(fmt.Errorf("you can't override worker model template (cmd,shell,envs)")) - } - case wm.Openstack != nil: - if wm.Openstack.Flavor == "" { - return WithStack(fmt.Errorf("missing flavor")) - } - if wm.Openstack.Image == "" { - return WithStack(fmt.Errorf("missing image")) - } - if wm.From != "" && (wm.Openstack.Cmd != "" || wm.Openstack.PreCmd != "" || wm.Openstack.PostCmd != "") { - return WithStack(fmt.Errorf("you can't override worker model template (cmd,pre_cmd,post_cmd)")) - } - case wm.VSphere != nil: - if wm.VSphere.Image == "" { - return WithStack(fmt.Errorf("missing image")) - } - if wm.VSphere.Username == "" || wm.VSphere.Password == "" { - return WithStack(fmt.Errorf("missing vm credentials")) - } - if wm.From != "" && (wm.VSphere.Cmd != "" || wm.VSphere.PreCmd != "" || wm.VSphere.PostCmd != "") { - return WithStack(fmt.Errorf("you can't override worker model template (cmd,pre_cmd,post_cmd)")) - } - } - return nil -} - -type WorkerModelDocker struct { - Image string `json:"image"` - Registry string `json:"registry,omitempty"` - Username string `json:"username,omitempty"` - Password string `json:"password,omitempty"` - Cmd string `json:"cmd,omitempty"` - Shell string `json:"shell"` - Envs map[string]string `json:"envs"` -} - -type WorkerModelOpenstack struct { - Image string `json:"image"` - Flavor string `json:"flavor"` - Cmd string `json:"cmd,omitempty"` - PreCmd string `json:"pre_cmd"` - PostCmd string `json:"post_cmd"` -} - -type WorkerModelVSphere struct { - Image string `json:"image"` - Username string `json:"username"` - Password string `json:"password"` - Cmd string `json:"cmd,omitempty"` - PreCmd string `json:"pre_cmd"` - PostCmd string `json:"post_cmd"` -} - type WorkerModelTemplate struct { Name string `json:"name"` Docker *WorkerModelTemplateDocker `json:"docker,omitempty"` @@ -120,3 +42,7 @@ func (wmt WorkerModelTemplate) Lint() error { } return nil } + +func (wmt WorkerModelTemplate) GetName() string { + return wmt.Name +} From d2b6f746d9165f6c11f7d90769b85d5eb17aa7c4 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Tue, 6 Sep 2022 14:07:28 +0200 Subject: [PATCH 06/15] fix: append all entities --- engine/api/v2_repository_analyze.go | 17 +++++---- engine/api/v2_repository_analyze_test.go | 46 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/engine/api/v2_repository_analyze.go b/engine/api/v2_repository_analyze.go index 81201092c6..a4ac7aba71 100644 --- a/engine/api/v2_repository_analyze.go +++ b/engine/api/v2_repository_analyze.go @@ -403,24 +403,23 @@ func (api *API) analyzeRepository(ctx context.Context, projectRepoID string, ana func (api *API) handleEntitiesFiles(_ context.Context, filesContent map[string][]byte, analysis sdk.ProjectRepositoryAnalysis) ([]sdk.Entity, error) { entities := make([]sdk.Entity, 0) - var err error for filePath, content := range filesContent { dir, fileName := filepath.Split(filePath) fileName = strings.TrimSuffix(fileName, ".yml") + var es []sdk.Entity + var err error switch { case strings.HasPrefix(filePath, ".cds/worker-model-templates/"): var tmpls []sdk.WorkerModelTemplate - entities, err = sdk.ReadEntityFile(dir, fileName, content, &tmpls, sdk.EntityTypeWorkerModelTemplate, analysis) - if err != nil { - return nil, err - } + es, err = sdk.ReadEntityFile(dir, fileName, content, &tmpls, sdk.EntityTypeWorkerModelTemplate, analysis) case strings.HasPrefix(filePath, ".cds/worker-models/"): var wms []sdk.V2WorkerModel - entities, err = sdk.ReadEntityFile(dir, fileName, content, &wms, sdk.EntityTypeWorkerModel, analysis) - if err != nil { - return nil, err - } + es, err = sdk.ReadEntityFile(dir, fileName, content, &wms, sdk.EntityTypeWorkerModel, analysis) + } + if err != nil { + return nil, err } + entities = append(entities, es...) } return entities, nil diff --git a/engine/api/v2_repository_analyze_test.go b/engine/api/v2_repository_analyze_test.go index 36192e129d..1a49f1eb6b 100644 --- a/engine/api/v2_repository_analyze_test.go +++ b/engine/api/v2_repository_analyze_test.go @@ -629,6 +629,13 @@ docker: ` encodedModel := base64.StdEncoding.EncodeToString([]byte(model)) + modelTemplate := `name: openstack-debian +openstack: + pre_cmd: apt-get install docker-ce + cmd: ./worker + post_cmd: sudo shutdown -h now` + encodedTemplate := base64.StdEncoding.EncodeToString([]byte(modelTemplate)) + servicesClients.EXPECT(). DoJSONRequest(gomock.Any(), "GET", "/vcs/vcs-server/repos/myrepo/commits/abcdef", gomock.Any(), gomock.Any(), gomock.Any()). DoAndReturn( @@ -651,6 +658,10 @@ docker: IsDirectory: true, Name: "worker-models", }, + { + IsDirectory: true, + Name: "worker-model-templates", + }, } *(out.(*[]sdk.VCSContent)) = contents return nil, 200, nil @@ -687,6 +698,37 @@ docker: }, ).MaxTimes(1) + servicesClients.EXPECT(). + DoJSONRequest(gomock.Any(), "GET", "/vcs/vcs-server/repos/myrepo/contents/.cds%2Fworker-model-templates?commit=abcdef", gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn( + func(ctx context.Context, method, path string, in interface{}, out interface{}, _ interface{}) (http.Header, int, error) { + contents := []sdk.VCSContent{ + { + IsDirectory: false, + IsFile: true, + Name: "mytemplate.yml", + }, + } + *(out.(*[]sdk.VCSContent)) = contents + return nil, 200, nil + }, + ).MaxTimes(1) + servicesClients.EXPECT(). + DoJSONRequest(gomock.Any(), "GET", "/vcs/vcs-server/repos/myrepo/content/.cds%2Fworker-model-templates%2Fmytemplate.yml?commit=abcdef", gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn( + func(ctx context.Context, method, path string, in interface{}, out interface{}, _ interface{}) (http.Header, int, error) { + + content := sdk.VCSContent{ + IsDirectory: false, + IsFile: true, + Name: "mytemplate.yml", + Content: encodedTemplate, + } + *(out.(*sdk.VCSContent)) = content + return nil, 200, nil + }, + ).MaxTimes(1) + require.NoError(t, api.analyzeRepository(ctx, repo.ID, analysis.ID)) analysisUpdated, err := repository.LoadRepositoryAnalysisById(ctx, db, repo.ID, analysis.ID) @@ -704,4 +746,8 @@ docker: require.NoError(t, err) require.Equal(t, model, e.Data) + esTempalte, err := entity.LoadByType(context.TODO(), db, repo.ID, sdk.EntityTypeWorkerModelTemplate) + require.NoError(t, err) + t.Logf("%+v", es[0]) + require.Equal(t, 1, len(esTempalte)) } From da51e45443d740a84dc155f4371db3e95ca26712 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Tue, 6 Sep 2022 16:09:08 +0200 Subject: [PATCH 07/15] fix: add format json --- tests/08_v2_analyze.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/08_v2_analyze.yml b/tests/08_v2_analyze.yml index c8b69371ee..a742b8db0e 100644 --- a/tests/08_v2_analyze.yml +++ b/tests/08_v2_analyze.yml @@ -77,11 +77,11 @@ testcases: - result.code ShouldEqual 0 - 'result.systemout ShouldContainSubstring "status: Success"' - 'result.systemout ShouldContainSubstring "key_sign_id: E027B500E97E52E7"' - - script: {{.cdsctl}} -f {{.cdsctl.config}} experimental worker-model template list ITCLIPRJVCS my_vcs_server {{.git.user}}/myrepo + - script: {{.cdsctl}} -f {{.cdsctl.config}} experimental worker-model template list ITCLIPRJVCS my_vcs_server {{.git.user}}/myrepo --format json assertions: - result.code ShouldEqual 0 - result.systemoutjson.systemoutjson0.name ShouldEqual docker-unix - - script: {{.cdsctl}} -f {{.cdsctl.config}} experimental worker-model list ITCLIPRJVCS my_vcs_server {{.git.user}}/myrepo + - script: {{.cdsctl}} -f {{.cdsctl.config}} experimental worker-model list ITCLIPRJVCS my_vcs_server {{.git.user}}/myrepo --format json assertions: - result.code ShouldEqual 0 - result.systemoutjson.systemoutjson0.name ShouldEqual docker-debian From 3da819f8a2395d99a5d5b0fc602aabd62456cac2 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Thu, 8 Sep 2022 11:29:26 +0200 Subject: [PATCH 08/15] fix: use jsonschema to lint file --- ...-model.go => experimental_worker_model.go} | 0 ... => experimental_worker_model_template.go} | 2 +- engine/api/user_schema.go | 14 +- engine/api/v2_repository_analyze.go | 25 ++-- go.mod | 9 +- go.sum | 10 +- sdk/entity.go | 6 +- sdk/jsonschema.go | 33 +++++ sdk/v2_worker_model.go | 133 +++++++++--------- sdk/v2_worker_model_test.go | 45 ++++++ sdk/worker_model_template.go | 70 +++++---- sdk/worker_model_template_test.go | 40 ++++++ 12 files changed, 263 insertions(+), 124 deletions(-) rename cli/cdsctl/{experimental_worker-model.go => experimental_worker_model.go} (100%) rename cli/cdsctl/{experimental_worker-model-template.go => experimental_worker_model_template.go} (97%) create mode 100644 sdk/jsonschema.go create mode 100644 sdk/v2_worker_model_test.go create mode 100644 sdk/worker_model_template_test.go diff --git a/cli/cdsctl/experimental_worker-model.go b/cli/cdsctl/experimental_worker_model.go similarity index 100% rename from cli/cdsctl/experimental_worker-model.go rename to cli/cdsctl/experimental_worker_model.go diff --git a/cli/cdsctl/experimental_worker-model-template.go b/cli/cdsctl/experimental_worker_model_template.go similarity index 97% rename from cli/cdsctl/experimental_worker-model-template.go rename to cli/cdsctl/experimental_worker_model_template.go index cc3fbcf542..ca3ced060b 100644 --- a/cli/cdsctl/experimental_worker-model-template.go +++ b/cli/cdsctl/experimental_worker_model_template.go @@ -23,7 +23,7 @@ func experimentalWorkerModelTemplate() *cobra.Command { var wmTemplateListCmd = cli.Command{ Name: "list", - Example: "cdsctl worker-model-template list", + Example: "cdsctl worker-model template list", Ctx: []cli.Arg{ {Name: _ProjectKey}, }, diff --git a/engine/api/user_schema.go b/engine/api/user_schema.go index be4a3cb157..161762bddf 100644 --- a/engine/api/user_schema.go +++ b/engine/api/user_schema.go @@ -7,8 +7,8 @@ import ( "net/http" "reflect" - "github.com/alecthomas/jsonschema" "github.com/iancoleman/orderedmap" + "github.com/invopop/jsonschema" "github.com/ovh/cds/engine/api/action" "github.com/ovh/cds/engine/api/group" @@ -63,19 +63,19 @@ func (api *API) getUserJSONSchema() service.Handler { path = fmt.Sprintf("%s/%s", as[i].Group.Name, as[i].Name) } s := slug.Convert(path) - sch.Definitions["Step"].Properties.Set(path, &jsonschema.Type{ + sch.Definitions["Step"].Properties.Set(path, &jsonschema.Schema{ Version: "http://json-schema.org/draft-04/schema#", Ref: "#/definitions/" + s, Description: as[i].Description, }) - sch.Definitions["Step"].OneOf = append(sch.Definitions["Step"].OneOf, &jsonschema.Type{ + sch.Definitions["Step"].OneOf = append(sch.Definitions["Step"].OneOf, &jsonschema.Schema{ Required: []string{ path, }, Title: path, }) - sch.Definitions[s] = &jsonschema.Type{ + sch.Definitions[s] = &jsonschema.Schema{ Properties: orderedmap.New(), AdditionalProperties: sch.Definitions["Step"].AdditionalProperties, Type: "object", @@ -84,15 +84,15 @@ func (api *API) getUserJSONSchema() service.Handler { p := as[i].Parameters[j] switch p.Type { case "number": - sch.Definitions[s].Properties.Set(p.Name, &jsonschema.Type{ + sch.Definitions[s].Properties.Set(p.Name, &jsonschema.Schema{ Type: "integer", }) case "boolean": - sch.Definitions[s].Properties.Set(p.Name, &jsonschema.Type{ + sch.Definitions[s].Properties.Set(p.Name, &jsonschema.Schema{ Type: "boolean", }) default: - sch.Definitions[s].Properties.Set(p.Name, &jsonschema.Type{ + sch.Definitions[s].Properties.Set(p.Name, &jsonschema.Schema{ Type: "string", }) } diff --git a/engine/api/v2_repository_analyze.go b/engine/api/v2_repository_analyze.go index a4ac7aba71..3d1e89db34 100644 --- a/engine/api/v2_repository_analyze.go +++ b/engine/api/v2_repository_analyze.go @@ -371,9 +371,9 @@ func (api *API) analyzeRepository(ctx context.Context, projectRepoID string, ana return sdk.WithStack(tx.Commit()) } - entities, err := api.handleEntitiesFiles(ctx, filesContent, *analysis) - if err != nil { - return api.stopAnalysis(ctx, analysis, err) + entities, multiErr := api.handleEntitiesFiles(ctx, filesContent, *analysis) + if multiErr != nil { + return api.stopAnalysis(ctx, analysis, multiErr...) } for i := range entities { @@ -401,13 +401,13 @@ func (api *API) analyzeRepository(ctx context.Context, projectRepoID string, ana return sdk.WithStack(tx.Commit()) } -func (api *API) handleEntitiesFiles(_ context.Context, filesContent map[string][]byte, analysis sdk.ProjectRepositoryAnalysis) ([]sdk.Entity, error) { +func (api *API) handleEntitiesFiles(_ context.Context, filesContent map[string][]byte, analysis sdk.ProjectRepositoryAnalysis) ([]sdk.Entity, []error) { entities := make([]sdk.Entity, 0) for filePath, content := range filesContent { dir, fileName := filepath.Split(filePath) fileName = strings.TrimSuffix(fileName, ".yml") var es []sdk.Entity - var err error + var err sdk.MultiError switch { case strings.HasPrefix(filePath, ".cds/worker-model-templates/"): var tmpls []sdk.WorkerModelTemplate @@ -629,11 +629,11 @@ func (api *API) getCdsArchiveFileOnRepo(ctx context.Context, repo sdk.ProjectRep dir, fileName := filepath.Split(hdr.Name) if strings.HasSuffix(fileName, ".yml") { - entity := sdk.ProjectRepositoryDataEntity{ + e := sdk.ProjectRepositoryDataEntity{ FileName: fileName, Path: dir, } - analysis.Data.Entities = append(analysis.Data.Entities, entity) + analysis.Data.Entities = append(analysis.Data.Entities, e) } buff := new(bytes.Buffer) @@ -649,15 +649,20 @@ func (api *API) getCdsArchiveFileOnRepo(ctx context.Context, repo sdk.ProjectRep return filesContent, nil } -func (api *API) stopAnalysis(ctx context.Context, analysis *sdk.ProjectRepositoryAnalysis, originalError error) error { - log.ErrorWithStackTrace(ctx, originalError) +func (api *API) stopAnalysis(ctx context.Context, analysis *sdk.ProjectRepositoryAnalysis, originalErrors ...error) error { + me := sdk.MultiError{} + for _, e := range originalErrors { + log.ErrorWithStackTrace(ctx, e) + me.Append(e) + } tx, err := api.mustDB().Begin() if err != nil { return sdk.WithStack(err) } defer tx.Rollback() // nolint + analysis.Status = sdk.RepositoryAnalysisStatusError - analysis.Data.Error = fmt.Sprintf("%v", originalError) + analysis.Data.Error = fmt.Sprintf("%s", me.Error()) if err := repository.UpdateAnalysis(ctx, tx, analysis); err != nil { return err } diff --git a/go.mod b/go.mod index 118f8716b3..f7367cbfe3 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( contrib.go.opencensus.io/exporter/jaeger v0.1.0 contrib.go.opencensus.io/exporter/prometheus v0.1.0 github.com/Shopify/sarama v1.30.0 - github.com/alecthomas/jsonschema v0.0.0-20200123075451-43663a393755 github.com/andygrunwald/go-gerrit v0.0.0-20181207071854-19ef3e9332a4 github.com/aws/aws-sdk-go v1.19.11 github.com/blang/semver v3.5.1+incompatible @@ -39,6 +38,7 @@ require ( github.com/hashicorp/vault/api v1.0.4 github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf + github.com/invopop/jsonschema v0.6.0 github.com/jfrog/jfrog-client-go v1.5.1 github.com/jordan-wright/email v4.0.1-0.20200917010138-e1c00e156980+incompatible github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 @@ -85,6 +85,7 @@ require ( github.com/vmware/govmomi v0.23.0 github.com/whilp/git-urls v0.0.0-20160530060445-31bac0d230fa github.com/xanzy/go-gitlab v0.15.0 + github.com/xeipuuv/gojsonschema v1.2.0 github.com/yesnault/go-toml v0.0.0-20191205182532-f5ef6cee7945 github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed github.com/yuin/gopher-lua v0.0.0-20170901023928-8c2befcd3908 @@ -233,6 +234,8 @@ require ( github.com/subosito/gotenv v1.2.0 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect github.com/ziutek/mymysql v1.5.4 // indirect @@ -261,12 +264,12 @@ require ( sigs.k8s.io/yaml v1.2.0 // indirect ) +replace github.com/invopop/jsonschema v0.6.0 => github.com/sguiheux/jsonschema v0.0.0-20220907155307-5db145196fe8 + replace gopkg.in/yaml.v2 v2.4.0 => gopkg.in/yaml.v2 v2.3.0 replace github.com/vmware/go-nfs-client => github.com/sguiheux/go-nfs-client v0.0.0-20210311091651-4f075a6103cc -replace github.com/alecthomas/jsonschema => github.com/sguiheux/jsonschema v0.2.0 - replace github.com/go-gorp/gorp => github.com/yesnault/gorp v2.0.1-0.20200325154225-2dc6d8c2da37+incompatible replace github.com/docker/docker => github.com/docker/engine v0.0.0-20180816081446-320063a2ad06 diff --git a/go.sum b/go.sum index 755e76f2cc..832a285503 100644 --- a/go.sum +++ b/go.sum @@ -778,8 +778,8 @@ github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197 h1:qu90yDtRE5 github.com/sguiheux/go-coverage v0.0.0-20190710153556-287b082a7197/go.mod h1:0hhKrsUsoT7yvxwNGKa+TSYNA26DNWMqReeZEQq/9FI= github.com/sguiheux/go-nfs-client v0.0.0-20210311091651-4f075a6103cc h1:2hQK9ZA+R4QK6YSeI6J8h40fv1pQVmsoLwdn0omv4NE= github.com/sguiheux/go-nfs-client v0.0.0-20210311091651-4f075a6103cc/go.mod h1:JWMmlL5pWPL6DVIvix8TwfsDIfw8Cu1uyvid9Js3nyE= -github.com/sguiheux/jsonschema v0.2.0 h1:hFHEPxudR6sNcsg50/iuJzHT5d3h3KOvtcg2Hrshs2k= -github.com/sguiheux/jsonschema v0.2.0/go.mod h1:/n6+1/DWPltRLWL/VKyUxg6tzsl5kHUCcraimt4vr60= +github.com/sguiheux/jsonschema v0.0.0-20220907155307-5db145196fe8 h1:ZVa5RAVxY0ddYqLOS35oAvq5P3L5KbDdb9ubfLFP3L4= +github.com/sguiheux/jsonschema v0.0.0-20220907155307-5db145196fe8/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/shirou/gopsutil v0.0.0-20170406131756-e49a95f3d5f8 h1:05R1OwSk31dkzqf2Jf27n2IOoF9zkK9LcPgPsEm8U7U= github.com/shirou/gopsutil v0.0.0-20170406131756-e49a95f3d5f8/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -857,6 +857,12 @@ github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6e 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/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= diff --git a/sdk/entity.go b/sdk/entity.go index f260c99541..7645fc9aa4 100644 --- a/sdk/entity.go +++ b/sdk/entity.go @@ -23,13 +23,13 @@ type Entity struct { } type Lintable interface { - Lint() error + Lint() []error GetName() string } -func ReadEntityFile[T Lintable](directory, fileName string, content []byte, out *[]T, t string, analysis ProjectRepositoryAnalysis) ([]Entity, error) { +func ReadEntityFile[T Lintable](directory, fileName string, content []byte, out *[]T, t string, analysis ProjectRepositoryAnalysis) ([]Entity, MultiError) { if err := yaml.UnmarshalMultipleDocuments(content, out); err != nil { - return nil, WrapError(err, "unable to read %s%s", directory, fileName) + return nil, []error{WrapError(err, "unable to read %s%s", directory, fileName)} } var entities []Entity for _, o := range *out { diff --git a/sdk/jsonschema.go b/sdk/jsonschema.go new file mode 100644 index 0000000000..2c10877860 --- /dev/null +++ b/sdk/jsonschema.go @@ -0,0 +1,33 @@ +package sdk + +import ( + "github.com/invopop/jsonschema" +) + +func GetWorkerModelJsonSchema() *jsonschema.Schema { + wmSchema := jsonschema.Reflect(&V2WorkerModel{}) + wmDocker := jsonschema.Reflect(&V2WorkerModelDockerSpec{}) + wmOpenstack := jsonschema.Reflect(&V2WorkerModelOpenstackSpec{}) + wmVSphere := jsonschema.Reflect(&V2WorkerModelVSphereSpec{}) + + if wmSchema.Definitions == nil { + wmSchema.Definitions = make(map[string]*jsonschema.Schema) + } + wmSchema.Definitions["V2WorkerModelVSphereSpec"] = wmVSphere + wmSchema.Definitions["V2WorkerModelOpenstackSpec"] = wmOpenstack + wmSchema.Definitions["V2WorkerModelDockerSpec"] = wmDocker + return wmSchema +} + +func GetWorkerModelTemplateJsonSchema() *jsonschema.Schema { + wmtSchema := jsonschema.Reflect(&WorkerModelTemplate{}) + wmtDocker := jsonschema.Reflect(&WorkerModelTemplateDocker{}) + wmtVM := jsonschema.Reflect(&WorkerModelTemplateVM{}) + + if wmtSchema.Definitions == nil { + wmtSchema.Definitions = make(map[string]*jsonschema.Schema) + } + wmtSchema.Definitions["WorkerModelTemplateDocker"] = wmtDocker + wmtSchema.Definitions["WorkerModelTemplateVM"] = wmtVM + return wmtSchema +} diff --git a/sdk/v2_worker_model.go b/sdk/v2_worker_model.go index 66783e31c3..63e84044f0 100644 --- a/sdk/v2_worker_model.go +++ b/sdk/v2_worker_model.go @@ -1,85 +1,78 @@ package sdk -import "fmt" +import ( + "encoding/json" + "fmt" + "github.com/xeipuuv/gojsonschema" +) type V2WorkerModel struct { - Name string `json:"name"` - From string `json:"from"` - Description string `json:"description,omitempty"` - Docker *WorkerModelDocker `json:"docker,omitempty"` - Openstack *WorkerModelOpenstack `json:"openstack,omitempty"` - VSphere *WorkerModelVSphere `json:"vsphere,omitempty"` + Name string `json:"name" jsonschema:"required"` + From string `json:"from"` + Description string `json:"description,omitempty"` + Type string `json:"type" jsonschema:"required"` + Spec json.RawMessage `json:"spec" jsonschema:"required" jsonschema_allof_type:"type=docker:#/$defs/V2WorkerModelDockerSpec,type=openstack:#/$defs/V2WorkerModelOpenstackSpec,type=vsphere:#/$defs/V2WorkerModelVSphereSpec"` } -func (wm V2WorkerModel) GetName() string { - return wm.Name +type V2WorkerModelDockerSpec struct { + Image string `json:"image" jsonschema:"required"` + Registry string `json:"registry,omitempty" jsonschema:"required"` + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Cmd string `json:"cmd,omitempty" jsonschema:"required"` + Shell string `json:"shell,omitempty" jsonschema:"required"` + Envs map[string]string `json:"envs,omitempty"` } -func (wm V2WorkerModel) Lint() error { - if wm.Name == "" { - return WithStack(fmt.Errorf("missing worker model template name")) - } - if wm.VSphere != nil && (wm.Openstack != nil || wm.Docker != nil) || - wm.Docker != nil && (wm.Openstack != nil || wm.VSphere != nil) || - wm.Openstack != nil && (wm.Docker != nil || wm.VSphere != nil) { - return WithStack(fmt.Errorf("worker model cannot have multiple types")) - } - - switch { - case wm.Docker != nil: - if wm.Docker.Image == "" { - return WithStack(fmt.Errorf("missing image path")) - } - if wm.From != "" && (wm.Docker.Cmd != "" || wm.Docker.Shell != "" || len(wm.Docker.Envs) > 0) { - return WithStack(fmt.Errorf("you can't override worker model template (cmd,shell,envs)")) - } - case wm.Openstack != nil: - if wm.Openstack.Flavor == "" { - return WithStack(fmt.Errorf("missing flavor")) - } - if wm.Openstack.Image == "" { - return WithStack(fmt.Errorf("missing image")) - } - if wm.From != "" && (wm.Openstack.Cmd != "" || wm.Openstack.PreCmd != "" || wm.Openstack.PostCmd != "") { - return WithStack(fmt.Errorf("you can't override worker model template (cmd,pre_cmd,post_cmd)")) - } - case wm.VSphere != nil: - if wm.VSphere.Image == "" { - return WithStack(fmt.Errorf("missing image")) - } - if wm.VSphere.Username == "" || wm.VSphere.Password == "" { - return WithStack(fmt.Errorf("missing vm credentials")) - } - if wm.From != "" && (wm.VSphere.Cmd != "" || wm.VSphere.PreCmd != "" || wm.VSphere.PostCmd != "") { - return WithStack(fmt.Errorf("you can't override worker model template (cmd,pre_cmd,post_cmd)")) - } - } - return nil +type V2WorkerModelOpenstackSpec struct { + Image string `json:"image" jsonschema:"required"` + Cmd string `json:"cmd,omitempty" jsonschema:"required"` + Flavor string `json:"flavor,omitempty" jsonschema:"required"` + PreCmd string `json:"pre_cmd,omitempty"` + PostCmd string `json:"post_cmd,omitempty" jsonschema:"required"` } -type WorkerModelDocker struct { - Image string `json:"image"` - Registry string `json:"registry,omitempty"` - Username string `json:"username,omitempty"` - Password string `json:"password,omitempty"` - Cmd string `json:"cmd,omitempty"` - Shell string `json:"shell"` - Envs map[string]string `json:"envs"` +type V2WorkerModelVSphereSpec struct { + Image string `json:"image" jsonschema:"required"` + Username string `json:"username,omitempty" jsonschema:"required"` + Password string `json:"password,omitempty" jsonschema:"required"` + Cmd string `json:"cmd,omitempty" jsonschema:"required"` + PreCmd string `json:"pre_cmd,omitempty"` + PostCmd string `json:"post_cmd,omitempty" jsonschema:"required"` } -type WorkerModelOpenstack struct { - Image string `json:"image"` - Flavor string `json:"flavor"` - Cmd string `json:"cmd,omitempty"` - PreCmd string `json:"pre_cmd"` - PostCmd string `json:"post_cmd"` +func (wm V2WorkerModel) GetName() string { + return wm.Name } -type WorkerModelVSphere struct { - Image string `json:"image"` - Username string `json:"username"` - Password string `json:"password"` - Cmd string `json:"cmd,omitempty"` - PreCmd string `json:"pre_cmd"` - PostCmd string `json:"post_cmd"` +func (wm V2WorkerModel) Lint() []error { + multipleError := MultiError{} + + workerModelSchema := GetWorkerModelJsonSchema() + workerModelSchemaS, err := workerModelSchema.MarshalJSON() + if err != nil { + multipleError.Append(WrapError(err, "unable to load worker model schema")) + return multipleError + } + schemaLoader := gojsonschema.NewStringLoader(string(workerModelSchemaS)) + + modelJson, err := json.Marshal(wm) + if err != nil { + multipleError.Append(WithStack(err)) + return multipleError + } + documentLoader := gojsonschema.NewStringLoader(string(modelJson)) + + result, err := gojsonschema.Validate(schemaLoader, documentLoader) + if err != nil { + multipleError.Append(WithStack(err)) + return multipleError + } + if result.Valid() { + return nil + } + for _, e := range result.Errors() { + multipleError.Append(fmt.Errorf("%v", e)) + } + return multipleError } diff --git a/sdk/v2_worker_model_test.go b/sdk/v2_worker_model_test.go new file mode 100644 index 0000000000..185a7764ed --- /dev/null +++ b/sdk/v2_worker_model_test.go @@ -0,0 +1,45 @@ +package sdk + +import ( + "fmt" + "testing" + + "github.com/rockbears/yaml" + "github.com/stretchr/testify/require" +) + +func TestWorkerDockerModelWithoutImage(t *testing.T) { + dockerWM := `name: debian9 +image: debian:9 +description: "my debian worker model" +type: docker +spec: + envs: + CDS_GRAYLOG_EXTRA_KEY: '{{.GraylogExtraKey}}' + CDS_GRAYLOG_EXTRA_VALUE: '{{.GraylogExtraValue}}' + CDS_GRAYLOG_HOST: '{{.GraylogHost}}' + CDS_GRAYLOG_PORT: '{{.GraylogPort}}' + cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker` + + var dockerModel V2WorkerModel + require.NoError(t, yaml.Unmarshal([]byte(dockerWM), &dockerModel)) + + err := dockerModel.Lint() + require.NotEqual(t, 0, len(err)) + require.Contains(t, fmt.Sprintf("%v", err), "image is required") +} + +func TestWorkerDockerModelOK(t *testing.T) { + dockerWM := `name: debian9 +image: debian:9 +description: "my debian worker model" +type: docker +spec: + image: myimage' + cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker` + + var dockerModel V2WorkerModel + require.NoError(t, yaml.Unmarshal([]byte(dockerWM), &dockerModel)) + + require.Nil(t, dockerModel.Lint()) +} diff --git a/sdk/worker_model_template.go b/sdk/worker_model_template.go index 7be00dba63..d595e511c6 100644 --- a/sdk/worker_model_template.go +++ b/sdk/worker_model_template.go @@ -1,46 +1,60 @@ package sdk -import "fmt" +import ( + "encoding/json" + "fmt" + + "github.com/xeipuuv/gojsonschema" +) type WorkerModelTemplate struct { - Name string `json:"name"` - Docker *WorkerModelTemplateDocker `json:"docker,omitempty"` - VM *WorkerModelTemplateVM `json:"vm,omitempty"` + Name string `json:"name" jsonschema:"required"` + Type string `json:"type" jsonschema:"required"` + Spec json.RawMessage `json:"spec" jsonschema:"required" jsonschema_allof_type:"type=docker:#/$defs/WorkerModelTemplateDocker,type=vm:#/$defs/WorkerModelTemplateVM"` } type WorkerModelTemplateDocker struct { - Cmd string `json:"cmd"` - Shell string `json:"shell"` - Envs map[string]string `json:"envs"` + Cmd string `json:"cmd" jsonschema:"required"` + Shell string `json:"shell" jsonschema:"required"` + Envs map[string]string `json:"envs,omitempty"` } type WorkerModelTemplateVM struct { - Cmd string `json:"cmd"` - PreCmd string `json:"pre_cmd"` - PostCmd string `json:"post_cmd"` + Cmd string `json:"cmd" jsonschema:"required"` + PreCmd string `json:"pre_cmd,omitempty"` + PostCmd string `json:"post_cmd" jsonschema:"required"` } -func (wmt WorkerModelTemplate) Lint() error { - if wmt.Name == "" { - return WithStack(fmt.Errorf("missing worker model template name")) +func (wmt WorkerModelTemplate) Lint() []error { + multipleError := MultiError{} + + workerModelTemplateSchema := GetWorkerModelTemplateJsonSchema() + workerModelTemplateSchemaS, err := workerModelTemplateSchema.MarshalJSON() + if err != nil { + multipleError.Append(WrapError(err, "unable to load worker model template schema")) + return multipleError + } + schemaLoader := gojsonschema.NewStringLoader(string(workerModelTemplateSchemaS)) + + modelJson, err := json.Marshal(wmt) + if err != nil { + multipleError.Append(WithStack(err)) + return multipleError + } + documentLoader := gojsonschema.NewStringLoader(string(modelJson)) + + result, err := gojsonschema.Validate(schemaLoader, documentLoader) + if err != nil { + multipleError.Append(WithStack(err)) + return multipleError } - if wmt.Docker != nil { - if wmt.Docker.Cmd == "" { - return WithStack(fmt.Errorf("missing docker cmd")) - } - if wmt.Docker.Shell == "" { - return WithStack(fmt.Errorf("missing docker shell")) - } + if result.Valid() { + return nil } - if wmt.VM != nil { - if wmt.VM.Cmd == "" { - return WithStack(fmt.Errorf("missing vm cmd")) - } - if wmt.VM.PostCmd == "" { - return WithStack(fmt.Errorf("missing vm post_cmd to shutdown the VM")) - } + for _, e := range result.Errors() { + multipleError.Append(fmt.Errorf("%v", e)) } - return nil + return multipleError } func (wmt WorkerModelTemplate) GetName() string { diff --git a/sdk/worker_model_template_test.go b/sdk/worker_model_template_test.go new file mode 100644 index 0000000000..9380526d34 --- /dev/null +++ b/sdk/worker_model_template_test.go @@ -0,0 +1,40 @@ +package sdk + +import ( + "fmt" + "testing" + + "github.com/rockbears/yaml" + "github.com/stretchr/testify/require" +) + +func TestWorkerModelTemplateDockerWithoutCmd(t *testing.T) { + tmpl := `name: debian9 +description: "my debian worker model" +type: docker +spec: + shell: sh -c +` + + var wmTemplate WorkerModelTemplate + require.NoError(t, yaml.Unmarshal([]byte(tmpl), &wmTemplate)) + + err := wmTemplate.Lint() + require.NotEqual(t, 0, len(err)) + require.Contains(t, fmt.Sprintf("%v", err), "cmd is required") +} + +func TestWorkerModelTemplateDockerOK(t *testing.T) { + tmpl := `name: debian9 +description: "my debian worker model" +type: docker +spec: + shell: sh -c + cmd: ./worker +` + var wmTemplate WorkerModelTemplate + require.NoError(t, yaml.Unmarshal([]byte(tmpl), &wmTemplate)) + + require.Nil(t, wmTemplate.Lint()) + +} From 751d64686e77ad978b0b257ef4cc5c1e055fa1a1 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Thu, 8 Sep 2022 14:43:06 +0200 Subject: [PATCH 09/15] fix(cli): use standard struct --- cli/cdsctl/experimental_worker_model.go | 21 +------------------ .../experimental_worker_model_template.go | 16 +------------- sdk/v2_worker_model.go | 4 ++-- sdk/worker_model_template.go | 4 ++-- 4 files changed, 6 insertions(+), 39 deletions(-) diff --git a/cli/cdsctl/experimental_worker_model.go b/cli/cdsctl/experimental_worker_model.go index da1e7c4c6c..3e980353b1 100644 --- a/cli/cdsctl/experimental_worker_model.go +++ b/cli/cdsctl/experimental_worker_model.go @@ -54,24 +54,5 @@ func workerModelListFunc(v cli.Values) (cli.ListResult, error) { return nil, err } - type Result struct { - Name string `cli:"name"` - Type string `cli:"type"` - } - results := make([]Result, 0, len(wms)) - for _, t := range wms { - var modelType string - switch { - case t.Docker != nil: - modelType = "docker" - case t.VSphere != nil: - modelType = "vsphere" - case t.Openstack != nil: - modelType = "openstack" - default: - modelType = "unknown" - } - results = append(results, Result{Name: t.Name, Type: modelType}) - } - return cli.AsListResult(results), err + return cli.AsListResult(wms), err } diff --git a/cli/cdsctl/experimental_worker_model_template.go b/cli/cdsctl/experimental_worker_model_template.go index ca3ced060b..69406cd6a5 100644 --- a/cli/cdsctl/experimental_worker_model_template.go +++ b/cli/cdsctl/experimental_worker_model_template.go @@ -52,19 +52,5 @@ func wmTemplateListFunc(v cli.Values) (cli.ListResult, error) { if err != nil { return nil, err } - - type Result struct { - Name string `cli:"name"` - Type string `cli:"type"` - } - results := make([]Result, 0, len(tmpls)) - for _, t := range tmpls { - tmplType := "docker" - if t.VM != nil { - tmplType = "vm" - } - results = append(results, Result{Name: t.Name, Type: tmplType}) - } - - return cli.AsListResult(results), err + return cli.AsListResult(tmpls), err } diff --git a/sdk/v2_worker_model.go b/sdk/v2_worker_model.go index 63e84044f0..f0236447a9 100644 --- a/sdk/v2_worker_model.go +++ b/sdk/v2_worker_model.go @@ -7,10 +7,10 @@ import ( ) type V2WorkerModel struct { - Name string `json:"name" jsonschema:"required"` + Name string `json:"name" cli:"name" jsonschema:"required"` From string `json:"from"` Description string `json:"description,omitempty"` - Type string `json:"type" jsonschema:"required"` + Type string `json:"type" cli:"type" jsonschema:"required"` Spec json.RawMessage `json:"spec" jsonschema:"required" jsonschema_allof_type:"type=docker:#/$defs/V2WorkerModelDockerSpec,type=openstack:#/$defs/V2WorkerModelOpenstackSpec,type=vsphere:#/$defs/V2WorkerModelVSphereSpec"` } diff --git a/sdk/worker_model_template.go b/sdk/worker_model_template.go index d595e511c6..055a3f3a9c 100644 --- a/sdk/worker_model_template.go +++ b/sdk/worker_model_template.go @@ -8,8 +8,8 @@ import ( ) type WorkerModelTemplate struct { - Name string `json:"name" jsonschema:"required"` - Type string `json:"type" jsonschema:"required"` + Name string `json:"name" cli:"mane" jsonschema:"required"` + Type string `json:"type" cli:"type" jsonschema:"required"` Spec json.RawMessage `json:"spec" jsonschema:"required" jsonschema_allof_type:"type=docker:#/$defs/WorkerModelTemplateDocker,type=vm:#/$defs/WorkerModelTemplateVM"` } From ccfc6e6af9f376a576af477a337ad6080e4525c4 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Thu, 8 Sep 2022 17:03:48 +0200 Subject: [PATCH 10/15] fix: update go.sum --- contrib/grpcplugins/action/plugin-archive/go.mod | 5 +++++ contrib/grpcplugins/action/plugin-archive/go.sum | 11 +++++++++++ .../plugin-artifactory-release-bundle-create/go.mod | 5 +++++ .../plugin-artifactory-release-bundle-create/go.sum | 8 ++++++++ .../go.mod | 5 +++++ .../go.sum | 11 +++++++++++ contrib/grpcplugins/action/plugin-download/go.mod | 5 +++++ contrib/grpcplugins/action/plugin-download/go.sum | 11 +++++++++++ contrib/grpcplugins/action/plugin-group-tmpl/go.mod | 5 +++++ contrib/grpcplugins/action/plugin-group-tmpl/go.sum | 11 +++++++++++ .../grpcplugins/action/plugin-kafka-publish/go.mod | 5 +++++ .../grpcplugins/action/plugin-kafka-publish/go.sum | 11 +++++++++++ contrib/grpcplugins/action/plugin-marathon/go.mod | 2 ++ contrib/grpcplugins/action/plugin-marathon/go.sum | 5 +++++ .../grpcplugins/action/plugin-npm-audit-parser/go.mod | 5 +++++ .../grpcplugins/action/plugin-npm-audit-parser/go.sum | 11 +++++++++++ contrib/grpcplugins/action/plugin-ssh-cmd/go.mod | 5 +++++ contrib/grpcplugins/action/plugin-ssh-cmd/go.sum | 11 +++++++++++ contrib/grpcplugins/action/plugin-tmpl/go.mod | 5 +++++ contrib/grpcplugins/action/plugin-tmpl/go.sum | 11 +++++++++++ contrib/grpcplugins/action/plugin-venom/go.mod | 5 +++++ contrib/grpcplugins/action/plugin-venom/go.sum | 11 +++++++++++ tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod | 5 +++++ tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum | 11 +++++++++++ 24 files changed, 180 insertions(+) diff --git a/contrib/grpcplugins/action/plugin-archive/go.mod b/contrib/grpcplugins/action/plugin-archive/go.mod index 830b511e9b..20233c68f6 100644 --- a/contrib/grpcplugins/action/plugin-archive/go.mod +++ b/contrib/grpcplugins/action/plugin-archive/go.mod @@ -32,7 +32,9 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/gookit/color v1.4.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jfrog/gofrog v1.0.6 // indirect github.com/jfrog/jfrog-client-go v1.5.1 // indirect @@ -62,6 +64,9 @@ require ( github.com/spf13/cast v1.4.1 // indirect github.com/ulikunitz/xz v0.5.10 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-archive/go.sum b/contrib/grpcplugins/action/plugin-archive/go.sum index d8eef48d5b..2618e9fff6 100644 --- a/contrib/grpcplugins/action/plugin-archive/go.sum +++ b/contrib/grpcplugins/action/plugin-archive/go.sum @@ -193,10 +193,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -296,6 +300,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -310,6 +315,12 @@ github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= diff --git a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.mod b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.mod index bf72df4f40..8ea5db3892 100644 --- a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.mod +++ b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.mod @@ -41,7 +41,9 @@ require ( github.com/gookit/color v1.4.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jedib0t/go-pretty/v6 v6.2.2 // indirect github.com/jfrog/gofrog v1.0.7 // indirect @@ -84,6 +86,9 @@ require ( github.com/subosito/gotenv v1.2.0 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.sum b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.sum index be8192c02b..dd9d174a08 100644 --- a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.sum +++ b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-create/go.sum @@ -268,10 +268,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jedib0t/go-pretty/v6 v6.2.2 h1:o3McN0rQ4X+IU+HduppSp9TwRdGLRW2rhJXy9CJaCRw= @@ -468,6 +472,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -484,8 +489,11 @@ github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oW github.com/vbauerster/mpb/v4 v4.7.0/go.mod h1:ugxYn2kSUrY10WK5CWDUZvQxjdwKFN9K3Ja3/z6p4X0= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= diff --git a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.mod b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.mod index a026a16bd3..4c0dee04cd 100644 --- a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.mod +++ b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.mod @@ -30,7 +30,9 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/gookit/color v1.4.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jfrog/gofrog v1.0.7 // indirect github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect @@ -59,6 +61,9 @@ require ( github.com/spf13/cast v1.4.1 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.sum b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.sum index 6a1845db3b..ffe8685b76 100644 --- a/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.sum +++ b/contrib/grpcplugins/action/plugin-artifactory-release-bundle-distribute/go.sum @@ -192,10 +192,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -294,6 +298,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -305,6 +310,12 @@ github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= diff --git a/contrib/grpcplugins/action/plugin-download/go.mod b/contrib/grpcplugins/action/plugin-download/go.mod index 7808850447..77de4af4a7 100644 --- a/contrib/grpcplugins/action/plugin-download/go.mod +++ b/contrib/grpcplugins/action/plugin-download/go.mod @@ -31,7 +31,9 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/gookit/color v1.4.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jfrog/gofrog v1.0.6 // indirect github.com/jfrog/jfrog-client-go v1.5.1 // indirect @@ -62,6 +64,9 @@ require ( github.com/spf13/cast v1.4.1 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-download/go.sum b/contrib/grpcplugins/action/plugin-download/go.sum index 9875bd54ea..085f442e2f 100644 --- a/contrib/grpcplugins/action/plugin-download/go.sum +++ b/contrib/grpcplugins/action/plugin-download/go.sum @@ -192,10 +192,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -294,6 +298,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -307,6 +312,12 @@ github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= diff --git a/contrib/grpcplugins/action/plugin-group-tmpl/go.mod b/contrib/grpcplugins/action/plugin-group-tmpl/go.mod index 116025f41b..c48a9a8c9a 100644 --- a/contrib/grpcplugins/action/plugin-group-tmpl/go.mod +++ b/contrib/grpcplugins/action/plugin-group-tmpl/go.mod @@ -29,7 +29,9 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/gookit/color v1.4.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jfrog/gofrog v1.0.6 // indirect github.com/jfrog/jfrog-client-go v1.5.1 // indirect @@ -59,6 +61,9 @@ require ( github.com/spf13/cast v1.4.1 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-group-tmpl/go.sum b/contrib/grpcplugins/action/plugin-group-tmpl/go.sum index 1562efd1ff..cc108bd07b 100644 --- a/contrib/grpcplugins/action/plugin-group-tmpl/go.sum +++ b/contrib/grpcplugins/action/plugin-group-tmpl/go.sum @@ -192,10 +192,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -293,6 +297,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -304,6 +309,12 @@ github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= diff --git a/contrib/grpcplugins/action/plugin-kafka-publish/go.mod b/contrib/grpcplugins/action/plugin-kafka-publish/go.mod index e29b935125..f1ff3956a3 100644 --- a/contrib/grpcplugins/action/plugin-kafka-publish/go.mod +++ b/contrib/grpcplugins/action/plugin-kafka-publish/go.mod @@ -53,8 +53,10 @@ require ( github.com/gorilla/websocket v1.4.2 // indirect github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect @@ -107,6 +109,9 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.opencensus.io v0.23.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-kafka-publish/go.sum b/contrib/grpcplugins/action/plugin-kafka-publish/go.sum index 2055160fe1..5037551ff9 100644 --- a/contrib/grpcplugins/action/plugin-kafka-publish/go.sum +++ b/contrib/grpcplugins/action/plugin-kafka-publish/go.sum @@ -325,12 +325,16 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= @@ -552,6 +556,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -572,6 +577,12 @@ github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6e 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/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= diff --git a/contrib/grpcplugins/action/plugin-marathon/go.mod b/contrib/grpcplugins/action/plugin-marathon/go.mod index 7a0798ea72..641f471c5d 100644 --- a/contrib/grpcplugins/action/plugin-marathon/go.mod +++ b/contrib/grpcplugins/action/plugin-marathon/go.mod @@ -45,8 +45,10 @@ require ( github.com/gookit/color v1.4.2 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jfrog/gofrog v1.0.6 // indirect github.com/jfrog/jfrog-client-go v1.5.1 // indirect diff --git a/contrib/grpcplugins/action/plugin-marathon/go.sum b/contrib/grpcplugins/action/plugin-marathon/go.sum index 8315df88b6..ff596d2d18 100644 --- a/contrib/grpcplugins/action/plugin-marathon/go.sum +++ b/contrib/grpcplugins/action/plugin-marathon/go.sum @@ -305,12 +305,16 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -497,6 +501,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= diff --git a/contrib/grpcplugins/action/plugin-npm-audit-parser/go.mod b/contrib/grpcplugins/action/plugin-npm-audit-parser/go.mod index 439c195d41..9f59061a41 100644 --- a/contrib/grpcplugins/action/plugin-npm-audit-parser/go.mod +++ b/contrib/grpcplugins/action/plugin-npm-audit-parser/go.mod @@ -29,7 +29,9 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/gookit/color v1.4.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jfrog/gofrog v1.0.6 // indirect github.com/jfrog/jfrog-client-go v1.5.1 // indirect @@ -59,6 +61,9 @@ require ( github.com/spf13/cast v1.4.1 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-npm-audit-parser/go.sum b/contrib/grpcplugins/action/plugin-npm-audit-parser/go.sum index 1562efd1ff..cc108bd07b 100644 --- a/contrib/grpcplugins/action/plugin-npm-audit-parser/go.sum +++ b/contrib/grpcplugins/action/plugin-npm-audit-parser/go.sum @@ -192,10 +192,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -293,6 +297,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -304,6 +309,12 @@ github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= diff --git a/contrib/grpcplugins/action/plugin-ssh-cmd/go.mod b/contrib/grpcplugins/action/plugin-ssh-cmd/go.mod index 66747db234..e87865ddbb 100644 --- a/contrib/grpcplugins/action/plugin-ssh-cmd/go.mod +++ b/contrib/grpcplugins/action/plugin-ssh-cmd/go.mod @@ -30,7 +30,9 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/gookit/color v1.4.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jfrog/gofrog v1.0.6 // indirect github.com/jfrog/jfrog-client-go v1.5.1 // indirect @@ -60,6 +62,9 @@ require ( github.com/spf13/cast v1.4.1 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-ssh-cmd/go.sum b/contrib/grpcplugins/action/plugin-ssh-cmd/go.sum index 1562efd1ff..cc108bd07b 100644 --- a/contrib/grpcplugins/action/plugin-ssh-cmd/go.sum +++ b/contrib/grpcplugins/action/plugin-ssh-cmd/go.sum @@ -192,10 +192,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -293,6 +297,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -304,6 +309,12 @@ github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= diff --git a/contrib/grpcplugins/action/plugin-tmpl/go.mod b/contrib/grpcplugins/action/plugin-tmpl/go.mod index 44d9addd9e..6e51e3fd9b 100644 --- a/contrib/grpcplugins/action/plugin-tmpl/go.mod +++ b/contrib/grpcplugins/action/plugin-tmpl/go.mod @@ -29,7 +29,9 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/gookit/color v1.4.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jfrog/gofrog v1.0.6 // indirect github.com/jfrog/jfrog-client-go v1.5.1 // indirect @@ -59,6 +61,9 @@ require ( github.com/spf13/cast v1.4.1 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/contrib/grpcplugins/action/plugin-tmpl/go.sum b/contrib/grpcplugins/action/plugin-tmpl/go.sum index 1562efd1ff..cc108bd07b 100644 --- a/contrib/grpcplugins/action/plugin-tmpl/go.sum +++ b/contrib/grpcplugins/action/plugin-tmpl/go.sum @@ -192,10 +192,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -293,6 +297,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -304,6 +309,12 @@ github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= diff --git a/contrib/grpcplugins/action/plugin-venom/go.mod b/contrib/grpcplugins/action/plugin-venom/go.mod index 846bdbaad5..313297a257 100644 --- a/contrib/grpcplugins/action/plugin-venom/go.mod +++ b/contrib/grpcplugins/action/plugin-venom/go.mod @@ -42,7 +42,9 @@ require ( github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect @@ -90,6 +92,9 @@ require ( github.com/spf13/cast v1.4.1 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect github.com/yesnault/go-imap v0.0.0-20160710142244-eb9bbb66bd7b // indirect diff --git a/contrib/grpcplugins/action/plugin-venom/go.sum b/contrib/grpcplugins/action/plugin-venom/go.sum index 79485c113a..c7d40fff99 100644 --- a/contrib/grpcplugins/action/plugin-venom/go.sum +++ b/contrib/grpcplugins/action/plugin-venom/go.sum @@ -222,10 +222,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= @@ -370,6 +374,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -387,6 +392,12 @@ github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6e 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/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= diff --git a/tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod b/tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod index 408a4d7702..c6f75242a5 100644 --- a/tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod +++ b/tests/fixtures/04SCWorkflowRunSimplePlugin/go.mod @@ -27,7 +27,9 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/gookit/color v1.4.2 // indirect github.com/huandu/xstrings v1.2.0 // indirect + github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/invopop/jsonschema v0.6.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jfrog/gofrog v1.0.6 // indirect github.com/jfrog/jfrog-client-go v1.5.1 // indirect @@ -57,6 +59,9 @@ require ( github.com/spf13/cast v1.4.1 // indirect github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum b/tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum index 1562efd1ff..cc108bd07b 100644 --- a/tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum +++ b/tests/fixtures/04SCWorkflowRunSimplePlugin/go.sum @@ -192,10 +192,14 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 h1:i462o439ZjprVSFSZLZxcsoAe592sZB1rci2Z8j4wdk= +github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/jsonschema v0.6.0 h1:8e+xY8ZEn8gDHUYylSlLHy22P+SLeIRIHv3nM3hCbmY= +github.com/invopop/jsonschema v0.6.0/go.mod h1:O9uiLokuu0+MGFlyiaqtWxwqJm41/+8Nj0lD7A36YH0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -293,6 +297,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -304,6 +309,12 @@ github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= From edfa45f9550d8fb3da9847bc4b0fd5ea2b01ea7d Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Thu, 8 Sep 2022 17:57:48 +0200 Subject: [PATCH 11/15] fix: unit test --- engine/api/v2_worker_model_template_test.go | 11 +++++------ engine/api/v2_worker_model_test.go | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/engine/api/v2_worker_model_template_test.go b/engine/api/v2_worker_model_template_test.go index 5816858247..795ab2ee26 100644 --- a/engine/api/v2_worker_model_template_test.go +++ b/engine/api/v2_worker_model_template_test.go @@ -55,7 +55,8 @@ func TestGetWorkerModelTemplatesHandler(t *testing.T) { ProjectRepositoryID: repo.ID, ProjectKey: p.Key, Data: `name: docker-unix -docker: +type: docker +spec: cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker shell: sh -c envs: @@ -71,7 +72,8 @@ docker: ProjectRepositoryID: repo.ID, ProjectKey: p.Key, Data: `name: openstack-debian -vm: +type: vm +spec: pre_cmd: apt-get install docker-ce. cmd: ./worker post_cmd: sudo shutdown -h now`, @@ -116,8 +118,5 @@ vm: require.NoError(t, json.Unmarshal(bodyOne, &tmplsOne)) require.Equal(t, 1, len(tmplsOne)) - require.NotNil(t, tmplsOne[0].Docker) - require.Equal(t, "curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker", tmplsOne[0].Docker.Cmd) - require.Equal(t, "sh -c", tmplsOne[0].Docker.Shell) - require.Equal(t, 1, len(tmplsOne[0].Docker.Envs)) + require.Equal(t, "docker", tmplsOne[0].Type) } diff --git a/engine/api/v2_worker_model_test.go b/engine/api/v2_worker_model_test.go index a2677404cb..11ae0d0f13 100644 --- a/engine/api/v2_worker_model_test.go +++ b/engine/api/v2_worker_model_test.go @@ -55,7 +55,8 @@ func TestGetV2WorkerModelsHandler(t *testing.T) { ProjectRepositoryID: repo.ID, ProjectKey: p.Key, Data: `name: docker-unix -docker: +type: docker +spec: image: monimage cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker shell: sh -c @@ -72,7 +73,8 @@ docker: ProjectRepositoryID: repo.ID, ProjectKey: p.Key, Data: `name: openstack-debian -vm: +type: openstack +spec: image: monimage flavor: maflavor pre_cmd: apt-get install docker-ce. @@ -119,8 +121,5 @@ vm: require.NoError(t, json.Unmarshal(bodyOne, &wm)) require.Equal(t, 1, len(wm)) - require.NotNil(t, wm[0].Docker) - require.Equal(t, "curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker", wm[0].Docker.Cmd) - require.Equal(t, "sh -c", wm[0].Docker.Shell) - require.Equal(t, 1, len(wm[0].Docker.Envs)) + require.Equal(t, "docker", wm[0].Type) } From f74383b415d4ffb3bbdbee1216a4725c17563de0 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Fri, 9 Sep 2022 09:35:50 +0200 Subject: [PATCH 12/15] fix: remove internat server error from error --- engine/api/v2_repository_analyze.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/engine/api/v2_repository_analyze.go b/engine/api/v2_repository_analyze.go index 3d1e89db34..1ca73c4fba 100644 --- a/engine/api/v2_repository_analyze.go +++ b/engine/api/v2_repository_analyze.go @@ -650,10 +650,8 @@ func (api *API) getCdsArchiveFileOnRepo(ctx context.Context, repo sdk.ProjectRep } func (api *API) stopAnalysis(ctx context.Context, analysis *sdk.ProjectRepositoryAnalysis, originalErrors ...error) error { - me := sdk.MultiError{} for _, e := range originalErrors { log.ErrorWithStackTrace(ctx, e) - me.Append(e) } tx, err := api.mustDB().Begin() if err != nil { @@ -662,7 +660,12 @@ func (api *API) stopAnalysis(ctx context.Context, analysis *sdk.ProjectRepositor defer tx.Rollback() // nolint analysis.Status = sdk.RepositoryAnalysisStatusError - analysis.Data.Error = fmt.Sprintf("%s", me.Error()) + + analysisErrors := make([]string, 0, len(originalErrors)) + for _, e := range originalErrors { + analysisErrors = append(analysisErrors, e.Error()) + } + analysis.Data.Error = fmt.Sprintf("%s", strings.Join(analysisErrors, ", ")) if err := repository.UpdateAnalysis(ctx, tx, analysis); err != nil { return err } From e758ce1dab28d37d8b898491824e35ee5c876c97 Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Fri, 9 Sep 2022 11:40:50 +0200 Subject: [PATCH 13/15] fix: add enum on type --- sdk/v2_worker_model.go | 12 +++++------ sdk/v2_worker_model_test.go | 21 +++++++++++++++++++ sdk/worker_model_template.go | 12 +++++------ sdk/worker_model_template_test.go | 16 ++++++++++++++ .../worker-model-template/tmpl-docker.yml | 3 ++- .../fixtures/worker-model/docker-debian9.yml | 3 ++- 6 files changed, 53 insertions(+), 14 deletions(-) diff --git a/sdk/v2_worker_model.go b/sdk/v2_worker_model.go index f0236447a9..6a2b6765c1 100644 --- a/sdk/v2_worker_model.go +++ b/sdk/v2_worker_model.go @@ -7,20 +7,20 @@ import ( ) type V2WorkerModel struct { - Name string `json:"name" cli:"name" jsonschema:"required"` + Name string `json:"name" cli:"name" jsonschema:"required,minLength=1"` From string `json:"from"` Description string `json:"description,omitempty"` - Type string `json:"type" cli:"type" jsonschema:"required"` + Type string `json:"type" cli:"type" jsonschema:"required,enum=docker,enum=openstack,enum=vsphere"` Spec json.RawMessage `json:"spec" jsonschema:"required" jsonschema_allof_type:"type=docker:#/$defs/V2WorkerModelDockerSpec,type=openstack:#/$defs/V2WorkerModelOpenstackSpec,type=vsphere:#/$defs/V2WorkerModelVSphereSpec"` } type V2WorkerModelDockerSpec struct { - Image string `json:"image" jsonschema:"required"` - Registry string `json:"registry,omitempty" jsonschema:"required"` + Image string `json:"image" jsonschema:"required,minLength=1"` + Registry string `json:"registry,omitempty" jsonschema:"required,minLength=1"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` - Cmd string `json:"cmd,omitempty" jsonschema:"required"` - Shell string `json:"shell,omitempty" jsonschema:"required"` + Cmd string `json:"cmd,omitempty" jsonschema:"required,minLength=1"` + Shell string `json:"shell,omitempty" jsonschema:"required,minLength=1"` Envs map[string]string `json:"envs,omitempty"` } diff --git a/sdk/v2_worker_model_test.go b/sdk/v2_worker_model_test.go index 185a7764ed..d64eb43de9 100644 --- a/sdk/v2_worker_model_test.go +++ b/sdk/v2_worker_model_test.go @@ -29,6 +29,27 @@ spec: require.Contains(t, fmt.Sprintf("%v", err), "image is required") } +func TestWorkerDockerModelWrongType(t *testing.T) { + dockerWM := `name: debian9 +image: debian:9 +description: "my debian worker model" +type: marathon +spec: + envs: + CDS_GRAYLOG_EXTRA_KEY: '{{.GraylogExtraKey}}' + CDS_GRAYLOG_EXTRA_VALUE: '{{.GraylogExtraValue}}' + CDS_GRAYLOG_HOST: '{{.GraylogHost}}' + CDS_GRAYLOG_PORT: '{{.GraylogPort}}' + cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker` + + var dockerModel V2WorkerModel + require.NoError(t, yaml.Unmarshal([]byte(dockerWM), &dockerModel)) + + err := dockerModel.Lint() + require.NotEqual(t, 0, len(err)) + require.Contains(t, fmt.Sprintf("%v", err), "type must be one of the following") +} + func TestWorkerDockerModelOK(t *testing.T) { dockerWM := `name: debian9 image: debian:9 diff --git a/sdk/worker_model_template.go b/sdk/worker_model_template.go index 055a3f3a9c..764acac5b2 100644 --- a/sdk/worker_model_template.go +++ b/sdk/worker_model_template.go @@ -8,21 +8,21 @@ import ( ) type WorkerModelTemplate struct { - Name string `json:"name" cli:"mane" jsonschema:"required"` - Type string `json:"type" cli:"type" jsonschema:"required"` + Name string `json:"name" cli:"mane" jsonschema:"required,minLength=1"` + Type string `json:"type" cli:"type" jsonschema:"required,enum=docker,enum=vm"` Spec json.RawMessage `json:"spec" jsonschema:"required" jsonschema_allof_type:"type=docker:#/$defs/WorkerModelTemplateDocker,type=vm:#/$defs/WorkerModelTemplateVM"` } type WorkerModelTemplateDocker struct { - Cmd string `json:"cmd" jsonschema:"required"` - Shell string `json:"shell" jsonschema:"required"` + Cmd string `json:"cmd" jsonschema:"required,minLength=1"` + Shell string `json:"shell" jsonschema:"required,minLength=1"` Envs map[string]string `json:"envs,omitempty"` } type WorkerModelTemplateVM struct { - Cmd string `json:"cmd" jsonschema:"required"` + Cmd string `json:"cmd" jsonschema:"required,minLength=1"` PreCmd string `json:"pre_cmd,omitempty"` - PostCmd string `json:"post_cmd" jsonschema:"required"` + PostCmd string `json:"post_cmd" jsonschema:"required,minLength=1"` } func (wmt WorkerModelTemplate) Lint() []error { diff --git a/sdk/worker_model_template_test.go b/sdk/worker_model_template_test.go index 9380526d34..eedcd8c23c 100644 --- a/sdk/worker_model_template_test.go +++ b/sdk/worker_model_template_test.go @@ -24,6 +24,22 @@ spec: require.Contains(t, fmt.Sprintf("%v", err), "cmd is required") } +func TestWorkerModelTemplateDockerWrongType(t *testing.T) { + tmpl := `name: debian9 +description: "my debian worker model" +type: marathon +spec: + shell: sh -c +` + + var wmTemplate WorkerModelTemplate + require.NoError(t, yaml.Unmarshal([]byte(tmpl), &wmTemplate)) + + err := wmTemplate.Lint() + require.NotEqual(t, 0, len(err)) + require.Contains(t, fmt.Sprintf("%v", err), "type must be one of the following") +} + func TestWorkerModelTemplateDockerOK(t *testing.T) { tmpl := `name: debian9 description: "my debian worker model" diff --git a/tests/fixtures/worker-model-template/tmpl-docker.yml b/tests/fixtures/worker-model-template/tmpl-docker.yml index 30d82364f7..5fec35413b 100644 --- a/tests/fixtures/worker-model-template/tmpl-docker.yml +++ b/tests/fixtures/worker-model-template/tmpl-docker.yml @@ -1,5 +1,6 @@ name: docker-unix -docker: +type: docker +spec: cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker shell: sh -c envs: diff --git a/tests/fixtures/worker-model/docker-debian9.yml b/tests/fixtures/worker-model/docker-debian9.yml index 8fcb7c09a5..85d2800624 100644 --- a/tests/fixtures/worker-model/docker-debian9.yml +++ b/tests/fixtures/worker-model/docker-debian9.yml @@ -1,6 +1,7 @@ name: docker-debian description: my debian worker model -docker: +type: docker +spec: image: myimage:1.1 registry: http://my-registry:9000 cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker From ad8bf36694fa44f1b751806a943b77d69c8c157f Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Fri, 9 Sep 2022 13:50:57 +0200 Subject: [PATCH 14/15] fix: unit test --- engine/api/v2_repository_analyze_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/engine/api/v2_repository_analyze_test.go b/engine/api/v2_repository_analyze_test.go index 1a49f1eb6b..fb6f3a8820 100644 --- a/engine/api/v2_repository_analyze_test.go +++ b/engine/api/v2_repository_analyze_test.go @@ -618,7 +618,8 @@ GDFkaTe3nUJdYV4= model := `name: docker-debian description: my debian worker model -docker: +type: docker +spec: image: myimage:1.1 registry: http://my-registry:9000 cmd: curl {{.API}}/download/worker/linux/$(uname -m) -o worker && chmod +x worker && exec ./worker @@ -630,10 +631,11 @@ docker: encodedModel := base64.StdEncoding.EncodeToString([]byte(model)) modelTemplate := `name: openstack-debian -openstack: - pre_cmd: apt-get install docker-ce - cmd: ./worker - post_cmd: sudo shutdown -h now` +type: vm +spec: + pre_cmd: apt-get install docker-ce + cmd: ./worker + post_cmd: sudo shutdown -h now` encodedTemplate := base64.StdEncoding.EncodeToString([]byte(modelTemplate)) servicesClients.EXPECT(). From 36925efb4aa9e549500038578921423ee22b440f Mon Sep 17 00:00:00 2001 From: Steven Guiheux Date: Mon, 12 Sep 2022 10:24:37 +0200 Subject: [PATCH 15/15] fix: cli annotation --- sdk/worker_model_template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/worker_model_template.go b/sdk/worker_model_template.go index 764acac5b2..72205b6092 100644 --- a/sdk/worker_model_template.go +++ b/sdk/worker_model_template.go @@ -8,7 +8,7 @@ import ( ) type WorkerModelTemplate struct { - Name string `json:"name" cli:"mane" jsonschema:"required,minLength=1"` + Name string `json:"name" cli:"name" jsonschema:"required,minLength=1"` Type string `json:"type" cli:"type" jsonschema:"required,enum=docker,enum=vm"` Spec json.RawMessage `json:"spec" jsonschema:"required" jsonschema_allof_type:"type=docker:#/$defs/WorkerModelTemplateDocker,type=vm:#/$defs/WorkerModelTemplateVM"` }