Skip to content

Commit 8aaff3f

Browse files
committed
feat: aa database version
1 parent 263cdc4 commit 8aaff3f

File tree

4 files changed

+45
-35
lines changed

4 files changed

+45
-35
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.0
55
toolchain go1.24.1
66

77
require (
8-
github.com/RedisLabs/rediscloud-go-api v0.34.0
8+
github.com/RedisLabs/rediscloud-go-api v0.34.1
99
github.com/bflad/tfproviderlint v0.31.0
1010
github.com/hashicorp/go-cty v1.5.0
1111
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
@@ -70,4 +70,4 @@ require (
7070
)
7171

7272
// for local development, uncomment this
73-
//replace github.com/RedisLabs/rediscloud-go-api => ../rediscloud-go-api
73+
replace github.com/RedisLabs/rediscloud-go-api => ../rediscloud-go-api

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
44
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
55
github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
66
github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
7-
github.com/RedisLabs/rediscloud-go-api v0.34.0 h1:TjiABMGCa7SXfwdlqAEj53GX0ipC/b6MOagQc7wIo7g=
8-
github.com/RedisLabs/rediscloud-go-api v0.34.0/go.mod h1:3/oVb71rv2OstFRYEc65QCIbfwnJTgZeQhtPCcdHook=
97
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
108
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
119
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=

provider/resource_rediscloud_active_active_database.go

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package provider
22

33
import (
44
"context"
5+
"github.com/RedisLabs/terraform-provider-rediscloud/provider/utils"
56
"log"
67
"regexp"
78
"strings"
@@ -97,6 +98,13 @@ func resourceRedisCloudActiveActiveDatabase() *schema.Resource {
9798
Computed: true,
9899
ExactlyOneOf: []string{"memory_limit_in_gb", "dataset_size_in_gb"},
99100
},
101+
"redis_version": {
102+
Description: "Defines the Redis database version. If omitted, the Redis version will be set to the default version",
103+
Type: schema.TypeString,
104+
Optional: true,
105+
Computed: true,
106+
ForceNew: true,
107+
},
100108
"support_oss_cluster_api": {
101109
Description: "Support Redis open-source (OSS) Cluster API",
102110
Type: schema.TypeBool,
@@ -339,11 +347,7 @@ func resourceRedisCloudActiveActiveDatabaseCreate(ctx context.Context, d *schema
339347
name := d.Get("name").(string)
340348
supportOSSClusterAPI := d.Get("support_oss_cluster_api").(bool)
341349
useExternalEndpointForOSSClusterAPI := d.Get("external_endpoint_for_oss_cluster_api").(bool)
342-
dataEviction := d.Get("data_eviction").(string)
343-
globalDataPersistence := d.Get("global_data_persistence").(string)
344-
globalPassword := d.Get("global_password").(string)
345350
globalSourceIp := setToStringSlice(d.Get("global_source_ips").(*schema.Set))
346-
respVersion := d.Get("global_resp_version").(string)
347351

348352
createAlerts := make([]*databases.Alert, 0)
349353
alerts := d.Get("global_alert").(*schema.Set)
@@ -399,33 +403,37 @@ func resourceRedisCloudActiveActiveDatabaseCreate(ctx context.Context, d *schema
399403
LocalThroughputMeasurement: localThroughputs,
400404
}
401405

402-
if dataEviction != "" {
403-
createDatabase.DataEvictionPolicy = redis.String(dataEviction)
404-
}
406+
utils.SetStringIfNotEmpty(d, "data_eviction", func(s *string) {
407+
createDatabase.DataEvictionPolicy = s
408+
})
405409

406-
if globalDataPersistence != "" {
407-
createDatabase.GlobalDataPersistence = redis.String(globalDataPersistence)
408-
}
410+
utils.SetStringIfNotEmpty(d, "global_data_persistence", func(s *string) {
411+
createDatabase.GlobalDataPersistence = s
412+
})
409413

410-
if globalPassword != "" {
411-
createDatabase.GlobalPassword = redis.String(globalPassword)
412-
}
414+
utils.SetStringIfNotEmpty(d, "global_password", func(s *string) {
415+
createDatabase.GlobalPassword = s
416+
})
413417

414-
if v, ok := d.GetOk("dataset_size_in_gb"); ok {
415-
createDatabase.DatasetSizeInGB = redis.Float64(v.(float64))
416-
}
418+
utils.SetFloat64(d, "dataset_size_in_gb", func(f *float64) {
419+
createDatabase.DatasetSizeInGB = f
420+
})
417421

418-
if v, ok := d.GetOk("memory_limit_in_gb"); ok {
419-
createDatabase.MemoryLimitInGB = redis.Float64(v.(float64))
420-
}
422+
utils.SetFloat64(d, "memory_limit_in_gb", func(f *float64) {
423+
createDatabase.MemoryLimitInGB = f
424+
})
421425

422-
if v, ok := d.GetOk("port"); ok {
423-
createDatabase.PortNumber = redis.Int(v.(int))
424-
}
426+
utils.SetIntIfPositive(d, "port", func(i *int) {
427+
createDatabase.PortNumber = i
428+
})
425429

426-
if respVersion != "" {
427-
createDatabase.RespVersion = redis.String(respVersion)
428-
}
430+
utils.SetStringIfNotEmpty(d, "global_resp_version", func(s *string) {
431+
createDatabase.RespVersion = s
432+
})
433+
434+
utils.SetStringIfNotEmpty(d, "redis_version", func(s *string) {
435+
createDatabase.RedisVersion = s
436+
})
429437

430438
// Confirm Subscription Active status before creating database
431439
err = waitForSubscriptionToBeActive(ctx, subId, api)
@@ -591,6 +599,10 @@ func resourceRedisCloudActiveActiveDatabaseRead(ctx context.Context, d *schema.R
591599
return diag.FromErr(err)
592600
}
593601

602+
if err := d.Set("redis_version", redis.StringValue(db.RedisVersion)); err != nil {
603+
return diag.FromErr(err)
604+
}
605+
594606
tlsAuthEnabled := *db.CrdbDatabases[0].Security.TLSClientAuthentication
595607
if err := applyCertificateHints(tlsAuthEnabled, d); err != nil {
596608
return diag.FromErr(err)

provider/resource_rediscloud_pro_database.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ func resourceRedisCloudProDatabase() *schema.Resource {
9494
Computed: true,
9595
ExactlyOneOf: []string{"memory_limit_in_gb", "dataset_size_in_gb"},
9696
},
97+
"redis_version": {
98+
Description: "Defines the Redis database version. If omitted, the Redis version will be set to the default version",
99+
Type: schema.TypeString,
100+
Optional: true,
101+
Computed: true,
102+
},
97103
"support_oss_cluster_api": {
98104
Description: "Support Redis open-source (OSS) Cluster API",
99105
Type: schema.TypeBool,
@@ -237,12 +243,6 @@ func resourceRedisCloudProDatabase() *schema.Resource {
237243
return
238244
},
239245
},
240-
"redis_version": {
241-
Description: "Defines the Redis database version. If omitted, the Redis version will be set to the default version",
242-
Type: schema.TypeString,
243-
Optional: true,
244-
Computed: true,
245-
},
246246
"modules": {
247247
Description: "Modules to be provisioned in the database",
248248
Type: schema.TypeSet,

0 commit comments

Comments
 (0)