Skip to content

Commit

Permalink
fine tune changes from initial testing
Browse files Browse the repository at this point in the history
Signed-off-by: erikbaranowski <[email protected]>
  • Loading branch information
erikbaranowski committed Oct 16, 2023
1 parent f84d2e5 commit 8469b93
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion converter/internal/prometheusconvert/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 8 additions & 4 deletions converter/internal/prometheusconvert/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
10 changes: 7 additions & 3 deletions converter/internal/prometheusconvert/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
10 changes: 7 additions & 3 deletions converter/internal/prometheusconvert/lightsail.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion converter/internal/prometheusconvert/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8469b93

Please sign in to comment.