Skip to content

Commit 614bc5a

Browse files
bikramHarnessHarness
authored andcommitted
feat: [DBOPS-1541]: Replacing liquibaseSubstituteProperties with SubstituteProperties in TF (#1296)
* 957b9a feat: [DBOPS-1541]: Removing liquibaseSubstituteProperties from Terraform
1 parent 849f723 commit 614bc5a

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

docs/data-sources/platform_db_instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ data "harness_platform_db_instance" "example" {
3333

3434
### Optional
3535

36-
- `liquibase_substitute_properties` (Map of String) The properties to substitute in liquibase changelog
36+
- `substitute_properties` (Map of String) The properties to substitute in changelog/migration script
3737
- `name` (String) Name of the resource.
3838

3939
### Read-Only

docs/resources/platform_db_instance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ resource "harness_platform_db_instance" "test" {
2424
connector = "jdbcConnector"
2525
context = "ctx"
2626
27-
liquibase_substitute_properties = {
27+
substitute_properties = {
2828
"key1" = "value1"
2929
"key2" = "value2"
3030
}
@@ -48,7 +48,7 @@ resource "harness_platform_db_instance" "test" {
4848
- `branch` (String) The branch of changeSet repository
4949
- `context` (String) The liquibase context
5050
- `description` (String) Description of the resource.
51-
- `liquibase_substitute_properties` (Map of String) The properties to substitute in liquibase changelog
51+
- `substitute_properties` (Map of String) The properties to substitute in changelog/migration script
5252
- `tags` (Set of String) Tags to associate with the resource.
5353

5454
### Read-Only

examples/resources/harness_platform_db_instance/resource.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resource "harness_platform_db_instance" "test" {
99
connector = "jdbcConnector"
1010
context = "ctx"
1111

12-
liquibase_substitute_properties = {
12+
substitute_properties = {
1313
"key1" = "value1"
1414
"key2" = "value2"
1515
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/aws/aws-sdk-go v1.46.4
1010
github.com/docker/docker v28.3.2+incompatible
1111
github.com/google/uuid v1.6.0
12-
github.com/harness/harness-go-sdk v0.5.16
12+
github.com/harness/harness-go-sdk v0.5.17
1313
github.com/harness/harness-openapi-go-client v0.0.25
1414
github.com/hashicorp/go-cleanhttp v0.5.2
1515
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
7878
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
7979
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 h1:e9Rjr40Z98/clHv5Yg79Is0NtosR5LXRvdr7o/6NwbA=
8080
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M=
81-
github.com/harness/harness-go-sdk v0.5.16 h1:OAKDXZAHpIRosVyQS4e79qyVwfnuR5m1iBTZvtCr8fE=
82-
github.com/harness/harness-go-sdk v0.5.16/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
81+
github.com/harness/harness-go-sdk v0.5.17 h1:sjkeJjx2DUxynAuOiYJb4O+YujAbhjo6IW8rRw4GjHg=
82+
github.com/harness/harness-go-sdk v0.5.17/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
8383
github.com/harness/harness-openapi-go-client v0.0.25 h1:s1ALpC6cCJCMBkEVPjAjyHTPEpBfPyV78TeXpp3CEoU=
8484
github.com/harness/harness-openapi-go-client v0.0.25/go.mod h1:u0vqYb994BJGotmEwJevF4L3BNAdU9i8ui2d22gmLPA=
8585
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=

internal/service/platform/db_instance/data_source_db_instance.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ func DataSourceDBInstance() *schema.Resource {
3939
Type: schema.TypeString,
4040
Computed: true,
4141
},
42-
"liquibase_substitute_properties": {
43-
Description: "The properties to substitute in liquibase changelog",
42+
"substitute_properties": {
43+
Description: "The properties to substitute in changelog migration script",
4444
Type: schema.TypeMap,
4545
Optional: true,
4646
},
@@ -84,5 +84,5 @@ func readDataSourceDBInstance(d *schema.ResourceData, dbInstance *dbops.DbInstan
8484
d.Set("connector", dbInstance.Connector)
8585
d.Set("context", dbInstance.Context)
8686

87-
d.Set("liquibase_substitute_properties", dbInstance.LiquibaseSubstituteProperties)
87+
d.Set("substitute_properties", dbInstance.SubstituteProperties)
8888
}

internal/service/platform/db_instance/data_source_db_instance_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func testAccDataSourceDBInstance(id string, name string) string {
121121
`, id, name)
122122
}
123123

124-
func TestAccDataSourceDBInstanceWithLiquibaseProps(t *testing.T) {
124+
func TestAccDataSourceDBInstanceWithSubstituteProps(t *testing.T) {
125125
id := fmt.Sprintf("%s_%s", t.Name(), utils.RandStringBytes(6))
126126
name := id
127127
resourceName := "data.harness_platform_db_instance.test"
@@ -131,24 +131,24 @@ func TestAccDataSourceDBInstanceWithLiquibaseProps(t *testing.T) {
131131
ProviderFactories: acctest.ProviderFactories,
132132
Steps: []resource.TestStep{
133133
{
134-
Config: testAccDataSourceDBInstanceWithLiquibaseProps(id, name),
134+
Config: testAccDataSourceDBInstanceWithSubstituteProps(id, name),
135135
Check: resource.ComposeTestCheckFunc(
136136
resource.TestCheckResourceAttr(resourceName, "identifier", id),
137137
resource.TestCheckResourceAttr(resourceName, "org_id", id),
138138
resource.TestCheckResourceAttr(resourceName, "name", name),
139139
resource.TestCheckResourceAttr(resourceName, "project_id", id),
140140
resource.TestCheckResourceAttr(resourceName, "branch", "feature/test"),
141141
resource.TestCheckResourceAttr(resourceName, "context", "test-context"),
142-
resource.TestCheckResourceAttr(resourceName, "liquibase_substitute_properties.db_user", "testuser"),
143-
resource.TestCheckResourceAttr(resourceName, "liquibase_substitute_properties.db_password", "testpass"),
142+
resource.TestCheckResourceAttr(resourceName, "substitute_properties.db_user", "testuser"),
143+
resource.TestCheckResourceAttr(resourceName, "substitute_properties.db_password", "testpass"),
144144
resource.TestCheckResourceAttr(resourceName, "tags.#", "2"),
145145
),
146146
},
147147
},
148148
})
149149
}
150150

151-
func testAccDataSourceDBInstanceWithLiquibaseProps(id string, name string) string {
151+
func testAccDataSourceDBInstanceWithSubstituteProps(id string, name string) string {
152152
return fmt.Sprintf(`
153153
resource "harness_platform_organization" "test" {
154154
identifier = "%[1]s"
@@ -227,7 +227,7 @@ func testAccDataSourceDBInstanceWithLiquibaseProps(id string, name string) strin
227227
connector = harness_platform_connector_jdbc.test.id
228228
schema = harness_platform_db_schema.test.id
229229
context = "test-context"
230-
liquibase_substitute_properties = {
230+
substitute_properties = {
231231
db_user = "testuser"
232232
db_password = "testpass"
233233
}

internal/service/platform/db_instance/resource_db_instance.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ func ResourceDBInstance() *schema.Resource {
4343
Type: schema.TypeString,
4444
Optional: true,
4545
},
46-
"liquibase_substitute_properties": {
47-
Description: "The properties to substitute in liquibase changelog",
46+
"substitute_properties": {
47+
Description: "The properties to substitute in changelog migration script",
4848
Type: schema.TypeMap,
4949
Optional: true,
5050
},
@@ -121,27 +121,27 @@ func resourceDBInstanceDelete(ctx context.Context, d *schema.ResourceData, meta
121121

122122
func buildDbInstance(d *schema.ResourceData) *dbops.DbInstanceIn {
123123

124-
liquibaseSubstituteProperties := make(map[string]string)
125-
if props, ok := d.GetOk("liquibase_substitute_properties"); ok {
124+
substituteProperties := make(map[string]string)
125+
if props, ok := d.GetOk("substitute_properties"); ok {
126126
if propsMap, isMap := props.(map[string]interface{}); isMap {
127127
if propsMap != nil && len(propsMap) > 0 {
128128
for k, v := range propsMap {
129129
if strVal, isStr := v.(string); isStr {
130-
liquibaseSubstituteProperties[k] = strVal
130+
substituteProperties[k] = strVal
131131
}
132132
}
133133
}
134134
}
135135
}
136136

137137
return &dbops.DbInstanceIn{
138-
Identifier: d.Get("identifier").(string),
139-
Name: d.Get("name").(string),
140-
Tags: helpers.ExpandTags(d.Get("tags").(*schema.Set).List()),
141-
Branch: d.Get("branch").(string),
142-
Connector: d.Get("connector").(string),
143-
Context: d.Get("context").(string),
144-
LiquibaseSubstituteProperties: liquibaseSubstituteProperties,
138+
Identifier: d.Get("identifier").(string),
139+
Name: d.Get("name").(string),
140+
Tags: helpers.ExpandTags(d.Get("tags").(*schema.Set).List()),
141+
Branch: d.Get("branch").(string),
142+
Connector: d.Get("connector").(string),
143+
Context: d.Get("context").(string),
144+
SubstituteProperties: substituteProperties,
145145
}
146146
}
147147

@@ -154,5 +154,5 @@ func readDBInstance(d *schema.ResourceData, dbInstance *dbops.DbInstanceOut) {
154154
d.Set("connector", dbInstance.Connector)
155155
d.Set("context", dbInstance.Context)
156156

157-
d.Set("liquibase_substitute_properties", dbInstance.LiquibaseSubstituteProperties)
157+
d.Set("substitute_properties", dbInstance.SubstituteProperties)
158158
}

internal/service/platform/db_instance/resource_db_instance_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestAccResourceDBInstance(t *testing.T) {
5252
})
5353
}
5454

55-
func TestAccResourceDBInstanceWithLiquibaseProps(t *testing.T) {
55+
func TestAccResourceDBInstanceWithSubstituteProps(t *testing.T) {
5656
name := t.Name()
5757
id := fmt.Sprintf("%s_%s", name, utils.RandStringBytes(5))
5858
updatedName := fmt.Sprintf("%s_updated", name)
@@ -64,30 +64,30 @@ func TestAccResourceDBInstanceWithLiquibaseProps(t *testing.T) {
6464
CheckDestroy: testAccDBInstanceDestroy(resourceName),
6565
Steps: []resource.TestStep{
6666
{
67-
Config: testAccResourceDBInstanceWithLiquibaseProps(id, name),
67+
Config: testAccResourceDBInstanceWithSubstituteProps(id, name),
6868
Check: resource.ComposeTestCheckFunc(
6969
resource.TestCheckResourceAttr(resourceName, "id", id),
7070
resource.TestCheckResourceAttr(resourceName, "name", name),
7171
resource.TestCheckResourceAttr(resourceName, "org_id", id),
7272
resource.TestCheckResourceAttr(resourceName, "project_id", id),
7373
resource.TestCheckResourceAttr(resourceName, "branch", "feature/test"),
7474
resource.TestCheckResourceAttr(resourceName, "context", "test-context"),
75-
resource.TestCheckResourceAttr(resourceName, "liquibase_substitute_properties.db_user", "testuser"),
76-
resource.TestCheckResourceAttr(resourceName, "liquibase_substitute_properties.db_password", "testpass"),
75+
resource.TestCheckResourceAttr(resourceName, "substitute_properties.db_user", "testuser"),
76+
resource.TestCheckResourceAttr(resourceName, "substitute_properties.db_password", "testpass"),
7777
resource.TestCheckResourceAttr(resourceName, "tags.#", "2"),
7878
),
7979
},
8080
{
81-
Config: testAccResourceDBInstanceWithLiquibaseProps(id, updatedName),
81+
Config: testAccResourceDBInstanceWithSubstituteProps(id, updatedName),
8282
Check: resource.ComposeTestCheckFunc(
8383
resource.TestCheckResourceAttr(resourceName, "id", id),
8484
resource.TestCheckResourceAttr(resourceName, "name", updatedName),
8585
resource.TestCheckResourceAttr(resourceName, "org_id", id),
8686
resource.TestCheckResourceAttr(resourceName, "project_id", id),
8787
resource.TestCheckResourceAttr(resourceName, "branch", "feature/test"),
8888
resource.TestCheckResourceAttr(resourceName, "context", "test-context"),
89-
resource.TestCheckResourceAttr(resourceName, "liquibase_substitute_properties.db_user", "testuser"),
90-
resource.TestCheckResourceAttr(resourceName, "liquibase_substitute_properties.db_password", "testpass"),
89+
resource.TestCheckResourceAttr(resourceName, "substitute_properties.db_user", "testuser"),
90+
resource.TestCheckResourceAttr(resourceName, "substitute_properties.db_password", "testpass"),
9191
resource.TestCheckResourceAttr(resourceName, "tags.#", "2"),
9292
),
9393
},
@@ -218,7 +218,7 @@ func testAccResourceDBInstance(id string, name string) string {
218218
`, id, name)
219219
}
220220

221-
func testAccResourceDBInstanceWithLiquibaseProps(id string, name string) string {
221+
func testAccResourceDBInstanceWithSubstituteProps(id string, name string) string {
222222
return fmt.Sprintf(`
223223
resource "harness_platform_organization" "test" {
224224
identifier = "%[1]s"
@@ -299,7 +299,7 @@ func testAccResourceDBInstanceWithLiquibaseProps(id string, name string) string
299299
connector = harness_platform_connector_jdbc.test.id
300300
schema = harness_platform_db_schema.test.id
301301
context = "test-context"
302-
liquibase_substitute_properties = {
302+
substitute_properties = {
303303
db_user = "testuser"
304304
db_password = "testpass"
305305
}

0 commit comments

Comments
 (0)