diff --git a/converter/internal/prometheusconvert/common.go b/converter/internal/prometheusconvert/common.go index 13d1580d9f3f..9fa2e6c37379 100644 --- a/converter/internal/prometheusconvert/common.go +++ b/converter/internal/prometheusconvert/common.go @@ -35,7 +35,7 @@ func ValidateHttpClientConfig(httpClientConfig *prom_config.HTTPClientConfig) di diags.AddAll(common.UnsupportedNotEquals(httpClientConfig.NoProxy, "", "HTTP Client no_proxy")) diags.AddAll(common.UnsupportedEquals(httpClientConfig.ProxyFromEnvironment, true, "HTTP Client proxy_from_environment")) diags.AddAll(common.UnsupportedEquals(len(httpClientConfig.ProxyConnectHeader) > 0, true, "HTTP Client proxy_connect_header")) - diags.AddAll(common.UnsupportedNotEquals(httpClientConfig.TLSConfig.MaxVersion, 0, "HTTP Client max_version")) + diags.AddAll(common.UnsupportedNotEquals(httpClientConfig.TLSConfig.MaxVersion, prom_config.TLSVersion(0), "HTTP Client max_version")) return diags } diff --git a/converter/internal/prometheusconvert/digitalocean.go b/converter/internal/prometheusconvert/digitalocean.go index 2ef40a5afc0b..8283889bcfd6 100644 --- a/converter/internal/prometheusconvert/digitalocean.go +++ b/converter/internal/prometheusconvert/digitalocean.go @@ -24,10 +24,14 @@ func appendDiscoveryDigitalOcean(pb *prometheusBlocks, label string, sdConfig *p func validateDiscoveryDigitalOcean(sdConfig *prom_digitalocean.SDConfig) diag.Diagnostics { var diags diag.Diagnostics - diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.BasicAuth, nil, "digitalocean_sd_configs basic_auth")) - diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.Authorization, nil, "digitalocean_sd_configs authorization")) - diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.OAuth2, nil, "digitalocean_sd_configs oauth2")) - diags.AddAll(common.UnsupportedNotDeepEquals(prom_config.TLSConfig{}, sdConfig.HTTPClientConfig.TLSConfig, "digitalocean_sd_configs tls_config")) + var nilBasicAuth *prom_config.BasicAuth + var nilAuthorization *prom_config.Authorization + var nilOAuth2 *prom_config.OAuth2 + + diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.BasicAuth, nilBasicAuth, "digitalocean_sd_configs basic_auth")) + diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.Authorization, nilAuthorization, "digitalocean_sd_configs authorization")) + diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.OAuth2, nilOAuth2, "digitalocean_sd_configs oauth2")) + diags.AddAll(common.UnsupportedNotDeepEquals(sdConfig.HTTPClientConfig.TLSConfig, prom_config.TLSConfig{}, "digitalocean_sd_configs tls_config")) diags.AddAll(ValidateHttpClientConfig(&sdConfig.HTTPClientConfig)) diff --git a/converter/internal/prometheusconvert/ec2.go b/converter/internal/prometheusconvert/ec2.go index d7ebe0a2876c..e9167f0b1e53 100644 --- a/converter/internal/prometheusconvert/ec2.go +++ b/converter/internal/prometheusconvert/ec2.go @@ -23,9 +23,13 @@ func appendDiscoveryEC2(pb *prometheusBlocks, label string, sdConfig *prom_aws.E func validateDiscoveryEC2(sdConfig *prom_aws.EC2SDConfig) diag.Diagnostics { var diags diag.Diagnostics - diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.BasicAuth, nil, "ec2_sd_configs basic_auth")) - diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.Authorization, nil, "ec2_sd_configs authorization")) - diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.OAuth2, nil, "ec2_sd_configs oauth2")) + var nilBasicAuth *prom_config.BasicAuth + var nilAuthorization *prom_config.Authorization + var nilOAuth2 *prom_config.OAuth2 + + diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.BasicAuth, nilBasicAuth, "ec2_sd_configs basic_auth")) + diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.Authorization, nilAuthorization, "ec2_sd_configs authorization")) + diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.OAuth2, nilOAuth2, "ec2_sd_configs oauth2")) diags.AddAll(common.UnsupportedNotDeepEquals(sdConfig.HTTPClientConfig.BearerToken, prom_config.DefaultHTTPClientConfig.BearerToken, "ec2_sd_configs bearer_token")) diags.AddAll(common.UnsupportedNotDeepEquals(sdConfig.HTTPClientConfig.BearerTokenFile, prom_config.DefaultHTTPClientConfig.BearerTokenFile, "ec2_sd_configs bearer_token_file")) diags.AddAll(common.UnsupportedNotDeepEquals(sdConfig.HTTPClientConfig.FollowRedirects, prom_config.DefaultHTTPClientConfig.FollowRedirects, "ec2_sd_configs follow_redirects")) diff --git a/converter/internal/prometheusconvert/lightsail.go b/converter/internal/prometheusconvert/lightsail.go index 982918bc3646..24add5c04a1a 100644 --- a/converter/internal/prometheusconvert/lightsail.go +++ b/converter/internal/prometheusconvert/lightsail.go @@ -23,9 +23,13 @@ func appendDiscoveryLightsail(pb *prometheusBlocks, label string, sdConfig *prom func validateDiscoveryLightsail(sdConfig *prom_aws.LightsailSDConfig) diag.Diagnostics { var diags diag.Diagnostics - diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.BasicAuth, nil, "lightsail_sd_configs basic_auth")) - diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.Authorization, nil, "lightsail_sd_configs authorization")) - diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.OAuth2, nil, "lightsail_sd_configs oauth2")) + var nilBasicAuth *prom_config.BasicAuth + var nilAuthorization *prom_config.Authorization + var nilOAuth2 *prom_config.OAuth2 + + diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.BasicAuth, nilBasicAuth, "lightsail_sd_configs basic_auth")) + diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.Authorization, nilAuthorization, "lightsail_sd_configs authorization")) + diags.AddAll(common.UnsupportedNotEquals(sdConfig.HTTPClientConfig.OAuth2, nilOAuth2, "lightsail_sd_configs oauth2")) diags.AddAll(common.UnsupportedNotDeepEquals(sdConfig.HTTPClientConfig.BearerToken, prom_config.DefaultHTTPClientConfig.BearerToken, "lightsail_sd_configs bearer_token")) diags.AddAll(common.UnsupportedNotDeepEquals(sdConfig.HTTPClientConfig.BearerTokenFile, prom_config.DefaultHTTPClientConfig.BearerTokenFile, "lightsail_sd_configs bearer_token_file")) diags.AddAll(common.UnsupportedNotDeepEquals(sdConfig.HTTPClientConfig.FollowRedirects, prom_config.DefaultHTTPClientConfig.FollowRedirects, "lightsail_sd_configs follow_redirects")) diff --git a/converter/internal/prometheusconvert/scrape.go b/converter/internal/prometheusconvert/scrape.go index 476c85fb4e74..746de910bf2b 100644 --- a/converter/internal/prometheusconvert/scrape.go +++ b/converter/internal/prometheusconvert/scrape.go @@ -28,7 +28,7 @@ func appendPrometheusScrape(pb *prometheusBlocks, scrapeConfig *prom_config.Scra func validatePrometheusScrape(scrapeConfig *prom_config.ScrapeConfig) diag.Diagnostics { var diags diag.Diagnostics - diags.AddAll(common.UnsupportedNotEquals(scrapeConfig.NativeHistogramBucketLimit != 0, true, "scrape_configs native_histogram_bucket_limit")) + diags.AddAll(common.UnsupportedNotEquals(scrapeConfig.NativeHistogramBucketLimit, uint(0), "scrape_configs native_histogram_bucket_limit")) diags.AddAll(ValidateHttpClientConfig(&scrapeConfig.HTTPClientConfig)) return diags