Skip to content

Commit

Permalink
Removed a TODO that has been addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnSharpe committed Oct 30, 2023
1 parent 31e120b commit 0f65c86
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
12 changes: 11 additions & 1 deletion database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestDatabase_Create(t *testing.T) {
"protocol": "redis",
"memoryLimitInGb": 1,
"supportOSSClusterApi": false,
"respVersion": "resp3",
"useExternalEndpointForOSSClusterApi": false,
"dataPersistence": "none",
"dataEvictionPolicy": "allkeys-lru",
Expand Down Expand Up @@ -87,6 +88,7 @@ func TestDatabase_Create(t *testing.T) {
Protocol: redis.String("redis"),
MemoryLimitInGB: redis.Float64(1),
SupportOSSClusterAPI: redis.Bool(false),
RespVersion: redis.String("resp3"),
UseExternalEndpointForOSSClusterAPI: redis.Bool(false),
DataPersistence: redis.String("none"),
DataEvictionPolicy: redis.String("allkeys-lru"),
Expand Down Expand Up @@ -191,6 +193,7 @@ func TestDatabase_Get(t *testing.T) {
"memoryUsedInMb": 5,
"memoryStorage": "ram",
"supportOSSClusterApi": true,
"respVersion": "resp2",
"dataPersistence": "none",
"replication": false,
"dataEvictionPolicy": "volatile-random",
Expand Down Expand Up @@ -220,6 +223,7 @@ func TestDatabase_Get(t *testing.T) {
"hashingPolicy": "custom"
},
"security": {
"enableDefaultUser": false,
"password": "test",
"sslClientAuthentication": false,
"sourceIps": [
Expand Down Expand Up @@ -252,6 +256,7 @@ func TestDatabase_Get(t *testing.T) {
MemoryLimitInGB: redis.Float64(7),
MemoryUsedInMB: redis.Float64(5),
SupportOSSClusterAPI: redis.Bool(true),
RespVersion: redis.String("resp2"),
DataPersistence: redis.String("none"),
Replication: redis.Bool(false),
ReplicaOf: &databases.ReplicaOf{
Expand Down Expand Up @@ -282,6 +287,7 @@ func TestDatabase_Get(t *testing.T) {
},
},
Security: &databases.Security{
EnableDefaultUser: redis.Bool(false),
SSLClientAuthentication: redis.Bool(false),
SourceIPs: redis.StringSlice("0.0.0.0/0"),
Password: redis.String("test"),
Expand Down Expand Up @@ -309,6 +315,7 @@ func TestDatabase_Update(t *testing.T) {
"name": "example",
"memoryLimitInGb": 1,
"supportOSSClusterApi": false,
"respVersion": "resp3",
"useExternalEndpointForOSSClusterApi": false,
"dataEvictionPolicy": "allkeys-lru",
"replication": true,
Expand All @@ -332,7 +339,8 @@ func TestDatabase_Update(t *testing.T) {
"name": "dataset-size",
"value": 80
}
]
],
"enableDefaultUser": false
}`, `{
"taskId": "task",
"commandType": "databaseUpdateRequest",
Expand Down Expand Up @@ -369,6 +377,7 @@ func TestDatabase_Update(t *testing.T) {
Name: redis.String("example"),
MemoryLimitInGB: redis.Float64(1),
SupportOSSClusterAPI: redis.Bool(false),
RespVersion: redis.String("resp3"),
UseExternalEndpointForOSSClusterAPI: redis.Bool(false),
DataPersistence: redis.String("none"),
DataEvictionPolicy: redis.String("allkeys-lru"),
Expand All @@ -389,6 +398,7 @@ func TestDatabase_Update(t *testing.T) {
Value: redis.Int(80),
},
},
EnableDefaultUser: redis.Bool(false),
})
require.NoError(t, err)
}
Expand Down
14 changes: 8 additions & 6 deletions service/databases/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type CreateDatabase struct {
Protocol *string `json:"protocol,omitempty"`
MemoryLimitInGB *float64 `json:"memoryLimitInGb,omitempty"`
SupportOSSClusterAPI *bool `json:"supportOSSClusterApi,omitempty"`
RespVersion *string `json:"respVersion,omitempty"`
UseExternalEndpointForOSSClusterAPI *bool `json:"useExternalEndpointForOSSClusterApi,omitempty"`
DataPersistence *string `json:"dataPersistence,omitempty"`
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
Expand Down Expand Up @@ -62,7 +63,6 @@ func (o CreateModule) String() string {
return internal.ToString(o)
}

// TODO: do we need a separate ActiveActiveDatabase type as well?
type Database struct {
ID *int `json:"databaseId,omitempty"`
Name *string `json:"name,omitempty"`
Expand All @@ -73,6 +73,7 @@ type Database struct {
MemoryLimitInGB *float64 `json:"memoryLimitInGb,omitempty"`
MemoryUsedInMB *float64 `json:"memoryUsedInMb,omitempty"`
SupportOSSClusterAPI *bool `json:"supportOSSClusterApi,omitempty"`
RespVersion *string `json:"respVersion,omitempty"`
DataPersistence *string `json:"dataPersistence,omitempty"`
Replication *bool `json:"replication,omitempty"`
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
Expand Down Expand Up @@ -119,6 +120,7 @@ func (o RegexRule) String() string {
}

type Security struct {
EnableDefaultUser *bool `json:"enableDefaultUser,omitempty"`
SSLClientAuthentication *bool `json:"sslClientAuthentication,omitempty"`
SourceIPs []*string `json:"sourceIps,omitempty"`
Password *string `json:"password,omitempty"`
Expand Down Expand Up @@ -160,6 +162,7 @@ type UpdateDatabase struct {
Name *string `json:"name,omitempty"`
MemoryLimitInGB *float64 `json:"memoryLimitInGb,omitempty"`
SupportOSSClusterAPI *bool `json:"supportOSSClusterApi,omitempty"`
RespVersion *string `json:"respVersion,omitempty"`
UseExternalEndpointForOSSClusterAPI *bool `json:"useExternalEndpointForOSSClusterApi,omitempty"`
DataEvictionPolicy *string `json:"dataEvictionPolicy,omitempty"`
Replication *bool `json:"replication,omitempty"`
Expand All @@ -171,14 +174,13 @@ type UpdateDatabase struct {
SourceIP []*string `json:"sourceIp,omitempty"`
ClientSSLCertificate *string `json:"clientSslCertificate,omitempty"`
Password *string `json:"password,omitempty"`

// It's important to use a pointer here, because the terraform user may want to send an empty list.
// In that case, the developer must pass a (pointer to a) non-nil, zero-length slice
// If the developer really wants to omit this value, passing a nil slice value would work
Alerts *[]*UpdateAlert `json:"alerts,omitempty"`

EnableTls *bool `json:"enableTls,omitempty"`
RemoteBackup *DatabaseBackupConfig `json:"remoteBackup,omitempty"`
Alerts *[]*UpdateAlert `json:"alerts,omitempty"`
EnableTls *bool `json:"enableTls,omitempty"`
RemoteBackup *DatabaseBackupConfig `json:"remoteBackup,omitempty"`
EnableDefaultUser *bool `json:"enableDefaultUser,omitempty"`
}

func (o UpdateDatabase) String() string {
Expand Down

0 comments on commit 0f65c86

Please sign in to comment.