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

fix(server): do not modify boolean values by default #249

Merged
merged 1 commit into from
Jul 11, 2023
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: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
### Changed
- `service.GetKubernetesNodeGroup` method to return `upcloud.KubernetesNodeGroupDetails` type which is extended version of the previous `upcloud.KubernetesNodeGroup`

### Fixed
- `request.ModifyServerRequest` does not set boolean properties `Metadata` and `RemoteAccessEnabled` to `"no"` by default.

## [6.3.2]

### Added
Expand Down
4 changes: 2 additions & 2 deletions upcloud/request/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,14 @@ type ModifyServerRequest struct {
Hostname string `json:"hostname,omitempty"`
Labels *upcloud.LabelSlice `json:"labels,omitempty"`
MemoryAmount int `json:"memory_amount,omitempty,string"`
Metadata upcloud.Boolean `json:"metadata"`
Metadata upcloud.Boolean `json:"metadata,omitempty"`
NICModel string `json:"nic_model,omitempty"`
Plan string `json:"plan,omitempty"`
SimpleBackup string `json:"simple_backup,omitempty"`
TimeZone string `json:"timezone,omitempty"`
Title string `json:"title,omitempty"`
VideoModel string `json:"video_model,omitempty"`
RemoteAccessEnabled upcloud.Boolean `json:"remote_access_enabled"`
RemoteAccessEnabled upcloud.Boolean `json:"remote_access_enabled,omitempty"`
RemoteAccessType string `json:"remote_access_type,omitempty"`
RemoteAccessPassword string `json:"remote_access_password,omitempty"`
Zone string `json:"zone,omitempty"`
Expand Down
28 changes: 26 additions & 2 deletions upcloud/request/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,32 @@ func TestModifyServerRequest(t *testing.T) {
"core_number": "8",
"memory_amount": "16384",
"plan" : "custom",
"metadata": "yes",
"remote_access_enabled": "no"
"metadata": "yes"
}
}
`
actualJSON, err := json.Marshal(&request)
assert.Nil(t, err)
assert.JSONEq(t, expectedJSON, string(actualJSON))
assert.Equal(t, "/server/foo", request.RequestURL())
}

func TestModifyServerRequest_BooleanDefaults(t *testing.T) {
request := ModifyServerRequest{
UUID: "foo",
Title: "Modified server",
CoreNumber: 8,
MemoryAmount: 16384,
Plan: "custom",
}

expectedJSON := `
{
"server" : {
"title": "Modified server",
"core_number": "8",
"memory_amount": "16384",
"plan" : "custom"
}
}
`
Expand Down
Loading