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

bug: fix scheduler parameters to support bools and numbers #808

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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