ctx

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewList

func NewList(items []list.Item) list.Model

Types

type Accepting

type Accepting interface {
	NavigationState
	Accept(upCtx *upbound.Context, navCtx *navContext) (string, error)
}

Accepting is a model state that provides a method to accept a navigation node.

type AcceptingFunc

type AcceptingFunc func(ctx context.Context, upCtx *upbound.Context) error

func (AcceptingFunc) Accept

func (f AcceptingFunc) Accept(ctx context.Context, upCtx *upbound.Context) error

type Back

type Back interface {
	NavigationState
	Back(m model) (model, error)
	BackLabel() string
}

Back is a model state that provides a method to go back to the parent navigation node.

type Cmd

type Cmd struct {
	// Common Upbound API configuration
	Flags upbound.Flags `embed:""`

	Argument    string `` /* 132-byte string literal not displayed */
	Short       bool   `short:"s" env:"UP_SHORT" name:"short" help:"Short output."`
	KubeContext string `env:"UP_CONTEXT" default:"upbound" name:"context" help:"Kubernetes context to operate on."`
	File        string `short:"f" name:"kubeconfig" help:"Kubeconfig to modify when saving a new context"`
}

func (*Cmd) AfterApply

func (c *Cmd) AfterApply(kongCtx *kong.Context) error

func (*Cmd) Run

func (c *Cmd) Run(ctx context.Context, kongCtx *kong.Context, upCtx *upbound.Context) error

func (*Cmd) RunInteractive

func (c *Cmd) RunInteractive(ctx context.Context, kongCtx *kong.Context, upCtx *upbound.Context, navCtx *navContext, initialState NavigationState) error

func (*Cmd) RunRelative

func (c *Cmd) RunRelative(ctx context.Context, upCtx *upbound.Context, navCtx *navContext, initialState NavigationState) error

func (*Cmd) RunSwap

func (c *Cmd) RunSwap(ctx context.Context, upCtx *upbound.Context, navCtx *navContext) error

type ControlPlane

type ControlPlane struct {
	Group Group
	Name  string
}

ControlPlane provides the navigation node for a concrete controlplane.

func (*ControlPlane) Accept

func (ctp *ControlPlane) Accept(upCtx *upbound.Context, navCtx *navContext) (msg string, err error)

Accept upserts a controlplane context and cluster to the chosen kubeconfig.

func (*ControlPlane) Back

func (ctp *ControlPlane) Back(m model) (model, error)

func (*ControlPlane) BackLabel added in v0.31.0

func (ctp *ControlPlane) BackLabel() string

func (*ControlPlane) Breadcrumbs

func (ctp *ControlPlane) Breadcrumbs() string

func (*ControlPlane) Items

func (ctp *ControlPlane) Items(ctx context.Context, upCtx *upbound.Context, navCtx *navContext) ([]list.Item, error)

func (*ControlPlane) NamespacedName

func (ctp *ControlPlane) NamespacedName() types.NamespacedName

type Disconnected added in v0.31.0

type Disconnected struct{}

func (*Disconnected) Back added in v0.31.0

func (d *Disconnected) Back(m model) (model, error)

func (*Disconnected) BackLabel added in v0.31.0

func (d *Disconnected) BackLabel() string

func (*Disconnected) Breadcrumbs added in v0.31.0

func (d *Disconnected) Breadcrumbs() string

func (*Disconnected) Items added in v0.31.0

func (d *Disconnected) Items(ctx context.Context, upCtx *upbound.Context, navCtx *navContext) ([]list.Item, error)

type Group

type Group struct {
	Space Space
	Name  string
}

Group provides the navigation node for a concrete group aka namespace.

func (*Group) Accept

func (g *Group) Accept(upCtx *upbound.Context, navCtx *navContext) (msg string, err error)

Accept upserts the "upbound" kubeconfig context and cluster to the chosen kubeconfig, pointing to the group.

func (*Group) Back

func (g *Group) Back(m model) (model, error)

func (*Group) BackLabel added in v0.31.0

func (g *Group) BackLabel() string

func (*Group) Breadcrumbs

func (g *Group) Breadcrumbs() string

func (*Group) Items

func (g *Group) Items(ctx context.Context, upCtx *upbound.Context, navCtx *navContext) ([]list.Item, error)

type KeyFunc

type KeyFunc func(m model) (model, error)
type NavigationState interface {
	Items(ctx context.Context, upCtx *upbound.Context, navCtx *navContext) ([]list.Item, error)
	Breadcrumbs() string
}

NavigationState is a model state that provides a list of items for a navigation node.

func DeriveExistingCloudState added in v0.30.0

func DeriveExistingCloudState(upCtx *upbound.Context, conf *clientcmdapi.Config, cloud *upbound.CloudConfiguration) (NavigationState, error)

DeriveExistingCloudState derives the navigation state assuming that the current context in the passed kubeconfig is pointing at an existing Cloud space previously created by the CLI

func DeriveExistingDisconnectedState added in v0.30.0

func DeriveExistingDisconnectedState(ctx context.Context, upCtx *upbound.Context, conf *clientcmdapi.Config, disconnected *upbound.DisconnectedConfiguration, getIngressHost getIngressHostFn) (NavigationState, error)

DeriveExistingDisconnectedState derives the navigation state assuming the current context in the passed kubeconfig is pointing at an existing disconnected space created by the CLI

func DeriveNewState added in v0.30.0

func DeriveNewState(ctx context.Context, conf *clientcmdapi.Config, getIngressHost getIngressHostFn) (NavigationState, error)

DeriveNewState derives the current navigation state assuming that the current context was created by a process other than the CLI. Depending on what we are pointing at, there are a few options as to what to do. If spaces **is not** installed in the cluster, then we fall back to root Cloud navigation. If spaces **is** installed cluster, we should derive the space information from the cluster. For all other cases and for all errors, we should fall back to root Cloud navigation. TODO(redbackthomson): Add support for passing a non-blocking error message back if derivation was partially successful (maybe only when --debug is set?)

func DeriveState

func DeriveState(ctx context.Context, upCtx *upbound.Context, conf *clientcmdapi.Config, getIngressHost getIngressHostFn) (NavigationState, error)

DeriveState returns the navigation state based on the current context set in the given kubeconfig

type Organization

type Organization struct {
	Name string
}

func (*Organization) Back

func (o *Organization) Back(m model) (model, error)

func (*Organization) BackLabel added in v0.31.0

func (o *Organization) BackLabel() string

func (*Organization) Breadcrumbs

func (o *Organization) Breadcrumbs() string

func (*Organization) Items

func (o *Organization) Items(ctx context.Context, upCtx *upbound.Context, navCtx *navContext) ([]list.Item, error)

type Root

type Root struct{}

func (*Root) Breadcrumbs

func (r *Root) Breadcrumbs() string

func (*Root) Items

func (r *Root) Items(ctx context.Context, upCtx *upbound.Context, navCtx *navContext) ([]list.Item, error)

type Space

type Space struct {
	Org  Organization
	Name string

	Ingress  spaces.SpaceIngress
	AuthInfo *clientcmdapi.AuthInfo

	// HubContext is an optional field that stores which context in the
	// kubeconfig points at the hub
	HubContext string
}

Space provides the navigation node for a space.

func (*Space) Accept

func (s *Space) Accept(upCtx *upbound.Context, navCtx *navContext) (msg string, err error)

Accept upserts the "upbound" kubeconfig context and cluster to the chosen kubeconfig, pointing to the space.

func (*Space) Back

func (s *Space) Back(m model) (model, error)

func (*Space) BackLabel added in v0.31.0

func (s *Space) BackLabel() string

func (*Space) Breadcrumbs

func (s *Space) Breadcrumbs() string

func (*Space) GetClient

func (s *Space) GetClient(upCtx *upbound.Context) (client.Client, error)

GetClient returns a kube client pointed at the current space

func (*Space) IsCloud

func (s *Space) IsCloud() bool

func (*Space) Items

func (s *Space) Items(ctx context.Context, upCtx *upbound.Context, navCtx *navContext) ([]list.Item, error)

type Termination

type Termination struct {
	Err     error
	Message string
}

Termination is a model state that indicates the command should be terminated, optionally with a message and an error.

Jump to

Keyboard shortcuts

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