config

package
v0.0.279 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig = errors.New("invalid config")

	ErrContextDoesNotExist = func(context string) error {
		return fmt.Errorf(
			util.Doc(
				fmt.Sprintf("%s: current context \"%s\" does not exist in config file. run '<BIN> config create-context' to create one.", ErrInvalidConfig, context),
			),
		)
	}
)

Errors

Functions

This section is empty.

Types

type AuthContext

type AuthContext struct {
	Type           string `mapstructure:"type" json:"type"`
	Name           string `mapstructure:"name" json:"name"`
	URL            string `mapstructure:"url" json:"url"`
	Token          string `mapstructure:"token" json:"token"`
	Beta           bool   `mapstructure:"beta" json:"beta"`
	OnPrem         bool   `mapstructure:"onPrem" json:"onPrem"`
	DefaultRuntime string `mapstructure:"defaultRuntime" json:"defaultRuntime"`
	// contains filtered or unexported fields
}

func (*AuthContext) GetUser added in v0.0.202

func (a *AuthContext) GetUser(ctx context.Context) (*codefresh.User, error)

type Config

type Config struct {
	CurrentContext string                  `mapstructure:"current-context" json:"current-context"`
	Contexts       map[string]*AuthContext `mapstructure:"contexts" json:"contexts"`
	// contains filtered or unexported fields
}

func AddFlags

func AddFlags(f *pflag.FlagSet) *Config

func (*Config) CreateContext

func (c *Config) CreateContext(ctx context.Context, name, token, url string) error

func (*Config) DeleteContext

func (c *Config) DeleteContext(name string) error

Delete

func (*Config) GetCurrentContext

func (c *Config) GetCurrentContext() *AuthContext

GetCurrentContext returns current authentication context or the one specified with --auth-context.

func (*Config) Load

func (c *Config) Load(cmd *cobra.Command, args []string) error

func (*Config) NewClient

func (c *Config) NewClient() codefresh.Codefresh

NewClient creates a new codefresh client for the current context or for override context (if specified with --auth-context).

func (*Config) RequireAuthentication

func (c *Config) RequireAuthentication(cmd *cobra.Command, args []string) error

RequireAuthentication is ment to be used as cobra PreRunE or PersistentPreRunE function on commands that require authentication context.

func (*Config) Save

func (c *Config) Save() error

Save persists the config to the file it was read from

func (*Config) UseContext

func (c *Config) UseContext(ctx context.Context, name string) error

func (*Config) Write

func (c *Config) Write(ctx context.Context, w io.Writer) error

Jump to

Keyboard shortcuts

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