app

package
v0.0.0-...-6783019 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoInputConfigItem        = "no-input"
	NonInteractiveConfigItem = "non-interactive"
	NoVersionCheckConfigItem = "no-version-check"
	ConfigPathConfigItem     = "config"
)
View Source
const (
	// Name is the name of the application
	Name = "kconnect"
)

Variables

View Source
var (
	ErrUnknownConfigItemType     = errors.New("unknown item type")
	ErrClusterNotFound           = errors.New("cluster not found")
	ErrAliasAlreadyUsed          = errors.New("alias already in use")
	ErrSourceLocationRequired    = errors.New("source location is required for importing")
	ErrHistoryLocationRequired   = errors.New("history location is required")
	ErrHistoryIDRequired         = errors.New("history id is required")
	ErrAliasRequired             = errors.New("alias is required")
	ErrAliasAndIDNotAllowed      = errors.New("alias and id bith specified, only 1 is allowed")
	ErrAliasNotFound             = errors.New("no alias found")
	ErrNoEntriesFound            = errors.New("no entries found")
	ErrUnknownProvider           = errors.New("unknown provider")
	ErrDiscoveryProviderRequired = errors.New("discovery provider required")
	ErrIdentityProviderRequired  = errors.New("identity provider required")
	ErrUnsuportedIdpProtocol     = errors.New("unsupported idp protocol")
)
View Source
var ErrNotOKHTTPStatusCode = errors.New("non 200 status code")

Functions

func AddCommonConfigItems

func AddCommonConfigItems(cs config.ConfigurationSet) error

func AddCommonUseConfigItems

func AddCommonUseConfigItems(cs config.ConfigurationSet) error

func AddHistoryConfigItems

func AddHistoryConfigItems(cs config.ConfigurationSet) error

func AddHistoryExportConfig

func AddHistoryExportConfig(cs config.ConfigurationSet) error

func AddHistoryIdentifierConfig

func AddHistoryIdentifierConfig(cs config.ConfigurationSet) error

func AddHistoryImportConfig

func AddHistoryImportConfig(cs config.ConfigurationSet) error

func AddHistoryLocationItems

func AddHistoryLocationItems(cs config.ConfigurationSet) error

func AddHistoryQueryConfig

func AddHistoryQueryConfig(cs config.ConfigurationSet) error

func AddHistoryRemoveConfig

func AddHistoryRemoveConfig(cs config.ConfigurationSet) error

func AddKubeconfigConfigItems

func AddKubeconfigConfigItems(cs config.ConfigurationSet) error

AddKubeconfigConfigItems will add the kubeconfig related config items

func DefaultSelectCluster

func DefaultSelectCluster(discoverOutput *discovery.DiscoverOutput) (*discovery.Cluster, error)

DefaultSelectCluster is the default cluster selection function. If there is only 1 cluster then it automatically selects it. If there are more than 1 cluster then a selection is displayed and the user must choose one

Types

type AliasAddInput

AliasAddInput defines the inputs for AliasAdd

type AliasListInput

type AliasListInput struct {
	CommonConfig
	HistoryLocationConfig
	Output *printer.OutputPrinter `json:"output,omitempty"`
}

AliasListInput defines the inputs for AliasList

type AliasRemoveInput

type AliasRemoveInput struct {
	CommonConfig
	HistoryLocationConfig
	HistoryIdentifierConfig
	All bool `json:"all"`
}

AliasRemoveInput defines the inputs for AliasRemove

type App

type App struct {
	// contains filtered or unexported fields
}

App represents the kconnect application and contains the implementation of the apps logic

func New

func New(opts ...Option) *App

New creates a new instance of the kconnect app with options

func (*App) AliasAdd

func (a *App) AliasAdd(ctx context.Context, input *AliasAddInput) error

AliasAdd will add an alias to an existing history entry

func (*App) AliasList

func (a *App) AliasList(ctx context.Context, input *AliasListInput) error

AliasList implements the alias listing functionality

func (*App) AliasRemove

func (a *App) AliasRemove(ctx context.Context, input *AliasRemoveInput) error

AliasRemove will remove an alias from history entries. You can also remove all aliases.

func (*App) Configuration

func (a *App) Configuration(ctx context.Context, input *ConfigureInput) error

Configuration implements the configure command

func (*App) ConnectTo

func (a *App) ConnectTo(ctx context.Context, params *ConnectToInput) error

func (*App) HistoryExport

func (a *App) HistoryExport(ctx context.Context, input *HistoryExportInput) error

AliasList implements the alias listing functionality

func (*App) HistoryImport

func (a *App) HistoryImport(ctx context.Context, input *HistoryImportInput) error

AliasList implements the alias listing functionality

func (*App) HistoryRemove

func (a *App) HistoryRemove(ctx context.Context, input *HistoryRemoveInput) error

func (*App) Logout

func (a *App) Logout(ctx context.Context, params *LogoutInput) error

func (*App) QueryHistory

func (a *App) QueryHistory(ctx context.Context, input *HistoryQueryInput) error

func (*App) SetNonInteractive

func (a *App) SetNonInteractive()

func (*App) Use

func (a *App) Use(ctx context.Context, input *UseInput) error

type CommonConfig

type CommonConfig struct {
	ConfigFile          string `json:"config"`
	Verbosity           int    `json:"verbosity"`
	NoInput             bool   `json:"no-input"`
	DisableVersionCheck bool   `json:"no-version-check"`
}

type CommonUseConfig

type CommonUseConfig struct {
	Namespace string `json:"namespace,omitempty"`
}

type ConfigureInput

type ConfigureInput struct {
	SourceLocation *string                `json:"file,omitempty"`
	Output         *printer.OutputPrinter `json:"output,omitempty"`
	Username       string                 `json:"username,omitempty"`
	Password       string                 `json:"password,omitempty"`
}

ConfigureInput is the input type for the configure command

type ConnectToInput

type ConnectToInput struct {
	CommonConfig
	HistoryConfig
	KubernetesConfig

	AliasOrIDORPosition string
	Password            string `json:"password"`
	SetCurrent          bool   `json:"set-current,omitempty"`
}

type HistoryConfig

type HistoryConfig struct {
	HistoryLocationConfig
	MaxItems  int    `json:"max-history"`
	NoHistory bool   `json:"no-history"`
	EntryID   string `json:"entry-id"`
}

type HistoryExportConfig

type HistoryExportConfig struct {
	File   string `json:"file,omitempty"`
	Filter string `json:"filter,omitempty"`
	Set    string `json:"set,omitempty"`
}

type HistoryIdentifierConfig

type HistoryIdentifierConfig struct {
	Alias string `json:"alias,omitempty"`
	ID    string `json:"id,omitempty"`
}

type HistoryImportConfig

type HistoryImportConfig struct {
	Clean     bool   `json:"clean,omitempty"`
	File      string `json:"file,omitempty"`
	Filter    string `json:"filter,omitempty"`
	Overwrite bool   `json:"overwrite,omitempty"`
	Set       string `json:"set,omitempty"`
}

type HistoryLocationConfig

type HistoryLocationConfig struct {
	Location string `json:"history-location"`
}

type HistoryQueryConfig

type HistoryQueryConfig struct {
	Filter string                 `json:"filter,omitempty"`
	Output *printer.OutputPrinter `json:"output,omitempty"`
}

type HistoryQueryInput

type HistoryQueryInput struct {
	HistoryConfig
	KubernetesConfig
	HistoryQueryConfig

	ClusterProvider  *string `json:"cluster-provider,omitempty"`
	IdentityProvider *string `json:"identity-provider,omitempty"`

	ProviderID *string `json:"provider-id,omitempty"`
	HistoryID  *string `json:"id,omitempty"`
	Alias      *string `json:"alias,omitempty"`

	Flags map[string]string `json:"flags,omitempty"`

	Output *printer.OutputPrinter `json:"output,omitempty"`
}

type HistoryRemoveConfig

type HistoryRemoveConfig struct {
	All    bool   `json:"all,omitempty"`
	Filter string `json:"filter,omitempty"`
}

type HistoryRemoveInput

type HistoryRemoveInput struct {
	CommonConfig
	HistoryLocationConfig
	HistoryRemoveConfig
	RemoveList []string
}

type KubernetesConfig

type KubernetesConfig struct {
	Kubeconfig string `json:"kubeconfig"`
}

type LogoutInput

type LogoutInput struct {
	CommonConfig
	HistoryConfig
	KubernetesConfig

	All   bool
	Alias string
	IDs   string
}

type Option

type Option func(*App)

Option represents an option to use with the kcinnect application

func WithHTTPClient

func WithHTTPClient(client khttp.Client) Option

func WithHistoryStore

func WithHistoryStore(store history.Store) Option

func WithInteractive

func WithInteractive(interactive bool) Option

func WithItemSelectorFunc

func WithItemSelectorFunc(itemSelector provider.SelectItemFunc) Option

func WithLogger

func WithLogger(logger *zap.SugaredLogger) Option

func WithSelectClusterFn

func WithSelectClusterFn(fn SelectClusterFunc) Option

WithSelectClusterFn is an option to allow using a custom select cluster function

func WithSelectClusterFunc

func WithSelectClusterFunc(selectFunc SelectClusterFunc) Option

type SelectClusterFunc

type SelectClusterFunc func(discoverOutput *discovery.DiscoverOutput) (*discovery.Cluster, error)

SelectClusterFunc is a function type that is used to allow selection of a cluster

type UseInput

type UseInput struct {
	CommonConfig
	CommonUseConfig
	HistoryConfig
	KubernetesConfig
	common.IdentityProviderConfig
	common.ClusterProviderConfig

	SetCurrent bool `json:"set-current,omitempty"`

	DiscoveryProvider string
	IdentityProvider  string

	IgnoreAlias bool

	ConfigSet config.ConfigurationSet
}

UseInput are the parameters to the use function

Jump to

Keyboard shortcuts

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