config

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MainManager = NewManager()

	Formats = []string{
		"stylish",
		"json",
		"yaml",
	}
	FormatDescriptions = []string{
		"stylish\tOutput format for human consumption",
		"json\tOutput in JSON",
		"yaml\tOutput in YAML",
	}

	ErrConfigExists     = errors.New("configFile already exists")
	ErrUnknownProfile   = errors.New("profile not found")
	ErrDuplicateProfile = errors.New("profile already exists")
	ErrConfigLoad       = errors.New("unable to load config")
	ErrInvalidValue     = errors.New("invalid value")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug bool `json:"debug" yaml:"debug"`

	OutputFormat string        `json:"outputFormat,omitempty" yaml:"outputFormat,omitempty"`
	Timeout      time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`

	DefaultProfile string        `json:"defaultProfile,omitempty" yaml:"defaultProfile,omitempty"`
	Profiles       NamedProfiles `json:"profiles,omitempty" yaml:"profiles,omitempty"`
}

func GetConfig

func GetConfig() *Config

type Context

type Context struct {
	Organization     string `json:"organization,omitempty" yaml:"organization,omitempty"`
	Project          string `json:"project,omitempty" yaml:"project,omitempty"`
	Environment      string `json:"environment,omitempty" yaml:"environment,omitempty"`
	ServiceComponent string `json:"serviceComponent,omitempty" yaml:"serviceComponent,omitempty"`
}

type Manager

type Manager struct {
	Error error
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

func (*Manager) AddProfile

func (manager *Manager) AddProfile(profile Profile) error

func (*Manager) CommandWithAPI

func (manager *Manager) CommandWithAPI(command *cobra.Command)

func (*Manager) CommandWithGlobalOptions

func (manager *Manager) CommandWithGlobalOptions(command *cobra.Command)

func (*Manager) GetProfile

func (manager *Manager) GetProfile(name string) (*Profile, error)

func (*Manager) HasProfile

func (manager *Manager) HasProfile(name string) bool

func (*Manager) Load

func (manager *Manager) Load()

func (*Manager) RemoveProfile

func (manager *Manager) RemoveProfile(name string) error

func (*Manager) SafeSave

func (manager *Manager) SafeSave() error

func (*Manager) Save

func (manager *Manager) Save() error

func (*Manager) SetDefaultProfile

func (manager *Manager) SetDefaultProfile(name string) error

func (*Manager) SetProfile

func (manager *Manager) SetProfile(profile Profile)

type NamedProfiles

type NamedProfiles map[string]Profile

type Options

type Options struct {
	// other options
	ConfigFile     *option.String
	Verbosity      *option.Count
	Timeout        *option.Duration
	NoProgress     *option.Bool
	NonInteractive *option.Bool

	// global options
	Debug        *option.Bool
	OutputFormat *option.String
	ProfileName  *option.String

	// profile options
	Host   *option.String
	Scheme *option.String
	Token  *option.String

	// Profile.Context options
	Organization     *option.String
	Project          *option.String
	Environment      *option.String
	ServiceComponent *option.String
}

func GetOptions

func GetOptions() *Options

func NewOptions

func NewOptions(settings *Settings) *Options

type Profile

type Profile struct {
	Name string `json:"-" yaml:"-"`

	Host   string `json:"host,omitempty" yaml:"host,omitempty"`
	Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
	Token  string `json:"token,omitempty" yaml:"token,omitempty"`

	Context Context `json:"context,omitempty" yaml:"context,omitempty"`
}

type Settings

type Settings struct {
	ConfigFile string

	Debug      bool
	NoProgress bool

	NonInteractive bool

	Profile Profile

	Verbosity int

	OutputFormat string
	Timeout      time.Duration
}

func GetSettings

func GetSettings() *Settings

func NewSettings

func NewSettings() *Settings

func (*Settings) IsStylish

func (settings *Settings) IsStylish() bool

type ShellCompletion

type ShellCompletion func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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