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(repo): nested repository from server #549

Merged
merged 2 commits into from
Apr 12, 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
3 changes: 2 additions & 1 deletion action/pipeline/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"github.com/sirupsen/logrus"

"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/types/library"
Expand All @@ -21,7 +22,7 @@
)

// Exec executes a pipeline based off the provided configuration.
func (c *Config) Exec(client compiler.Engine) error {

Check failure on line 25 in action/pipeline/exec.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] action/pipeline/exec.go#L25

Function 'Exec' is too long (163 > 160) (funlen)
Raw output
action/pipeline/exec.go:25: Function 'Exec' is too long (163 > 160) (funlen)
func (c *Config) Exec(client compiler.Engine) error {
logrus.Debug("executing exec for pipeline configuration")

// send Filesystem call to capture base directory path
Expand Down Expand Up @@ -63,7 +64,7 @@
}

// create repo object for use in pipeline
r := new(library.Repo)
r := new(api.Repo)
r.SetOrg(c.Org)
r.SetName(c.Repo)
r.SetFullName(fmt.Sprintf("%s/%s", c.Org, c.Repo))
Expand Down
4 changes: 2 additions & 2 deletions action/pipeline/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/go-vela/cli/internal/output"
"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/library"
"github.com/go-vela/types/pipeline"
"github.com/go-vela/types/yaml"
)
Expand Down Expand Up @@ -106,7 +106,7 @@ func (c *Config) ValidateLocal(client compiler.Engine) error {
}

// set pipelineType within client
client.WithRepo(&library.Repo{PipelineType: &c.PipelineType})
client.WithRepo(&api.Repo{PipelineType: &c.PipelineType})

var p *yaml.Build

Expand Down
8 changes: 4 additions & 4 deletions action/repo/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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 repository based off the provided configuration.
Expand All @@ -19,8 +19,8 @@ func (c *Config) Add(client *vela.Client) error {

// create the repository object
//
// https://pkg.go.dev/github.com/go-vela/types/library?tab=doc#Repo
r := &library.Repo{
// https://pkg.go.dev/github.com/go-vela/server/api/types?tab=doc#Repo
r := &api.Repo{
Org: vela.String(c.Org),
Name: vela.String(c.Name),
FullName: vela.String(fmt.Sprintf("%s/%s", c.Org, c.Name)),
Expand All @@ -41,7 +41,7 @@ func (c *Config) Add(client *vela.Client) error {
logrus.Tracef("adding repo %s/%s", c.Org, c.Name)

if len(c.Events) > 0 {
evs, err := library.NewEventsFromSlice(c.Events)
evs, err := api.NewEventsFromSlice(c.Events)
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions action/repo/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 repos in a table format with
// a specific set of fields displayed.
func table(repos *[]library.Repo) error {
func table(repos *[]api.Repo) error {
logrus.Debug("creating table for list of repos")

// create a new table
Expand Down Expand Up @@ -44,7 +44,7 @@ func table(repos *[]library.Repo) error {
for _, r := range *repos {
logrus.Tracef("adding repo %s to repo table", r.GetFullName())

e := strings.Join(r.AllowEvents.List(), ",")
e := strings.Join(r.GetAllowEvents().List(), ",")

// add a row to the table with the specified values
//
Expand All @@ -61,7 +61,7 @@ func table(repos *[]library.Repo) error {
// wideTable is a helper function to output the
// provided repos in a wide table format with
// a specific set of fields displayed.
func wideTable(repos *[]library.Repo) error {
func wideTable(repos *[]api.Repo) error {
logrus.Debug("creating wide table for list of repos")

// create new wide table
Expand Down Expand Up @@ -90,7 +90,7 @@ func wideTable(repos *[]library.Repo) error {
for _, r := range *repos {
logrus.Tracef("adding repo %s to wide repo table", r.GetFullName())

e := strings.Join(r.AllowEvents.List(), ",")
e := strings.Join(r.GetAllowEvents().List(), ",")

// add a row to the table with the specified values
//
Expand Down
14 changes: 7 additions & 7 deletions action/repo/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package repo
import (
"testing"

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

func TestRepo_table(t *testing.T) {
Expand All @@ -23,11 +23,11 @@ func TestRepo_table(t *testing.T) {
// setup tests
tests := []struct {
failure bool
repos *[]library.Repo
repos *[]api.Repo
}{
{
failure: false,
repos: &[]library.Repo{
repos: &[]api.Repo{
*r1,
*r2,
},
Expand Down Expand Up @@ -67,11 +67,11 @@ func TestRepo_wideTable(t *testing.T) {
// setup tests
tests := []struct {
failure bool
repos *[]library.Repo
repos *[]api.Repo
}{
{
failure: false,
repos: &[]library.Repo{
repos: &[]api.Repo{
*r1,
*r2,
},
Expand All @@ -98,8 +98,8 @@ func TestRepo_wideTable(t *testing.T) {

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

r.SetID(1)
r.SetOrg("github")
Expand Down
8 changes: 4 additions & 4 deletions action/repo/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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"
)

// Update modifies a repository based off the provided configuration.
Expand All @@ -19,8 +19,8 @@ func (c *Config) Update(client *vela.Client) error {

// create the repository object
//
// https://pkg.go.dev/github.com/go-vela/types/library?tab=doc#Repo
r := &library.Repo{
// https://pkg.go.dev/github.com/go-vela/server/api/types?tab=doc#Repo
r := &api.Repo{
Org: vela.String(c.Org),
Name: vela.String(c.Name),
FullName: vela.String(fmt.Sprintf("%s/%s", c.Org, c.Name)),
Expand All @@ -39,7 +39,7 @@ func (c *Config) Update(client *vela.Client) error {
}

if len(c.Events) > 0 {
evs, err := library.NewEventsFromSlice(c.Events)
evs, err := api.NewEventsFromSlice(c.Events)
if err != nil {
return err
}
Expand Down
19 changes: 13 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ require (
github.com/dustin/go-humanize v1.0.1
github.com/gin-gonic/gin v1.9.1
github.com/go-git/go-git/v5 v5.11.0
github.com/go-vela/sdk-go v0.23.3-0.20240408141059-b3581213c0f2
github.com/go-vela/server v0.23.4-0.20240405160933-fb31ea5a6e96
github.com/go-vela/sdk-go v0.23.3-0.20240411165353-c3fdc7210625
github.com/go-vela/server v0.23.4-0.20240411145541-132447406cf7
github.com/go-vela/types v0.23.4-0.20240405205548-f24f795ac0b7
github.com/go-vela/worker v0.23.2
github.com/go-vela/worker v0.23.3-0.20240411184512-e8783c7459ef
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/gosuri/uitable v0.0.4
github.com/joho/godotenv v1.5.1
Expand Down Expand Up @@ -42,25 +42,27 @@ require (
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containerd/containerd v1.7.11 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v24.0.9+incompatible // indirect
github.com/docker/docker v26.0.0+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/drone/envsubst v1.0.3 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/fatih/color v1.10.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
Expand All @@ -73,7 +75,7 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github/v59 v59.0.0 // indirect
github.com/google/go-github/v61 v61.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
Expand All @@ -98,6 +100,7 @@ require (
github.com/microcosm-cc/bluemonday v1.0.26 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
Expand All @@ -117,6 +120,10 @@ require (
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.starlark.net v0.0.0-20240314022150-ee8ed142361c // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
Expand Down
Loading
Loading