Documentation ¶
Index ¶
- type HCPConfig
- type HCPConfigOption
- func FromEnv() HCPConfigOption
- func WithAPI(address string, tlsConfig *tls.Config) HCPConfigOption
- func WithAuth(authURL string, tlsConfig *tls.Config) HCPConfigOption
- func WithClientCredentials(clientID, clientSecret string) HCPConfigOption
- func WithPortalURL(portalURL string) HCPConfigOption
- func WithSCADA(address string, tlsConfig *tls.Config) HCPConfigOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HCPConfig ¶
type HCPConfig interface { // TokenSource will return a token that can be used to authenticate to HCP. oauth2.TokenSource // PortalURL will return the URL of the portal. // // The default portal URL will be the production portal, but the value may // be overwritten for development purposes. PortalURL() *url.URL // APIAddress will return the HCP API address (<hostname>[:port]). // // The default address will be the HCP production API, but it may be // overwritten for development purposes. APIAddress() string // APITLSConfig will return the API TLS configuration. // // TLS will be enabled by default but may be disabled for development // purposes. APITLSConfig() *tls.Config // SCADAAddress will return the SCADA address (<hostname>[:port]). // // The default address will be the HCP production SCADA endpoint, but it may // be overwritten for development purposes. SCADAAddress() string // SCADATLSConfig will return the SCADA TLS configuration. // // TLS will be enabled by default but may be disabled for development // purposes. SCADATLSConfig() *tls.Config }
HCPConfig provides configuration values that are useful to interact with HCP.
func NewHCPConfig ¶
func NewHCPConfig(opts ...HCPConfigOption) (HCPConfig, error)
NewHCPConfig will return a HCPConfig. The configuration will be constructed from default values and the passed options.
Based on the provided options the configuration values can be provided directly or will be read from other places (e.g. the environment).
The configuration will default to values for the HCP production environment, but can be overwritten for development purposes.
In addition to the default values the configuration requires client credentials to be provided through one of the passed options (e.g. by using WithCredentials or by using FromEnv and providing the client credentials via environment variables).
type HCPConfigOption ¶
type HCPConfigOption = func(config *hcpConfig) error
HCPConfigOption are functions that modify the hcpConfig struct. They can be passed to NewHCPConfig.
func FromEnv ¶
func FromEnv() HCPConfigOption
FromEnv will return a HCPConfigOption that will populate the configuration with values from the environment.
It will not fail if no or only part of the variables are present.
func WithAPI ¶
func WithAPI(address string, tlsConfig *tls.Config) HCPConfigOption
WithAPI credentials is an option that can be used to provide a custom configuration for the API endpoint.
If nil is provided for the tlsConfig value, TLS will be disabled.
This should only be necessary for development purposes.
func WithAuth ¶
func WithAuth(authURL string, tlsConfig *tls.Config) HCPConfigOption
WithAuth credentials is an option that can be used to provide a custom URL for the auth endpoint.
An alternative TLS configuration can be provided, if non is provided the default TLS configuration will be used. It is not possible to disable TLS for the auth endpoint.
This should only be necessary for development purposes.
func WithClientCredentials ¶
func WithClientCredentials(clientID, clientSecret string) HCPConfigOption
WithClientCredentials credentials is an option that can be used to set HCP client credentials on the configuration.
func WithPortalURL ¶
func WithPortalURL(portalURL string) HCPConfigOption
WithPortalURL credentials is an option that can be used to provide a custom URL for the portal.
This should only be necessary for development purposes.
func WithSCADA ¶
func WithSCADA(address string, tlsConfig *tls.Config) HCPConfigOption
WithSCADA credentials is an option that can be used to provide a custom configuration for the SCADA endpoint.
If nil is provided for the tlsConfig value, TLS will be disabled.
This should only be necessary for development purposes.