Skip to content

Commit 91f67cc

Browse files
authored
fix(objsto): omit empty labels when creating managed object storage (#281)
1 parent b23b343 commit 91f67cc

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
88
### Added
99
- Managed Database sub-properties support. E.g., PostgreSQL property `timescaledb` is of type `object` and has `max_background_workers` sub-property.
1010

11+
### Fixed
12+
- Managed Object Storage: omit empty labels slice when creating managed object storage instance
13+
1114
## [6.10.0]
1215

1316
### Added

upcloud/request/managed_object_storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (r *GetManagedObjectStorageRegionRequest) RequestURL() string {
3737
// CreateManagedObjectStorageRequest represents a request for creating a new Managed Object Storage service
3838
type CreateManagedObjectStorageRequest struct {
3939
ConfiguredStatus upcloud.ManagedObjectStorageConfiguredStatus `json:"configured_status"`
40-
Labels []upcloud.Label `json:"labels"`
40+
Labels []upcloud.Label `json:"labels,omitempty"`
4141
Networks []upcloud.ManagedObjectStorageNetwork `json:"networks"`
4242
Region string `json:"region"`
4343
Users []ManagedObjectStorageUser `json:"users"`

upcloud/request/managed_object_storage_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package request
22

33
import (
4+
"encoding/json"
45
"testing"
56

67
"github.com/stretchr/testify/assert"
@@ -23,6 +24,24 @@ func TestCreateManagedObjectStorageRequest_RequestURL(t *testing.T) {
2324
assert.Equal(t, "/object-storage-2", req.RequestURL())
2425
}
2526

27+
func TestCreateManagedObjectStorageRequest_MarshalJSON(t *testing.T) {
28+
t.Run("TestMinimal", func(t *testing.T) {
29+
req := CreateManagedObjectStorageRequest{
30+
Region: "europe-1",
31+
}
32+
d, err := json.Marshal(&req)
33+
assert.NoError(t, err)
34+
35+
const expected = `{
36+
"configured_status":"",
37+
"networks":null,
38+
"region":"europe-1",
39+
"users":null
40+
}`
41+
assert.JSONEq(t, expected, string(d))
42+
})
43+
}
44+
2645
func TestGetManagedObjectStoragesRequest_RequestURL(t *testing.T) {
2746
req := &GetManagedObjectStoragesRequest{}
2847
assert.Equal(t, "/object-storage-2", req.RequestURL())

0 commit comments

Comments
 (0)