Skip to content

Commit

Permalink
fix: SLO validation, typo in the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
celaus committed Jan 13, 2025
1 parent 07920ac commit 224080d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
8 changes: 4 additions & 4 deletions coralogix/resource_coralogix_slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,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",
Expand Down
39 changes: 21 additions & 18 deletions coralogix/resource_coralogix_slo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,25 @@ func testAccSLOCheckDestroy(s *terraform.State) error {
}

func testAccCoralogixResourceSLO() string {
return `resource "coralogix_slo" "test" {
name = "coralogix_slo_example"
service_name = "service_name"
description = "description"
target_percentage = 30
type = "latency"
threshold_microseconds = 1000000
threshold_symbol_type = "greater"
period = "7_days"
filters = [
{
field = "severity"
compare_type = "is"
field_values = ["error", "warning"]
},
]
}
`
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 = var.test
threshold_symbol_type = "greater"
period = "7_days"
filters = [{
field = "severity"
compare_type = "is"
field_values = ["error", "warning"]
}]
}
`
}
2 changes: 1 addition & 1 deletion docs/guides/alerts-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This guide provides step-by-step instructions on how to use the Terraform migrat

## Prerequisites
0. **Get the scripts**:
- Download from [https://github.com/coralogix/coralogix-management-sdk/tree/master/tools/terraform-importer]()
- Download from https://github.com/coralogix/coralogix-management-sdk/tree/master/tools/terraform-importer
1. **Terraform Installed**:
- Ensure you have Terraform installed. You can download it [here](https://www.terraform.io/downloads).
2. **Go Installed**:
Expand Down

0 comments on commit 224080d

Please sign in to comment.