Documentation ¶
Overview ¶
Package config contains types and functions for managing the user's local configuration for the command-line interface.
Index ¶
- Variables
- func DefaultConfigDir() (string, error)
- func Delete(ctx context.Context) error
- func MigrateDefaultConfig(newConfigDir string) error
- func ReadConfigFile(ctx context.Context, path string) ([]byte, error)
- func Save(ctx context.Context, cfg *Config) error
- func ToContext(ctx context.Context, config *Config) context.Context
- func WriteConfigFile(ctx context.Context, path string, data []byte) error
- type Config
- type ContextKey
Constants ¶
This section is empty.
Variables ¶
var ErrNoConfiguration = errors.New("no configuration file")
ErrNoConfiguration is the error given when a configuration file cannot be found in the config directory.
Functions ¶
func DefaultConfigDir ¶ added in v0.1.12
DefaultConfigDir returns the preferred config directory for the current platform
func Delete ¶ added in v0.1.12
Delete will remove the config file if one exists at the path set in the context
func MigrateDefaultConfig ¶ added in v0.1.12
MigrateDefaultConfig has been implemented in response to: https://github.com/jetstack/jsctl/issues/52 We were using UserConfigDir from the os package, however, users did not expect this. So we have moved to ~/.jsctl or something equivalent instead.
func ReadConfigFile ¶ added in v0.1.12
ReadConfigFile reads a file from the config directory specified in the provided context
Types ¶
type Config ¶
type Config struct { // Organization denotes the user's selected organization. Organization string `json:"organization"` }
The Config type describes the structure of the user's local configuration file. These values are used for performing operations against the control-plane API.
func FromContext ¶
FromContext attempts to obtain a Config type contained within the provided context.Context. The boolean return value is used to indicate if the context contains a Config.
type ContextKey ¶ added in v0.1.12
type ContextKey struct{}
ContextKey is a type used as a key for the config path in the context