lib

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ENV_PREFIX = "bunnyshell"

Variables

View Source
var CLIContext = CLI{
	OutputFormat: defaultFormat,
	Timeout:      defaultTimeout,
}

Functions

func AddProfile

func AddProfile(profile Profile, name string) error

func FormatCommandData

func FormatCommandData(cmd *cobra.Command, data interface{}) error

func FormatCommandError

func FormatCommandError(cmd *cobra.Command, err error) error

func FormatRequestResult

func FormatRequestResult(cmd *cobra.Command, data interface{}, r *http.Response, err error) error

func GetAPI

func GetAPI() *sdk.APIClient

func GetApiFromProfile

func GetApiFromProfile(profile Profile) *sdk.APIClient

func GetContext

func GetContext() (context.Context, context.CancelFunc)

func GetContextFromProfile

func GetContextFromProfile(profile Profile) (context.Context, context.CancelFunc)

func LoadViperConfigIntoContext

func LoadViperConfigIntoContext()

func MakeDefaultContext

func MakeDefaultContext()

func RemoveProfile

func RemoveProfile(name string) error

func SetDefaultProfile

func SetDefaultProfile(name string) error

Types

type CLI

type CLI struct {
	Debug        bool
	Feedback     bool
	NoProgress   bool
	ProfileName  string
	Profile      Profile
	OutputFormat string
	ConfigFile   string
	Verbosity    int
	Timeout      time.Duration
	// contains filtered or unexported fields
}

func (*CLI) Load

func (c *CLI) Load(config Config) error

func (*CLI) RequireTokenOnCommand

func (c *CLI) RequireTokenOnCommand(cmd *cobra.Command)

func (*CLI) SetGlobalFlags

func (c *CLI) SetGlobalFlags(cmd *cobra.Command)

type Config

type Config struct {
	Debug          bool          `json:"debug" yaml:"debug"`
	OutputFormat   string        `json:"outputFormat,omitempty" yaml:"outputFormat,omitempty" binding:"required"`
	DefaultProfile string        `json:"defaultProfile" yaml:"defaultProfile" binding:"required"`
	Timeout        time.Duration `json:",omitempty" yaml:",omitempty"`
	Profiles       NamedProfiles `json:",omitempty" yaml:",omitempty"`
}

func GetConfig

func GetConfig() (*Config, error)

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 NamedProfiles

type NamedProfiles map[string]Profile

type Profile

type Profile struct {
	Host    string  `json:"host,omitempty" yaml:"host,omitempty"`
	Token   string  `json:"token,omitempty" yaml:"token,omitempty"`
	Context Context `json:"context,omitempty" yaml:"context,omitempty"`
}

func GetProfile

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

func NewProfile

func NewProfile() *Profile

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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