diff --git a/coralogix/resource_coralogix_slo.go b/coralogix/resource_coralogix_slo.go index c3f5bd5d..06c0ebf0 100644 --- a/coralogix/resource_coralogix_slo.go +++ b/coralogix/resource_coralogix_slo.go @@ -1,11 +1,11 @@ // Copyright 2024 Coralogix Ltd. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // https://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -115,28 +115,28 @@ func (S SLOResourceValidator) ValidateResource(ctx context.Context, req resource resp.Diagnostics = diags return } - if config.Type.ValueString() == "latency" && (config.ThresholdMicroseconds.IsNull() || config.ThresholdMicroseconds.IsUnknown()) { + if config.Type.ValueString() == "latency" && config.ThresholdMicroseconds.IsNull() { resp.Diagnostics.AddError( "ThresholdMicroseconds is required when type is latency", "ThresholdMicroseconds is required when type is latency", ) return } - if config.Type.ValueString() == "latency" && (config.ThresholdSymbolType.IsNull() || config.ThresholdSymbolType.IsUnknown()) { + if config.Type.ValueString() == "latency" && config.ThresholdSymbolType.IsNull() { resp.Diagnostics.AddError( "ThresholdSymbolType is required when type is latency", "ThresholdSymbolType is required when type is latency", ) return } - if config.Type.ValueString() == "error" && !(config.ThresholdMicroseconds.IsNull() || config.ThresholdMicroseconds.IsUnknown()) { + if config.Type.ValueString() == "error" && !config.ThresholdMicroseconds.IsNull() { resp.Diagnostics.AddError( "ThresholdMicroseconds is not allowed when type is error", "ThresholdMicroseconds is not allowed when type is error", ) return } - if config.Type.ValueString() == "error" && !(config.ThresholdSymbolType.IsNull() || config.ThresholdSymbolType.IsUnknown()) { + if config.Type.ValueString() == "error" && !config.ThresholdSymbolType.IsNull() { resp.Diagnostics.AddError( "ThresholdSymbolType is not allowed when type is error", "ThresholdSymbolType is not allowed when type is error", diff --git a/coralogix/resource_coralogix_slo_test.go b/coralogix/resource_coralogix_slo_test.go index 8b5f8351..78e9a023 100644 --- a/coralogix/resource_coralogix_slo_test.go +++ b/coralogix/resource_coralogix_slo_test.go @@ -1,11 +1,11 @@ // Copyright 2024 Coralogix Ltd. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // https://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -77,13 +77,18 @@ func testAccSLOCheckDestroy(s *terraform.State) error { } func testAccCoralogixResourceSLO() string { - return `resource "coralogix_slo" "test" { + return `variable "test" { + type = number + default = 1000000 + } + + resource "coralogix_slo" "test" { name = "coralogix_slo_example" service_name = "service_name" description = "description" target_percentage = 30 type = "latency" - threshold_microseconds = 1000000 + threshold_microseconds = var.test threshold_symbol_type = "greater" period = "7_days" filters = [