config

package
v0.0.0-...-1f45761 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COLUMN  = "column"
	CSV     = "csv"
	JSON    = "json"
	TABLE   = "table"
	TEXT    = "text"
	DEFAULT = "default"
)

Output formats

View Source
const DEFAULT_ACS_API_ENDPOINT = "http://localhost:8080/client/api"
View Source
const FAKE = "fake"

FAKE is used for fake CLI only options like filter=

Variables

This section is empty.

Functions

func CheckIfValuePresent

func CheckIfValuePresent(dataset []string, element string) bool

func Debug

func Debug(params ...interface{})

Debug allows debugging when enabled

func DisableDebugging

func DisableDebugging()

DisableDebugging disables debug mode

func EnableDebugging

func EnableDebugging()

EnableDebugging enables debug mode

func GetOutputFormats

func GetOutputFormats() []string

func GetProfiles

func GetProfiles() []string

GetProfiles returns list of available profiles

func LoadCache

func LoadCache(c *Config) interface{}

LoadCache loads cache using the default cache file

func SetupContext

func SetupContext(cfg *Config)

Types

type API

type API struct {
	Name         string
	Verb         string
	Noun         string
	Args         []*APIArg
	RequiredArgs []string
	Related      []string
	Async        bool
	Description  string
	ResponseKeys []string
}

API describes a CloudStack API

type APIArg

type APIArg struct {
	Name        string
	Type        string
	Related     []string
	Description string
	Required    bool
	Length      int
}

APIArg are the args passable to an API

type Config

type Config struct {
	Dir           string
	ConfigFile    string
	HistoryFile   string
	LogFile       string
	HasShell      bool
	Core          *Core
	ActiveProfile *ServerProfile
	Context       *context.Context
	Cancel        context.CancelFunc
	C             chan bool
}

Config describes CLI config file and default options

func NewConfig

func NewConfig(configFilePath *string) *Config

NewConfig creates or reload config and loads API cache

func (Config) CacheFile

func (c Config) CacheFile() string

CacheFile returns the path to the cache file for a server profile

func (*Config) GetAPIVerbMap

func (c *Config) GetAPIVerbMap() map[string][]*API

GetAPIVerbMap returns API cache by verb

func (*Config) GetCache

func (c *Config) GetCache() map[string]*API

GetCache returns API cache by full API name

func (*Config) GetPrompt

func (c *Config) GetPrompt() string

GetPrompt returns prompt that the CLI should use

func (*Config) LoadProfile

func (c *Config) LoadProfile(name string)

LoadProfile loads an existing profile

func (*Config) Name

func (c *Config) Name() string

Name of the CLI

func (*Config) PrintHeader

func (c *Config) PrintHeader()

PrintHeader prints startup message in CLI mode

func (*Config) SaveCache

func (c *Config) SaveCache(response map[string]interface{})

SaveCache saves received auto-discovery data to cache file

func (*Config) StartSpinner

func (c *Config) StartSpinner(suffix string) *spinner.Spinner

StartSpinner starts and returns a waiting cursor that the CLI can use

func (*Config) StopSpinner

func (c *Config) StopSpinner(waiter *spinner.Spinner)

StopSpinner stops the provided spinner if it is valid

func (*Config) UpdateCache

func (c *Config) UpdateCache(response map[string]interface{}) interface{}

UpdateCache uses auto-discovery data to update internal API cache

func (*Config) UpdateConfig

func (c *Config) UpdateConfig(key string, value string, update bool)

UpdateConfig updates and saves config

func (*Config) Version

func (c *Config) Version() string

Version CLI

type Core

type Core struct {
	Prompt       string `ini:"prompt"`
	AsyncBlock   bool   `ini:"asyncblock"`
	Timeout      int    `ini:"timeout"`
	Output       string `ini:"output"`
	VerifyCert   bool   `ini:"verifycert"`
	ProfileName  string `ini:"profile"`
	AutoComplete bool   `ini:"autocomplete"`
}

Core block describes common options for the CLI

type ServerProfile

type ServerProfile struct {
	URL       string       `ini:"url"`
	Username  string       `ini:"username"`
	Password  string       `ini:"password"`
	Domain    string       `ini:"domain"`
	APIKey    string       `ini:"apikey"`
	SecretKey string       `ini:"secretkey"`
	Client    *http.Client `ini:"-"`
}

ServerProfile describes a management server

Jump to

Keyboard shortcuts

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