config

package
v0.1.64 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 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),
			),
		)
	}

	NewCodefresh = func(opts *codefresh.ClientOptions) codefresh.Codefresh { return codefresh.New(opts) }
)

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"`
	DefaultRuntime string `mapstructure:"defaultRuntime" json:"defaultRuntime,omitempty"`
	CACert         string `mapstructure:"caCert" json:"caCert,omitempty"`
}

type Config

type Config interface {
	CreateContext(ctx context.Context, name, token, url, caCert string) error
	DeleteContext(name string) error
	GetAccountId(ctx context.Context) (string, error)
	GetCurrentContext() *AuthContext
	GetUser(ctx context.Context) (*cfrest.User, error)
	Load(cmd *cobra.Command, args []string) error
	NewAdHocClient(ctx context.Context, url, token, caCert string) (codefresh.Codefresh, error)
	NewClient() codefresh.Codefresh
	RequireAuthentication(cmd *cobra.Command, args []string) error
	Save() error
	UseContext(ctx context.Context, name string) error
	Write(ctx context.Context, w io.Writer) error
}

func AddFlags

func AddFlags(f *pflag.FlagSet) Config

type ConfigImpl added in v0.1.43

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

func (*ConfigImpl) CreateContext added in v0.1.43

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

func (*ConfigImpl) DeleteContext added in v0.1.43

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

Delete

func (*ConfigImpl) GetAccountId added in v0.1.43

func (c *ConfigImpl) GetAccountId(ctx context.Context) (string, error)

func (*ConfigImpl) GetCurrentContext added in v0.1.43

func (c *ConfigImpl) GetCurrentContext() *AuthContext

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

func (*ConfigImpl) GetUser added in v0.1.43

func (c *ConfigImpl) GetUser(ctx context.Context) (*cfrest.User, error)

func (*ConfigImpl) Load added in v0.1.43

func (c *ConfigImpl) Load(_ *cobra.Command, _ []string) error

func (*ConfigImpl) NewAdHocClient added in v0.1.43

func (c *ConfigImpl) NewAdHocClient(ctx context.Context, url, token, caCert string) (codefresh.Codefresh, error)

func (*ConfigImpl) NewClient added in v0.1.43

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

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

func (*ConfigImpl) RequireAuthentication added in v0.1.43

func (c *ConfigImpl) 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 (*ConfigImpl) Save added in v0.1.43

func (c *ConfigImpl) Save() error

Save persists the config to the file it was read from

func (*ConfigImpl) UseContext added in v0.1.43

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

func (*ConfigImpl) Write added in v0.1.43

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

Directories

Path Synopsis
Package config is a generated GoMock package.
Package config is a generated GoMock package.

Jump to

Keyboard shortcuts

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