Skip to content

Commit

Permalink
refactor(schedule): use server API types for schedule (#553)
Browse files Browse the repository at this point in the history
* Use server API types for schedule

* Update go.mod
  • Loading branch information
wsan3 authored May 9, 2024
1 parent c4a682a commit f58e94d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions action/schedule/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,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 schedule based off the provided configuration.
func (c *Config) Add(client *vela.Client) error {
logrus.Debug("executing add for schedule configuration")

// create the schedule object
s := &library.Schedule{
s := &api.Schedule{
Active: vela.Bool(c.Active),
Name: vela.String(c.Name),
Entry: vela.String(c.Entry),
Expand Down
6 changes: 3 additions & 3 deletions action/schedule/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,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 schedules in a table format with
// a specific set of fields displayed.
func table(schedules *[]library.Schedule) error {
func table(schedules *[]api.Schedule) error {
logrus.Debug("creating table for list of schedules")

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

// create new wide table
Expand Down
14 changes: 7 additions & 7 deletions action/schedule/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 TestSchedule_table(t *testing.T) {
Expand All @@ -21,12 +21,12 @@ func TestSchedule_table(t *testing.T) {
tests := []struct {
name string
failure bool
schedules *[]library.Schedule
schedules *[]api.Schedule
}{
{
name: "success",
failure: false,
schedules: &[]library.Schedule{*_scheduleOne, *_scheduleTwo},
schedules: &[]api.Schedule{*_scheduleOne, *_scheduleTwo},
},
}

Expand Down Expand Up @@ -62,12 +62,12 @@ func TestSchedule_wideTable(t *testing.T) {
tests := []struct {
name string
failure bool
schedules *[]library.Schedule
schedules *[]api.Schedule
}{
{
name: "success",
failure: false,
schedules: &[]library.Schedule{*_scheduleOne, *_scheduleTwo},
schedules: &[]api.Schedule{*_scheduleOne, *_scheduleTwo},
},
}

Expand All @@ -92,8 +92,8 @@ func TestSchedule_wideTable(t *testing.T) {
}

// testSchedule is a test helper function to create a Schedule type with all fields set to a fake value.
func testSchedule() *library.Schedule {
s := new(library.Schedule)
func testSchedule() *api.Schedule {
s := new(api.Schedule)
s.SetID(1)
s.SetActive(true)
s.SetName("nightly")
Expand Down
4 changes: 2 additions & 2 deletions action/schedule/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,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"
)

// Update modifies a schedule based off the provided configuration.
func (c *Config) Update(client *vela.Client) error {
logrus.Debug("executing update for schedule configuration")

// create the schedule object
s := &library.Schedule{
s := &api.Schedule{
Active: vela.Bool(c.Active),
Name: vela.String(c.Name),
Entry: vela.String(c.Entry),
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ 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.20240507145321-54c8961e00a9
github.com/go-vela/server v0.23.4-0.20240506154118-8ad123451469
github.com/go-vela/sdk-go v0.23.3-0.20240508193030-1cd2e5cf3dbd
github.com/go-vela/server v0.23.4-0.20240508133721-300ca456e3bb
github.com/go-vela/types v0.23.4-0.20240417135026-fb4a95c30338
github.com/go-vela/worker v0.23.3-0.20240424172515-3d4399807a4b
github.com/golang-jwt/jwt/v5 v5.2.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/go-vela/sdk-go v0.23.3-0.20240507145321-54c8961e00a9 h1:05QVYi/gRn0ZphF/cMQFEdsmmzROdDssX5dXZv+BrvQ=
github.com/go-vela/sdk-go v0.23.3-0.20240507145321-54c8961e00a9/go.mod h1:uBY1/Vcz6m2emXJw5vbYDnUOYn1F9aFsmlMaLNHr/2k=
github.com/go-vela/server v0.23.4-0.20240506154118-8ad123451469 h1:t+g5Gqdhrv7E7XGAD3ZaoxQ1hko/lKA7N1Az0dcXrgI=
github.com/go-vela/server v0.23.4-0.20240506154118-8ad123451469/go.mod h1:2KcNYX+DfNH/aWwu0pu89Gj9+wAm3S70VMy53/LMZjs=
github.com/go-vela/sdk-go v0.23.3-0.20240508193030-1cd2e5cf3dbd h1:69FJDdgtnu+jame1Mcu/KCQ51OuOMpKYNoZTvuXvZbc=
github.com/go-vela/sdk-go v0.23.3-0.20240508193030-1cd2e5cf3dbd/go.mod h1:382f+z7TrcBk+F92US53M+l490mGiU93/h86zGqMU94=
github.com/go-vela/server v0.23.4-0.20240508133721-300ca456e3bb h1:nzDitT5zNk5k49n/oEESPwL8xwLWf5iLLJDJkT3Vwik=
github.com/go-vela/server v0.23.4-0.20240508133721-300ca456e3bb/go.mod h1:2KcNYX+DfNH/aWwu0pu89Gj9+wAm3S70VMy53/LMZjs=
github.com/go-vela/types v0.23.4-0.20240417135026-fb4a95c30338 h1:I0v47dOdAvjX7lOFN4s28uONChmluD6TNgFL1hpav60=
github.com/go-vela/types v0.23.4-0.20240417135026-fb4a95c30338/go.mod h1:vISsYDdjz9RPEK6qZ+MxtrdZEjTVU4K30NomB3826u8=
github.com/go-vela/worker v0.23.3-0.20240424172515-3d4399807a4b h1:BAfnoo7pqj7girJPYloKybqehjf3uKT3p9n/aMWMQTU=
Expand Down

0 comments on commit f58e94d

Please sign in to comment.