Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(synthetics): Add missing tags for newrelic_synthetics_cert_check_monitor #2642

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions newrelic/resource_helpers_synthetics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package newrelic
import (
"encoding/base64"
"fmt"
"strconv"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -488,3 +489,23 @@ var syntheticsMonitorTagKeyToSchemaAttrMap = map[string]string{
"deviceOrientation": "device_orientation",
"deviceType": "device_type",
}

func getCertCheckMonitorValuesFromEntityTags(tags []entities.EntityTag) (domain string, daysUntilExpiration int) {
domain = ""
daysUntilExpiration = 0

for _, tag := range tags {

if tag.Key == "domain" {
domain = tag.Values[0]
}

if tag.Key == "daysUntilExpiration" {
// Parse string to integer
days := tag.Values[0]
daysUntilExpiration, _ = strconv.Atoi(days)
}
}

return domain, daysUntilExpiration
}
6 changes: 6 additions & 0 deletions newrelic/resource_newrelic_synthetics_cert_check_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ func resourceNewRelicSyntheticsCertCheckMonitorRead(ctx context.Context, d *sche
_ = d.Set("runtime_type_version", runtimeTypeVersion)
}

domain, daysUntilExpiration := getCertCheckMonitorValuesFromEntityTags(entity.GetTags())
if domain != "" && daysUntilExpiration != 0 {
_ = d.Set("domain", domain)
_ = d.Set("certificate_expiration", daysUntilExpiration)
}

}

return diag.FromErr(err)
Expand Down
Loading