Skip to content

Commit

Permalink
[fix]: [SRM-15255]: Removing enabled scope from terraform (#640)
Browse files Browse the repository at this point in the history
* [fix]: [SRM-15255]: Deprecating enabled scope from terraform
---------

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@harness.io>
Co-authored-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
  • Loading branch information
deepak-harness and mteodor committed Aug 11, 2023
1 parent 2db8ff5 commit d9a4ada
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .changelog/640.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
- Deprecated enabled from the monitored service dto to not allow customer to set monitored service as enabled to start with via terraform
```
3 changes: 1 addition & 2 deletions docs/resources/platform_monitored_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ resource "harness_platform_monitored_service" "example" {
notification_rule_ref = "notification_rule_ref1"
enabled = false
}
enabled = true
}
}
```
Expand Down Expand Up @@ -107,9 +106,9 @@ Optional:

- `dependencies` (Block Set) Dependencies of the monitored service. (see [below for nested schema](#nestedblock--request--dependencies))
- `description` (String) Description for the monitored service.
- `enabled` (Boolean) Enable or disable the monitored service.
- `environment_ref_list` (List of String) Environment reference list for the monitored service.
- `notification_rule_refs` (Block List) Notification rule references for the monitored service. (see [below for nested schema](#nestedblock--request--notification_rule_refs))
- `enabled` (Boolean) Enable or disable the monitored service. Enabled field is deprecated.
- `tags` (Set of String) Tags for the monitored service. comma-separated key value string pairs.
- `template_ref` (String) Template reference for the monitored service.
- `version_label` (String) Template version label for the monitored service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,5 @@ resource "harness_platform_monitored_service" "example" {
}
template_ref = "template_ref"
version_label = "version_label"
enabled = true
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/antihax/optional v1.0.0
github.com/docker/docker v20.10.22+incompatible
github.com/harness/harness-go-sdk v0.3.41
github.com/harness/harness-go-sdk v0.3.42
github.com/harness/harness-openapi-go-client v0.0.17
github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/harness/harness-go-sdk v0.3.41 h1:KwH+1NrRV72lSH/4YsQqNOP7JOZVCj1L5kH1Jnd1zb8=
github.com/harness/harness-go-sdk v0.3.41/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-go-sdk v0.3.42 h1:zvj2Dq/T5LA3fmoMLf8BX50spC1ado5JWnjBCFzK/kc=
github.com/harness/harness-go-sdk v0.3.42/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-openapi-go-client v0.0.17 h1:EZneIyi6sV+dlTgXbawxdVD0OoDmG3mnGHEJbwslRzc=
github.com/harness/harness-openapi-go-client v0.0.17/go.mod h1:u0vqYb994BJGotmEwJevF4L3BNAdU9i8ui2d22gmLPA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func testAccDataSourceMonitoredService(id string, name string) string {
}
template_ref = "template_ref"
version_label = "version_label"
enabled = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func ResourceMonitoredService() *schema.Resource {
Description: "Enable or disable the monitored service.",
Type: schema.TypeBool,
Optional: true,
Deprecated: "enabled field is deprecated",
},
},
},
Expand Down Expand Up @@ -396,7 +397,6 @@ func buildMonitoredServiceRequest(d *schema.ResourceData) *nextgen.MonitoredServ
VersionLabel: request["version_label"].(string),
}

monitoredServiceDto.Enabled = request["enabled"].(bool)
}

return monitoredServiceDto
Expand All @@ -411,3 +411,4 @@ func readMonitoredService(d *schema.ResourceData, monitoredServiceResponse **nex
d.Set("project_id", (*monitoredServiceDto).ProjectIdentifier)
d.Set("identifier", (*monitoredServiceDto).Identifier)
}

Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,82 @@ func testMonitoredServiceWithoutChangeSource(id string, name string) string {
}
`, id, name)
}

func TestMonitoredServiceWithoutEnabled(t *testing.T) {
name := t.Name()
id := fmt.Sprintf("%s_%s", name, utils.RandStringBytes(5))
updatedName := fmt.Sprintf("%s_updated", name)
resourceName := "harness_platform_monitored_service.test"

resource.UnitTest(t, resource.TestCase{
PreCheck: func() { acctest.TestAccPreCheck(t) },
ProviderFactories: acctest.ProviderFactories,
CheckDestroy: testAccMonitoredServiceDestroy(resourceName),
Steps: []resource.TestStep{
{
Config: testMonitoredServiceWithoutEnabled(id, name),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "id", id),
),
},
{
Config: testMonitoredServiceWithoutEnabled(id, updatedName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "id", id),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateIdFunc: acctest.ProjectResourceImportStateIdFunc(resourceName),
},
},
})
}

func testMonitoredServiceWithoutEnabled(id string, name string) string {
return fmt.Sprintf(`
resource "harness_platform_organization" "test" {
identifier = "%[1]s"
name = "%[2]s"
}
resource "harness_platform_project" "test" {
identifier = "%[1]s"
name = "%[2]s"
org_id = harness_platform_organization.test.id
color = "#472848"
}
resource "harness_platform_monitored_service" "test" {
org_id = harness_platform_project.test.org_id
project_id = harness_platform_project.test.id
identifier = "%[1]s"
request {
name = "%[2]s"
type = "Application"
description = "description"
service_ref = "service_ref"
environment_ref = "environment_ref"
tags = ["foo:bar", "bar:foo"]
health_sources {
name = "name"
identifier = "identifier"
type = "DatadogLog"
spec = jsonencode({
connectorRef = "connectorRef"
feature = "feature"
queries = [
{
name = "name"
query = "query"
indexes = ["index"]
serviceInstanceIdentifier = "serviceInstanceIdentifier"
}
]})
}
}
}
`, id, name)
}

1 change: 0 additions & 1 deletion internal/service/platform/slo/data_source_slo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func testAccDataSourceSlo(id string, name string) string {
}
template_ref = "template_ref"
version_label = "version_label"
enabled = true
}
}
Expand Down
1 change: 0 additions & 1 deletion internal/service/platform/slo/resource_slo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ func testAccResourceSlo(id string, name string) string {
}
template_ref = "template_ref"
version_label = "version_label"
enabled = true
}
}
Expand Down

0 comments on commit d9a4ada

Please sign in to comment.