Skip to content

Commit

Permalink
Backup Schedule : pointers on fields (#145)
Browse files Browse the repository at this point in the history
* make backup schedule pointers to allow 0

* backup schedule : dom removing pointer
  • Loading branch information
ddymko authored May 10, 2021
1 parent b1629b5 commit 60eea9f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions govultr.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,15 @@ func (c *Client) vultrErrorHandler(resp *http.Response, err error, numTries int)

// BoolToBoolPtr helper function that returns a pointer from your bool value
func BoolToBoolPtr(value bool) *bool {
b := value
return &b
return &value
}

// StringToStringPtr helper function that returns a pointer from your string value
func StringToStringPtr(value string) *string {
return &value
}

// IntToIntPtr helper function that returns a pointer from your string value
func IntToIntPtr(value int) *int {
return &value
}
4 changes: 2 additions & 2 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ type BackupSchedule struct {
// BackupScheduleReq struct used to create a backup schedule for an instance.
type BackupScheduleReq struct {
Type string `json:"type"`
Hour int `json:"hour,omitempty"`
Dow int `json:"dow,omitempty"`
Hour *int `json:"hour,omitempty"`
Dow *int `json:"dow,omitempty"`
Dom int `json:"dom,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func TestServerServiceHandler_SetBackupSchedule(t *testing.T) {

bs := &BackupScheduleReq{
Type: "weekly",
Hour: 22,
Dow: 2,
Hour: IntToIntPtr(22),
Dow: IntToIntPtr(2),
Dom: 3,
}

Expand Down

0 comments on commit 60eea9f

Please sign in to comment.