From 3db6801bfd102b410a27ebe6fc1d7e3209ae6e0c Mon Sep 17 00:00:00 2001 From: Easton Crupper <65553218+ecrupper@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:38:22 -0400 Subject: [PATCH] refactor: remove types dependency (#610) --- api/build.go | 6 ++-- api/executor.go | 13 ++++---- api/pipeline.go | 4 +-- api/repo.go | 4 +-- cmd/vela-worker/exec.go | 8 ++--- cmd/vela-worker/operate.go | 2 +- cmd/vela-worker/register.go | 5 ++- cmd/vela-worker/run.go | 2 +- executor/executor.go | 2 +- executor/executor_test.go | 2 +- executor/flags.go | 2 +- executor/linux/api.go | 2 +- executor/linux/api_test.go | 2 +- executor/linux/build.go | 35 ++------------------- executor/linux/build_test.go | 2 +- executor/linux/driver.go | 2 +- executor/linux/driver_test.go | 2 +- executor/linux/linux_test.go | 2 +- executor/linux/opts_test.go | 2 +- executor/linux/outputs_test.go | 2 +- executor/linux/secret.go | 6 +--- executor/linux/secret_test.go | 13 ++++---- executor/linux/service.go | 11 +------ executor/linux/service_test.go | 5 ++- executor/linux/stage.go | 6 +--- executor/linux/step.go | 15 ++------- executor/linux/step_test.go | 9 +++--- executor/local/api.go | 2 +- executor/local/build.go | 2 +- executor/local/driver.go | 2 +- executor/local/driver_test.go | 2 +- executor/local/service.go | 6 +--- executor/local/step.go | 6 +--- executor/setup.go | 2 +- executor/setup_test.go | 2 +- go.mod | 5 ++- go.sum | 10 +++--- internal/build/snapshot.go | 2 +- internal/build/upload.go | 2 +- internal/service/environment.go | 12 +------ internal/service/load.go | 5 ++- internal/service/load_test.go | 7 ++--- internal/service/snapshot.go | 2 +- internal/service/upload.go | 2 +- internal/step/environment.go | 12 +------ internal/step/load.go | 5 ++- internal/step/load_test.go | 7 ++--- internal/step/skip.go | 6 +--- internal/step/snapshot.go | 5 ++- internal/step/snapshot_test.go | 7 ++--- internal/step/upload.go | 2 +- mock/worker/build.go | 5 ++- mock/worker/executor.go | 3 +- mock/worker/pipeline.go | 3 +- mock/worker/repo.go | 3 +- router/middleware/executor/executor.go | 12 +++---- router/middleware/executor/executor_test.go | 2 +- router/middleware/perm/perm.go | 12 +++---- runtime/context_test.go | 2 +- runtime/docker/container.go | 2 +- runtime/docker/driver.go | 2 +- runtime/docker/driver_test.go | 2 +- runtime/docker/image.go | 2 +- runtime/docker/volume.go | 2 +- runtime/flags.go | 2 +- runtime/kubernetes/container.go | 2 +- runtime/kubernetes/driver.go | 2 +- runtime/kubernetes/driver_test.go | 2 +- runtime/kubernetes/image.go | 2 +- runtime/kubernetes/volume.go | 2 +- runtime/runtime.go | 2 +- runtime/runtime_test.go | 2 +- runtime/setup.go | 2 +- runtime/setup_test.go | 2 +- version/version.go | 2 +- 75 files changed, 122 insertions(+), 233 deletions(-) diff --git a/api/build.go b/api/build.go index 173dd733..9ac5deb9 100644 --- a/api/build.go +++ b/api/build.go @@ -8,7 +8,7 @@ import ( "github.com/gin-gonic/gin" - "github.com/go-vela/types" + api "github.com/go-vela/server/api/types" "github.com/go-vela/worker/router/middleware/executor" ) @@ -47,7 +47,7 @@ func GetBuild(c *gin.Context) { if err != nil { msg := fmt.Errorf("unable to read build: %w", err).Error() - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -90,7 +90,7 @@ func CancelBuild(c *gin.Context) { if err != nil { msg := fmt.Errorf("unable to cancel build: %w", err).Error() - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } diff --git a/api/executor.go b/api/executor.go index a51cd033..1a755137 100644 --- a/api/executor.go +++ b/api/executor.go @@ -9,7 +9,6 @@ import ( "github.com/gin-gonic/gin" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types" "github.com/go-vela/worker/executor" exec "github.com/go-vela/worker/router/middleware/executor" ) @@ -57,7 +56,7 @@ func GetExecutor(c *gin.Context) { if err != nil { msg := fmt.Errorf("unable to retrieve build: %w", err).Error() - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -67,7 +66,7 @@ func GetExecutor(c *gin.Context) { if err != nil { msg := fmt.Errorf("unable to retrieve pipeline: %w", err).Error() - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -104,7 +103,7 @@ func GetExecutors(c *gin.Context) { if value == nil { msg := "no running executors found" - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -114,7 +113,7 @@ func GetExecutors(c *gin.Context) { if !ok { msg := "unable to get executors" - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -136,7 +135,7 @@ func GetExecutors(c *gin.Context) { if err != nil { msg := fmt.Errorf("unable to retrieve build: %w", err).Error() - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -146,7 +145,7 @@ func GetExecutors(c *gin.Context) { if err != nil { msg := fmt.Errorf("unable to retrieve pipeline: %w", err).Error() - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } diff --git a/api/pipeline.go b/api/pipeline.go index f1ec05ab..74e9e581 100644 --- a/api/pipeline.go +++ b/api/pipeline.go @@ -8,7 +8,7 @@ import ( "github.com/gin-gonic/gin" - "github.com/go-vela/types" + api "github.com/go-vela/server/api/types" "github.com/go-vela/worker/router/middleware/executor" ) @@ -46,7 +46,7 @@ func GetPipeline(c *gin.Context) { if err != nil { msg := fmt.Errorf("unable to read pipeline: %w", err).Error() - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } diff --git a/api/repo.go b/api/repo.go index ed4ab318..16f927e2 100644 --- a/api/repo.go +++ b/api/repo.go @@ -8,7 +8,7 @@ import ( "github.com/gin-gonic/gin" - "github.com/go-vela/types" + api "github.com/go-vela/server/api/types" "github.com/go-vela/worker/router/middleware/executor" ) @@ -46,7 +46,7 @@ func GetRepo(c *gin.Context) { if err != nil { msg := fmt.Errorf("unable to read build: %w", err).Error() - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } diff --git a/cmd/vela-worker/exec.go b/cmd/vela-worker/exec.go index 25b9e3e3..d5d7f7a3 100644 --- a/cmd/vela-worker/exec.go +++ b/cmd/vela-worker/exec.go @@ -15,10 +15,8 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" + "github.com/go-vela/server/constants" "github.com/go-vela/server/queue/models" - "github.com/go-vela/types" - "github.com/go-vela/types/constants" - "github.com/go-vela/types/library" "github.com/go-vela/worker/executor" "github.com/go-vela/worker/runtime" "github.com/go-vela/worker/version" @@ -36,7 +34,7 @@ func (w *Worker) exec(index int, config *api.Worker) error { var ( execBuildClient *vela.Client - execBuildExecutable *library.BuildExecutable + execBuildExecutable *api.BuildExecutable p *pipeline.Build item *models.Item retries = 3 @@ -188,7 +186,7 @@ func (w *Worker) exec(index int, config *api.Worker) error { // If the ItemVersion is older or newer than what we expect, then it might // not be safe to process the build. Fail the build and loop to the next item. // TODO: Ask the server to re-compile and requeue the build instead of failing it. - logrus.Errorf("Failing stale queued build due to wrong item version: want %d, got %d", types.ItemVersion, item.ItemVersion) + logrus.Errorf("Failing stale queued build due to wrong item version: want %d, got %d", models.ItemVersion, item.ItemVersion) build := item.Build build.SetError("Unable to process stale build (queued before Vela upgrade/downgrade).") diff --git a/cmd/vela-worker/operate.go b/cmd/vela-worker/operate.go index ca8684e0..46c2bc34 100644 --- a/cmd/vela-worker/operate.go +++ b/cmd/vela-worker/operate.go @@ -10,8 +10,8 @@ import ( "golang.org/x/sync/errgroup" api "github.com/go-vela/server/api/types" + "github.com/go-vela/server/constants" "github.com/go-vela/server/queue" - "github.com/go-vela/types/constants" ) // operate is a helper function to initiate all diff --git a/cmd/vela-worker/register.go b/cmd/vela-worker/register.go index 68967f49..e1e5098d 100644 --- a/cmd/vela-worker/register.go +++ b/cmd/vela-worker/register.go @@ -11,8 +11,7 @@ import ( "github.com/sirupsen/logrus" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types/constants" - "github.com/go-vela/types/library" + "github.com/go-vela/server/constants" ) // checkIn is a helper function to phone home to the server. @@ -21,7 +20,7 @@ func (w *Worker) checkIn(config *api.Worker) (bool, string, error) { logrus.Infof("retrieving worker %s from the server", config.GetHostname()) var ( - tkn *library.Token + tkn *api.Token retries = 3 ) diff --git a/cmd/vela-worker/run.go b/cmd/vela-worker/run.go index d317fb56..dbe5e287 100644 --- a/cmd/vela-worker/run.go +++ b/cmd/vela-worker/run.go @@ -14,8 +14,8 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" + "github.com/go-vela/server/constants" "github.com/go-vela/server/queue" - "github.com/go-vela/types/constants" "github.com/go-vela/worker/executor" "github.com/go-vela/worker/runtime" ) diff --git a/executor/executor.go b/executor/executor.go index c166a40a..6eefc633 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -7,7 +7,7 @@ import ( "github.com/sirupsen/logrus" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // New creates and returns a Vela engine capable of diff --git a/executor/executor_test.go b/executor/executor_test.go index 7ac70f2b..8282d75f 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -14,8 +14,8 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/api/types/actions" "github.com/go-vela/server/compiler/types/pipeline" + "github.com/go-vela/server/constants" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/constants" "github.com/go-vela/worker/executor/linux" "github.com/go-vela/worker/executor/local" "github.com/go-vela/worker/runtime/docker" diff --git a/executor/flags.go b/executor/flags.go index 946a7b2f..e913ab87 100644 --- a/executor/flags.go +++ b/executor/flags.go @@ -7,7 +7,7 @@ import ( "github.com/urfave/cli/v2" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Flags represents all supported command line diff --git a/executor/linux/api.go b/executor/linux/api.go index 13c8c4b0..44478794 100644 --- a/executor/linux/api.go +++ b/executor/linux/api.go @@ -9,7 +9,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/service" "github.com/go-vela/worker/internal/step" ) diff --git a/executor/linux/api_test.go b/executor/linux/api_test.go index 23dfd654..ee8f5af5 100644 --- a/executor/linux/api_test.go +++ b/executor/linux/api_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) func TestLinux_GetBuild(t *testing.T) { diff --git a/executor/linux/build.go b/executor/linux/build.go index a594a15a..f6665ee6 100644 --- a/executor/linux/build.go +++ b/executor/linux/build.go @@ -14,8 +14,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" - "github.com/go-vela/types/library" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/build" context2 "github.com/go-vela/worker/internal/context" "github.com/go-vela/worker/internal/image" @@ -121,8 +120,6 @@ func (c *client) PlanBuild(ctx context.Context) error { } // update the init log with progress - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData([]byte("> Inspecting runtime network...\n")) // inspect the runtime network for the pipeline @@ -133,8 +130,6 @@ func (c *client) PlanBuild(ctx context.Context) error { } // update the init log with network information - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(network) c.Logger.Info("creating volume") @@ -145,8 +140,6 @@ func (c *client) PlanBuild(ctx context.Context) error { } // update the init log with progress - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData([]byte("> Inspecting runtime volume...\n")) // inspect the runtime volume for the pipeline @@ -157,13 +150,9 @@ func (c *client) PlanBuild(ctx context.Context) error { } // update the init log with volume information - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(volume) // update the init log with progress - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData([]byte("> Preparing secrets...\n")) // iterate through each secret provided in the pipeline @@ -262,8 +251,6 @@ func (c *client) AssembleBuild(ctx context.Context) error { }() // update the init log with progress - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData([]byte("> Preparing service images...\n")) // create the services for the pipeline @@ -291,14 +278,10 @@ func (c *client) AssembleBuild(ctx context.Context) error { } // update the init log with service image info - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(image) } // update the init log with progress - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData([]byte("> Preparing stage images...\n")) // create the stages for the pipeline @@ -319,8 +302,6 @@ func (c *client) AssembleBuild(ctx context.Context) error { } // update the init log with progress - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData([]byte("> Preparing step images...\n")) // create the steps for the pipeline @@ -349,14 +330,10 @@ func (c *client) AssembleBuild(ctx context.Context) error { } // update the init log with step image info - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(image) } // update the init log with progress - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData([]byte("> Preparing secret images...\n")) // create the secrets for the pipeline @@ -394,8 +371,6 @@ func (c *client) AssembleBuild(ctx context.Context) error { } // update the init log with secret image info - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(image) } @@ -415,8 +390,6 @@ func (c *client) AssembleBuild(ctx context.Context) error { if len(buildOutput) > 0 { // update the init log with progress // (an empty value allows the runtime to opt out of providing this) - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(buildOutput) } @@ -427,8 +400,6 @@ func (c *client) AssembleBuild(ctx context.Context) error { } // update the init log with progress - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData([]byte("> Executing secret images...\n")) return c.err @@ -698,7 +669,7 @@ func (c *client) StreamBuild(ctx context.Context) error { // //nolint:funlen // explanation takes up a lot of lines func loadLazySecrets(c *client, _step *pipeline.Container) error { - _log := new(library.Log) + _log := new(api.Log) lazySecrets := make(map[string]*api.Secret) lazyNoSubSecrets := make(map[string]*api.Secret) @@ -836,8 +807,6 @@ func loadLazySecrets(c *client, _step *pipeline.Container) error { c.Logger.Debug("substituting container configuration after lazy loaded secret injection") // substitute container configuration - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.Substitute err = tmpStep.Substitute() if err != nil { return err diff --git a/executor/linux/build_test.go b/executor/linux/build_test.go index 4ee5696b..bf8bcf86 100644 --- a/executor/linux/build_test.go +++ b/executor/linux/build_test.go @@ -20,8 +20,8 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/native" "github.com/go-vela/server/compiler/types/pipeline" + "github.com/go-vela/server/constants" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/constants" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/runtime" "github.com/go-vela/worker/runtime/docker" diff --git a/executor/linux/driver.go b/executor/linux/driver.go index bbf3a56e..5ef1dd59 100644 --- a/executor/linux/driver.go +++ b/executor/linux/driver.go @@ -2,7 +2,7 @@ package linux -import "github.com/go-vela/types/constants" +import "github.com/go-vela/server/constants" // Driver outputs the configured executor driver. func (c *client) Driver() string { diff --git a/executor/linux/driver_test.go b/executor/linux/driver_test.go index bc12ed30..b356777d 100644 --- a/executor/linux/driver_test.go +++ b/executor/linux/driver_test.go @@ -10,8 +10,8 @@ import ( "github.com/gin-gonic/gin" "github.com/go-vela/sdk-go/vela" + "github.com/go-vela/server/constants" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/constants" "github.com/go-vela/worker/runtime/docker" ) diff --git a/executor/linux/linux_test.go b/executor/linux/linux_test.go index 45fcc05f..d6c7d0fd 100644 --- a/executor/linux/linux_test.go +++ b/executor/linux/linux_test.go @@ -14,8 +14,8 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" + "github.com/go-vela/server/constants" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/constants" "github.com/go-vela/worker/runtime/docker" ) diff --git a/executor/linux/opts_test.go b/executor/linux/opts_test.go index 707e0e21..36196330 100644 --- a/executor/linux/opts_test.go +++ b/executor/linux/opts_test.go @@ -14,8 +14,8 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" + "github.com/go-vela/server/constants" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/constants" "github.com/go-vela/worker/runtime" "github.com/go-vela/worker/runtime/docker" "github.com/go-vela/worker/runtime/kubernetes" diff --git a/executor/linux/outputs_test.go b/executor/linux/outputs_test.go index c555515d..d832be5c 100644 --- a/executor/linux/outputs_test.go +++ b/executor/linux/outputs_test.go @@ -16,8 +16,8 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/native" "github.com/go-vela/server/compiler/types/pipeline" + "github.com/go-vela/server/constants" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/constants" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/runtime" "github.com/go-vela/worker/runtime/docker" diff --git a/executor/linux/secret.go b/executor/linux/secret.go index 7577ae0d..b09d763c 100644 --- a/executor/linux/secret.go +++ b/executor/linux/secret.go @@ -15,7 +15,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/internal/step" ) @@ -275,8 +275,6 @@ func (s *secretSvc) stream(ctx context.Context, ctn *pipeline.Container) error { logger.Trace(logs.String()) // update the existing log with the last bytes - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(logs.Bytes()) logger.Debug("uploading logs") @@ -310,8 +308,6 @@ func (s *secretSvc) stream(ctx context.Context, ctn *pipeline.Container) error { logger.Trace(logs.String()) // update the existing log with the new bytes - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(logs.Bytes()) logger.Debug("appending logs") diff --git a/executor/linux/secret_test.go b/executor/linux/secret_test.go index f9a60d0a..c1f6026f 100644 --- a/executor/linux/secret_test.go +++ b/executor/linux/secret_test.go @@ -18,9 +18,8 @@ import ( "github.com/go-vela/server/api/types/actions" "github.com/go-vela/server/compiler/native" "github.com/go-vela/server/compiler/types/pipeline" + "github.com/go-vela/server/constants" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/constants" - "github.com/go-vela/types/library" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/runtime" "github.com/go-vela/worker/runtime/docker" @@ -813,14 +812,14 @@ func TestLinux_Secret_stream(t *testing.T) { name string failure bool runtime runtime.Engine - logs *library.Log + logs *api.Log container *pipeline.Container }{ { name: "docker-container step succeeds", failure: false, runtime: _docker, - logs: new(library.Log), + logs: new(api.Log), container: &pipeline.Container{ ID: "step_github_octocat_1_init", Directory: "/home/github/octocat", @@ -835,7 +834,7 @@ func TestLinux_Secret_stream(t *testing.T) { name: "kubernetes-container step succeeds", failure: false, runtime: _kubernetes, - logs: new(library.Log), + logs: new(api.Log), container: &pipeline.Container{ ID: "step-github-octocat-1-init", Directory: "/home/github/octocat", @@ -850,7 +849,7 @@ func TestLinux_Secret_stream(t *testing.T) { name: "docker-container step fails because of invalid container id", failure: true, runtime: _docker, - logs: new(library.Log), + logs: new(api.Log), container: &pipeline.Container{ ID: "secret_github_octocat_1_notfound", Directory: "/vela/src/vcs.company.com/github/octocat", @@ -865,7 +864,7 @@ func TestLinux_Secret_stream(t *testing.T) { // name: "kubernetes-container step fails because of invalid container id", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock // runtime: _kubernetes, - // logs: new(library.Log), + // logs: new(api.Log), // container: &pipeline.Container{ // ID: "secret-github-octocat-1-notfound", // Directory: "/vela/src/vcs.company.com/github/octocat", diff --git a/executor/linux/service.go b/executor/linux/service.go index a4e4621c..923320bd 100644 --- a/executor/linux/service.go +++ b/executor/linux/service.go @@ -12,7 +12,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/image" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/internal/service" @@ -49,8 +49,6 @@ func (c *client) CreateService(ctx context.Context, ctn *pipeline.Container) err logger.Debug("substituting container configuration") // substitute container configuration - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.Substitute err = ctn.Substitute() if err != nil { return fmt.Errorf("unable to substitute container configuration") @@ -69,7 +67,6 @@ func (c *client) CreateService(ctx context.Context, ctn *pipeline.Container) err // PlanService prepares the service for execution. func (c *client) PlanService(ctx context.Context, ctn *pipeline.Container) error { var err error - // update engine logger with service metadata // // https://pkg.go.dev/github.com/sirupsen/logrus#Entry.WithField @@ -215,8 +212,6 @@ func (c *client) StreamService(ctx context.Context, ctn *pipeline.Container) err } // overwrite the existing log with all bytes - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.SetData _log.SetData(data) logger.Debug("uploading logs") @@ -274,8 +269,6 @@ func (c *client) StreamService(ctx context.Context, ctn *pipeline.Container) err logger.Trace(logs.String()) // update the existing log with the new bytes - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(logs.Bytes()) logger.Debug("appending logs") @@ -331,8 +324,6 @@ func (c *client) DestroyService(ctx context.Context, ctn *pipeline.Container) er _service, err := service.Load(ctn, &c.services) if err != nil { // create the service from the container - // - // https://pkg.go.dev/github.com/go-vela/types/library#ServiceFromContainerEnvironment _service = api.ServiceFromContainerEnvironment(ctn) } diff --git a/executor/linux/service_test.go b/executor/linux/service_test.go index e8940d06..11179339 100644 --- a/executor/linux/service_test.go +++ b/executor/linux/service_test.go @@ -13,7 +13,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/library" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/runtime" "github.com/go-vela/worker/runtime/docker" @@ -439,7 +438,7 @@ func TestLinux_ExecService(t *testing.T) { if !test.container.Empty() { _engine.services.Store(test.container.ID, new(api.Service)) - _engine.serviceLogs.Store(test.container.ID, new(library.Log)) + _engine.serviceLogs.Store(test.container.ID, new(api.Log)) } err = _engine.ExecService(context.Background(), test.container) @@ -582,7 +581,7 @@ func TestLinux_StreamService(t *testing.T) { if !test.container.Empty() { _engine.services.Store(test.container.ID, new(api.Service)) - _engine.serviceLogs.Store(test.container.ID, new(library.Log)) + _engine.serviceLogs.Store(test.container.ID, new(api.Log)) } err = _engine.StreamService(context.Background(), test.container) diff --git a/executor/linux/stage.go b/executor/linux/stage.go index 823cfe4a..cfeff50b 100644 --- a/executor/linux/stage.go +++ b/executor/linux/stage.go @@ -8,7 +8,7 @@ import ( "sync" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/step" ) @@ -28,8 +28,6 @@ func (c *client) CreateStage(ctx context.Context, s *pipeline.Stage) error { logger := c.Logger.WithField("stage", s.Name) // update the init log with progress - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData([]byte(fmt.Sprintf("> Preparing step images for stage %s...\n", s.Name))) // create the steps for the stage @@ -54,8 +52,6 @@ func (c *client) CreateStage(ctx context.Context, s *pipeline.Stage) error { } // update the init log with step image info - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(image) } diff --git a/executor/linux/step.go b/executor/linux/step.go index 38dd6e0f..8568bc06 100644 --- a/executor/linux/step.go +++ b/executor/linux/step.go @@ -14,7 +14,7 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/image" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/internal/step" @@ -62,8 +62,6 @@ func (c *client) CreateStep(ctx context.Context, ctn *pipeline.Container) error if c.Runtime.Driver() == constants.DriverKubernetes { logger.Debug("substituting container configuration") // substitute container configuration - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.Substitute err = ctn.Substitute() if err != nil { return fmt.Errorf("unable to substitute container configuration") @@ -278,13 +276,9 @@ func (c *client) StreamStep(ctx context.Context, ctn *pipeline.Container) error } // overwrite the existing log with all bytes - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.SetData _log.SetData(append(existingLog.GetData(), data...)) // mask secrets in the log data - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.MaskData _log.MaskData(secretValues) logger.Debug("uploading logs") @@ -342,12 +336,9 @@ func (c *client) StreamStep(ctx context.Context, ctn *pipeline.Container) error logger.Trace(logs.String()) // update the existing log with the new bytes - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.AppendData _log.AppendData(logs.Bytes()) + // mask secrets within the logs before updating database - // - // https://pkg.go.dev/github.com/go-vela/types/library#Log.MaskData _log.MaskData(secretValues) logger.Debug("appending logs") @@ -408,8 +399,6 @@ func (c *client) DestroyStep(ctx context.Context, ctn *pipeline.Container) error _step, err := step.Load(ctn, &c.steps) if err != nil { // create the step from the container - // - // https://pkg.go.dev/github.com/go-vela/types/library#StepFromContainerEnvironment _step = api.StepFromContainerEnvironment(ctn) } diff --git a/executor/linux/step_test.go b/executor/linux/step_test.go index 93042236..30aaee0e 100644 --- a/executor/linux/step_test.go +++ b/executor/linux/step_test.go @@ -15,7 +15,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/library" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/runtime" "github.com/go-vela/worker/runtime/docker" @@ -505,7 +504,7 @@ func TestLinux_ExecStep(t *testing.T) { if !test.container.Empty() { _engine.steps.Store(test.container.ID, new(api.Step)) - _engine.stepLogs.Store(test.container.ID, new(library.Log)) + _engine.stepLogs.Store(test.container.ID, new(api.Log)) } err = _engine.ExecStep(context.Background(), test.container) @@ -528,7 +527,7 @@ func TestLinux_ExecStep(t *testing.T) { func TestLinux_StreamStep(t *testing.T) { // setup types _build := testBuild() - _logs := new(library.Log) + _logs := new(api.Log) // fill log with bytes _logs.SetData(make([]byte, 1000)) @@ -557,7 +556,7 @@ func TestLinux_StreamStep(t *testing.T) { name string failure bool runtime runtime.Engine - logs *library.Log + logs *api.Log container *pipeline.Container }{ { @@ -682,7 +681,7 @@ func TestLinux_StreamStep(t *testing.T) { if !test.container.Empty() { _engine.steps.Store(test.container.ID, new(api.Step)) - _engine.stepLogs.Store(test.container.ID, new(library.Log)) + _engine.stepLogs.Store(test.container.ID, new(api.Log)) } err = _engine.StreamStep(context.Background(), test.container) diff --git a/executor/local/api.go b/executor/local/api.go index ee48a56d..9fa40647 100644 --- a/executor/local/api.go +++ b/executor/local/api.go @@ -9,7 +9,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/service" "github.com/go-vela/worker/internal/step" ) diff --git a/executor/local/build.go b/executor/local/build.go index c3d9e196..62be5b3f 100644 --- a/executor/local/build.go +++ b/executor/local/build.go @@ -11,7 +11,7 @@ import ( "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/build" "github.com/go-vela/worker/internal/step" ) diff --git a/executor/local/driver.go b/executor/local/driver.go index 981ddf1d..34a50b91 100644 --- a/executor/local/driver.go +++ b/executor/local/driver.go @@ -2,7 +2,7 @@ package local -import "github.com/go-vela/types/constants" +import "github.com/go-vela/server/constants" // Driver outputs the configured executor driver. func (c *client) Driver() string { diff --git a/executor/local/driver_test.go b/executor/local/driver_test.go index 75d68114..3d74637d 100644 --- a/executor/local/driver_test.go +++ b/executor/local/driver_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/runtime/docker" ) diff --git a/executor/local/service.go b/executor/local/service.go index 1f5f51ab..c1417a24 100644 --- a/executor/local/service.go +++ b/executor/local/service.go @@ -10,7 +10,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/internal/service" ) @@ -35,8 +35,6 @@ func (c *client) CreateService(ctx context.Context, ctn *pipeline.Container) err } // substitute container configuration - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.Substitute err = ctn.Substitute() if err != nil { return err @@ -135,8 +133,6 @@ func (c *client) DestroyService(ctx context.Context, ctn *pipeline.Container) er _service, err := service.Load(ctn, &c.services) if err != nil { // create the service from the container - // - // https://pkg.go.dev/github.com/go-vela/types/library#ServiceFromContainerEnvironment _service = api.ServiceFromContainerEnvironment(ctn) } diff --git a/executor/local/step.go b/executor/local/step.go index 2ee95b5b..9154e848 100644 --- a/executor/local/step.go +++ b/executor/local/step.go @@ -10,7 +10,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/message" "github.com/go-vela/worker/internal/step" ) @@ -32,8 +32,6 @@ func (c *client) CreateStep(ctx context.Context, ctn *pipeline.Container) error } // substitute container configuration - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.Substitute err = ctn.Substitute() if err != nil { return err @@ -169,8 +167,6 @@ func (c *client) DestroyStep(ctx context.Context, ctn *pipeline.Container) error _step, err := step.Load(ctn, &c.steps) if err != nil { // create the step from the container - // - // https://pkg.go.dev/github.com/go-vela/types/library#StepFromContainerEnvironment _step = api.StepFromContainerEnvironment(ctn) } diff --git a/executor/setup.go b/executor/setup.go index 2edbb2a0..51ded028 100644 --- a/executor/setup.go +++ b/executor/setup.go @@ -12,7 +12,7 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/executor/linux" "github.com/go-vela/worker/executor/local" "github.com/go-vela/worker/runtime" diff --git a/executor/setup_test.go b/executor/setup_test.go index 48193850..e89700a7 100644 --- a/executor/setup_test.go +++ b/executor/setup_test.go @@ -12,8 +12,8 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" + "github.com/go-vela/server/constants" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/constants" "github.com/go-vela/worker/executor/linux" "github.com/go-vela/worker/executor/local" "github.com/go-vela/worker/runtime/docker" diff --git a/go.mod b/go.mod index 55f10ddb..22ff2514 100644 --- a/go.mod +++ b/go.mod @@ -8,9 +8,8 @@ require ( github.com/docker/docker v27.3.1+incompatible github.com/docker/go-units v0.5.0 github.com/gin-gonic/gin v1.10.0 - github.com/go-vela/sdk-go v0.25.2-0.20241018192247-0d47b4597aaf - github.com/go-vela/server v0.25.1-0.20241018194931-72b59eb80018 - github.com/go-vela/types v0.25.1 + github.com/go-vela/sdk-go v0.25.2-0.20241022142543-b9de2ce2abea + github.com/go-vela/server v0.25.1-0.20241022141112-a2b0d9146d65 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/go-cmp v0.6.0 github.com/joho/godotenv v1.5.1 diff --git a/go.sum b/go.sum index 290af08c..2571aa1b 100644 --- a/go.sum +++ b/go.sum @@ -109,12 +109,10 @@ github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27 github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/go-vela/sdk-go v0.25.2-0.20241018192247-0d47b4597aaf h1:TH5ygvwQKBtOa9QAT76Jl8is/fwBz+NjDSlir8aXYSs= -github.com/go-vela/sdk-go v0.25.2-0.20241018192247-0d47b4597aaf/go.mod h1:g9/Ic60AgLYuML1Wf/NTxewqNSGN8K+9tIX38ZPWDQo= -github.com/go-vela/server v0.25.1-0.20241018194931-72b59eb80018 h1:UpJSFzf4qKAHnuPcmCfsCl9Go0hbzUBKInFSEkO2Rlw= -github.com/go-vela/server v0.25.1-0.20241018194931-72b59eb80018/go.mod h1:/DmGHNzsjsBOStLzlGDIDGCmNztUgCdvHiuWmyafFs8= -github.com/go-vela/types v0.25.1 h1:DCPHv1+ouqldjfsjfcVTcm/Yyd0OwazIfxYyR+GwpMo= -github.com/go-vela/types v0.25.1/go.mod h1:5+MHUI9ZSY2Uz1cTJa64FWUv8jKzzUUq96UQTokGJzs= +github.com/go-vela/sdk-go v0.25.2-0.20241022142543-b9de2ce2abea h1:tdUe3vW8HCMutfmttFt3UE0hH8qHSz4PgQYs4Q2eBX0= +github.com/go-vela/sdk-go v0.25.2-0.20241022142543-b9de2ce2abea/go.mod h1:4Q8UW6fLzke4SVU1dJBViZMOSfMiIKMGZ42lPrzk5WA= +github.com/go-vela/server v0.25.1-0.20241022141112-a2b0d9146d65 h1:BepNezNRDLfookgMn81U9WB0/aMBxkqot9w8nLPWNhU= +github.com/go-vela/server v0.25.1-0.20241022141112-a2b0d9146d65/go.mod h1:hdVkyyxnRtk+Vjs7nCnKEkwWmd9yVQUV5Akpt7BY6wg= github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= diff --git a/internal/build/snapshot.go b/internal/build/snapshot.go index e2864882..f07a00aa 100644 --- a/internal/build/snapshot.go +++ b/internal/build/snapshot.go @@ -10,7 +10,7 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Snapshot creates a moment in time record of the build diff --git a/internal/build/upload.go b/internal/build/upload.go index f3994e7d..b20ecfc4 100644 --- a/internal/build/upload.go +++ b/internal/build/upload.go @@ -10,7 +10,7 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Upload tracks the final state of the build diff --git a/internal/service/environment.go b/internal/service/environment.go index 4368e471..2100a355 100644 --- a/internal/service/environment.go +++ b/internal/service/environment.go @@ -7,7 +7,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Environment attempts to update the environment variables @@ -41,10 +41,6 @@ func Environment(c *pipeline.Container, b *api.Build, s *api.Service, version st c.Environment["VELA_VERSION"] = version // populate environment variables from build library - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.MergeEnv - // -> - // https://pkg.go.dev/github.com/go-vela/types/library#Build.Environment err := c.MergeEnv(b.Environment(workspace, channel)) if err != nil { return err @@ -52,8 +48,6 @@ func Environment(c *pipeline.Container, b *api.Build, s *api.Service, version st } // populate environment variables from repo library - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.MergeEnv err := c.MergeEnv(b.GetRepo().Environment()) if err != nil { return err @@ -62,10 +56,6 @@ func Environment(c *pipeline.Container, b *api.Build, s *api.Service, version st // check if the service provided is empty if s != nil { // populate environment variables from service library - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.MergeEnv - // -> - // https://pkg.go.dev/github.com/go-vela/types/library#Service.Environment err := c.MergeEnv(s.Environment()) if err != nil { return err diff --git a/internal/service/load.go b/internal/service/load.go index 85a8bf3c..4be50761 100644 --- a/internal/service/load.go +++ b/internal/service/load.go @@ -8,7 +8,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/library" ) // Load attempts to capture the library service @@ -36,7 +35,7 @@ func Load(c *pipeline.Container, m *sync.Map) (*api.Service, error) { // LoadLogs attempts to capture the library service logs // representing the container from the map. -func LoadLogs(c *pipeline.Container, m *sync.Map) (*library.Log, error) { +func LoadLogs(c *pipeline.Container, m *sync.Map) (*api.Log, error) { // check if the container provided is empty if c == nil { return nil, fmt.Errorf("empty container provided") @@ -49,7 +48,7 @@ func LoadLogs(c *pipeline.Container, m *sync.Map) (*library.Log, error) { } // cast the value from the service log key to the expected type - l, ok := result.(*library.Log) + l, ok := result.(*api.Log) if !ok { return nil, fmt.Errorf("unable to cast value to logs for service %s", c.ID) } diff --git a/internal/service/load_test.go b/internal/service/load_test.go index 9856eb77..a605d8d5 100644 --- a/internal/service/load_test.go +++ b/internal/service/load_test.go @@ -9,7 +9,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/library" ) func TestService_Load(t *testing.T) { @@ -107,7 +106,7 @@ func TestStep_LoadLogs(t *testing.T) { } goodMap := new(sync.Map) - goodMap.Store(c.ID, new(library.Log)) + goodMap.Store(c.ID, new(api.Log)) badMap := new(sync.Map) badMap.Store(c.ID, c) @@ -118,13 +117,13 @@ func TestStep_LoadLogs(t *testing.T) { failure bool container *pipeline.Container _map *sync.Map - want *library.Log + want *api.Log }{ { name: "good map", failure: false, container: c, - want: new(library.Log), + want: new(api.Log), _map: goodMap, }, { diff --git a/internal/service/snapshot.go b/internal/service/snapshot.go index 53effcd6..b4f52086 100644 --- a/internal/service/snapshot.go +++ b/internal/service/snapshot.go @@ -11,7 +11,7 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Snapshot creates a moment in time record of the diff --git a/internal/service/upload.go b/internal/service/upload.go index e29defc8..cf43c436 100644 --- a/internal/service/upload.go +++ b/internal/service/upload.go @@ -10,7 +10,7 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Upload tracks the final state of the service diff --git a/internal/step/environment.go b/internal/step/environment.go index d395936b..f883aff4 100644 --- a/internal/step/environment.go +++ b/internal/step/environment.go @@ -7,7 +7,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Environment attempts to update the environment variables @@ -44,10 +44,6 @@ func Environment(c *pipeline.Container, b *api.Build, s *api.Step, version, reqT c.Environment["VELA_MASKED_OUTPUTS"] = "/vela/outputs/masked.env" // populate environment variables from build library - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.MergeEnv - // -> - // https://pkg.go.dev/github.com/go-vela/types/library#Build.Environment err := c.MergeEnv(b.Environment(workspace, channel)) if err != nil { return err @@ -55,8 +51,6 @@ func Environment(c *pipeline.Container, b *api.Build, s *api.Step, version, reqT } // populate environment variables from build library - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.MergeEnv err := c.MergeEnv(b.GetRepo().Environment()) if err != nil { return err @@ -65,10 +59,6 @@ func Environment(c *pipeline.Container, b *api.Build, s *api.Step, version, reqT // check if the step provided is empty if s != nil { // populate environment variables from step library - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.MergeEnv - // -> - // https://pkg.go.dev/github.com/go-vela/types/library#Service.Environment err := c.MergeEnv(s.Environment()) if err != nil { return err diff --git a/internal/step/load.go b/internal/step/load.go index d543a6e8..e2f23f3f 100644 --- a/internal/step/load.go +++ b/internal/step/load.go @@ -8,7 +8,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/library" ) // Load attempts to capture the library step @@ -62,7 +61,7 @@ func LoadInit(p *pipeline.Build) (*pipeline.Container, error) { // LoadLogs attempts to capture the library step logs // representing the container from the map. -func LoadLogs(c *pipeline.Container, m *sync.Map) (*library.Log, error) { +func LoadLogs(c *pipeline.Container, m *sync.Map) (*api.Log, error) { // check if the container provided is empty if c == nil { return nil, fmt.Errorf("empty container provided") @@ -75,7 +74,7 @@ func LoadLogs(c *pipeline.Container, m *sync.Map) (*library.Log, error) { } // cast the value from the step log key to the expected type - l, ok := result.(*library.Log) + l, ok := result.(*api.Log) if !ok { return nil, fmt.Errorf("unable to cast value to logs for step %s", c.ID) } diff --git a/internal/step/load_test.go b/internal/step/load_test.go index b20b7ff7..03534975 100644 --- a/internal/step/load_test.go +++ b/internal/step/load_test.go @@ -9,7 +9,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/library" ) func TestStep_Load(t *testing.T) { @@ -206,7 +205,7 @@ func TestStep_LoadLogs(t *testing.T) { } goodMap := new(sync.Map) - goodMap.Store(c.ID, new(library.Log)) + goodMap.Store(c.ID, new(api.Log)) badMap := new(sync.Map) badMap.Store(c.ID, c) @@ -217,13 +216,13 @@ func TestStep_LoadLogs(t *testing.T) { failure bool container *pipeline.Container _map *sync.Map - want *library.Log + want *api.Log }{ { name: "good map", failure: false, container: c, - want: new(library.Log), + want: new(api.Log), _map: goodMap, }, { diff --git a/internal/step/skip.go b/internal/step/skip.go index 641f2916..ca08740b 100644 --- a/internal/step/skip.go +++ b/internal/step/skip.go @@ -7,7 +7,7 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Skip creates the ruledata from the build and repository @@ -28,8 +28,6 @@ func Skip(c *pipeline.Container, b *api.Build) (bool, error) { } // create ruledata from build and repository information - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#RuleData ruledata := &pipeline.RuleData{ Branch: b.GetBranch(), Event: event, @@ -62,8 +60,6 @@ func Skip(c *pipeline.Container, b *api.Build) (bool, error) { } // return the inverse of container execute - // - // https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.Execute exec, err := c.Execute(ruledata) return !exec, err diff --git a/internal/step/snapshot.go b/internal/step/snapshot.go index 0f271077..4d67d390 100644 --- a/internal/step/snapshot.go +++ b/internal/step/snapshot.go @@ -11,8 +11,7 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" - "github.com/go-vela/types/library" + "github.com/go-vela/server/constants" ) // Snapshot creates a moment in time record of the @@ -68,7 +67,7 @@ func Snapshot(ctn *pipeline.Container, b *api.Build, c *vela.Client, l *logrus.E // SnapshotInit creates a moment in time record of the // init step and attempts to upload it to the server. -func SnapshotInit(ctn *pipeline.Container, b *api.Build, c *vela.Client, l *logrus.Entry, s *api.Step, lg *library.Log) { +func SnapshotInit(ctn *pipeline.Container, b *api.Build, c *vela.Client, l *logrus.Entry, s *api.Step, lg *api.Log) { // check if the build is not in a canceled status if !strings.EqualFold(s.GetStatus(), constants.StatusCanceled) { // check if the container has an unsuccessful exit code diff --git a/internal/step/snapshot_test.go b/internal/step/snapshot_test.go index 1d546157..835d238d 100644 --- a/internal/step/snapshot_test.go +++ b/internal/step/snapshot_test.go @@ -12,7 +12,6 @@ import ( api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" "github.com/go-vela/server/mock/server" - "github.com/go-vela/types/library" ) func TestStep_Snapshot(t *testing.T) { @@ -237,7 +236,7 @@ func TestStep_SnapshotInit(t *testing.T) { build *api.Build client *vela.Client container *pipeline.Container - log *library.Log + log *api.Log step *api.Step }{ { @@ -245,7 +244,7 @@ func TestStep_SnapshotInit(t *testing.T) { build: _build, client: _client, container: _container, - log: new(library.Log), + log: new(api.Log), step: _step, }, { @@ -253,7 +252,7 @@ func TestStep_SnapshotInit(t *testing.T) { build: _build, client: _client, container: _exitCode, - log: new(library.Log), + log: new(api.Log), step: nil, }, } diff --git a/internal/step/upload.go b/internal/step/upload.go index 13fc77d0..5fe38454 100644 --- a/internal/step/upload.go +++ b/internal/step/upload.go @@ -10,7 +10,7 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Upload tracks the final state of the step diff --git a/mock/worker/build.go b/mock/worker/build.go index a9558c43..eea3e1ba 100644 --- a/mock/worker/build.go +++ b/mock/worker/build.go @@ -11,7 +11,6 @@ import ( "github.com/gin-gonic/gin" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types" ) const ( @@ -105,7 +104,7 @@ func getBuild(c *gin.Context) { if strings.EqualFold(b, "0") { msg := fmt.Sprintf("Build %s does not exist", b) - c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusNotFound, api.Error{Message: &msg}) return } @@ -127,7 +126,7 @@ func cancelBuild(c *gin.Context) { if strings.EqualFold(b, "0") { msg := fmt.Sprintf("Build %s does not exist", b) - c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusNotFound, api.Error{Message: &msg}) return } diff --git a/mock/worker/executor.go b/mock/worker/executor.go index 44744c2d..b66ed1f4 100644 --- a/mock/worker/executor.go +++ b/mock/worker/executor.go @@ -11,7 +11,6 @@ import ( "github.com/gin-gonic/gin" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types" ) const ( @@ -48,7 +47,7 @@ func getExecutor(c *gin.Context) { if strings.EqualFold(w, "0") { msg := fmt.Sprintf("Executor %s does not exist", w) - c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusNotFound, api.Error{Message: &msg}) return } diff --git a/mock/worker/pipeline.go b/mock/worker/pipeline.go index 5f13c9e2..e9de0e51 100644 --- a/mock/worker/pipeline.go +++ b/mock/worker/pipeline.go @@ -11,7 +11,6 @@ import ( "github.com/gin-gonic/gin" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types" ) const ( @@ -44,7 +43,7 @@ func getPipeline(c *gin.Context) { if strings.EqualFold(p, "0") { msg := fmt.Sprintf("Pipeline %s does not exist", p) - c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusNotFound, api.Error{Message: &msg}) return } diff --git a/mock/worker/repo.go b/mock/worker/repo.go index 766097bf..49c4cd00 100644 --- a/mock/worker/repo.go +++ b/mock/worker/repo.go @@ -11,7 +11,6 @@ import ( "github.com/gin-gonic/gin" api "github.com/go-vela/server/api/types" - "github.com/go-vela/types" ) const ( @@ -47,7 +46,7 @@ func getRepo(c *gin.Context) { if strings.Contains(r, "not-found") { msg := fmt.Sprintf("Repo %s does not exist", r) - c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusNotFound, api.Error{Message: &msg}) return } diff --git a/router/middleware/executor/executor.go b/router/middleware/executor/executor.go index 6954b975..2e9a8fe6 100644 --- a/router/middleware/executor/executor.go +++ b/router/middleware/executor/executor.go @@ -10,7 +10,7 @@ import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" - "github.com/go-vela/types" + api "github.com/go-vela/server/api/types" "github.com/go-vela/worker/executor" ) @@ -26,7 +26,7 @@ func Establish() gin.HandlerFunc { if len(param) == 0 { msg := "No executor parameter provided" - c.AbortWithStatusJSON(http.StatusBadRequest, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusBadRequest, api.Error{Message: &msg}) return } @@ -35,7 +35,7 @@ func Establish() gin.HandlerFunc { if err != nil { msg := fmt.Sprintf("invalid executor parameter provided: %s", param) - c.AbortWithStatusJSON(http.StatusBadRequest, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusBadRequest, api.Error{Message: &msg}) return } @@ -45,7 +45,7 @@ func Establish() gin.HandlerFunc { if value == nil { msg := "no running executors found" - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -55,7 +55,7 @@ func Establish() gin.HandlerFunc { if !ok { msg := "unable to get executors" - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -66,7 +66,7 @@ func Establish() gin.HandlerFunc { if !ok { msg := fmt.Sprintf("unable to get executor %s", param) - c.AbortWithStatusJSON(http.StatusBadRequest, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusBadRequest, api.Error{Message: &msg}) return } diff --git a/router/middleware/executor/executor_test.go b/router/middleware/executor/executor_test.go index 78913ee6..e522af22 100644 --- a/router/middleware/executor/executor_test.go +++ b/router/middleware/executor/executor_test.go @@ -13,7 +13,7 @@ import ( "github.com/go-vela/sdk-go/vela" api "github.com/go-vela/server/api/types" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/executor" "github.com/go-vela/worker/runtime/docker" ) diff --git a/router/middleware/perm/perm.go b/router/middleware/perm/perm.go index a6ff7b88..d5bf5ec8 100644 --- a/router/middleware/perm/perm.go +++ b/router/middleware/perm/perm.go @@ -11,7 +11,7 @@ import ( "github.com/sirupsen/logrus" "github.com/go-vela/sdk-go/vela" - "github.com/go-vela/types" + api "github.com/go-vela/server/api/types" "github.com/go-vela/worker/router/middleware/token" ) @@ -25,7 +25,7 @@ func MustServer() gin.HandlerFunc { logrus.Error(msg) - c.AbortWithStatusJSON(http.StatusBadRequest, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusBadRequest, api.Error{Message: &msg}) return } @@ -40,7 +40,7 @@ func MustServer() gin.HandlerFunc { logrus.Error(msg) - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -51,7 +51,7 @@ func MustServer() gin.HandlerFunc { logrus.Error(msg) - c.AbortWithStatusJSON(http.StatusBadRequest, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusBadRequest, api.Error{Message: &msg}) return } @@ -66,7 +66,7 @@ func MustServer() gin.HandlerFunc { logrus.Error(msg) - c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg}) return } @@ -77,7 +77,7 @@ func MustServer() gin.HandlerFunc { logrus.Error(msg) - c.AbortWithStatusJSON(http.StatusUnauthorized, types.Error{Message: &msg}) + c.AbortWithStatusJSON(http.StatusUnauthorized, api.Error{Message: &msg}) return } diff --git a/runtime/context_test.go b/runtime/context_test.go index d8088201..8f1c7fe3 100644 --- a/runtime/context_test.go +++ b/runtime/context_test.go @@ -9,7 +9,7 @@ import ( "github.com/gin-gonic/gin" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) func TestRuntime_FromContext(t *testing.T) { diff --git a/runtime/docker/container.go b/runtime/docker/container.go index 07a6c1f9..811b69ca 100644 --- a/runtime/docker/container.go +++ b/runtime/docker/container.go @@ -15,7 +15,7 @@ import ( "github.com/docker/docker/pkg/stdcopy" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/image" ) diff --git a/runtime/docker/driver.go b/runtime/docker/driver.go index e2d94f15..420d75c2 100644 --- a/runtime/docker/driver.go +++ b/runtime/docker/driver.go @@ -2,7 +2,7 @@ package docker -import "github.com/go-vela/types/constants" +import "github.com/go-vela/server/constants" // Driver outputs the configured runtime driver. func (c *client) Driver() string { diff --git a/runtime/docker/driver_test.go b/runtime/docker/driver_test.go index e062708b..ba11041c 100644 --- a/runtime/docker/driver_test.go +++ b/runtime/docker/driver_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) func TestDocker_Driver(t *testing.T) { diff --git a/runtime/docker/image.go b/runtime/docker/image.go index c3b62ef8..67888873 100644 --- a/runtime/docker/image.go +++ b/runtime/docker/image.go @@ -13,7 +13,7 @@ import ( "github.com/sirupsen/logrus" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/image" ) diff --git a/runtime/docker/volume.go b/runtime/docker/volume.go index 5c846a2c..d14cca4b 100644 --- a/runtime/docker/volume.go +++ b/runtime/docker/volume.go @@ -14,7 +14,7 @@ import ( "github.com/sirupsen/logrus" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" vol "github.com/go-vela/worker/internal/volume" ) diff --git a/runtime/flags.go b/runtime/flags.go index 7a65da6c..ded1ebc7 100644 --- a/runtime/flags.go +++ b/runtime/flags.go @@ -5,7 +5,7 @@ package runtime import ( "github.com/urfave/cli/v2" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // Flags represents all supported command line diff --git a/runtime/kubernetes/container.go b/runtime/kubernetes/container.go index 076d2641..576cf417 100644 --- a/runtime/kubernetes/container.go +++ b/runtime/kubernetes/container.go @@ -16,7 +16,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/internal/image" ) diff --git a/runtime/kubernetes/driver.go b/runtime/kubernetes/driver.go index 6adadbfc..5f2d1c0a 100644 --- a/runtime/kubernetes/driver.go +++ b/runtime/kubernetes/driver.go @@ -2,7 +2,7 @@ package kubernetes -import "github.com/go-vela/types/constants" +import "github.com/go-vela/server/constants" // Driver outputs the configured runtime driver. func (c *client) Driver() string { diff --git a/runtime/kubernetes/driver_test.go b/runtime/kubernetes/driver_test.go index 222537b6..0f4d7953 100644 --- a/runtime/kubernetes/driver_test.go +++ b/runtime/kubernetes/driver_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) func TestKubernetes_Driver(t *testing.T) { diff --git a/runtime/kubernetes/image.go b/runtime/kubernetes/image.go index 9824bc10..0542cbfb 100644 --- a/runtime/kubernetes/image.go +++ b/runtime/kubernetes/image.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) const ( diff --git a/runtime/kubernetes/volume.go b/runtime/kubernetes/volume.go index c3a0581d..394db079 100644 --- a/runtime/kubernetes/volume.go +++ b/runtime/kubernetes/volume.go @@ -11,7 +11,7 @@ import ( v1 "k8s.io/api/core/v1" "github.com/go-vela/server/compiler/types/pipeline" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" vol "github.com/go-vela/worker/internal/volume" ) diff --git a/runtime/runtime.go b/runtime/runtime.go index a3889bfb..094a1b86 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -7,7 +7,7 @@ import ( "github.com/sirupsen/logrus" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) // New creates and returns a Vela engine capable of diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index 474a9e8e..5fe2f9ad 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -5,7 +5,7 @@ package runtime import ( "testing" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) func TestRuntime_New(t *testing.T) { diff --git a/runtime/setup.go b/runtime/setup.go index 7c491223..aae289a7 100644 --- a/runtime/setup.go +++ b/runtime/setup.go @@ -10,7 +10,7 @@ import ( "github.com/sirupsen/logrus" v1 "k8s.io/api/core/v1" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" "github.com/go-vela/worker/runtime/docker" "github.com/go-vela/worker/runtime/kubernetes" ) diff --git a/runtime/setup_test.go b/runtime/setup_test.go index 67c6047e..57f4b2c7 100644 --- a/runtime/setup_test.go +++ b/runtime/setup_test.go @@ -5,7 +5,7 @@ package runtime import ( "testing" - "github.com/go-vela/types/constants" + "github.com/go-vela/server/constants" ) func TestRuntime_Setup_Docker(t *testing.T) { diff --git a/version/version.go b/version/version.go index f363d79b..f0709fe4 100644 --- a/version/version.go +++ b/version/version.go @@ -9,7 +9,7 @@ import ( "github.com/Masterminds/semver/v3" "github.com/sirupsen/logrus" - "github.com/go-vela/types/version" + "github.com/go-vela/server/version" ) var (