Skip to content

Commit 458242d

Browse files
trentrosenbaumburythehammer
authored andcommitted
Updates datasource and resources to handle QPF
1 parent 0e577c8 commit 458242d

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

provider/datasource_rediscloud_pro_database.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func dataSourceRedisCloudProDatabase() *schema.Resource {
6262
"query_performance_factor": {
6363
Description: "Query performance factor for this specific database",
6464
Type: schema.TypeString,
65-
Optional: true,
6665
Computed: true,
6766
},
6867
"support_oss_cluster_api": {
@@ -482,6 +481,10 @@ func dataSourceRedisCloudProDatabaseRead(ctx context.Context, d *schema.Resource
482481
return diag.FromErr(err)
483482
}
484483

484+
if err := d.Set("query_performance_factor", redis.String(*db.QueryPerformanceFactor)); err != nil {
485+
return diag.FromErr(err)
486+
}
487+
485488
return diags
486489
}
487490

provider/datasource_rediscloud_pro_database_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ resource "rediscloud_subscription" "example" {
9696
support_oss_cluster_api=true
9797
throughput_measurement_by = "operations-per-second"
9898
throughput_measurement_value = 1000
99+
query_performance_factor = "2x"
99100
modules = ["RediSearch"]
100101
}
101102
}

provider/resource_rediscloud_pro_database.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,13 @@ func resourceRedisCloudProDatabaseCreate(ctx context.Context, d *schema.Resource
391391
By: redis.String(throughputMeasurementBy),
392392
Value: redis.Int(throughputMeasurementValue),
393393
},
394-
Modules: createModules,
395-
Alerts: createAlerts,
396-
RemoteBackup: buildBackupPlan(d.Get("remote_backup").([]interface{}), d.Get("periodic_backup_path")),
397-
QueryPerformanceFactor: redis.String(queryPerformanceFactor),
394+
Modules: createModules,
395+
Alerts: createAlerts,
396+
RemoteBackup: buildBackupPlan(d.Get("remote_backup").([]interface{}), d.Get("periodic_backup_path")),
397+
}
398+
399+
if queryPerformanceFactor != "" {
400+
createDatabase.QueryPerformanceFactor = redis.String(queryPerformanceFactor)
398401
}
399402

400403
if password != "" {
@@ -597,11 +600,10 @@ func resourceRedisCloudProDatabaseRead(ctx context.Context, d *schema.ResourceDa
597600
if err := d.Set("remote_backup", flattenBackupPlan(db.Backup, d.Get("remote_backup").([]interface{}), d.Get("periodic_backup_path").(string))); err != nil {
598601
return diag.FromErr(err)
599602
}
600-
601-
////query_performance_factor
602-
//if err := d.Set("query_performance_factor", redis.String(*db.)); err != nil {
603-
// return diag.FromErr(err)
604-
//}
603+
604+
if err := d.Set("query_performance_factor", redis.String(*db.QueryPerformanceFactor)); err != nil {
605+
return diag.FromErr(err)
606+
}
605607

606608
if err := readTags(ctx, api, subId, dbId, d); err != nil {
607609
return diag.FromErr(err)
@@ -677,13 +679,12 @@ func resourceRedisCloudProDatabaseUpdate(ctx context.Context, d *schema.Resource
677679
By: redis.String(d.Get("throughput_measurement_by").(string)),
678680
Value: redis.Int(d.Get("throughput_measurement_value").(int)),
679681
},
680-
DataPersistence: redis.String(d.Get("data_persistence").(string)),
681-
DataEvictionPolicy: redis.String(d.Get("data_eviction").(string)),
682-
SourceIP: setToStringSlice(d.Get("source_ips").(*schema.Set)),
683-
Alerts: &alerts,
684-
RemoteBackup: buildBackupPlan(d.Get("remote_backup").([]interface{}), d.Get("periodic_backup_path")),
685-
EnableDefaultUser: redis.Bool(d.Get("enable_default_user").(bool)),
686-
QueryPerformanceFactor: redis.String(d.Get("query_performance_factor").(string)),
682+
DataPersistence: redis.String(d.Get("data_persistence").(string)),
683+
DataEvictionPolicy: redis.String(d.Get("data_eviction").(string)),
684+
SourceIP: setToStringSlice(d.Get("source_ips").(*schema.Set)),
685+
Alerts: &alerts,
686+
RemoteBackup: buildBackupPlan(d.Get("remote_backup").([]interface{}), d.Get("periodic_backup_path")),
687+
EnableDefaultUser: redis.Bool(d.Get("enable_default_user").(bool)),
687688
}
688689

689690
// One of the following fields must be set, validation is handled in the schema (ExactlyOneOf)
@@ -700,6 +701,11 @@ func resourceRedisCloudProDatabaseUpdate(ctx context.Context, d *schema.Resource
700701
update.SourceIP = []*string{redis.String("0.0.0.0/0")}
701702
}
702703

704+
queryPerformanceFactor := d.Get("query_performance_factor").(string)
705+
if queryPerformanceFactor != "" {
706+
update.QueryPerformanceFactor = redis.String(queryPerformanceFactor)
707+
}
708+
703709
if d.Get("password").(string) != "" {
704710
update.Password = redis.String(d.Get("password").(string))
705711
}

0 commit comments

Comments
 (0)