Documentation ¶
Overview ¶
Package config package contains everything related to the CF CLI Configuration.
Index ¶
- Constants
- func ConfigFilePath() string
- func WriteConfig(c *Config) error
- type CFConfig
- type ColorSetting
- type Config
- func (config *Config) APIVersion() string
- func (config *Config) AccessToken() string
- func (config *Config) BinaryName() string
- func (config *Config) ClientID() string
- func (config *Config) ClientSecret() string
- func (config *Config) ColorEnabled() ColorSetting
- func (config *Config) CurrentUser() (User, error)
- func (config *Config) Experimental() bool
- func (config *Config) HTTPSProxy() string
- func (config *Config) Locale() string
- func (config *Config) PluginHome() string
- func (config *Config) PluginRepos() []PluginRepos
- func (config *Config) Plugins() map[string]Plugin
- func (config *Config) RefreshToken() string
- func (config *Config) SetAccessToken(accessToken string)
- func (config *Config) SetOrganizationInformation(guid string, name string)
- func (config *Config) SetSpaceInformation(guid string, name string, allowSSH bool)
- func (config *Config) SetTargetInformation(api string, apiVersion string, auth string, loggregator string, doppler string, ...)
- func (config *Config) SetTokenInformation(accessToken string, refreshToken string, sshOAuthClient string)
- func (config *Config) SkipSSLValidation() bool
- func (config *Config) StagingTimeout() time.Duration
- func (config *Config) StartupTimeout() time.Duration
- func (config *Config) Target() string
- func (config *Config) TargetedOrganization() Organization
- func (config *Config) TargetedSpace() Space
- type EnvOverride
- type Organization
- type Plugin
- type PluginCommand
- type PluginCommands
- type PluginRepos
- type PluginUsageDetails
- type PluginVersion
- type PluginsConfig
- type QuotaDefinition
- type Space
- type User
Constants ¶
const ( DefaultStagingTimeout = 15 * time.Minute DefaultStartupTimeout = 5 * time.Minute DefaultTarget = "" UAAClientID = "cf" UAAClientSecret = "" )
const ( DefaultPluginRepoName = "CF-Community" DefaultPluginRepoURL = "https://plugins.cloudfoundry.org" )
const (
DefaultLocale = ""
)
Variables ¶
This section is empty.
Functions ¶
func ConfigFilePath ¶
func ConfigFilePath() string
ConfigFilePath returns the location of the config file
func WriteConfig ¶
WriteConfig creates the .cf directory and then writes the config.json. The location of .cf directory is written in the same way LoadConfig reads .cf directory.
Types ¶
type CFConfig ¶
type CFConfig struct { ConfigVersion int `json:"ConfigVersion"` Target string `json:"Target"` APIVersion string `json:"APIVersion"` AuthorizationEndpoint string `json:"AuthorizationEndpoint"` LoggregatorEndpoint string `json:"LoggregatorEndPoint"` DopplerEndpoint string `json:"DopplerEndPoint"` UAAEndpoint string `json:"UaaEndpoint"` RoutingEndpoint string `json:"RoutingAPIEndpoint"` AccessToken string `json:"AccessToken"` SSHOAuthClient string `json:"SSHOAuthClient"` RefreshToken string `json:"RefreshToken"` TargetedOrganization Organization `json:"OrganizationFields"` TargetedSpace Space `json:"SpaceFields"` SkipSSLValidation bool `json:"SSLDisabled"` AsyncTimeout int `json:"AsyncTimeout"` Trace string `json:"Trace"` ColorEnabled string `json:"ColorEnabled"` Locale string `json:"Locale"` PluginRepos []PluginRepos `json:"PluginRepos"` MinCLIVersion string `json:"MinCLIVersion"` MinRecommendedCLIVersion string `json:"MinRecommendedCLIVersion"` }
CFConfig represents .cf/config.json
type ColorSetting ¶
type ColorSetting int
ColorSetting is a trinary operator that represents if the display should have colors enabled, disabled, or automatically detected.
const ( DefaultColorEnabled = "" // ColorDisabled means that no colors/bolding will be displayed ColorDisabled ColorSetting = iota // ColorEnabled means colors/bolding will be displayed ColorEnabled // ColorAuto means that the UI should decide if colors/bolding will be // enabled ColorAuto )
type Config ¶
type Config struct { // ConfigFile stores the configuration from the .cf/config ConfigFile CFConfig // ENV stores the configuration from os.ENV ENV EnvOverride // contains filtered or unexported fields }
Config combines the settings taken from the .cf/config.json, os.ENV, and the plugin config.
func LoadConfig ¶
LoadConfig loads the config from the .cf/config.json and os.ENV. If the config.json does not exists, it will use a default config in it's place.
The '.cf' directory will be read in one of the following locations on UNIX Systems:
- $CF_HOME/.cf if $CF_HOME is set
- $HOME/.cf as the default
The '.cf' directory will be read in one of the following locations on Windows Systems:
- CF_HOME\.cf if CF_HOME is set
- HOMEDRIVE\HOMEPATH\.cf if HOMEDRIVE or HOMEPATH is set
- USERPROFILE\.cf as the default
func (*Config) APIVersion ¶
APIVersion returns the CC API Version
func (*Config) AccessToken ¶
AccessToken returns the access token for making authenticated API calls
func (*Config) BinaryName ¶
BinaryName returns the running name of the CF CLI
func (*Config) ClientSecret ¶
ClientSecret returns the CLI's secret
func (*Config) ColorEnabled ¶
func (config *Config) ColorEnabled() ColorSetting
ColorEnabled returns the color setting based off:
- The $CF_COLOR environment variable if set (0/1/t/f/true/false)
- The 'ColorEnabled' value in the .cf/config.json if set
- Defaults to ColorEnabled if nothing is set
func (*Config) CurrentUser ¶
CurrentUser returns user information decoded from the JWT access token in .cf/config.json
func (*Config) Experimental ¶
Experimental returns whether or not to run experimental CLI commands
func (*Config) HTTPSProxy ¶
HTTPSProxy returns the proxy url that the CLI should use. The url is based off of:
- The $https_proxy environment variable if set
- Defaults to the empty string
func (*Config) Locale ¶
Locale returns the locale/language the UI should be displayed in. This value is based off of:
- The 'Locale' setting in the .cf/config.json
- The $LC_ALL environment variable if set
- The $LANG environment variable if set
- Defaults to DefaultLocale
func (*Config) PluginHome ¶
PluginHome returns the plugin configuration directory based off:
- The $CF_PLUGIN_HOME environment variable if set
- Defaults to the home diretory (outlined in LoadConfig)/.cf/plugins
func (*Config) PluginRepos ¶
func (config *Config) PluginRepos() []PluginRepos
PluginRepos returns the currently configured plugin repositories from the .cf/config.json
func (*Config) RefreshToken ¶
RefreshToken returns the refresh token for getting a new access token
func (*Config) SetAccessToken ¶
SetAccessToken sets the current access token
func (*Config) SetOrganizationInformation ¶
SetOrganizationInformation sets the currently targeted organization
func (*Config) SetSpaceInformation ¶
SetSpaceInformation sets the currently targeted space
func (*Config) SetTargetInformation ¶
func (config *Config) SetTargetInformation(api string, apiVersion string, auth string, loggregator string, doppler string, uaa string, routing string, skipSSLValidation bool)
SetTargetInformation sets the currently targeted CC API and related other related API URLs
func (*Config) SetTokenInformation ¶
func (config *Config) SetTokenInformation(accessToken string, refreshToken string, sshOAuthClient string)
SetTokenInformation sets the current token/user information
func (*Config) SkipSSLValidation ¶
SkipSSLValidation returns whether or not to skip SSL validation when targeting an API endpoint
func (*Config) StagingTimeout ¶
StagingTimeout returns the max time an application staging should take. The time is based off of:
- The $CF_STAGING_TIMEOUT environment variable if set
- Defaults to the DefaultStagingTimeout
func (*Config) StartupTimeout ¶
StartupTimeout returns the max time an application should take to start. The time is based off of:
- The $CF_STARTUP_TIMEOUT environment variable if set
- Defaults to the DefaultStartupTimeout
func (*Config) TargetedOrganization ¶
func (config *Config) TargetedOrganization() Organization
TargetedOrganization returns the currently targeted organization
func (*Config) TargetedSpace ¶
TargetedSpace returns the currently targeted space
type EnvOverride ¶
type EnvOverride struct { BinaryName string CFColor string CFHome string CFPluginHome string CFStagingTimeout string CFStartupTimeout string CFTrace string HTTPSProxy string Lang string LCAll string Experimental string }
EnvOverride represents all the environment variables read by the CF CLI
type Organization ¶
type Organization struct { GUID string `json:"GUID"` Name string `json:"Name"` QuotaDefinition QuotaDefinition `json:"QuotaDefinition"` }
Organization contains basic information about the targeted organization
type Plugin ¶
type Plugin struct { Location string `json:"Location"` Version PluginVersion `json:"Version"` Commands PluginCommands `json:"Commands"` }
Plugin represents the plugin as a whole, not be confused with PluginCommand
type PluginCommand ¶
type PluginCommand struct { Name string `json:"Name"` Alias string `json:"Alias"` HelpText string `json:"HelpText"` UsageDetails PluginUsageDetails `json:"UsageDetails"` }
PluginCommand represents an individual command inside a plugin
type PluginCommands ¶
type PluginCommands []PluginCommand
PluginCommands is a list of plugins that implements the sort.Interface
func (PluginCommands) Len ¶
func (p PluginCommands) Len() int
func (PluginCommands) Swap ¶
func (p PluginCommands) Swap(i int, j int)
type PluginRepos ¶
PluginRepos is a saved plugin repository
type PluginUsageDetails ¶
type PluginUsageDetails struct { Usage string `json:"Usage"` Options map[string]string `json:"Options"` }
PluginUsageDetails contains the usage metadata provided by the plugin
type PluginVersion ¶
type PluginVersion struct { Major int `json:"Major"` Minor int `json:"Minor"` Build int `json:"Build"` }
PluginVersion is the plugin version information
type PluginsConfig ¶
PluginsConfig represents the plugin configuration
type QuotaDefinition ¶
type QuotaDefinition struct { GUID string `json:"guid"` Name string `json:"name"` MemoryLimit int `json:"memory_limit"` InstanceMemoryLimit int `json:"instance_memory_limit"` TotalRoutes int `json:"total_routes"` TotalServices int `json:"total_services"` NonBasicServicesAllowed bool `json:"non_basic_services_allowed"` AppInstanceLimit int `json:"app_instance_limit"` TotalReservedRoutePorts int `json:"total_reserved_route_ports"` }
QuotaDefinition contains information about the organization's quota