Skip to content

Commit a7c40d7

Browse files
committed
feat: adding redis_version to schema and create database call
1 parent a065767 commit a7c40d7

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ require (
6868
)
6969

7070
// for local development, uncomment this
71-
//replace github.com/RedisLabs/rediscloud-go-api => ../rediscloud-go-api
71+
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.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
44
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
55
github.com/ProtonMail/go-crypto v1.1.3 h1:nRBOetoydLeUb4nHajyO2bKqMLfWQ/ZPwkXqXxPxCFk=
66
github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
7-
github.com/RedisLabs/rediscloud-go-api v0.31.0 h1:hFdR7nrJcCVQN8h3DeXtP0g4zVQP6X5wtS5FoinG8bo=
8-
github.com/RedisLabs/rediscloud-go-api v0.31.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_pro_database.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ func resourceRedisCloudProDatabase() *schema.Resource {
235235
return
236236
},
237237
},
238+
"redis_version": {
239+
Description: "Defines the Redis database version. If omitted, the Redis version will be set to the default version",
240+
Type: schema.TypeString,
241+
Optional: true,
242+
},
238243
"modules": {
239244
Description: "Modules to be provisioned in the database",
240245
Type: schema.TypeSet,
@@ -413,6 +418,10 @@ func resourceRedisCloudProDatabaseCreate(ctx context.Context, d *schema.Resource
413418
createDatabase.QueryPerformanceFactor = redis.String(queryPerformanceFactor)
414419
}
415420

421+
if v, ok := d.GetOk("redis_version"); ok {
422+
createDatabase.RedisVersion = redis.String(v.(string))
423+
}
424+
416425
if password != "" {
417426
createDatabase.Password = redis.String(password)
418427
}

provider/utils/utils.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package utils
2+
3+
import (
4+
"github.com/RedisLabs/rediscloud-go-api/redis"
5+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
6+
)
7+
8+
// GetString safely retrieves a string value from schema.ResourceData.
9+
func GetString(d *schema.ResourceData, key string) *string {
10+
if v, ok := d.GetOk(key); ok {
11+
return redis.String(v.(string))
12+
}
13+
return redis.String("")
14+
}
15+
16+
// GetBool safely retrieves a bool value from schema.ResourceData.
17+
func GetBool(d *schema.ResourceData, key string) *bool {
18+
if v, ok := d.GetOk(key); ok {
19+
return redis.Bool(v.(bool))
20+
}
21+
return redis.Bool(false)
22+
}
23+
24+
// GetInt safely retrieves an int value from schema.ResourceData.
25+
func GetInt(d *schema.ResourceData, key string) *int {
26+
if v, ok := d.GetOk(key); ok {
27+
return redis.Int(v.(int))
28+
}
29+
return redis.Int(0)
30+
}

0 commit comments

Comments
 (0)