Skip to content

Commit 61b3cfc

Browse files
fix(dbaas): access control fields to pointers (#292)
1 parent 59b0f32 commit 61b3cfc

10 files changed

+438
-250
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
55

66
## [Unreleased]
77

8+
### Changed
9+
- **Breaking**, Managed Database: `ManagedDatabaseUserOpernSearchAccessControl` fields changed to pointers
10+
- **Breaking**, Managed Database: `ManagedDatabaseUserPGAccessControl` fields changed to pointers
11+
- **Breaking**, Managed Database: `ManagedDatabaseUserRedisAccessControl` fields changed to pointers
12+
813
### Removed
914
- **Breaking**, Managed Database: connection related methods in favor of session
1015

upcloud/managed_database.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,18 +618,18 @@ type ManagedDatabaseUser struct {
618618
}
619619

620620
type ManagedDatabaseUserPGAccessControl struct {
621-
AllowReplication bool `json:"allow_replication"`
621+
AllowReplication *bool `json:"allow_replication,omitempty"`
622622
}
623623

624624
type ManagedDatabaseUserRedisAccessControl struct {
625-
Categories []string `json:"categories,omitempty"`
626-
Channels []string `json:"channels,omitempty"`
627-
Commands []string `json:"commands,omitempty"`
628-
Keys []string `json:"keys,omitempty"`
625+
Categories *[]string `json:"categories,omitempty"`
626+
Channels *[]string `json:"channels,omitempty"`
627+
Commands *[]string `json:"commands,omitempty"`
628+
Keys *[]string `json:"keys,omitempty"`
629629
}
630630

631631
type ManagedDatabaseUserOpenSearchAccessControl struct {
632-
Rules []ManagedDatabaseUserOpenSearchAccessControlRule `json:"rules"`
632+
Rules *[]ManagedDatabaseUserOpenSearchAccessControlRule `json:"rules,omitempty"`
633633
}
634634

635635
type ManagedDatabaseUserOpenSearchAccessControlRule struct {

upcloud/managed_database_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -776,13 +776,13 @@ func TestManagedDatabaseUser(t *testing.T) {
776776
Password: "new-password",
777777
Username: "api-doc-user",
778778
PGAccessControl: &ManagedDatabaseUserPGAccessControl{
779-
AllowReplication: false,
779+
AllowReplication: BoolPtr(false),
780780
},
781781
RedisAccessControl: &ManagedDatabaseUserRedisAccessControl{
782-
Categories: []string{"+@set"},
783-
Channels: []string{"*"},
784-
Commands: []string{"+set"},
785-
Keys: []string{"key_*"},
782+
Categories: &[]string{"+@set"},
783+
Channels: &[]string{"*"},
784+
Commands: &[]string{"+set"},
785+
Keys: &[]string{"key_*"},
786786
},
787787
}
788788
assert.Equal(t, want, got)

upcloud/request/managed_database_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,13 @@ func TestCreateManagedDatabaseUserRequest(t *testing.T) {
429429
Password: "new-password",
430430
Authentication: upcloud.ManagedDatabaseUserAuthenticationCachingSHA2Password,
431431
PGAccessControl: &upcloud.ManagedDatabaseUserPGAccessControl{
432-
AllowReplication: true,
432+
AllowReplication: upcloud.BoolPtr(true),
433433
},
434434
RedisAccessControl: &upcloud.ManagedDatabaseUserRedisAccessControl{
435-
Categories: []string{"+@set"},
436-
Channels: []string{"*"},
437-
Commands: []string{"+set"},
438-
Keys: []string{"key_*"},
435+
Categories: &[]string{"+@set"},
436+
Channels: &[]string{"*"},
437+
Commands: &[]string{"+set"},
438+
Keys: &[]string{"key_*"},
439439
},
440440
}
441441
got, err := json.Marshal(&r)
@@ -475,13 +475,13 @@ func TestModifyManagedDatabaseUserAccessControlRequest(t *testing.T) {
475475
ServiceUUID: "fakeuuid",
476476
Username: "fakeuser",
477477
PGAccessControl: &upcloud.ManagedDatabaseUserPGAccessControl{
478-
AllowReplication: true,
478+
AllowReplication: upcloud.BoolPtr(true),
479479
},
480480
RedisAccessControl: &upcloud.ManagedDatabaseUserRedisAccessControl{
481-
Categories: []string{"+@set"},
482-
Channels: []string{"*"},
483-
Commands: []string{"+set"},
484-
Keys: []string{"key_*"},
481+
Categories: &[]string{"+@set"},
482+
Channels: &[]string{"*"},
483+
Commands: &[]string{"+set"},
484+
Keys: &[]string{"key_*"},
485485
},
486486
}
487487
got, err := json.Marshal(&r)

upcloud/service/fixtures/modifymanageddatabaseuseraccesscontrol.yaml

Lines changed: 0 additions & 107 deletions
This file was deleted.

upcloud/service/fixtures/modifymanageddatabaseuseraccesscontrolos.yaml

Lines changed: 0 additions & 109 deletions
This file was deleted.

0 commit comments

Comments
 (0)