config

package
v3.0.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const UserAgent = "Go-CF-Client/3.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	APIEndpointURL   string
	LoginEndpointURL string
	UAAEndpointURL   string

	Username     string
	Password     string
	ClientID     string
	ClientSecret string
	UserAgent    string
	Origin       string
	Token        string
	// contains filtered or unexported fields
}

Config is used to configure the creation of a client

func NewClientSecret

func NewClientSecret(apiRoot, clientID, clientSecret string) (*Config, error)

NewClientSecret creates a new config configured for client id and client secret authentication

func NewFromCFHome

func NewFromCFHome() (*Config, error)

NewFromCFHome is similar to NewToken but reads the access token from the CF_HOME config, which must exist and have a valid access token.

This will use the currently configured CF_HOME env var if it exists, otherwise attempts to use the default CF_HOME directory.

func NewFromCFHomeDir

func NewFromCFHomeDir(cfHomeDir string) (*Config, error)

NewFromCFHomeDir is similar to NewToken but reads the access token from the config in the specified directory which must exist and have a valid access token.

func NewToken

func NewToken(apiRoot, token string) (*Config, error)

NewToken creates a new config configured to use a static access token

This method of authentication does _not_ support refresh tokens or re-authentication, the access token must be valid and created externally to this client.

func NewUserPassword

func NewUserPassword(apiRootURL, username, password string) (*Config, error)

NewUserPassword creates a new config configured for regular user/password authentication

func (*Config) HTTPClient

func (c *Config) HTTPClient() *http.Client

HTTPClient returns the currently configured default base http.Client to be used as the base for all requests

func (*Config) RequestTimeout

func (c *Config) RequestTimeout() time.Duration

RequestTimeout returns the currently configured http.Client underlying transport request timeout

func (*Config) SkipTLSValidation

func (c *Config) SkipTLSValidation() bool

SkipTLSValidation returns the currently configured http.Client underlying transport InsecureSkipVerify

func (*Config) WithHTTPClient

func (c *Config) WithHTTPClient(httpClient *http.Client)

WithHTTPClient overrides the default http.Client to be used as the base for all requests

The TLS and Timeout values on the http.Client will be set to match the config

This is useful if you need to configure advanced http.Client or http.Transport settings, most consumers will not need to use this.

func (*Config) WithRequestTimeout

func (c *Config) WithRequestTimeout(timeout time.Duration)

WithRequestTimeout overrides the http.Client underlying transport request timeout

func (*Config) WithSkipTLSValidation

func (c *Config) WithSkipTLSValidation(skip bool)

WithSkipTLSValidation sets the http.Client underlying transport InsecureSkipVerify

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL