config

package
v3.0.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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 New

func New(apiRootURL string, options ...Option) (*Config, error)

New creates a new Config with specified API root URL and options.

func NewFromCFHome

func NewFromCFHome(options ...Option) (*Config, error)

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

func NewFromCFHomeDir(cfHomeDir string, options ...Option) (*Config, error)

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) ApiURL

func (c *Config) ApiURL(urlPath string) string

func (*Config) AuthURL

func (c *Config) AuthURL(urlPath string) string

func (*Config) CreateOAuth2TokenSource

func (c *Config) CreateOAuth2TokenSource(ctx context.Context) (oauth2.TokenSource, error)

CreateOAuth2TokenSource is used by the HTTP transport infrastructure to generate new TokenSource instances on-demand.

func (*Config) HTTPAuthClient

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

HTTPAuthClient returns the authenticated http.Client.

func (*Config) HTTPClient

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

HTTPClient returns the un-authenticated http.Client.

func (*Config) SSHOAuthClientID

func (c *Config) SSHOAuthClientID() string

SSHOAuthClientID returns the clientID used to request an SSH code, typically 'ssh-proxy'.

func (*Config) UserAgent

func (c *Config) UserAgent() string

UserAgent returns the configured user agent header string.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error if the Config is incomplete or invalid.

type Option

type Option func(*Config) error

Option is a functional option for configuring the client.

func AuthTokenURL

func AuthTokenURL(loginURL, tokenURL string) Option

AuthTokenURL is a functional option to set the authorize and token url.

func ClientCredentials

func ClientCredentials(clientID, clientSecret string) Option

ClientCredentials is a functional option to set client credentials.

func HttpClient

func HttpClient(client *http.Client) Option

HttpClient is a functional option to set the HTTP client.

func Origin

func Origin(origin string) Option

Origin is a functional option to set the origin.

func RequestTimeout

func RequestTimeout(timeout time.Duration) Option

RequestTimeout is a functional option to set the request timeout.

func SSHOAuthClient

func SSHOAuthClient(clientID string) Option

SSHOAuthClient configures a clientID used to request an SSH code.

func Scopes

func Scopes(scopes ...string) Option

Scopes is a functional option to set scopes.

func SkipTLSValidation

func SkipTLSValidation() Option

SkipTLSValidation is a functional option to skip TLS validation.

func Token

func Token(accessToken, refreshToken string) Option

Token is a functional option to set the access and refresh tokens.

func UserAgent

func UserAgent(userAgent string) Option

UserAgent is a functional option to set user agent.

func UserPassword

func UserPassword(username, password string) Option

UserPassword is a functional option to set user credentials.

Jump to

Keyboard shortcuts

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