Skip to content

Commit

Permalink
bug: fix scheduler parameters to support bools and numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Royle authored and andyroyle committed Dec 14, 2022
1 parent 802994b commit 4f8fe1a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
18 changes: 9 additions & 9 deletions api/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ type Actor struct {
}

type Schedule struct {
ID string `json:"id"`
ProjectSlug string `json:"project-slug"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Timetable Timetable `json:"timetable"`
Actor Actor `json:"actor"`
Parameters map[string]string `json:"parameters"`
CreatedAt time.Time `json:"created-at"`
UpdatedAt time.Time `json:"updated-at"`
ID string `json:"id"`
ProjectSlug string `json:"project-slug"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Timetable Timetable `json:"timetable"`
Actor Actor `json:"actor"`
Parameters map[string]interface{} `json:"parameters"`
CreatedAt time.Time `json:"created-at"`
UpdatedAt time.Time `json:"updated-at"`
}

type ScheduleInterface interface {
Expand Down
28 changes: 14 additions & 14 deletions api/schedule_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type listSchedulesParams struct {

// Creates a new schedule in the supplied project.
func (c *ScheduleRestClient) CreateSchedule(vcs, org, project, name, description string,
useSchedulingSystem bool, timetable Timetable, parameters map[string]string) (*Schedule, error) {
useSchedulingSystem bool, timetable Timetable, parameters map[string]interface{}) (*Schedule, error) {

req, err := c.newCreateScheduleRequest(vcs, org, project, name, description, useSchedulingSystem, timetable, parameters)
if err != nil {
Expand Down Expand Up @@ -73,7 +73,7 @@ func (c *ScheduleRestClient) CreateSchedule(vcs, org, project, name, description

// Updates an existing schedule.
func (c *ScheduleRestClient) UpdateSchedule(scheduleID, name, description string,
useSchedulingSystem bool, timetable Timetable, parameters map[string]string) (*Schedule, error) {
useSchedulingSystem bool, timetable Timetable, parameters map[string]interface{}) (*Schedule, error) {

req, err := c.newUpdateScheduleRequest(scheduleID, name, description, useSchedulingSystem, timetable, parameters)
if err != nil {
Expand Down Expand Up @@ -273,7 +273,7 @@ func (c *ScheduleRestClient) newGetScheduleRequest(scheduleID string) (*http.Req

// Builds a request to create a new schedule.
func (c *ScheduleRestClient) newCreateScheduleRequest(vcs, org, project, name, description string,
useSchedulingSystem bool, timetable Timetable, parameters map[string]string) (*http.Request, error) {
useSchedulingSystem bool, timetable Timetable, parameters map[string]interface{}) (*http.Request, error) {

var err error
queryURL, err := url.Parse(c.server)
Expand All @@ -293,11 +293,11 @@ func (c *ScheduleRestClient) newCreateScheduleRequest(vcs, org, project, name, d
var bodyReader io.Reader

var body = struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
AttributionActor string `json:"attribution-actor"`
Parameters map[string]string `json:"parameters"`
Timetable Timetable `json:"timetable"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
AttributionActor string `json:"attribution-actor"`
Parameters map[string]interface{} `json:"parameters"`
Timetable Timetable `json:"timetable"`
}{
Name: name,
Description: description,
Expand All @@ -318,7 +318,7 @@ func (c *ScheduleRestClient) newCreateScheduleRequest(vcs, org, project, name, d

// Builds a request to update an existing schedule.
func (c *ScheduleRestClient) newUpdateScheduleRequest(scheduleID, name, description string,
useSchedulingSystem bool, timetable Timetable, parameters map[string]string) (*http.Request, error) {
useSchedulingSystem bool, timetable Timetable, parameters map[string]interface{}) (*http.Request, error) {

var err error
queryURL, err := url.Parse(c.server)
Expand All @@ -338,11 +338,11 @@ func (c *ScheduleRestClient) newUpdateScheduleRequest(scheduleID, name, descript
var bodyReader io.Reader

var body = struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
AttributionActor string `json:"attribution-actor,omitempty"`
Parameters map[string]string `json:"parameters,omitempty"`
Timetable Timetable `json:"timetable,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
AttributionActor string `json:"attribution-actor,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
Timetable Timetable `json:"timetable,omitempty"`
}{
Name: name,
Description: description,
Expand Down
3 changes: 2 additions & 1 deletion api/schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func mockSchedule() Schedule {
Login: "test-actor",
Name: "T. Actor",
},
Parameters: map[string]string{
Parameters: map[string]interface{}{
"test": "parameter",
"bool": true,
},
}
}
Expand Down

0 comments on commit 4f8fe1a

Please sign in to comment.