Documentation ¶
Index ¶
- Constants
- func GetDefaultPath() (string, error)
- type Config
- func (c *Config) AddOrUpdateUpboundProfile(name string, new profile.Profile) error
- func (c *Config) AddToBaseConfig(name, key, value string) error
- func (c *Config) BaseToJSON(name string) (io.Reader, error)
- func (c *Config) GetBaseConfig(name string) (map[string]string, error)
- func (c *Config) GetDefaultUpboundProfile() (string, profile.Profile, error)
- func (c *Config) GetUpboundProfile(name string) (profile.Profile, error)
- func (c *Config) GetUpboundProfiles() (map[string]profile.Profile, error)
- func (c *Config) RemoveFromBaseConfig(name, key string) error
- func (c *Config) SetDefaultUpboundProfile(name string) error
- type FSSource
- type FSSourceModifier
- type Format
- type MockSource
- type QuietFlag
- type Source
- type Upbound
Constants ¶
const ( ConfigDir = ".up" ConfigFile = "config.json" )
Location of up config file.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultPath ¶ added in v0.25.0
GetDefaultPath returns the default config path or error.
Types ¶
type Config ¶
type Config struct {
Upbound Upbound `json:"upbound"`
}
Config is format for the up configuration file.
func Extract ¶ added in v0.5.0
Extract performs extraction of configuration from the provided source.
func (*Config) AddOrUpdateUpboundProfile ¶ added in v0.5.0
AddOrUpdateUpboundProfile adds or updates an Upbound profile to the Config.
func (*Config) AddToBaseConfig ¶ added in v0.25.0
AddToBaseConfig adds the supplied key, value pair to the base config map of the profile that corresponds to the given name. If the supplied name does not match an existing Profile an error is returned. If the overrides map does not currently exist on the corresponding profile, a map is initialized.
func (*Config) BaseToJSON ¶ added in v0.25.0
BaseToJSON converts the base config of the given Profile to JSON. If the config couldn't be converted or if the supplied name does not correspond to an existing Profile, an error is returned.
func (*Config) GetBaseConfig ¶ added in v0.25.0
GetBaseConfig returns the persisted base configuration associated with the provided Profile. If the supplied name does not match an existing Profile an error is returned.
func (*Config) GetDefaultUpboundProfile ¶ added in v0.5.0
GetDefaultUpboundProfile gets the default Upbound profile or returns an error if default is not set or default profile does not exist.
func (*Config) GetUpboundProfile ¶ added in v0.5.0
GetUpboundProfile gets a profile with a given identifier. If a profile does not exist for the given identifier an error will be returned. Multiple profiles should never exist for the same identifier, but in the case that they do, the first will be returned.
func (*Config) GetUpboundProfiles ¶ added in v0.25.0
GetUpboundProfiles returns the list of existing profiles. If no profiles exist, then an error will be returned.
func (*Config) RemoveFromBaseConfig ¶ added in v0.25.0
RemoveFromBaseConfig removes the supplied key from the base config map of the Profile that corresponds to the given name. If the supplied name does not match an existing Profile an error is returned. If the base config map does not currently exist on the corresponding profile, a no-op occurs.
func (*Config) SetDefaultUpboundProfile ¶ added in v0.5.0
SetDefaultUpboundProfile sets the default profile for communicating with Upbound. Setting a default profile that does not exist will return an error.
type FSSource ¶
type FSSource struct {
// contains filtered or unexported fields
}
FSSource provides a filesystem source for interacting with a Config.
func NewFSSource ¶
func NewFSSource(modifiers ...FSSourceModifier) *FSSource
NewFSSource constructs a new FSSource. Path must be supplied via modifier or Initialize must be called to use default. NOTE(hasheddan): using empty path by default is a bit of a footgun, so we should consider refactoring here. The motivation for the current design is to allow for flexibility in cases where the consumer does not want to create if the path does not exist, or they want to provide the FSSource as the default without handling an error in construction (see Docker credential helper for example).
func (*FSSource) Initialize ¶ added in v0.25.0
Initialize creates a config in the filesystem if one does not exist. If path is not defined the default path is constructed.
func (*FSSource) UpdateConfig ¶
UpdateConfig updates the Config in the filesystem.
type FSSourceModifier ¶
type FSSourceModifier func(*FSSource)
FSSourceModifier modifies an FSSource.
func WithFS ¶ added in v0.25.0
func WithFS(fs afero.Fs) FSSourceModifier
WithFS overrides the FSSource filesystem with the given filesystem.
func WithPath ¶ added in v0.25.0
func WithPath(p string) FSSourceModifier
WithPath sets the config path for the filesystem source.
type MockSource ¶ added in v0.25.0
type MockSource struct { InitializeFn func() error GetConfigFn func() (*Config, error) UpdateConfigFn func(*Config) error }
MockSource is a mock source.
func (*MockSource) GetConfig ¶ added in v0.25.0
func (m *MockSource) GetConfig() (*Config, error)
GetConfig calls the underlying get config function.
func (*MockSource) Initialize ¶ added in v0.25.0
func (m *MockSource) Initialize() error
Initialize calls the underlying initialize function.
func (*MockSource) UpdateConfig ¶ added in v0.25.0
func (m *MockSource) UpdateConfig(c *Config) error
UpdateConfig calls the underlying update config function.
type QuietFlag ¶ added in v0.25.0
type QuietFlag bool
QuietFlag provides a named boolean type for the QuietFlag.
type Source ¶
type Source interface { Initialize() error GetConfig() (*Config, error) UpdateConfig(*Config) error }
Source is a source for interacting with a Config.
type Upbound ¶ added in v0.5.0
type Upbound struct { // Default indicates the default profile. Default string `json:"default"` // Profiles contain sets of credentials for communicating with Upbound. Key // is name of the profile. Profiles map[string]profile.Profile `json:"profiles,omitempty"` }
Upbound contains configuration information for Upbound.