config

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BinaryName is the name of the cli in all help texts
	BinaryName = "metal"
	// ConfigDir is the directory in either the homedir or in /etc where the cli searches for a file config.yaml
	// also used as prefix for environment based configuration, e.g. METAL_STACK_CLOUD_ will be the variable prefix.
	ConfigDir = "metal-stack-cloud"
)

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath() (string, error)

func DefaultConfigDirectory

func DefaultConfigDirectory() (string, error)

func HelpTemplate

func HelpTemplate() string

Types

type Config

type Config struct {
	Fs              afero.Fs
	In              io.Reader
	Out             io.Writer
	PromptOut       io.Writer
	Client          client.Client
	ListPrinter     printers.Printer
	DescribePrinter printers.Printer
	Completion      *completion.Completion
	Context         Context
}

func (*Config) ContextListCompletion

func (c *Config) ContextListCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

func (*Config) GetApiURL

func (c *Config) GetApiURL() string

func (*Config) GetContexts

func (c *Config) GetContexts() (*Contexts, error)

func (*Config) GetProject

func (c *Config) GetProject() string

func (*Config) GetToken

func (c *Config) GetToken() string

func (*Config) MustDefaultContext

func (c *Config) MustDefaultContext() Context

func (*Config) NewRequestContext

func (c *Config) NewRequestContext() (context.Context, context.CancelFunc)

func (*Config) WriteContexts

func (c *Config) WriteContexts(ctxs *Contexts) error

type Context

type Context struct {
	Name           string         `json:"name"`
	ApiURL         *string        `json:"api-url,omitempty"`
	Token          string         `json:"api-token"`
	DefaultProject string         `json:"default-project"`
	Timeout        *time.Duration `json:"timeout,omitempty"`
}

Context configure

type Contexts

type Contexts struct {
	CurrentContext  string     `json:"current-context"`
	PreviousContext string     `json:"previous-context"`
	Contexts        []*Context `json:"contexts"`
}

Contexts contains all configuration contexts

func (*Contexts) Delete

func (cs *Contexts) Delete(name string)

func (Contexts) Get

func (cs Contexts) Get(name string) (*Context, bool)

func (Contexts) List

func (cs Contexts) List() []*Context

func (Contexts) Validate

func (cs Contexts) Validate() error

Jump to

Keyboard shortcuts

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