Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove types dependency #583

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions action/deployment/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ import (

"github.com/go-vela/cli/internal/output"
"github.com/go-vela/sdk-go/vela"
"github.com/go-vela/types/library"
api "github.com/go-vela/server/api/types"
)

// Add creates a deployment based off the provided configuration.
func (c *Config) Add(client *vela.Client) error {
logrus.Debug("executing add for deployment configuration")

// create the deployment object
//
// https://pkg.go.dev/github.com/go-vela/types/library?tab=doc#Deployment
d := &library.Deployment{
d := &api.Deployment{
Ref: &c.Ref,
Task: &c.Task,
Target: &c.Target,
Expand Down
2 changes: 1 addition & 1 deletion action/deployment/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"testing"

"github.com/go-vela/sdk-go/vela"
"github.com/go-vela/server/compiler/types/raw"
"github.com/go-vela/server/mock/server"
"github.com/go-vela/types/raw"
)

func TestDeployment_Config_Add(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion action/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package deployment

import (
"github.com/go-vela/cli/internal/output"
"github.com/go-vela/types/raw"
"github.com/go-vela/server/compiler/types/raw"
)

// Config represents the configuration necessary
Expand Down
8 changes: 4 additions & 4 deletions action/deployment/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/cli/internal/output"
"github.com/go-vela/types/library"
api "github.com/go-vela/server/api/types"
)

// table is a helper function to output the
// provided deployments in a table format with
// a specific set of fields displayed.
func table(deployments *[]library.Deployment) error {
func table(deployments *[]api.Deployment) error {
logrus.Debug("creating table for list of deployments")

// create a new table
Expand Down Expand Up @@ -59,7 +59,7 @@ func table(deployments *[]library.Deployment) error {
// wideTable is a helper function to output the
// provided deployments in a wide table format with
// a specific set of fields displayed.
func wideTable(deployments *[]library.Deployment) error {
func wideTable(deployments *[]api.Deployment) error {
logrus.Debug("creating wide table for list of deployments")

// create new wide table
Expand Down Expand Up @@ -103,7 +103,7 @@ func wideTable(deployments *[]library.Deployment) error {
// reverse is a helper function to sort the deployments
// based off the deployment number and then flip the
// order they get displayed in.
func reverse(d []library.Deployment) []library.Deployment {
func reverse(d []api.Deployment) []api.Deployment {
// sort the list of deployments based off the deployment id
sort.SliceStable(d, func(i, j int) bool {
return d[i].GetID() < d[j].GetID()
Expand Down
15 changes: 7 additions & 8 deletions action/deployment/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package deployment
import (
"testing"

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

func TestDeployment_table(t *testing.T) {
Expand All @@ -19,11 +19,11 @@ func TestDeployment_table(t *testing.T) {
// setup tests
tests := []struct {
failure bool
steps *[]library.Deployment
steps *[]api.Deployment
}{
{
failure: false,
steps: &[]library.Deployment{
steps: &[]api.Deployment{
*d1,
*d2,
},
Expand Down Expand Up @@ -59,11 +59,11 @@ func TestDeployment_wideTable(t *testing.T) {
// setup tests
tests := []struct {
failure bool
steps *[]library.Deployment
steps *[]api.Deployment
}{
{
failure: false,
steps: &[]library.Deployment{
steps: &[]api.Deployment{
*d1,
*d2,
},
Expand All @@ -90,11 +90,10 @@ func TestDeployment_wideTable(t *testing.T) {

// testDeployment is a test helper function to create a Deployment
// type with all fields set to a fake value.
func testDeployment() *library.Deployment {
d := new(library.Deployment)
func testDeployment() *api.Deployment {
d := new(api.Deployment)

d.SetID(1)
d.SetRepoID(1)
d.SetURL("https://api.github.com/repos/github/octocat/deployments/1")
d.SetCreatedBy("octocat")
d.SetCommit("48afb5bdc41ad69bf22588491333f7cf71135163")
Expand Down
8 changes: 4 additions & 4 deletions action/hook/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/cli/internal/output"
"github.com/go-vela/types/library"
api "github.com/go-vela/server/api/types"
)

// table is a helper function to output the
// provided hooks in a table format with
// a specific set of fields displayed.
func table(hooks *[]library.Hook) error {
func table(hooks *[]api.Hook) error {
logrus.Debug("creating table for list of hooks")

// create a new table
Expand Down Expand Up @@ -66,7 +66,7 @@ func table(hooks *[]library.Hook) error {
// wideTable is a helper function to output the
// provided hooks in a wide table format with
// a specific set of fields displayed.
func wideTable(hooks *[]library.Hook) error {
func wideTable(hooks *[]api.Hook) error {
logrus.Debug("creating wide table for list of hooks")

// create new wide table
Expand Down Expand Up @@ -115,7 +115,7 @@ func wideTable(hooks *[]library.Hook) error {
// reverse is a helper function to sort the hooks
// based off the hook number and then flip the
// order they get displayed in.
func reverse(h []library.Hook) []library.Hook {
func reverse(h []api.Hook) []api.Hook {
// sort the list of hooks based off the hook number
sort.SliceStable(h, func(i, j int) bool {
return h[i].GetNumber() < h[j].GetNumber()
Expand Down
16 changes: 7 additions & 9 deletions action/hook/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

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

func TestHook_table(t *testing.T) {
Expand All @@ -20,11 +20,11 @@ func TestHook_table(t *testing.T) {
// setup tests
tests := []struct {
failure bool
steps *[]library.Hook
steps *[]api.Hook
}{
{
failure: false,
steps: &[]library.Hook{
steps: &[]api.Hook{
*h1,
*h2,
},
Expand Down Expand Up @@ -60,11 +60,11 @@ func TestHook_wideTable(t *testing.T) {
// setup tests
tests := []struct {
failure bool
steps *[]library.Hook
steps *[]api.Hook
}{
{
failure: false,
steps: &[]library.Hook{
steps: &[]api.Hook{
*h1,
*h2,
},
Expand All @@ -91,12 +91,10 @@ func TestHook_wideTable(t *testing.T) {

// testHook is a test helper function to create a Hook
// type with all fields set to a fake value.
func testHook() *library.Hook {
h := new(library.Hook)
func testHook() *api.Hook {
h := new(api.Hook)

h.SetID(1)
h.SetRepoID(1)
h.SetBuildID(1)
h.SetNumber(1)
h.SetSourceID("c8da1302-07d6-11ea-882f-4893bca275b8")
h.SetCreated(time.Now().UTC().Unix())
Expand Down
2 changes: 1 addition & 1 deletion action/pipeline/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/go-vela/cli/version"
api "github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler"
"github.com/go-vela/types/constants"
"github.com/go-vela/server/constants"
"github.com/go-vela/worker/executor"
"github.com/go-vela/worker/runtime"
)
Expand Down
4 changes: 2 additions & 2 deletions action/pipeline/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package pipeline
import (
"github.com/sirupsen/logrus"

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

func stages(pipelineType string) *yaml.Build {
Expand Down Expand Up @@ -38,7 +38,7 @@ func stages(pipelineType string) *yaml.Build {

// return a stages pipeline based off the type
//
// https://pkg.go.dev/github.com/go-vela/types/yaml?tab=doc#Build
// https://pkg.go.dev/github.com/go-vela/server/compiler/types/yaml?tab=doc#Build
return &yaml.Build{
Version: "1",
Stages: yaml.StageSlice{
Expand Down
2 changes: 1 addition & 1 deletion action/pipeline/stage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"
"testing"

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

func TestPipeline_stages(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions action/pipeline/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package pipeline
import (
"github.com/sirupsen/logrus"

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

func steps(pipelineType string) *yaml.Build {
Expand Down Expand Up @@ -38,7 +38,7 @@ func steps(pipelineType string) *yaml.Build {

// return a steps pipeline based off the type
//
// https://pkg.go.dev/github.com/go-vela/types/yaml?tab=doc#Build
// https://pkg.go.dev/github.com/go-vela/server/compiler/types/yaml?tab=doc#Build
return &yaml.Build{
Version: "1",
Steps: yaml.StepSlice{
Expand Down
2 changes: 1 addition & 1 deletion action/pipeline/step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"
"testing"

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

func TestPipeline_steps(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions action/pipeline/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/cli/internal/output"
"github.com/go-vela/types/library"
api "github.com/go-vela/server/api/types"
)

// table is a helper function to output the
// provided pipelines in a table format with
// a specific set of fields displayed.
func table(pipelines *[]library.Pipeline) error {
func table(pipelines *[]api.Pipeline) error {
logrus.Debug("creating table for list of pipelines")

// create a new table
Expand Down Expand Up @@ -59,7 +59,7 @@ func table(pipelines *[]library.Pipeline) error {
// wideTable is a helper function to output the
// provided pipelines in a wide table format with
// a specific set of fields displayed.
func wideTable(pipelines *[]library.Pipeline) error {
func wideTable(pipelines *[]api.Pipeline) error {
logrus.Debug("creating wide table for list of pipelines")

// create new wide table
Expand Down Expand Up @@ -103,7 +103,7 @@ func wideTable(pipelines *[]library.Pipeline) error {
// reverse is a helper function to sort the pipelines
// based off the pipeline number and then flip the
// order they get displayed in.
func reverse(p []library.Pipeline) []library.Pipeline {
func reverse(p []api.Pipeline) []api.Pipeline {
// sort the list of pipelines based off the pipeline id
sort.SliceStable(p, func(i, j int) bool {
return p[i].GetID() < p[j].GetID()
Expand Down
15 changes: 7 additions & 8 deletions action/pipeline/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package pipeline
import (
"testing"

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

func TestPipeline_table(t *testing.T) {
Expand All @@ -20,12 +20,12 @@ func TestPipeline_table(t *testing.T) {
tests := []struct {
name string
failure bool
pipelines *[]library.Pipeline
pipelines *[]api.Pipeline
}{
{
name: "success",
failure: false,
pipelines: &[]library.Pipeline{
pipelines: &[]api.Pipeline{
*p1,
*p2,
},
Expand Down Expand Up @@ -64,12 +64,12 @@ func TestPipeline_wideTable(t *testing.T) {
tests := []struct {
name string
failure bool
pipelines *[]library.Pipeline
pipelines *[]api.Pipeline
}{
{
name: "success",
failure: false,
pipelines: &[]library.Pipeline{
pipelines: &[]api.Pipeline{
*p1,
*p2,
},
Expand Down Expand Up @@ -98,11 +98,10 @@ func TestPipeline_wideTable(t *testing.T) {

// testPipeline is a test helper function to create a Pipeline
// type with all fields set to a fake value.
func testPipeline() *library.Pipeline {
p := new(library.Pipeline)
func testPipeline() *api.Pipeline {
p := new(api.Pipeline)

p.SetID(1)
p.SetRepoID(1)
p.SetCommit("48afb5bdc41ad69bf22588491333f7cf71135163")
p.SetFlavor("large")
p.SetPlatform("docker")
Expand Down
6 changes: 3 additions & 3 deletions action/pipeline/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
"github.com/go-vela/sdk-go/vela"
api "github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/types/yaml"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/compiler/types/yaml"
"github.com/go-vela/server/constants"
)

// Validate verifies the configuration provided.
Expand Down
2 changes: 1 addition & 1 deletion action/repo/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/sirupsen/logrus"

"github.com/go-vela/types/constants"
"github.com/go-vela/server/constants"
)

// Validate verifies the configuration provided.
Expand Down
Loading
Loading