Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHTTPClientConfig = HTTPClientConfig{
	FollowRedirects: true,
}

    DefaultHTTPClientConfig is the default HTTP client configuration.

    Functions

    func JoinDir

    func JoinDir(dir, path string) string

      JoinDir joins dir and path if path is relative. If path is empty or absolute, it is returned unchanged.

      func NewAuthorizationCredentialsFileRoundTripper

      func NewAuthorizationCredentialsFileRoundTripper(authType, authCredentialsFile string, rt http.RoundTripper) http.RoundTripper

        NewAuthorizationCredentialsFileRoundTripper adds the authorization credentials read from the provided file to a request unless the authorization header has already been set. This file is read for every request.

        func NewAuthorizationCredentialsRoundTripper

        func NewAuthorizationCredentialsRoundTripper(authType string, authCredentials Secret, rt http.RoundTripper) http.RoundTripper

          NewAuthorizationCredentialsRoundTripper adds the provided credentials to a request unless the authorization header has already been set.

          func NewBasicAuthRoundTripper

          func NewBasicAuthRoundTripper(username string, password Secret, passwordFile string, rt http.RoundTripper) http.RoundTripper

            NewBasicAuthRoundTripper will apply a BASIC auth authorization header to a request unless it has already been set.

            func NewClientFromConfig

            func NewClientFromConfig(cfg HTTPClientConfig, name string, disableKeepAlives, enableHTTP2 bool) (*http.Client, error)

              NewClientFromConfig returns a new HTTP client configured for the given config.HTTPClientConfig. The name is used as go-conntrack metric label.

              func NewRoundTripperFromConfig

              func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, disableKeepAlives, enableHTTP2 bool) (http.RoundTripper, error)

                NewRoundTripperFromConfig returns a new HTTP RoundTripper configured for the given config.HTTPClientConfig. The name is used as go-conntrack metric label.

                func NewTLSConfig

                func NewTLSConfig(cfg *TLSConfig) (*tls.Config, error)

                  NewTLSConfig creates a new tls.Config from the given TLSConfig.

                  Types

                  type Authorization

                  type Authorization struct {
                  	Type            string `yaml:"type,omitempty"`
                  	Credentials     Secret `yaml:"credentials,omitempty"`
                  	CredentialsFile string `yaml:"credentials_file,omitempty"`
                  }

                    Authorization contains HTTP authorization credentials.

                    func (*Authorization) SetDirectory

                    func (a *Authorization) SetDirectory(dir string)

                      SetDirectory joins any relative file paths with dir.

                      type BasicAuth

                      type BasicAuth struct {
                      	Username     string `yaml:"username"`
                      	Password     Secret `yaml:"password,omitempty"`
                      	PasswordFile string `yaml:"password_file,omitempty"`
                      }

                        BasicAuth contains basic HTTP authentication credentials.

                        func (*BasicAuth) SetDirectory

                        func (a *BasicAuth) SetDirectory(dir string)

                          SetDirectory joins any relative file paths with dir.

                          func (*BasicAuth) UnmarshalYAML

                          func (a *BasicAuth) UnmarshalYAML(unmarshal func(interface{}) error) error

                            UnmarshalYAML implements the yaml.Unmarshaler interface.

                            type DirectorySetter

                            type DirectorySetter interface {
                            	// SetDirectory joins any relative file paths with dir.
                            	// Any paths that are empty or absolute remain unchanged.
                            	SetDirectory(dir string)
                            }

                              DirectorySetter is a config type that contains file paths that may be relative to the file containing the config.

                              type HTTPClientConfig

                              type HTTPClientConfig struct {
                              	// The HTTP basic authentication credentials for the targets.
                              	BasicAuth *BasicAuth `yaml:"basic_auth,omitempty"`
                              	// The HTTP authorization credentials for the targets.
                              	Authorization *Authorization `yaml:"authorization,omitempty"`
                              	// The bearer token for the targets. Deprecated in favour of
                              	// Authorization.Credentials.
                              	BearerToken Secret `yaml:"bearer_token,omitempty"`
                              	// The bearer token file for the targets. Deprecated in favour of
                              	// Authorization.CredentialsFile.
                              	BearerTokenFile string `yaml:"bearer_token_file,omitempty"`
                              	// HTTP proxy server to use to connect to the targets.
                              	ProxyURL URL `yaml:"proxy_url,omitempty"`
                              	// TLSConfig to use to connect to the targets.
                              	TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
                              	// FollowRedirects specifies whether the client should follow HTTP 3xx redirects.
                              	// The omitempty flag is not set, because it would be hidden from the
                              	// marshalled configuration when set to false.
                              	FollowRedirects bool `yaml:"follow_redirects"`
                              }

                                HTTPClientConfig configures an HTTP client.

                                func (*HTTPClientConfig) SetDirectory

                                func (c *HTTPClientConfig) SetDirectory(dir string)

                                  SetDirectory joins any relative file paths with dir.

                                  func (HTTPClientConfig) String

                                  func (c HTTPClientConfig) String() string

                                  func (*HTTPClientConfig) UnmarshalYAML

                                  func (c *HTTPClientConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

                                    UnmarshalYAML implements the yaml.Unmarshaler interface

                                    func (*HTTPClientConfig) Validate

                                    func (c *HTTPClientConfig) Validate() error

                                      Validate validates the HTTPClientConfig to check only one of BearerToken, BasicAuth and BearerTokenFile is configured.

                                      type Secret

                                      type Secret string

                                        Secret special type for storing secrets.

                                        func (Secret) MarshalYAML

                                        func (s Secret) MarshalYAML() (interface{}, error)

                                          MarshalYAML implements the yaml.Marshaler interface for Secrets.

                                          func (*Secret) UnmarshalYAML

                                          func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error

                                            UnmarshalYAML implements the yaml.Unmarshaler interface for Secrets.

                                            type TLSConfig

                                            type TLSConfig struct {
                                            	// The CA cert to use for the targets.
                                            	CAFile string `yaml:"ca_file,omitempty"`
                                            	// The client cert file for the targets.
                                            	CertFile string `yaml:"cert_file,omitempty"`
                                            	// The client key file for the targets.
                                            	KeyFile string `yaml:"key_file,omitempty"`
                                            	// Used to verify the hostname for the targets.
                                            	ServerName string `yaml:"server_name,omitempty"`
                                            	// Disable target certificate validation.
                                            	InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
                                            }

                                              TLSConfig configures the options for TLS connections.

                                              func (*TLSConfig) SetDirectory

                                              func (c *TLSConfig) SetDirectory(dir string)

                                                SetDirectory joins any relative file paths with dir.

                                                func (*TLSConfig) UnmarshalYAML

                                                func (c *TLSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

                                                  UnmarshalYAML implements the yaml.Unmarshaler interface.

                                                  type URL

                                                  type URL struct {
                                                  	*url.URL
                                                  }

                                                    URL is a custom URL type that allows validation at configuration load time.

                                                    func (URL) MarshalYAML

                                                    func (u URL) MarshalYAML() (interface{}, error)

                                                      MarshalYAML implements the yaml.Marshaler interface for URLs.

                                                      func (*URL) UnmarshalYAML

                                                      func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error

                                                        UnmarshalYAML implements the yaml.Unmarshaler interface for URLs.