Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- func (c *Config) ApiURL(urlPath string) string
- func (c *Config) AuthURL(urlPath string) string
- func (c *Config) CreateOAuth2TokenSource(ctx context.Context) (oauth2.TokenSource, error)
- func (c *Config) HTTPAuthClient() *http.Client
- func (c *Config) HTTPClient() *http.Client
- func (c *Config) SSHOAuthClientID() string
- func (c *Config) UserAgent() string
- func (c *Config) Validate() error
- type Option
- func AuthTokenURL(loginURL, tokenURL string) Option
- func ClientCredentials(clientID, clientSecret string) Option
- func HttpClient(client *http.Client) Option
- func Origin(origin string) Option
- func RequestTimeout(timeout time.Duration) Option
- func SSHOAuthClient(clientID string) Option
- func Scopes(scopes ...string) Option
- func SkipTLSValidation() Option
- func Token(accessToken, refreshToken string) Option
- func UserAgent(userAgent string) Option
- func UserPassword(username, password string) Option
Constants ¶
const ( GrantTypeRefreshToken = "refresh_token" GrantTypeClientCredentials = "client_credentials" GrantTypePassword = "password" DefaultRequestTimeout = 30 * time.Second DefaultUserAgent = "Go-CF-Client/3.0" DefaultClientID = "cf" DefaultSSHClientID = "ssh-proxy" )
Variables ¶
var ErrConfigInvalid = errors.New("configuration is invalid")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is used to configure the creation of a client
func NewFromCFHome ¶
NewFromCFHome creates a client config from the CF CLI config.
This will use the currently configured CF_HOME env var if it exists, otherwise attempts to use the default CF_HOME directory.
If CF_USERNAME and CF_PASSWORD env vars are set then those credentials will be used to get an oauth2 token. If those env vars are not set then the stored oauth2 token is used.
func NewFromCFHomeDir ¶
NewFromCFHomeDir creates a client config from the CF CLI config using the specified directory.
This will attempt to read the CF CLI config from the specified directory only.
If CF_USERNAME and CF_PASSWORD env vars are set then those credentials will be used to get an oauth2 token. If those env vars are not set then the stored oauth2 token is used.
func (*Config) CreateOAuth2TokenSource ¶
CreateOAuth2TokenSource is used by the HTTP transport infrastructure to generate new TokenSource instances on-demand.
func (*Config) HTTPAuthClient ¶
HTTPAuthClient returns the authenticated http.Client.
func (*Config) HTTPClient ¶
HTTPClient returns the un-authenticated http.Client.
func (*Config) SSHOAuthClientID ¶
SSHOAuthClientID returns the clientID used to request an SSH code, typically 'ssh-proxy'.
type Option ¶
Option is a functional option for configuring the client.
func AuthTokenURL ¶
AuthTokenURL is a functional option to set the authorize and token url.
func ClientCredentials ¶
ClientCredentials is a functional option to set client credentials.
func HttpClient ¶
HttpClient is a functional option to set the HTTP client.
func RequestTimeout ¶
RequestTimeout is a functional option to set the request timeout.
func SSHOAuthClient ¶
SSHOAuthClient configures a clientID used to request an SSH code.
func SkipTLSValidation ¶
func SkipTLSValidation() Option
SkipTLSValidation is a functional option to skip TLS validation.
func UserPassword ¶
UserPassword is a functional option to set user credentials.