From 23e08667c6574803f070acc9e3229320b509dfaf Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Mon, 28 Mar 2022 14:36:57 +0200 Subject: [PATCH] refactor(cdn,sdk,cdsctl): remove old artifacts engine (#6117) Signed-off-by: Yvonnick Esnault --- cli/cdsctl/workflow_artifact.go | 233 +---------------- contrib/actions/cds-go-build.yml | 2 +- contrib/actions/cds-split-upload.yml | 4 +- engine/cdn/cdn_router.go | 2 - engine/cdn/item_upload.go | 1 - engine/cdn/migrate_handler.go | 71 ------ engine/hatchery/marathon/helper_test.go | 2 +- engine/hatchery/marathon/marathon_test.go | 6 +- engine/hatchery/swarm/helper_test.go | 4 +- engine/hatchery/swarm/swarm_test.go | 74 +++--- engine/hatchery/swarm/swarm_util_logs_test.go | 10 +- engine/hatchery/swarm/swarm_util_pull_test.go | 22 +- sdk/cdsclient/client_queue.go | 238 ------------------ sdk/cdsclient/client_workflow.go | 145 ----------- sdk/cdsclient/interface.go | 9 - .../mock_cdsclient/interface_mock.go | 224 +---------------- 16 files changed, 64 insertions(+), 983 deletions(-) delete mode 100644 engine/cdn/migrate_handler.go diff --git a/cli/cdsctl/workflow_artifact.go b/cli/cdsctl/workflow_artifact.go index bcfbf8cae3..00303984cd 100644 --- a/cli/cdsctl/workflow_artifact.go +++ b/cli/cdsctl/workflow_artifact.go @@ -2,7 +2,6 @@ package main import ( "context" - "encoding/json" "fmt" "os" "regexp" @@ -12,7 +11,6 @@ import ( "github.com/ovh/cds/cli" "github.com/ovh/cds/sdk" - "github.com/ovh/cds/sdk/cdn" ) var workflowArtifactCmd = cli.Command{ @@ -23,141 +21,10 @@ var workflowArtifactCmd = cli.Command{ func workflowArtifact() *cobra.Command { return cli.NewCommand(workflowArtifactCmd, nil, []*cobra.Command{ - cli.NewListCommand(workflowArtifactListCmd, workflowArtifactListRun, nil, withAllCommandModifiers()...), cli.NewCommand(workflowArtifactDownloadCmd, workflowArtifactDownloadRun, nil, withAllCommandModifiers()...), - cli.NewCommand(workflowArtifactCDNMigrateCmd, workflowArtifactCDNMigrate, nil, withAllCommandModifiers()...), }) } -var workflowArtifactCDNMigrateCmd = cli.Command{ - Name: "cdn-migrate", - Short: "Migrate artifact into CDN", - Long: `Migrate artifact from CDS to CDN -cdsctl workflow artifact cdn-migrate - -CDN does not manage artifact with same name inside a run. They will be renamed _ -Migrated artifacts will not be visible with cdsctl workflow result command -`, - Ctx: []cli.Arg{ - {Name: _ProjectKey}, - {Name: _WorkflowName}, - }, - Args: []cli.Arg{ - {Name: "number"}, - }, -} - -func workflowArtifactCDNMigrate(v cli.Values) error { - number, err := strconv.ParseInt(v.GetString("number"), 10, 64) - if err != nil { - return cli.NewError("number parameter have to be an integer") - } - projKey := v.GetString(_ProjectKey) - wName := v.GetString(_WorkflowName) - - run, err := client.WorkflowRunGet(projKey, wName, number) - if err != nil { - return err - } - - workflowArtifacts, err := client.WorkflowRunArtifacts(projKey, wName, number) - if err != nil { - return err - } - - artName := make(map[string]int64) - for _, art := range workflowArtifacts { - prefix := "" - nb, has := artName[art.Name] - if has { - prefix = fmt.Sprintf("%d_", nb) - fmt.Printf("%s/%s will be renamed to %s%s\n", art.Name, art.Tag, prefix, art.Name) - - } - artName[art.Name] = nb + 1 - artName := prefix + art.Name - // Call cdn to migrate - sign := cdn.Signature{ - ProjectKey: projKey, - WorkflowName: wName, - WorkflowID: run.WorkflowID, - RunID: art.WorkflowID, - RunNumber: run.Number, - NodeRunID: art.WorkflowNodeRunID, - JobName: "", - JobID: 0, - Worker: &cdn.SignatureWorker{ - FileName: artName, - FilePerm: art.Perm, - RunResultType: string(sdk.CDNTypeItemRunResult), - }, - } - - // call cdn - url := fmt.Sprintf("/migrate/artifact/%s/%s/%d", projKey, wName, art.ID) - bts, _ := json.Marshal(sign) - if bts, err := client.ServiceCallPOST(sdk.TypeCDN, url, bts); err != nil { - fmt.Printf("unable to migrate %s: %s: %v\n", art.Name, string(bts), err) - continue - } - fmt.Printf("artifact %s migrated\n", artName) - - } - fmt.Printf("Migration done.") - return nil -} - -var workflowArtifactListCmd = cli.Command{ - Name: "list", - Short: "List artifacts of one Workflow Run", - Ctx: []cli.Arg{ - {Name: _ProjectKey}, - {Name: _WorkflowName}, - }, - Args: []cli.Arg{ - {Name: "number"}, - }, -} - -func workflowArtifactListRun(v cli.Values) (cli.ListResult, error) { - number, err := strconv.ParseInt(v.GetString("number"), 10, 64) - if err != nil { - return nil, cli.NewError("number parameter have to be an integer") - } - - workflowArtifacts, err := client.WorkflowRunArtifacts(v.GetString(_ProjectKey), v.GetString(_WorkflowName), number) - if err != nil { - return nil, err - } - - results, err := client.WorkflowRunResultsList(context.Background(), v.GetString(_ProjectKey), v.GetString(_WorkflowName), number) - if err != nil { - return nil, err - } - - type Artifact struct { - Name string `cli:"name"` - Md5 string `cli:"md5"` - } - - artifacts := make([]Artifact, 0, len(workflowArtifacts)) - for _, art := range workflowArtifacts { - artifacts = append(artifacts, Artifact{Name: art.Name, Md5: art.MD5sum}) - } - for _, runResult := range results { - if runResult.Type != sdk.WorkflowRunResultTypeArtifact { - continue - } - artiData, err := runResult.GetArtifact() - if err != nil { - return nil, err - } - artifacts = append(artifacts, Artifact{Name: artiData.Name, Md5: artiData.MD5}) - } - - return cli.AsListResult(artifacts), nil -} - var workflowArtifactDownloadCmd = cli.Command{ Name: "download", Short: "Download artifacts of one Workflow Run", @@ -200,14 +67,6 @@ func workflowArtifactDownloadRun(v cli.Values) error { cdnURL = confCDN.HTTPURL } - ok, err := downloadFromCDSAPI(v, number) - if err != nil { - return err - } - if ok { - return nil - } - // Search in result results, err := client.WorkflowRunResultsList(context.Background(), v.GetString(_ProjectKey), v.GetString(_WorkflowName), number) if err != nil { @@ -222,6 +81,7 @@ func workflowArtifactDownloadRun(v cli.Values) error { return cli.WrapError(err, "exclude parameter is not valid") } } + var ok bool for _, runResult := range results { if runResult.Type != sdk.WorkflowRunResultTypeArtifact { continue @@ -288,94 +148,3 @@ func workflowArtifactDownloadRun(v cli.Values) error { } return nil } - -func downloadFromCDSAPI(v cli.Values, number int64) (bool, error) { - artifacts, err := client.WorkflowRunArtifacts(v.GetString(_ProjectKey), v.GetString(_WorkflowName), number) - if err != nil { - return false, err - } - - var reg *regexp.Regexp - if len(v.GetString("exclude")) > 0 { - var err error - reg, err = regexp.Compile(v.GetString("exclude")) - if err != nil { - return false, cli.WrapError(err, "exclude parameter is not valid") - } - } - - var ok bool - - for _, a := range artifacts { - if v.GetString("artifact-name") != "" && v.GetString("artifact-name") != a.Name { - continue - } - if v.GetString("exclude") != "" && reg.MatchString(a.Name) { - fmt.Printf("File %s is excluded from download\n", a.Name) - continue - } - - var f *os.File - var toDownload bool - if _, err := os.Stat(a.Name); os.IsNotExist(err) { - toDownload = true - } else { - // file exists, check sha512 - var errf error - f, errf = os.OpenFile(a.Name, os.O_RDWR|os.O_CREATE, os.FileMode(a.Perm)) - if errf != nil { - return ok, errf - } - sha512sum, err512 := sdk.FileSHA512sum(a.Name) - if err512 != nil { - return ok, err512 - } - - if sha512sum != a.SHA512sum { - toDownload = true - } - } - - if toDownload { - var errf error - f, errf = os.OpenFile(a.Name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.FileMode(a.Perm)) - if errf != nil { - return ok, errf - } - fmt.Printf("Downloading %s...\n", a.Name) - if err := client.WorkflowNodeRunArtifactDownload(v.GetString(_ProjectKey), v.GetString(_WorkflowName), a, f); err != nil { - return ok, err - } - if err := f.Close(); err != nil { - return ok, err - } - } - - sha512sum, err512 := sdk.FileSHA512sum(a.Name) - if err512 != nil { - return ok, err512 - } - - if sha512sum != a.SHA512sum { - return ok, cli.NewError("Invalid sha512sum \ndownloaded file:%s\n%s:%s", sha512sum, f.Name(), a.SHA512sum) - } - - md5sum, errmd5 := sdk.FileMd5sum(a.Name) - if errmd5 != nil { - return ok, errmd5 - } - - if md5sum != a.MD5sum { - return ok, cli.NewError("Invalid md5sum \ndownloaded file:%s\n%s:%s", md5sum, f.Name(), a.MD5sum) - } - - if toDownload { - fmt.Printf("File %s created, checksum OK\n", f.Name()) - } else { - fmt.Printf("File %s already downloaded, checksum OK\n", f.Name()) - } - - ok = true - } - return ok, nil -} diff --git a/contrib/actions/cds-go-build.yml b/contrib/actions/cds-go-build.yml index d37650ea53..fc466cca01 100644 --- a/contrib/actions/cds-go-build.yml +++ b/contrib/actions/cds-go-build.yml @@ -92,7 +92,7 @@ steps: - " \techo \"File ${GOPATH}/src/{{.package}}/{{.binary}} not found!\"" - ' exit 1;' - "\tfi" - - "\tworker upload --tag={{.cds.version}} \"${GOPATH}/src/{{.package}}/{{.binary}}\"" + - "\tworker upload \"${GOPATH}/src/{{.package}}/{{.binary}}\"" - else - "\techo \"artifact upload: {{.artifactUpload}}. So, artifact is not uploaded\"" - fi; diff --git a/contrib/actions/cds-split-upload.yml b/contrib/actions/cds-split-upload.yml index 1c159eb0f7..d079616caf 100644 --- a/contrib/actions/cds-split-upload.yml +++ b/contrib/actions/cds-split-upload.yml @@ -55,11 +55,11 @@ steps: - 'worker export ${SOURCE}_md5 $x' - "" - 'echo -e "\n$x > ${SOURCE}-md5"' - - 'worker upload --tag={{.cds.version}} ${SOURCE}-md5' + - 'worker upload ${SOURCE}-md5' - "" - echo -e "\n" - 'split --verbose --bytes={{.splitSize}} ${ARGS} ${SOURCE} ${PREFIX_HANDLE}-' - "" - echo -e "\n" - - 'worker upload --tag=${TAG} ./${PREFIX_HANDLE}-*' + - 'worker upload ./${PREFIX_HANDLE}-*' - "" diff --git a/engine/cdn/cdn_router.go b/engine/cdn/cdn_router.go index bb5460f473..60350eb4ba 100644 --- a/engine/cdn/cdn_router.go +++ b/engine/cdn/cdn_router.go @@ -38,8 +38,6 @@ func (s *Service) initRouter(ctx context.Context) { r.Handle("/item/{type}/{apiRef}/download/{unit}", nil, r.GET(s.getItemDownloadInUnitHandler, service.OverrideAuth(s.itemAccessMiddleware))) r.Handle("/item/{type}/{apiRef}/lines", nil, r.GET(s.getItemLogsLinesHandler, service.OverrideAuth(s.itemAccessMiddleware))) - r.Handle("/migrate/artifact/{projectKey}/{workflowName}/{artifactID}", nil, r.POST(s.migrateArtifactInCDNHandler)) - r.Handle("/unit", nil, r.GET(s.getUnitsHandler)) r.Handle("/unit/{id}", nil, r.DELETE(s.deleteUnitHandler)) r.Handle("/unit/{id}/item", nil, r.DELETE(s.markItemUnitAsDeleteHandler)) diff --git a/engine/cdn/item_upload.go b/engine/cdn/item_upload.go index 4eae33d353..64c7d90440 100644 --- a/engine/cdn/item_upload.go +++ b/engine/cdn/item_upload.go @@ -6,7 +6,6 @@ import ( "github.com/ovh/cds/engine/service" "github.com/ovh/cds/sdk" - _ "github.com/ovh/cds/sdk" "github.com/ovh/cds/sdk/cdn" "github.com/ovh/cds/sdk/jws" ) diff --git a/engine/cdn/migrate_handler.go b/engine/cdn/migrate_handler.go deleted file mode 100644 index 47e24ee41c..0000000000 --- a/engine/cdn/migrate_handler.go +++ /dev/null @@ -1,71 +0,0 @@ -package cdn - -import ( - "context" - "fmt" - "io" - "net/http" - "strconv" - - "github.com/gorilla/mux" - - "github.com/ovh/cds/engine/service" - "github.com/ovh/cds/sdk" - "github.com/ovh/cds/sdk/cdn" -) - -func (s *Service) migrateArtifactInCDNHandler() service.Handler { - return func(ctx context.Context, w http.ResponseWriter, r *http.Request) error { - vars := mux.Vars(r) - projectKey := vars["projectKey"] - workflowName := vars["workflowName"] - - artifactIDS := vars["artifactID"] - artifactID, err := strconv.ParseInt(artifactIDS, 10, 64) - if err != nil { - return sdk.NewErrorFrom(sdk.ErrInvalidData, "wrong artifact id") - } - - var sign cdn.Signature - if err := service.UnmarshalBody(r, &sign); err != nil { - return err - } - - nodeRun, err := s.Client.WorkflowNodeRun(projectKey, workflowName, sign.RunNumber, sign.NodeRunID) - if err != nil { - return err - } - - if sign.WorkflowID != nodeRun.WorkflowID || sign.NodeRunID != nodeRun.ID || sign.RunID != nodeRun.WorkflowRunID || nodeRun.Number != sign.RunNumber { - return sdk.NewErrorFrom(sdk.ErrInvalidData, "signature doesn't match request") - } - - // Check if artifact exist - found := false - for _, a := range nodeRun.Artifacts { - if a.ID == artifactID { - found = true - break - } - } - if !found { - return sdk.NewErrorFrom(sdk.ErrNotFound, "unable to find artifact in the given run") - } - - // Retrieve Artifact from CDS API - url := fmt.Sprintf("/project/%s/workflows/%s/artifact/%d", projectKey, workflowName, artifactID) - readcloser, _, code, err := s.Client.Stream(ctx, s.Client.HTTPNoTimeoutClient(), "GET", url, nil) - if err != nil { - return sdk.WithStack(err) - } - if code >= 400 { - var bodyBtes []byte - bodyBtes, errR := io.ReadAll(readcloser) - if errR != nil { - return errR - } - return sdk.NewErrorFrom(sdk.ErrUnknownError, "unable to get artifact: %s", string(bodyBtes)) - } - return s.storeFile(ctx, sign, readcloser, StoreFileOptions{DisableApiRunResult: true}) - } -} diff --git a/engine/hatchery/marathon/helper_test.go b/engine/hatchery/marathon/helper_test.go index 9cc10340b6..50ca488082 100644 --- a/engine/hatchery/marathon/helper_test.go +++ b/engine/hatchery/marathon/helper_test.go @@ -38,7 +38,7 @@ func InitMarathonMarathonTest(opts marathonJDD) *HatcheryMarathon { if opts.WorkerSpawnTimeout > 0 { h.Config.WorkerSpawnTimeout = opts.WorkerSpawnTimeout } - h.Client = cdsclient.New(cdsclient.Config{Host: "http://lolcat.host", InsecureSkipVerifyTLS: false}) + h.Client = cdsclient.New(cdsclient.Config{Host: "http://cds-api.local", InsecureSkipVerifyTLS: false}) gock.InterceptClient(h.Client.(cdsclient.Raw).HTTPClient()) return h } diff --git a/engine/hatchery/marathon/marathon_test.go b/engine/hatchery/marathon/marathon_test.go index 05c58bfcfa..065bb0e613 100644 --- a/engine/hatchery/marathon/marathon_test.go +++ b/engine/hatchery/marathon/marathon_test.go @@ -39,7 +39,7 @@ func TestWorkerStarted(t *testing.T) { gock.New("http://mara.thon").Get("/v2/apps").Reply(200).JSON(apps) wkrs, err := h.WorkersStarted(context.TODO()) - require.NoError(t, err) + require.NoError(t, err) t.Logf("%+v", wkrs) assert.Equal(t, 2, len(wkrs)) assert.Equal(t, "w1", wkrs[0]) @@ -73,7 +73,7 @@ func TestKillDisabledWorker(t *testing.T) { Status: sdk.StatusDisabled, }, } - gock.New("http://lolcat.host").Get("/worker").Reply(200).JSON(workers) + gock.New("http://cds-api.local").Get("/worker").Reply(200).JSON(workers) apps := marathon.Applications{ Apps: []marathon.Application{ @@ -139,7 +139,7 @@ func TestKillAwolWOrkers(t *testing.T) { Status: sdk.StatusDisabled, }, } - gock.New("http://lolcat.host").Get("/worker").Reply(200).JSON(workers) + gock.New("http://cds-api.local").Get("/worker").Reply(200).JSON(workers) d := time.Now() d3 := d.Add(-3 * time.Minute) diff --git a/engine/hatchery/swarm/helper_test.go b/engine/hatchery/swarm/helper_test.go index da3a2c1a6e..165c0c7a8b 100644 --- a/engine/hatchery/swarm/helper_test.go +++ b/engine/hatchery/swarm/helper_test.go @@ -53,7 +53,7 @@ func InitTestHatcherySwarm(t *testing.T) *HatcherySwarm { httpClient := cdsclient.NewHTTPClient(1*time.Minute, false) c, err := docker.NewClientWithOpts( docker.WithHTTPClient(httpClient), - docker.WithHost("https://lolcat.host"), + docker.WithHost("https://lolcat.local"), docker.WithVersion("6.66"), ) require.NoError(t, err) @@ -74,7 +74,7 @@ func InitTestHatcherySwarm(t *testing.T) *HatcherySwarm { } h.dockerClients["default"] = &dockerClient{Client: *c, name: "default"} - h.Client = cdsclient.New(cdsclient.Config{Host: "https://lolcat.api"}) + h.Client = cdsclient.New(cdsclient.Config{Host: "https://cds-api.local"}) gock.InterceptClient(h.Client.HTTPClient()) return h } diff --git a/engine/hatchery/swarm/swarm_test.go b/engine/hatchery/swarm/swarm_test.go index ff19eed16e..bb712eae60 100644 --- a/engine/hatchery/swarm/swarm_test.go +++ b/engine/hatchery/swarm/swarm_test.go @@ -23,9 +23,9 @@ func TestHatcherySwarm_KillAwolNetwork(t *testing.T) { h.Config.Name = "swarmy" containers := []types.Container{} - gock.New("https://lolcat.host").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) + gock.New("https://lolcat.local").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) workers := []sdk.Worker{} - gock.New("https://lolcat.api").Get("/worker").Reply(200).JSON(workers) + gock.New("https://cds-api.local").Get("/worker").Reply(200).JSON(workers) // AWOL Network net := []types.NetworkResource{ @@ -66,15 +66,15 @@ func TestHatcherySwarm_KillAwolNetwork(t *testing.T) { Created: time.Now().Add(-11 * time.Minute), }, } - gock.New("https://lolcat.host").Get("/v6.66/networks").Reply(http.StatusOK).JSON(net) - gock.New("https://lolcat.host").Get("/v6.66/networks/net-1").Reply(http.StatusOK).JSON(net[0]) - gock.New("https://lolcat.host").Get("/v6.66/networks/net-2").Reply(http.StatusOK).JSON(net[1]) - gock.New("https://lolcat.host").Get("/v6.66/networks/net-3").Reply(http.StatusOK).JSON(net[2]) - gock.New("https://lolcat.host").Get("/v6.66/networks/net-4").Reply(http.StatusOK).JSON(net[3]) - gock.New("https://lolcat.host").Get("/v6.66/networks/net-5").Reply(http.StatusOK).JSON(net[4]) + gock.New("https://lolcat.local").Get("/v6.66/networks").Reply(http.StatusOK).JSON(net) + gock.New("https://lolcat.local").Get("/v6.66/networks/net-1").Reply(http.StatusOK).JSON(net[0]) + gock.New("https://lolcat.local").Get("/v6.66/networks/net-2").Reply(http.StatusOK).JSON(net[1]) + gock.New("https://lolcat.local").Get("/v6.66/networks/net-3").Reply(http.StatusOK).JSON(net[2]) + gock.New("https://lolcat.local").Get("/v6.66/networks/net-4").Reply(http.StatusOK).JSON(net[3]) + gock.New("https://lolcat.local").Get("/v6.66/networks/net-5").Reply(http.StatusOK).JSON(net[4]) // JUJST DELETE NET-5 - gock.New("https://lolcat.host").Delete("/v6.66/networks/net-5").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Delete("/v6.66/networks/net-5").Reply(http.StatusOK).JSON(nil) err := h.killAwolWorker(context.TODO()) require.NoError(t, err) @@ -141,7 +141,7 @@ func TestHatcherySwarm_ListAwolWorker(t *testing.T) { }, }, } - gock.New("https://lolcat.host").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) + gock.New("https://lolcat.local").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) workers := []sdk.Worker{ { @@ -157,7 +157,7 @@ func TestHatcherySwarm_ListAwolWorker(t *testing.T) { Status: sdk.StatusDisabled, }, } - gock.New("https://lolcat.api").Get("/worker").Reply(200).JSON(workers) + gock.New("https://cds-api.local").Get("/worker").Reply(200).JSON(workers) c1 := types.ContainerJSON{ ContainerJSONBase: &types.ContainerJSONBase{ @@ -169,9 +169,9 @@ func TestHatcherySwarm_ListAwolWorker(t *testing.T) { }, }, } - gock.New("https://lolcat.host").Get("/v6.66/containers/swarmy-model1-w1/json").Reply(http.StatusOK).JSON(c1) - gock.New("https://lolcat.host").Post("/v6.66/containers/swarmy-model1-w1/kill").Reply(http.StatusOK).JSON(nil) - gock.New("https://lolcat.host").Delete("/v6.66/containers/swarmy-model1-w1").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Get("/v6.66/containers/swarmy-model1-w1/json").Reply(http.StatusOK).JSON(c1) + gock.New("https://lolcat.local").Post("/v6.66/containers/swarmy-model1-w1/kill").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Delete("/v6.66/containers/swarmy-model1-w1").Reply(http.StatusOK).JSON(nil) c4 := types.ContainerJSON{ ContainerJSONBase: &types.ContainerJSONBase{ @@ -189,9 +189,9 @@ func TestHatcherySwarm_ListAwolWorker(t *testing.T) { }, }, } - gock.New("https://lolcat.host").Get("/v6.66/containers/swarmy-model1-w4/json").Reply(http.StatusOK).JSON(c4) - gock.New("https://lolcat.host").Post("/v6.66/containers/swarmy-model1-w4/kill").Reply(http.StatusOK).JSON(nil) - gock.New("https://lolcat.host").Delete("/v6.66/containers/swarmy-model1-w4").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Get("/v6.66/containers/swarmy-model1-w4/json").Reply(http.StatusOK).JSON(c4) + gock.New("https://lolcat.local").Post("/v6.66/containers/swarmy-model1-w4/kill").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Delete("/v6.66/containers/swarmy-model1-w4").Reply(http.StatusOK).JSON(nil) // Network ns := []types.NetworkResource{ @@ -211,17 +211,17 @@ func TestHatcherySwarm_ListAwolWorker(t *testing.T) { }, }, } - gock.New("https://lolcat.host").Get("/v6.66/networks/net-1").Reply(http.StatusOK).JSON(ns[0]) - gock.New("https://lolcat.host").Get("/v6.66/networks/net-2").Reply(http.StatusOK).JSON(ns[1]) + gock.New("https://lolcat.local").Get("/v6.66/networks/net-1").Reply(http.StatusOK).JSON(ns[0]) + gock.New("https://lolcat.local").Get("/v6.66/networks/net-2").Reply(http.StatusOK).JSON(ns[1]) - gock.New("https://lolcat.host").Post("/v6.66/containers/net-1-ctn-1/kill").Reply(http.StatusOK).JSON(nil) - gock.New("https://lolcat.host").Delete("/v6.66/containers/net-1-ctn-1").Reply(http.StatusOK).JSON(nil) - gock.New("https://lolcat.host").Post("/v6.66/containers/net-1-ctn-2/kill").Reply(http.StatusOK).JSON(nil) - gock.New("https://lolcat.host").Delete("/v6.66/containers/net-1-ctn-2").Reply(http.StatusOK).JSON(nil) - gock.New("https://lolcat.host").Delete("/v6.66/networks/net-2").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Post("/v6.66/containers/net-1-ctn-1/kill").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Delete("/v6.66/containers/net-1-ctn-1").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Post("/v6.66/containers/net-1-ctn-2/kill").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Delete("/v6.66/containers/net-1-ctn-2").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Delete("/v6.66/networks/net-2").Reply(http.StatusOK).JSON(nil) net := []types.NetworkResource{} - gock.New("https://lolcat.host").Get("/v6.66/networks").Reply(http.StatusOK).JSON(net) + gock.New("https://lolcat.local").Get("/v6.66/networks").Reply(http.StatusOK).JSON(net) // Must keep: swarmy-model1-w2, swarmy-model1-w3, swarmy2-model1-w4 // Must delete: swarmy-model1-w1, swarmy-model1-w4 @@ -258,7 +258,7 @@ func TestHatcherySwarm_WorkersStarted(t *testing.T) { }, }, } - gock.New("https://lolcat.host").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) + gock.New("https://lolcat.local").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) s, err := h.WorkersStarted(context.TODO()) require.NoError(t, err) @@ -294,27 +294,27 @@ func TestHatcherySwarm_Spawn(t *testing.T) { }, }, } - gock.New("https://lolcat.host").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) + gock.New("https://lolcat.local").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) // SERVICE n := types.NetworkCreateResponse{ ID: "net-666", } - gock.New("https://lolcat.host").Post("/v6.66/networks/create").Reply(http.StatusOK).JSON(n) - gock.New("https://lolcat.host").Post("/v6.66/images/create").MatchParam("fromImage", "postgresql").MatchParam("tag", "5.6.6").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Post("/v6.66/networks/create").Reply(http.StatusOK).JSON(n) + gock.New("https://lolcat.local").Post("/v6.66/images/create").MatchParam("fromImage", "postgresql").MatchParam("tag", "5.6.6").Reply(http.StatusOK).JSON(nil) cService := container.ContainerCreateCreatedBody{ ID: "serviceIdContainer", } - gock.New("https://lolcat.host").Post("/v6.66/containers/create").MatchParam("name", "pg-*").Reply(http.StatusOK).JSON(cService) - gock.New("https://lolcat.host").Post("/v6.66/containers/serviceIdContainer/start").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Post("/v6.66/containers/create").MatchParam("name", "pg-*").Reply(http.StatusOK).JSON(cService) + gock.New("https://lolcat.local").Post("/v6.66/containers/serviceIdContainer/start").Reply(http.StatusOK).JSON(nil) // WORKER - gock.New("https://lolcat.host").Post("/v6.66/images/create").MatchParam("fromImage", "model").MatchParam("tag", "9").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Post("/v6.66/images/create").MatchParam("fromImage", "model").MatchParam("tag", "9").Reply(http.StatusOK).JSON(nil) cWorker := container.ContainerCreateCreatedBody{ ID: "workerIDContainer", } - gock.New("https://lolcat.host").Post("/v6.66/containers/create").MatchParam("name", "swarmy-*").Reply(http.StatusOK).JSON(cWorker) - gock.New("https://lolcat.host").Post("/v6.66/containers/workerIDContainer/start").Reply(http.StatusOK).JSON(nil) + gock.New("https://lolcat.local").Post("/v6.66/containers/create").MatchParam("name", "swarmy-*").Reply(http.StatusOK).JSON(cWorker) + gock.New("https://lolcat.local").Post("/v6.66/containers/workerIDContainer/start").Reply(http.StatusOK).JSON(nil) err := h.SpawnWorker(context.TODO(), hatchery.SpawnArguments{ JobID: 1, @@ -360,7 +360,7 @@ func TestHatcherySwarm_SpawnMaxContainerReached(t *testing.T) { }, }, } - gock.New("https://lolcat.host").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) + gock.New("https://lolcat.local").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) err := h.SpawnWorker(context.TODO(), hatchery.SpawnArguments{ JobID: 666, @@ -393,7 +393,7 @@ func TestHatcherySwarm_CanSpawn(t *testing.T) { Labels: map[string]string{}, }, } - gock.New("https://lolcat.host").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) + gock.New("https://lolcat.local").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) b := h.CanSpawn(context.TODO(), &m, jobID, []sdk.Requirement{}) assert.True(t, b) @@ -430,7 +430,7 @@ func TestHatcherySwarm_MaxContainerReached(t *testing.T) { }, } - gock.New("https://lolcat.host").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) + gock.New("https://lolcat.local").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) b := h.CanSpawn(context.TODO(), &m, jobID, []sdk.Requirement{}) assert.False(t, b) assert.True(t, gock.IsDone()) diff --git a/engine/hatchery/swarm/swarm_util_logs_test.go b/engine/hatchery/swarm/swarm_util_logs_test.go index f9c06c945f..c6beb1b0c9 100644 --- a/engine/hatchery/swarm/swarm_util_logs_test.go +++ b/engine/hatchery/swarm/swarm_util_logs_test.go @@ -31,9 +31,9 @@ func Test_serviceLogs(t *testing.T) { require.NoError(t, err) h.Common.PrivateKey = key - gock.New("https://lolcat.api").Get("/worker").Reply(http.StatusOK).JSON([]sdk.Worker{{Name: "swarmy-model1-w1"}}) + gock.New("https://cds-api.local").Get("/worker").Reply(http.StatusOK).JSON([]sdk.Worker{{Name: "swarmy-model1-w1"}}) - gock.New("https://lolcat.api").Get("/config/cdn").Reply(http.StatusOK).JSON(sdk.CDNConfig{TCPURL: "tcphost:8090"}) + gock.New("https://cds-api.local").Get("/config/cdn").Reply(http.StatusOK).JSON(sdk.CDNConfig{TCPURL: "tcphost:8090"}) require.NoError(t, h.RefreshServiceLogger(context.TODO())) containers := []types.Container{ @@ -64,12 +64,12 @@ func Test_serviceLogs(t *testing.T) { }, } - gock.New("https://lolcat.host").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) + gock.New("https://lolcat.local").Get("/v6.66/containers/json").Reply(http.StatusOK).JSON(containers) - gock.New("https://lolcat.host").AddMatcher(func(r *http.Request, rr *gock.Request) (bool, error) { + gock.New("https://lolcat.local").AddMatcher(func(r *http.Request, rr *gock.Request) (bool, error) { b, err := gock.MatchPath(r, rr) assert.NoError(t, err) - if r.Method == http.MethodGet && strings.HasPrefix(r.URL.String(), "https://lolcat.host/v6.66/containers/service-1/logs") { + if r.Method == http.MethodGet && strings.HasPrefix(r.URL.String(), "https://lolcat.local/v6.66/containers/service-1/logs") { if b { return true, nil } diff --git a/engine/hatchery/swarm/swarm_util_pull_test.go b/engine/hatchery/swarm/swarm_util_pull_test.go index 0370b54fc4..dcb487b3d8 100644 --- a/engine/hatchery/swarm/swarm_util_pull_test.go +++ b/engine/hatchery/swarm/swarm_util_pull_test.go @@ -19,11 +19,11 @@ func Test_pullImage(t *testing.T) { h := InitTestHatcherySwarm(t) - gock.New("https://lolcat.host").Post("/images/create").Times(5).AddMatcher(func(r *http.Request, rr *gock.Request) (bool, error) { + gock.New("https://lolcat.local").Post("/images/create").Times(5).AddMatcher(func(r *http.Request, rr *gock.Request) (bool, error) { values := r.URL.Query() // Call 1 - if values.Get("fromImage") == "my-registry.lolcat.host/my-image-1" && values.Get("tag") == "my-tag" { + if values.Get("fromImage") == "my-registry.lolcat.local/my-image-1" && values.Get("tag") == "my-tag" { return true, nil } // Call 2 @@ -39,13 +39,13 @@ func Test_pullImage(t *testing.T) { t.Log("Auth config", auth) // Call 3 - if values.Get("fromImage") == "my-first-registry.lolcat.host/my-image-3" && values.Get("tag") == "my-tag" && - auth.Username == "my-user" && auth.Password == "my-pass-1" && auth.ServerAddress == "my-first-registry.lolcat.host" { + if values.Get("fromImage") == "my-first-registry.lolcat.local/my-image-3" && values.Get("tag") == "my-tag" && + auth.Username == "my-user" && auth.Password == "my-pass-1" && auth.ServerAddress == "my-first-registry.lolcat.local" { return true, nil } // Call 4 - if values.Get("fromImage") == "my-second-registry.lolcat.host/my-image-4" && values.Get("tag") == "my-tag" && - auth.Username == "my-user" && auth.Password == "my-pass-2" && auth.ServerAddress == "my-second-registry.lolcat.host" { + if values.Get("fromImage") == "my-second-registry.lolcat.local/my-image-4" && values.Get("tag") == "my-tag" && + auth.Username == "my-user" && auth.Password == "my-pass-2" && auth.ServerAddress == "my-second-registry.lolcat.local" { return true, nil } // Call 5 @@ -56,7 +56,7 @@ func Test_pullImage(t *testing.T) { return false, nil }).Reply(http.StatusOK) - require.NoError(t, h.pullImage(h.dockerClients["default"], "my-registry.lolcat.host/my-image-1:my-tag", time.Minute, sdk.Model{})) + require.NoError(t, h.pullImage(h.dockerClients["default"], "my-registry.lolcat.local/my-image-1:my-tag", time.Minute, sdk.Model{})) require.NoError(t, h.pullImage(h.dockerClients["default"], "my-image-2:my-tag", time.Minute, sdk.Model{})) h.Config.RegistryCredentials = []RegistryCredential{ @@ -66,19 +66,19 @@ func Test_pullImage(t *testing.T) { Password: "my-pass", }, { - Domain: "my-first-registry.lolcat.host", + Domain: "my-first-registry.lolcat.local", Username: "my-user", Password: "my-pass-1", }, { - Domain: "^*.lolcat.host$", + Domain: "^*.lolcat.local$", Username: "my-user", Password: "my-pass-2", }, } - require.NoError(t, h.pullImage(h.dockerClients["default"], "my-first-registry.lolcat.host/my-image-3:my-tag", time.Minute, sdk.Model{})) - require.NoError(t, h.pullImage(h.dockerClients["default"], "my-second-registry.lolcat.host/my-image-4:my-tag", time.Minute, sdk.Model{})) + require.NoError(t, h.pullImage(h.dockerClients["default"], "my-first-registry.lolcat.local/my-image-3:my-tag", time.Minute, sdk.Model{})) + require.NoError(t, h.pullImage(h.dockerClients["default"], "my-second-registry.lolcat.local/my-image-4:my-tag", time.Minute, sdk.Model{})) require.NoError(t, h.pullImage(h.dockerClients["default"], "my-image-5:my-tag", time.Minute, sdk.Model{})) require.True(t, gock.IsDone()) diff --git a/sdk/cdsclient/client_queue.go b/sdk/cdsclient/client_queue.go index 990c0b5c4b..59463051c5 100644 --- a/sdk/cdsclient/client_queue.go +++ b/sdk/cdsclient/client_queue.go @@ -3,17 +3,9 @@ package cdsclient import ( "bytes" "context" - "encoding/base64" "encoding/json" "fmt" - "io" - "mime/multipart" - "net/http" "net/url" - "os" - "path/filepath" - "strconv" - "strings" "time" "github.com/ovh/cds/sdk" @@ -260,236 +252,6 @@ func (c *client) QueueSendStepResult(ctx context.Context, id int64, res sdk.Step return err } -func (c *client) QueueArtifactUpload(ctx context.Context, projectKey, integrationName string, nodeJobRunID int64, tag, filePath, fileType string) (bool, time.Duration, error) { - t0 := time.Now() - store := new(sdk.ArtifactsStore) - uri := fmt.Sprintf("/project/%s/storage/%s", projectKey, integrationName) - _, _ = c.GetJSON(ctx, uri, store) - if store.TemporaryURLSupported { - err := c.queueIndirectArtifactUpload(ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType) - return true, time.Since(t0), err - } - err := c.queueDirectArtifactUpload(projectKey, integrationName, nodeJobRunID, tag, filePath, fileType) - return false, time.Since(t0), err -} - -// DEPRECATED -// TODO: remove this code after CDN would be mandatory -func (c *client) queueIndirectArtifactTempURL(ctx context.Context, projectKey, integrationName string, art *sdk.WorkflowNodeRunArtifact) error { - var retryURL = 10 - var globalURLErr error - uri := fmt.Sprintf("/project/%s/storage/%s/artifact/%s/url", projectKey, integrationName, art.Ref) - - for i := 0; i < retryURL; i++ { - var code int - ctx, cancel := context.WithTimeout(ctx, 10*time.Second) - code, globalURLErr = c.PostJSON(ctx, uri, art, art) - if code < 300 { - cancel() - break - } - cancel() - time.Sleep(500 * time.Millisecond) - } - - return globalURLErr -} - -// DEPRECATED -// TODO: remove this code after CDN would be mandatory -func (c *client) queueIndirectArtifactTempURLPost(url string, content []byte) error { - //Post the file to the temporary URL - var retry = 10 - var globalErr error - var body []byte - for i := 0; i < retry; i++ { - req, errRequest := http.NewRequest("PUT", url, bytes.NewBuffer(content)) - if errRequest != nil { - return errRequest - } - - var resp *http.Response - resp, globalErr = http.DefaultClient.Do(req) - if globalErr == nil { - defer resp.Body.Close() - - var err error - body, err = io.ReadAll(resp.Body) - if err != nil { - globalErr = err - time.Sleep(1 * time.Second) - continue - } - - if resp.StatusCode >= 300 { - globalErr = newError(fmt.Errorf("[%d] Unable to upload artifact: (HTTP %d) %s", i, resp.StatusCode, string(body))) - time.Sleep(1 * time.Second) - continue - } - - break - } - time.Sleep(1 * time.Second) - } - - return globalErr -} - -// DEPRECATED -// TODO: remove this code after CDN would be mandatory -func (c *client) queueIndirectArtifactUpload(ctx context.Context, projectKey, integrationName string, nodeJobRunID int64, tag, filePath, fileType string) error { - f, errop := os.Open(filePath) - if errop != nil { - return errop - } - defer f.Close() - - //File stat - stat, errst := f.Stat() - if errst != nil { - return errst - } - - sha512sum, err512 := sdk.FileSHA512sum(filePath) - if err512 != nil { - return err512 - } - - md5sum, errmd5 := sdk.FileMd5sum(filePath) - if errmd5 != nil { - return errmd5 - } - - _, name := filepath.Split(filePath) - - ref := base64.RawURLEncoding.EncodeToString([]byte(tag)) - art := sdk.WorkflowNodeRunArtifact{ - Name: name, - Tag: tag, - Ref: ref, - Size: stat.Size(), - Perm: uint32(stat.Mode().Perm()), - MD5sum: md5sum, - SHA512sum: sha512sum, - Created: time.Now(), - WorkflowNodeJobRunID: nodeJobRunID, - } - - if err := c.queueIndirectArtifactTempURL(ctx, projectKey, integrationName, &art); err != nil { - return err - } - - if c.config.Verbose { - fmt.Printf("Uploading %s with to %s\n", art.Name, art.TempURL) - } - - //Read the file once - fileContent, errFileContent := io.ReadAll(f) - if errFileContent != nil { - return errFileContent - } - - if err := c.queueIndirectArtifactTempURLPost(art.TempURL, fileContent); err != nil { - // If we got a 401 error from the objectstore, probably because temporary URL is not - // replicated on all cluster. Wait 5s before use it - if strings.Contains(err.Error(), "401 Unauthorized: Temp URL invalid") { - time.Sleep(5 * time.Second) - if err := c.queueIndirectArtifactTempURLPost(art.TempURL, fileContent); err != nil { - return err - } - } - return err - } - - //Try 50 times to make the callback - var callbackErr error - retry := 50 - for i := 0; i < retry; i++ { - uri := fmt.Sprintf("/project/%s/storage/%s/artifact/%s/url/callback", projectKey, integrationName, art.Ref) - ctxt, cancel := context.WithTimeout(ctx, 5*time.Second) - _, callbackErr = c.PostJSON(ctxt, uri, &art, nil) - if callbackErr == nil { - cancel() - return nil - } - cancel() - } - - return callbackErr -} - -// DEPRECATED -// TODO: remove this code after CDN would be mandatory -func (c *client) queueDirectArtifactUpload(projectKey, integrationName string, nodeJobRunID int64, tag, filePath, fileType string) error { - f, errop := os.Open(filePath) - if errop != nil { - return errop - } - defer f.Close() - //File stat - stat, errst := f.Stat() - if errst != nil { - return errst - } - - sha512sum, err512 := sdk.FileSHA512sum(filePath) - if err512 != nil { - return err512 - } - - md5sum, errmd5 := sdk.FileMd5sum(filePath) - if errmd5 != nil { - return errmd5 - } - - //Read the file once - fileContent, errFileContent := io.ReadAll(f) - if errFileContent != nil { - return errFileContent - } - - _, name := filepath.Split(filePath) - body := &bytes.Buffer{} - writer := multipart.NewWriter(body) - part, errc := writer.CreateFormFile(name, filepath.Base(filePath)) - if errc != nil { - return errc - } - - if _, err := io.Copy(part, bytes.NewBuffer(fileContent)); err != nil { - return err - } - - writer.WriteField("size", strconv.FormatInt(stat.Size(), 10)) // nolint - writer.WriteField("perm", strconv.FormatUint(uint64(stat.Mode().Perm()), 10)) // nolint - writer.WriteField("md5sum", md5sum) // nolint - writer.WriteField("sha512sum", sha512sum) // nolint - writer.WriteField("nodeJobRunID", fmt.Sprintf("%d", nodeJobRunID)) // nolint - - if errclose := writer.Close(); errclose != nil { - return errclose - } - - var err error - ref := base64.RawURLEncoding.EncodeToString([]byte(tag)) - uri := fmt.Sprintf("/project/%s/storage/%s/artifact/%s", projectKey, integrationName, ref) - for i := 0; i <= c.config.Retry; i++ { - var code int - _, code, err = c.UploadMultiPart("POST", uri, body, - SetHeader("Content-Disposition", "attachment; filename="+name), - SetHeader("Content-Type", writer.FormDataContentType())) - if err == nil { - if code < 400 { - return nil - } - err = newAPIError(fmt.Errorf("Error: HTTP code status %d", code)) - } - time.Sleep(3 * time.Second) - } - - return newError(fmt.Errorf("x%d: %v", c.config.Retry, err)) -} - func (c *client) QueueWorkerCacheLink(ctx context.Context, jobID int64, tag string) (sdk.CDNItemLinks, error) { var result sdk.CDNItemLinks path := fmt.Sprintf("/queue/workflows/%d/cache/%s/links", jobID, tag) diff --git a/sdk/cdsclient/client_workflow.go b/sdk/cdsclient/client_workflow.go index 234b835d2c..d7a7a477e4 100644 --- a/sdk/cdsclient/client_workflow.go +++ b/sdk/cdsclient/client_workflow.go @@ -5,11 +5,9 @@ import ( "context" "encoding/json" "fmt" - "io" "log" "net/http" "net/url" - "time" "github.com/ovh/cds/sdk" ) @@ -145,15 +143,6 @@ func (c *client) WorkflowDelete(projectKey string, workflowName string, opts ... return err } -func (c *client) WorkflowRunArtifacts(projectKey string, workflowName string, number int64) ([]sdk.WorkflowNodeRunArtifact, error) { - url := fmt.Sprintf("/project/%s/workflows/%s/runs/%d/artifacts", projectKey, workflowName, number) - arts := []sdk.WorkflowNodeRunArtifact{} - if _, err := c.GetJSON(context.Background(), url, &arts); err != nil { - return nil, err - } - return arts, nil -} - func (c *client) WorkflowRunArtifactsLinks(projectKey string, workflowName string, number int64) (sdk.CDNItemLinks, error) { url := fmt.Sprintf("/project/%s/workflows/%s/runs/%d/artifacts/links", projectKey, workflowName, number) var resp sdk.CDNItemLinks @@ -241,25 +230,6 @@ func (c *client) WorkflowLogDownload(ctx context.Context, link sdk.CDNLogLink) ( return data, nil } -func (c *client) WorkflowNodeRunArtifactDownload(projectKey string, workflowName string, a sdk.WorkflowNodeRunArtifact, w io.Writer) error { - var url = fmt.Sprintf("/project/%s/workflows/%s/artifact/%d", projectKey, workflowName, a.ID) - var reader io.ReadCloser - var err error - - if a.TempURL != "" { - url = a.TempURL - } - - reader, _, _, err = c.Stream(context.Background(), c.HTTPNoTimeoutClient(), "GET", url, nil) - if err != nil { - return err - } - defer reader.Close() - - _, err = io.Copy(w, reader) - return err -} - func (c *client) WorkflowNodeRunRelease(projectKey string, workflowName string, runNumber int64, nodeRunID int64, release sdk.WorkflowNodeRunRelease) error { url := fmt.Sprintf("/project/%s/workflows/%s/runs/%d/nodes/%d/release", projectKey, workflowName, runNumber, nodeRunID) btes, _ := json.Marshal(release) @@ -359,80 +329,6 @@ func (c *client) WorkflowNodeStop(projectKey string, workflowName string, number return nodeRun, nil } -func (c *client) WorkflowCachePush(projectKey, integrationName, ref string, tarContent io.Reader, size int) error { - store := new(sdk.ArtifactsStore) - uri := fmt.Sprintf("/project/%s/storage/%s", projectKey, integrationName) - _, _ = c.GetJSON(context.Background(), uri, store) - if store.TemporaryURLSupported { - return c.workflowCachePushIndirectUpload(projectKey, integrationName, ref, tarContent, size) - } - return c.workflowCachePushDirectUpload(projectKey, integrationName, ref, tarContent) -} - -func (c *client) workflowCachePushDirectUpload(projectKey, integrationName, ref string, tarContent io.Reader) error { - mods := []RequestModifier{ - (func(r *http.Request) { - r.Header.Set("Content-Type", "application/tar") - }), - } - - uri := fmt.Sprintf("/project/%s/storage/%s/cache/%s", projectKey, integrationName, ref) - _, _, code, err := c.Stream(context.Background(), c.HTTPNoTimeoutClient(), "POST", uri, tarContent, mods...) - if err != nil { - return err - } - - if code >= 400 { - return newAPIError(fmt.Errorf("HTTP Code %d", code)) - } - - return nil -} - -func (c *client) workflowCachePushIndirectUpload(projectKey, integrationName, ref string, tarContent io.Reader, size int) error { - uri := fmt.Sprintf("/project/%s/storage/%s/cache/%s/url", projectKey, integrationName, ref) - cacheObj := sdk.Cache{} - code, err := c.PostJSON(context.Background(), uri, cacheObj, &cacheObj) - if err != nil { - return err - } - - if code >= 400 { - return newAPIError(fmt.Errorf("HTTP Code %d", code)) - } - - // FIXME temporary fix that will be deprecated with cdn artifacts - time.Sleep(2 * time.Second) - - return c.workflowCachePushIndirectUploadPost(cacheObj.TmpURL, tarContent, size) -} - -func (c *client) workflowCachePushIndirectUploadPost(url string, tarContent io.Reader, size int) error { - req, err := http.NewRequest("PUT", url, tarContent) - if err != nil { - return newError(err) - } - req.Header.Set("Content-Type", "application/tar") - req.ContentLength = int64(size) - - resp, err := c.HTTPNoTimeoutClient().Do(req) - if err != nil { - return newTransportError(err) - } - - defer resp.Body.Close() - - body, err := io.ReadAll(resp.Body) - if err != nil { - return newError(err) - } - - if resp.StatusCode >= 300 { - return newAPIError(fmt.Errorf("unable to upload cache: (HTTP %d) %s", resp.StatusCode, string(body))) - } - return nil -} - func (c *client) WorkflowRunResultsList(ctx context.Context, projectKey string, name string, number int64) ([]sdk.WorkflowRunResult, error) { var results []sdk.WorkflowRunResult uri := fmt.Sprintf("/project/%s/workflows/%s/runs/%d/results", projectKey, name, number) @@ -441,44 +337,3 @@ func (c *client) WorkflowRunResultsList(ctx context.Context, projectKey string, } return results, nil } - -func (c *client) WorkflowCachePull(projectKey, integrationName, ref string) (io.Reader, error) { - uri := fmt.Sprintf("/project/%s/storage/%s", projectKey, integrationName) - store := new(sdk.ArtifactsStore) - _, _ = c.GetJSON(context.Background(), uri, store) - - downloadURL := fmt.Sprintf("/project/%s/storage/%s/cache/%s", projectKey, integrationName, ref) - - if store.TemporaryURLSupported { - url := fmt.Sprintf("/project/%s/storage/%s/cache/%s/url", projectKey, integrationName, ref) - var cacheObj sdk.Cache - code, err := c.GetJSON(context.Background(), url, &cacheObj) - if err != nil { - return nil, err - } - if code >= 400 { - return nil, newAPIError(fmt.Errorf("HTTP Code %d", code)) - } - downloadURL = cacheObj.TmpURL - } - - mods := []RequestModifier{ - (func(r *http.Request) { - r.Header.Set("Content-Type", "application/tar") - }), - } - - res, _, code, err := c.Stream(context.Background(), c.HTTPNoTimeoutClient(), "GET", downloadURL, nil, mods...) - if err != nil { - return nil, err - } - - if code >= 400 { - if code == 404 { - return nil, newError(fmt.Errorf("Cache not found")) - } - return nil, newAPIError(fmt.Errorf("HTTP Code %d", code)) - } - - return res, nil -} diff --git a/sdk/cdsclient/interface.go b/sdk/cdsclient/interface.go index 4e3db19150..efc8ba7e52 100644 --- a/sdk/cdsclient/interface.go +++ b/sdk/cdsclient/interface.go @@ -262,7 +262,6 @@ type QueueClient interface { QueueSendVulnerability(ctx context.Context, id int64, report sdk.VulnerabilityWorkerReport) error QueueSendStepResult(ctx context.Context, id int64, res sdk.StepStatus) error QueueSendResult(ctx context.Context, id int64, res sdk.Result) error - QueueArtifactUpload(ctx context.Context, projectKey, integrationName string, nodeJobRunID int64, tag, filePath, fileType string) (bool, time.Duration, error) QueueJobTag(ctx context.Context, jobID int64, tags []sdk.WorkflowRunTag) error QueueJobSetVersion(ctx context.Context, jobID int64, version sdk.WorkflowRunVersion) error QueueWorkerCacheLink(ctx context.Context, jobID int64, tag string) (sdk.CDNItemLinks, error) @@ -333,7 +332,6 @@ type WorkflowClient interface { WorkflowRunsDeleteByBranch(projectKey string, workflowName string, branch string) error WorkflowRunSearch(projectKey string, offset, limit int64, filter ...Filter) ([]sdk.WorkflowRun, error) WorkflowRunList(projectKey string, workflowName string, offset, limit int64) ([]sdk.WorkflowRun, error) - WorkflowRunArtifacts(projectKey string, name string, number int64) ([]sdk.WorkflowNodeRunArtifact, error) WorkflowRunArtifactsLinks(projectKey string, name string, number int64) (sdk.CDNItemLinks, error) WorkflowRunResultsList(ctx context.Context, projectKey string, name string, number int64) ([]sdk.WorkflowRunResult, error) WorkflowRunFromHook(projectKey string, workflowName string, hook sdk.WorkflowNodeRunHookEvent) (*sdk.WorkflowRun, error) @@ -343,7 +341,6 @@ type WorkflowClient interface { WorkflowStop(projectKey string, workflowName string, number int64) (*sdk.WorkflowRun, error) WorkflowNodeStop(projectKey string, workflowName string, number, fromNodeID int64) (*sdk.WorkflowNodeRun, error) WorkflowNodeRun(projectKey string, name string, number int64, nodeRunID int64) (*sdk.WorkflowNodeRun, error) - WorkflowNodeRunArtifactDownload(projectKey string, name string, a sdk.WorkflowNodeRunArtifact, w io.Writer) error WorkflowNodeRunJobStepLinks(ctx context.Context, projectKey string, workflowName string, nodeRunID, job int64) (*sdk.CDNLogLinks, error) WorkflowNodeRunJobStepLink(ctx context.Context, projectKey string, workflowName string, nodeRunID, job int64, step int64) (*sdk.CDNLogLink, error) WorkflowNodeRunJobServiceLink(ctx context.Context, projectKey string, workflowName string, nodeRunID, job int64, serviceName string) (*sdk.CDNLogLink, error) @@ -352,8 +349,6 @@ type WorkflowClient interface { WorkflowNodeRunRelease(projectKey string, workflowName string, runNumber int64, nodeRunID int64, release sdk.WorkflowNodeRunRelease) error WorkflowAllHooksList() ([]sdk.NodeHook, error) WorkflowAllHooksExecutions() ([]string, error) - WorkflowCachePush(projectKey, integrationName, ref string, tarContent io.Reader, size int) error - WorkflowCachePull(projectKey, integrationName, ref string) (io.Reader, error) WorkflowTransformAsCode(projectKey, workflowName, branch, message string) (*sdk.Operation, error) } @@ -425,12 +420,8 @@ type WorkerInterface interface { Requirements() ([]sdk.Requirement, error) ServiceClient WorkerClient - WorkflowRunArtifacts(projectKey string, name string, number int64) ([]sdk.WorkflowNodeRunArtifact, error) WorkflowRunGet(projectKey string, workflowName string, number int64) (*sdk.WorkflowRun, error) - WorkflowCachePush(projectKey, integrationName, ref string, tarContent io.Reader, size int) error - WorkflowCachePull(projectKey, integrationName, ref string) (io.Reader, error) WorkflowRunList(projectKey string, workflowName string, offset, limit int64) ([]sdk.WorkflowRun, error) - WorkflowNodeRunArtifactDownload(projectKey string, name string, a sdk.WorkflowNodeRunArtifact, w io.Writer) error WorkflowNodeRunRelease(projectKey string, workflowName string, runNumber int64, nodeRunID int64, release sdk.WorkflowNodeRunRelease) error WorkflowRunArtifactsLinks(projectKey string, name string, number int64) (sdk.CDNItemLinks, error) WorkflowRunResultsList(ctx context.Context, projectKey string, name string, number int64) ([]sdk.WorkflowRunResult, error) diff --git a/sdk/cdsclient/mock_cdsclient/interface_mock.go b/sdk/cdsclient/mock_cdsclient/interface_mock.go index 9b526ec0da..43e5aaefc3 100644 --- a/sdk/cdsclient/mock_cdsclient/interface_mock.go +++ b/sdk/cdsclient/mock_cdsclient/interface_mock.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: interface.go +// Source: sdk/cdsclient/interface.go // Package mock_cdsclient is a generated GoMock package. package mock_cdsclient @@ -3031,22 +3031,6 @@ func (m *MockQueueClient) EXPECT() *MockQueueClientMockRecorder { return m.recorder } -// QueueArtifactUpload mocks base method. -func (m *MockQueueClient) QueueArtifactUpload(ctx context.Context, projectKey, integrationName string, nodeJobRunID int64, tag, filePath, fileType string) (bool, time.Duration, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "QueueArtifactUpload", ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(time.Duration) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// QueueArtifactUpload indicates an expected call of QueueArtifactUpload. -func (mr *MockQueueClientMockRecorder) QueueArtifactUpload(ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueueArtifactUpload", reflect.TypeOf((*MockQueueClient)(nil).QueueArtifactUpload), ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType) -} - // QueueCountWorkflowNodeJobRun mocks base method. func (m *MockQueueClient) QueueCountWorkflowNodeJobRun(since, until *time.Time, modelType string) (sdk.WorkflowNodeJobRunCount, error) { m.ctrl.T.Helper() @@ -3959,35 +3943,6 @@ func (mr *MockWorkflowClientMockRecorder) WorkflowAllHooksList() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowAllHooksList", reflect.TypeOf((*MockWorkflowClient)(nil).WorkflowAllHooksList)) } -// WorkflowCachePull mocks base method. -func (m *MockWorkflowClient) WorkflowCachePull(projectKey, integrationName, ref string) (io.Reader, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowCachePull", projectKey, integrationName, ref) - ret0, _ := ret[0].(io.Reader) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WorkflowCachePull indicates an expected call of WorkflowCachePull. -func (mr *MockWorkflowClientMockRecorder) WorkflowCachePull(projectKey, integrationName, ref interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowCachePull", reflect.TypeOf((*MockWorkflowClient)(nil).WorkflowCachePull), projectKey, integrationName, ref) -} - -// WorkflowCachePush mocks base method. -func (m *MockWorkflowClient) WorkflowCachePush(projectKey, integrationName, ref string, tarContent io.Reader, size int) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowCachePush", projectKey, integrationName, ref, tarContent, size) - ret0, _ := ret[0].(error) - return ret0 -} - -// WorkflowCachePush indicates an expected call of WorkflowCachePush. -func (mr *MockWorkflowClientMockRecorder) WorkflowCachePush(projectKey, integrationName, ref, tarContent, size interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowCachePush", reflect.TypeOf((*MockWorkflowClient)(nil).WorkflowCachePush), projectKey, integrationName, ref, tarContent, size) -} - // WorkflowDelete mocks base method. func (m *MockWorkflowClient) WorkflowDelete(projectKey, workflowName string, opts ...cdsclient.RequestModifier) error { m.ctrl.T.Helper() @@ -4133,20 +4088,6 @@ func (mr *MockWorkflowClientMockRecorder) WorkflowNodeRun(projectKey, name, numb return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowNodeRun", reflect.TypeOf((*MockWorkflowClient)(nil).WorkflowNodeRun), projectKey, name, number, nodeRunID) } -// WorkflowNodeRunArtifactDownload mocks base method. -func (m *MockWorkflowClient) WorkflowNodeRunArtifactDownload(projectKey, name string, a sdk.WorkflowNodeRunArtifact, w io.Writer) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowNodeRunArtifactDownload", projectKey, name, a, w) - ret0, _ := ret[0].(error) - return ret0 -} - -// WorkflowNodeRunArtifactDownload indicates an expected call of WorkflowNodeRunArtifactDownload. -func (mr *MockWorkflowClientMockRecorder) WorkflowNodeRunArtifactDownload(projectKey, name, a, w interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowNodeRunArtifactDownload", reflect.TypeOf((*MockWorkflowClient)(nil).WorkflowNodeRunArtifactDownload), projectKey, name, a, w) -} - // WorkflowNodeRunJobServiceLink mocks base method. func (m *MockWorkflowClient) WorkflowNodeRunJobServiceLink(ctx context.Context, projectKey, workflowName string, nodeRunID, job int64, serviceName string) (*sdk.CDNLogLink, error) { m.ctrl.T.Helper() @@ -4221,21 +4162,6 @@ func (mr *MockWorkflowClientMockRecorder) WorkflowNodeStop(projectKey, workflowN return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowNodeStop", reflect.TypeOf((*MockWorkflowClient)(nil).WorkflowNodeStop), projectKey, workflowName, number, fromNodeID) } -// WorkflowRunArtifacts mocks base method. -func (m *MockWorkflowClient) WorkflowRunArtifacts(projectKey, name string, number int64) ([]sdk.WorkflowNodeRunArtifact, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowRunArtifacts", projectKey, name, number) - ret0, _ := ret[0].([]sdk.WorkflowNodeRunArtifact) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WorkflowRunArtifacts indicates an expected call of WorkflowRunArtifacts. -func (mr *MockWorkflowClientMockRecorder) WorkflowRunArtifacts(projectKey, name, number interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowRunArtifacts", reflect.TypeOf((*MockWorkflowClient)(nil).WorkflowRunArtifacts), projectKey, name, number) -} - // WorkflowRunArtifactsLinks mocks base method. func (m *MockWorkflowClient) WorkflowRunArtifactsLinks(projectKey, name string, number int64) (sdk.CDNItemLinks, error) { m.ctrl.T.Helper() @@ -6954,22 +6880,6 @@ func (mr *MockInterfaceMockRecorder) PutJSON(ctx, path, in, out interface{}, mod return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutJSON", reflect.TypeOf((*MockInterface)(nil).PutJSON), varargs...) } -// QueueArtifactUpload mocks base method. -func (m *MockInterface) QueueArtifactUpload(ctx context.Context, projectKey, integrationName string, nodeJobRunID int64, tag, filePath, fileType string) (bool, time.Duration, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "QueueArtifactUpload", ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(time.Duration) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// QueueArtifactUpload indicates an expected call of QueueArtifactUpload. -func (mr *MockInterfaceMockRecorder) QueueArtifactUpload(ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueueArtifactUpload", reflect.TypeOf((*MockInterface)(nil).QueueArtifactUpload), ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType) -} - // QueueCountWorkflowNodeJobRun mocks base method. func (m *MockInterface) QueueCountWorkflowNodeJobRun(since, until *time.Time, modelType string) (sdk.WorkflowNodeJobRunCount, error) { m.ctrl.T.Helper() @@ -8202,35 +8112,6 @@ func (mr *MockInterfaceMockRecorder) WorkflowAsCodeStart(projectKey, repoURL, re return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowAsCodeStart", reflect.TypeOf((*MockInterface)(nil).WorkflowAsCodeStart), projectKey, repoURL, repoStrategy) } -// WorkflowCachePull mocks base method. -func (m *MockInterface) WorkflowCachePull(projectKey, integrationName, ref string) (io.Reader, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowCachePull", projectKey, integrationName, ref) - ret0, _ := ret[0].(io.Reader) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WorkflowCachePull indicates an expected call of WorkflowCachePull. -func (mr *MockInterfaceMockRecorder) WorkflowCachePull(projectKey, integrationName, ref interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowCachePull", reflect.TypeOf((*MockInterface)(nil).WorkflowCachePull), projectKey, integrationName, ref) -} - -// WorkflowCachePush mocks base method. -func (m *MockInterface) WorkflowCachePush(projectKey, integrationName, ref string, tarContent io.Reader, size int) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowCachePush", projectKey, integrationName, ref, tarContent, size) - ret0, _ := ret[0].(error) - return ret0 -} - -// WorkflowCachePush indicates an expected call of WorkflowCachePush. -func (mr *MockInterfaceMockRecorder) WorkflowCachePush(projectKey, integrationName, ref, tarContent, size interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowCachePush", reflect.TypeOf((*MockInterface)(nil).WorkflowCachePush), projectKey, integrationName, ref, tarContent, size) -} - // WorkflowDelete mocks base method. func (m *MockInterface) WorkflowDelete(projectKey, workflowName string, opts ...cdsclient.RequestModifier) error { m.ctrl.T.Helper() @@ -8416,20 +8297,6 @@ func (mr *MockInterfaceMockRecorder) WorkflowNodeRun(projectKey, name, number, n return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowNodeRun", reflect.TypeOf((*MockInterface)(nil).WorkflowNodeRun), projectKey, name, number, nodeRunID) } -// WorkflowNodeRunArtifactDownload mocks base method. -func (m *MockInterface) WorkflowNodeRunArtifactDownload(projectKey, name string, a sdk.WorkflowNodeRunArtifact, w io.Writer) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowNodeRunArtifactDownload", projectKey, name, a, w) - ret0, _ := ret[0].(error) - return ret0 -} - -// WorkflowNodeRunArtifactDownload indicates an expected call of WorkflowNodeRunArtifactDownload. -func (mr *MockInterfaceMockRecorder) WorkflowNodeRunArtifactDownload(projectKey, name, a, w interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowNodeRunArtifactDownload", reflect.TypeOf((*MockInterface)(nil).WorkflowNodeRunArtifactDownload), projectKey, name, a, w) -} - // WorkflowNodeRunJobServiceLink mocks base method. func (m *MockInterface) WorkflowNodeRunJobServiceLink(ctx context.Context, projectKey, workflowName string, nodeRunID, job int64, serviceName string) (*sdk.CDNLogLink, error) { m.ctrl.T.Helper() @@ -8545,21 +8412,6 @@ func (mr *MockInterfaceMockRecorder) WorkflowPush(projectKey, tarContent interfa return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowPush", reflect.TypeOf((*MockInterface)(nil).WorkflowPush), varargs...) } -// WorkflowRunArtifacts mocks base method. -func (m *MockInterface) WorkflowRunArtifacts(projectKey, name string, number int64) ([]sdk.WorkflowNodeRunArtifact, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowRunArtifacts", projectKey, name, number) - ret0, _ := ret[0].([]sdk.WorkflowNodeRunArtifact) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WorkflowRunArtifacts indicates an expected call of WorkflowRunArtifacts. -func (mr *MockInterfaceMockRecorder) WorkflowRunArtifacts(projectKey, name, number interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowRunArtifacts", reflect.TypeOf((*MockInterface)(nil).WorkflowRunArtifacts), projectKey, name, number) -} - // WorkflowRunArtifactsLinks mocks base method. func (m *MockInterface) WorkflowRunArtifactsLinks(projectKey, name string, number int64) (sdk.CDNItemLinks, error) { m.ctrl.T.Helper() @@ -9022,22 +8874,6 @@ func (mr *MockWorkerInterfaceMockRecorder) ProjectIntegrationWorkerHookGet(proje return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProjectIntegrationWorkerHookGet", reflect.TypeOf((*MockWorkerInterface)(nil).ProjectIntegrationWorkerHookGet), projectKey, integrationName) } -// QueueArtifactUpload mocks base method. -func (m *MockWorkerInterface) QueueArtifactUpload(ctx context.Context, projectKey, integrationName string, nodeJobRunID int64, tag, filePath, fileType string) (bool, time.Duration, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "QueueArtifactUpload", ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(time.Duration) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// QueueArtifactUpload indicates an expected call of QueueArtifactUpload. -func (mr *MockWorkerInterfaceMockRecorder) QueueArtifactUpload(ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueueArtifactUpload", reflect.TypeOf((*MockWorkerInterface)(nil).QueueArtifactUpload), ctx, projectKey, integrationName, nodeJobRunID, tag, filePath, fileType) -} - // QueueCountWorkflowNodeJobRun mocks base method. func (m *MockWorkerInterface) QueueCountWorkflowNodeJobRun(since, until *time.Time, modelType string) (sdk.WorkflowNodeJobRunCount, error) { m.ctrl.T.Helper() @@ -9560,49 +9396,6 @@ func (mr *MockWorkerInterfaceMockRecorder) WorkerUnregister(ctx interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkerUnregister", reflect.TypeOf((*MockWorkerInterface)(nil).WorkerUnregister), ctx) } -// WorkflowCachePull mocks base method. -func (m *MockWorkerInterface) WorkflowCachePull(projectKey, integrationName, ref string) (io.Reader, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowCachePull", projectKey, integrationName, ref) - ret0, _ := ret[0].(io.Reader) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WorkflowCachePull indicates an expected call of WorkflowCachePull. -func (mr *MockWorkerInterfaceMockRecorder) WorkflowCachePull(projectKey, integrationName, ref interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowCachePull", reflect.TypeOf((*MockWorkerInterface)(nil).WorkflowCachePull), projectKey, integrationName, ref) -} - -// WorkflowCachePush mocks base method. -func (m *MockWorkerInterface) WorkflowCachePush(projectKey, integrationName, ref string, tarContent io.Reader, size int) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowCachePush", projectKey, integrationName, ref, tarContent, size) - ret0, _ := ret[0].(error) - return ret0 -} - -// WorkflowCachePush indicates an expected call of WorkflowCachePush. -func (mr *MockWorkerInterfaceMockRecorder) WorkflowCachePush(projectKey, integrationName, ref, tarContent, size interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowCachePush", reflect.TypeOf((*MockWorkerInterface)(nil).WorkflowCachePush), projectKey, integrationName, ref, tarContent, size) -} - -// WorkflowNodeRunArtifactDownload mocks base method. -func (m *MockWorkerInterface) WorkflowNodeRunArtifactDownload(projectKey, name string, a sdk.WorkflowNodeRunArtifact, w io.Writer) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowNodeRunArtifactDownload", projectKey, name, a, w) - ret0, _ := ret[0].(error) - return ret0 -} - -// WorkflowNodeRunArtifactDownload indicates an expected call of WorkflowNodeRunArtifactDownload. -func (mr *MockWorkerInterfaceMockRecorder) WorkflowNodeRunArtifactDownload(projectKey, name, a, w interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowNodeRunArtifactDownload", reflect.TypeOf((*MockWorkerInterface)(nil).WorkflowNodeRunArtifactDownload), projectKey, name, a, w) -} - // WorkflowNodeRunRelease mocks base method. func (m *MockWorkerInterface) WorkflowNodeRunRelease(projectKey, workflowName string, runNumber, nodeRunID int64, release sdk.WorkflowNodeRunRelease) error { m.ctrl.T.Helper() @@ -9617,21 +9410,6 @@ func (mr *MockWorkerInterfaceMockRecorder) WorkflowNodeRunRelease(projectKey, wo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowNodeRunRelease", reflect.TypeOf((*MockWorkerInterface)(nil).WorkflowNodeRunRelease), projectKey, workflowName, runNumber, nodeRunID, release) } -// WorkflowRunArtifacts mocks base method. -func (m *MockWorkerInterface) WorkflowRunArtifacts(projectKey, name string, number int64) ([]sdk.WorkflowNodeRunArtifact, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WorkflowRunArtifacts", projectKey, name, number) - ret0, _ := ret[0].([]sdk.WorkflowNodeRunArtifact) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// WorkflowRunArtifacts indicates an expected call of WorkflowRunArtifacts. -func (mr *MockWorkerInterfaceMockRecorder) WorkflowRunArtifacts(projectKey, name, number interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WorkflowRunArtifacts", reflect.TypeOf((*MockWorkerInterface)(nil).WorkflowRunArtifacts), projectKey, name, number) -} - // WorkflowRunArtifactsLinks mocks base method. func (m *MockWorkerInterface) WorkflowRunArtifactsLinks(projectKey, name string, number int64) (sdk.CDNItemLinks, error) { m.ctrl.T.Helper()