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

Method Validate

config/http_config.go:1698–1712  ·  view source on GitHub ↗

UnmarshalYAML implements the yaml.Unmarshaler interface.

()

Source from the content-addressed store, hash-verified

1696
1697// UnmarshalYAML implements the yaml.Unmarshaler interface.
1698func (c *ProxyConfig) Validate() error {
1699 if len(c.ProxyConnectHeader) > 0 && (!c.ProxyFromEnvironment && (c.ProxyURL.URL == nil || c.ProxyURL.String() == "")) {
1700 return errors.New("if proxy_connect_header is configured, proxy_url or proxy_from_environment must also be configured")
1701 }
1702 if c.ProxyFromEnvironment && c.ProxyURL.URL != nil && c.ProxyURL.String() != "" {
1703 return errors.New("if proxy_from_environment is configured, proxy_url must not be configured")
1704 }
1705 if c.ProxyFromEnvironment && c.NoProxy != "" {
1706 return errors.New("if proxy_from_environment is configured, no_proxy must not be configured")
1707 }
1708 if c.ProxyURL.URL == nil && c.NoProxy != "" {
1709 return errors.New("if no_proxy is configured, proxy_url must also be configured")
1710 }
1711 return nil
1712}
1713
1714// Proxy returns the Proxy URL for a request.
1715func (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