Skip to content

Commit

Permalink
chore: use server API and compiler types (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper authored Oct 18, 2024
1 parent 1632331 commit 0e10f28
Show file tree
Hide file tree
Showing 81 changed files with 217 additions and 222 deletions.
2 changes: 1 addition & 1 deletion cmd/vela-worker/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ 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/queue/models"
"github.com/go-vela/types"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/worker/executor"
"github.com/go-vela/worker/runtime"
"github.com/go-vela/worker/version"
Expand Down
2 changes: 1 addition & 1 deletion cmd/vela-worker/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
_ "github.com/joho/godotenv/autoload"

api "github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/queue"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/worker/executor"
"github.com/go-vela/worker/runtime"
)
Expand Down
2 changes: 1 addition & 1 deletion executor/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"

api "github.com/go-vela/server/api/types"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/server/compiler/types/pipeline"
)

// Engine represents the interface for Vela integrating
Expand Down
2 changes: 1 addition & 1 deletion executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/go-vela/sdk-go/vela"
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/mock/server"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/worker/executor/linux"
"github.com/go-vela/worker/executor/local"
"github.com/go-vela/worker/runtime/docker"
Expand Down
9 changes: 4 additions & 5 deletions executor/linux/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (
"time"

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/types/pipeline"
"github.com/go-vela/worker/internal/service"
"github.com/go-vela/worker/internal/step"
)
Expand Down Expand Up @@ -63,7 +62,7 @@ func (c *client) CancelBuild() (*api.Build, error) {
s, err := service.Load(_service, &c.services)
if err != nil {
// create the library service object
s = new(library.Service)
s = new(api.Service)
s.SetName(_service.Name)
s.SetNumber(_service.Number)
s.SetImage(_service.Image)
Expand Down Expand Up @@ -104,7 +103,7 @@ func (c *client) CancelBuild() (*api.Build, error) {
s, err := step.Load(_step, &c.steps)
if err != nil {
// create the library step object
s = new(library.Step)
s = new(api.Step)
s.SetName(_step.Name)
s.SetNumber(_step.Number)
s.SetImage(_step.Image)
Expand Down Expand Up @@ -146,7 +145,7 @@ func (c *client) CancelBuild() (*api.Build, error) {
s, err := step.Load(_step, &c.steps)
if err != nil {
// create the library step object
s = new(library.Step)
s = new(api.Step)
s.SetName(_step.Name)
s.SetNumber(_step.Number)
s.SetImage(_step.Image)
Expand Down
7 changes: 4 additions & 3 deletions executor/linux/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (

"golang.org/x/sync/errgroup"

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/types/pipeline"
"github.com/go-vela/worker/internal/build"
context2 "github.com/go-vela/worker/internal/context"
"github.com/go-vela/worker/internal/image"
Expand Down Expand Up @@ -699,8 +700,8 @@ func (c *client) StreamBuild(ctx context.Context) error {
func loadLazySecrets(c *client, _step *pipeline.Container) error {
_log := new(library.Log)

lazySecrets := make(map[string]*library.Secret)
lazyNoSubSecrets := make(map[string]*library.Secret)
lazySecrets := make(map[string]*api.Secret)
lazyNoSubSecrets := make(map[string]*api.Secret)

// this requires a small preface and brief description on
// how normal secrets make it into a container:
Expand Down
2 changes: 1 addition & 1 deletion executor/linux/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"github.com/go-vela/sdk-go/vela"
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/mock/server"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/worker/internal/message"
"github.com/go-vela/worker/runtime"
"github.com/go-vela/worker/runtime/docker"
Expand Down
11 changes: 5 additions & 6 deletions executor/linux/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (

"github.com/go-vela/sdk-go/vela"
api "github.com/go-vela/server/api/types"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/worker/internal/message"
"github.com/go-vela/worker/runtime"
)
Expand All @@ -25,8 +24,8 @@ type (
Logger *logrus.Entry
Vela *vela.Client
Runtime runtime.Engine
Secrets map[string]*library.Secret
NoSubSecrets map[string]*library.Secret
Secrets map[string]*api.Secret
NoSubSecrets map[string]*api.Secret
Hostname string
Version string
OutputCtn *pipeline.Container
Expand Down Expand Up @@ -117,10 +116,10 @@ func New(opts ...Opt) (*client, error) {
}

// instantiate map for non-plugin secrets
c.Secrets = make(map[string]*library.Secret)
c.Secrets = make(map[string]*api.Secret)

// instantiate map for non-substituted secrets
c.NoSubSecrets = make(map[string]*library.Secret)
c.NoSubSecrets = make(map[string]*api.Secret)

// instantiate all client services
c.secret = &secretSvc{client: c}
Expand Down
2 changes: 1 addition & 1 deletion executor/linux/linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ 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/mock/server"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/worker/runtime/docker"
)

Expand Down
2 changes: 1 addition & 1 deletion executor/linux/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/pipeline"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/worker/internal/message"
"github.com/go-vela/worker/runtime"
)
Expand Down
2 changes: 1 addition & 1 deletion executor/linux/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ 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/mock/server"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/worker/runtime"
"github.com/go-vela/worker/runtime/docker"
"github.com/go-vela/worker/runtime/kubernetes"
Expand Down
2 changes: 1 addition & 1 deletion executor/linux/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
envparse "github.com/hashicorp/go-envparse"
"github.com/sirupsen/logrus"

"github.com/go-vela/types/pipeline"
"github.com/go-vela/server/compiler/types/pipeline"
)

// outputSvc handles communication with the outputs container during the build.
Expand Down
14 changes: 7 additions & 7 deletions executor/linux/outputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"github.com/urfave/cli/v2"

"github.com/go-vela/sdk-go/vela"
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/mock/server"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/worker/internal/message"
"github.com/go-vela/worker/runtime"
"github.com/go-vela/worker/runtime/docker"
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestLinux_Outputs_delete(t *testing.T) {
t.Errorf("unable to create docker runtime engine: %v", err)
}

_step := new(library.Step)
_step := new(api.Step)
_step.SetName("clone")
_step.SetNumber(2)
_step.SetStatus(constants.StatusPending)
Expand All @@ -154,7 +154,7 @@ func TestLinux_Outputs_delete(t *testing.T) {
failure bool
runtime runtime.Engine
container *pipeline.Container
step *library.Step
step *api.Step
steps *pipeline.Build
}{
{
Expand All @@ -170,7 +170,7 @@ func TestLinux_Outputs_delete(t *testing.T) {
Number: 1,
Pull: "always",
},
step: new(library.Step),
step: new(api.Step),
steps: _dockerSteps,
},
{
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestLinux_Outputs_delete(t *testing.T) {
Number: 2,
Pull: "always",
},
step: new(library.Step),
step: new(api.Step),
steps: _dockerSteps,
},
{
Expand All @@ -218,7 +218,7 @@ func TestLinux_Outputs_delete(t *testing.T) {
Number: 2,
Pull: "always",
},
step: new(library.Step),
step: new(api.Step),
steps: _dockerSteps,
},
{
Expand Down
12 changes: 6 additions & 6 deletions executor/linux/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (

"github.com/sirupsen/logrus"

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/types/pipeline"
"github.com/go-vela/worker/internal/message"
"github.com/go-vela/worker/internal/step"
)
Expand Down Expand Up @@ -190,8 +190,8 @@ func (s *secretSvc) exec(ctx context.Context, p *pipeline.SecretSlice) error {
}

// pull defines a function that pulls the secrets from the server for a given pipeline.
func (s *secretSvc) pull(secret *pipeline.Secret) (*library.Secret, error) {
_secret := new(library.Secret)
func (s *secretSvc) pull(secret *pipeline.Secret) (*api.Secret, error) {
_secret := new(api.Secret)

switch secret.Type {
// handle repo secrets
Expand Down Expand Up @@ -336,7 +336,7 @@ func (s *secretSvc) stream(ctx context.Context, ctn *pipeline.Container) error {
// TODO: Evaluate pulling this into a "bool" types function for injecting
//
// helper function to check secret whitelist before setting value.
func injectSecrets(ctn *pipeline.Container, m map[string]*library.Secret) error {
func injectSecrets(ctn *pipeline.Container, m map[string]*api.Secret) error {
// inject secrets for step
for _, _secret := range ctn.Secrets {
logrus.Tracef("looking up secret %s from pipeline secrets", _secret.Source)
Expand All @@ -358,7 +358,7 @@ func injectSecrets(ctn *pipeline.Container, m map[string]*library.Secret) error

// escapeNewlineSecrets is a helper function to double-escape escaped newlines,
// double-escaped newlines are resolved to newlines during env substitution.
func escapeNewlineSecrets(m map[string]*library.Secret) {
func escapeNewlineSecrets(m map[string]*api.Secret) {
for i, secret := range m {
// only double-escape secrets that have been manually escaped
if !strings.Contains(secret.GetValue(), "\\\\n") {
Expand Down
Loading

0 comments on commit 0e10f28

Please sign in to comment.