MCPcopy Create free account
hub / github.com/prometheus/common / Validate

Method Validate

config/http_config.go:1214–1228  ·  view source on GitHub ↗

UnmarshalYAML implements the yaml.Unmarshaler interface.

()

Source from the content-addressed store, hash-verified

1212
1213// UnmarshalYAML implements the yaml.Unmarshaler interface.
1214func (c *ProxyConfig) Validate() error {
1215 if len(c.ProxyConnectHeader) > 0 && (!c.ProxyFromEnvironment && (c.ProxyURL.URL == nil || c.ProxyURL.String() == "")) {
1216 return fmt.Errorf("if proxy_connect_header is configured, proxy_url or proxy_from_environment must also be configured")
1217 }
1218 if c.ProxyFromEnvironment && c.ProxyURL.URL != nil && c.ProxyURL.String() != "" {
1219 return fmt.Errorf("if proxy_from_environment is configured, proxy_url must not be configured")
1220 }
1221 if c.ProxyFromEnvironment && c.NoProxy != "" {
1222 return fmt.Errorf("if proxy_from_environment is configured, no_proxy must not be configured")
1223 }
1224 if c.ProxyURL.URL == nil && c.NoProxy != "" {
1225 return fmt.Errorf("if no_proxy is configured, proxy_url must also be configured")
1226 }
1227 return nil
1228}
1229
1230// Proxy returns the Proxy URL for a request.
1231func (c *ProxyConfig) Proxy() (fn func(*http.Request) (*url.URL, error)) {

Callers

nothing calls this directly

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected