Documentation
¶
Overview ¶
Package factory implements the logic to initialize common objects for liqoctl commands.
Index ¶
- Constants
- func Silent(o *options)
- func WithScopedPrinter(o *options)
- type Factory
- func (f *Factory) AddFlags(flags *pflag.FlagSet, register completionFuncRegisterer)
- func (f *Factory) AddLiqoNamespaceFlag(flags *pflag.FlagSet)
- func (f *Factory) AddNamespaceFlag(flags *pflag.FlagSet)
- func (f *Factory) HelmClient(s ...*pterm.SpinnerPrinter) helm.Client
- func (f *Factory) HelmClientOrError() (helm.Client, error)
- func (f *Factory) Initialize(opts ...Options) (err error)
- type Options
- type Printer
Constants ¶
const FlagNamespace = "namespace"
FlagNamespace -> the name of the namespace flag.
Variables ¶
This section is empty.
Functions ¶
func Silent ¶
func Silent(o *options)
Silent disables the output of informational messages during the initialization.
func WithScopedPrinter ¶
func WithScopedPrinter(o *options)
WithScopedPrinter marks the generated printer as scoped.
Types ¶
type Factory ¶
type Factory struct { // Printer is the object used to output messages in the appropriate format. Printer *Printer // Whether to add a scope to the printer (i.e., local/remote). ScopedPrinter bool // Namespace is the namespace that the user has requested with the "--namespace" / "-n" flag, if registered (alternative to LiqoNamespace). Namespace string // LiqoNamespace is the namespace that the user has requested with the "--namespace" / "-n" flag, if registered (alternative to Namespace). LiqoNamespace string // RESTConfig is a Kubernetes REST config that contains the user's authentication and access configuration. RESTConfig *rest.Config // crClient is the controller runtime client. CRClient client.Client // kubeClient is a Kubernetes clientset for interacting with the base Kubernetes APIs. KubeClient kubernetes.Interface // contains filtered or unexported fields }
Factory provides a set of clients and configurations to authenticate and access a target Kubernetes cluster. Factory will ensure that its fields are populated and valid during command execution.
func NewForLocal ¶
func NewForLocal() *Factory
NewForLocal returns a new initialized Factory, to interact with a remote cluster.
func NewForRemote ¶
func NewForRemote() *Factory
NewForRemote returns a new initialized Factory, to interact with a remote cluster.
func (*Factory) AddFlags ¶
AddFlags registers the flags to interact with the Kubernetes access options, and the corresponding completion functions.
func (*Factory) AddLiqoNamespaceFlag ¶
AddLiqoNamespaceFlag registers the flag to select the Liqo namespace (alternative to AddNamespaceFlag).
func (*Factory) AddNamespaceFlag ¶
AddNamespaceFlag registers the flag to select the target namespace (alternative to AddLiqoNamespaceFlag).
func (*Factory) HelmClient ¶
func (f *Factory) HelmClient(s ...*pterm.SpinnerPrinter) helm.Client
HelmClient returns an Helm client, initializing it if necessary. In case of error, it outputs the error (through the spinner if provided, or leveraging the printer) and exits.
func (*Factory) HelmClientOrError ¶
HelmClientOrError returns an Helm client, initializing it if necessary.
func (*Factory) Initialize ¶
Initialize populates the object based on the provided flags.
type Options ¶
type Options func(*options)
Options represents an option for the initialize function.
type Printer ¶
type Printer struct { Info *pterm.PrefixPrinter Success *pterm.PrefixPrinter Warning *pterm.PrefixPrinter Error *pterm.PrefixPrinter // contains filtered or unexported fields }
Printer manages all kinds of outputs.
func NewFakePrinter ¶
NewFakePrinter returns a new printer to be used in tests.
func (*Printer) CheckErr ¶
func (p *Printer) CheckErr(err error, s ...*pterm.SpinnerPrinter)
CheckErr prints a user friendly error and exits with a non-zero exit code. If the spinner it is provided, then it is leveraged to print the message, otherwise it outputs the message through the printer or, if nil, to STDERR.
func (*Printer) StartSpinner ¶
func (p *Printer) StartSpinner(text ...interface{}) *pterm.SpinnerPrinter
StartSpinner starts a new spinner.