Skip to content

Commit

Permalink
Do not prevalidate dashboard json if it its value is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
lootag committed Dec 4, 2024
1 parent 598eb1f commit 436868b
Show file tree
Hide file tree
Showing 4 changed files with 1,272 additions and 2 deletions.
2 changes: 1 addition & 1 deletion coralogix/resource_coralogix_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -2947,7 +2947,7 @@ func (c ContentJsonValidator) MarkdownDescription(_ context.Context) string {
}

func (c ContentJsonValidator) ValidateString(_ context.Context, request validator.StringRequest, response *validator.StringResponse) {
if request.ConfigValue.IsNull() {
if request.ConfigValue.IsNull() || request.ConfigValue.IsUnknown() {
return
}

Expand Down
34 changes: 34 additions & 0 deletions coralogix/resource_coralogix_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,27 @@ func TestAccCoralogixResourceDashboardFromJson(t *testing.T) {
})
}

func TestAccCoralogixResourceDashboardFromJsonWithVar(t *testing.T) {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
parent := filepath.Dir(wd)
filePath := parent + "/examples/resources/coralogix_dashboard/dashboard.json"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
CheckDestroy: testAccCheckDashboardDestroy,
Steps: []resource.TestStep{
{
Config: testAccCoralogixResourceDashboardFromJsonWithVar(filePath),
Check: resource.ComposeAggregateTestCheckFunc(),
},
},
})
}

func testAccCheckDashboardDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*clientset.ClientSet).Dashboards()

Expand Down Expand Up @@ -330,6 +351,19 @@ func testAccCoralogixResourceDashboardFromJson(jsonFilePath string) string {
`, jsonFilePath)
}

func testAccCoralogixResourceDashboardFromJsonWithVar(jsonFilePath string) string {
return fmt.Sprintf(`
variable "dashboard_json_path" {
type = string
default = "%s"
}
resource "coralogix_dashboard" test {
content_json = file(var.dashboard_json_path)
}
`, jsonFilePath)
}

func TestParseRelativeTimeDuration(t *testing.T) {
res, err := parseDuration("seconds:900", "relative")
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion coralogix/resource_coralogix_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,6 @@ func (r *WebhookResource) Schema(_ context.Context, _ resource.SchemaRequest, re
},
"detail": schema.StringAttribute{
Required: true,
Default: stringdefault.StaticString(customDefaultPayload),
MarkdownDescription: "Event bridge message. JSON string. More details about the token [\"here\"](https://coralogix.com/docs/user-guides/alerting/outbound-webhooks/generic-outbound-webhooks-alert-webhooks/#placeholders)",
},
"detail_type": schema.StringAttribute{
Expand Down
Loading

0 comments on commit 436868b

Please sign in to comment.