commands

package
v0.0.0-...-60a31f3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const FakeNamespace = "current"
View Source
const TruncateAt = 100

Max length When to truncate long strings (when not "all" mode switched on)

View Source
const WaitDefaultTimeout = 600

Default time out to use when waiting for reconciliation. It is deliberately very long as it is expected that the service doesn't stay in `Unknown` status very long and eventually ends up as `False` or `True` in a timely manner

Variables

This section is empty.

Functions

func AddGitOpsFlags

func AddGitOpsFlags(flags *pflag.FlagSet)

AddGitOpsFlags adds flags to enable gitops mode

func AddNamespaceFlags

func AddNamespaceFlags(flags *pflag.FlagSet, allowAll bool)

AddNamespaceFlags adds the namespace-related flags: * --namespace * --all-namespaces

func Age

func Age(t time.Time) string

func ConditionsValue

func ConditionsValue(conditions duckv1.Conditions) string

conditionsValue returns the True conditions count among total conditions

func CreateDynamicTestKnCommand

func CreateDynamicTestKnCommand(cmd *cobra.Command, knParams *KnParams, objects ...runtime.Object) (*cobra.Command, *clientdynamic.KnDynamicClient, *bytes.Buffer)

CreateDynamicTestKnCommand helper for creating test commands using dynamic client

func CreateSourcesTestKnCommand

func CreateSourcesTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.Command, *sourcesv1fake.FakeSourcesV1, *bytes.Buffer)

CreateSourcesTestKnCommand helper for creating test commands

func CreateTestKnCommand

func CreateTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.Command, *servingv1fake.FakeServingV1, *bytes.Buffer)

CreateTestKnCommand helper for creating test commands

func NewTestCommand

func NewTestCommand(subCommand *cobra.Command, params *KnParams) *cobra.Command

NewTestCommand can be used by tes

func NonReadyConditionReason

func NonReadyConditionReason(conditions duckv1.Conditions) string

NonReadyConditionReason returns formatted string of reason and message for non ready conditions

func ReadyCondition

func ReadyCondition(conditions duckv1.Conditions) string

readyCondition returns status of resource's Ready type condition

func ResourceNameCompletionFunc

func ResourceNameCompletionFunc(p *KnParams) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

ResourceNameCompletionFunc will return a function that will autocomplete the name of the resource based on the subcommand

func TranslateTimestampSince

func TranslateTimestampSince(timestamp metav1.Time) string

translateTimestampSince returns the elapsed time since timestamp in human-readable approximation.

func WriteConditions

func WriteConditions(dw printers.PrefixWriter, conditions []apis.Condition, printMessage bool)

Print out a table with conditions.

func WriteMapDesc

func WriteMapDesc(dw printers.PrefixWriter, m map[string]string, label string, details bool)

Write a map either compact in a single line (possibly truncated) or, if printDetails is set, over multiple line, one line per key-value pair. The output is sorted by keys.

func WriteMetadata

func WriteMetadata(dw printers.PrefixWriter, m *metav1.ObjectMeta, printDetails bool)

func WriteSliceDesc

func WriteSliceDesc(dw printers.PrefixWriter, s []string, label string, printDetails bool)

Writer a slice compact (printDetails == false) in one line, or over multiple line with key-value line-by-line (printDetails == true)

Types

type HumanPrintFlags

type HumanPrintFlags struct {
	WithNamespace bool
	NoHeaders     bool
}

HumanPrintFlags provides default flags necessary for printing. Given the following flag values, a printer can be requested that knows how to handle printing based on these values.

func NewHumanPrintFlags

func NewHumanPrintFlags() *HumanPrintFlags

NewHumanPrintFlags returns flags associated with human-readable printing, with default values set.

func (*HumanPrintFlags) AddFlags

func (f *HumanPrintFlags) AddFlags(c *cobra.Command)

AddFlags receives a *cobra.Command reference and binds flags related to human-readable printing to it

func (*HumanPrintFlags) AllowedFormats

func (f *HumanPrintFlags) AllowedFormats() []string

AllowedFormats returns more customized formating options

func (*HumanPrintFlags) EnsureWithNamespace

func (f *HumanPrintFlags) EnsureWithNamespace()

EnsureWithNamespace sets the "WithNamespace" humanreadable option to true.

func (*HumanPrintFlags) ToPrinter

func (f *HumanPrintFlags) ToPrinter(getHandlerFunc func(h hprinters.PrintHandler)) (hprinters.ResourcePrinter, error)

ToPrinter receives returns a printer capable of handling human-readable output.

type KnParams

type KnParams struct {
	k8s.Params
	Output                   io.Writer
	NewKubeClient            func() (kubernetes.Interface, error)
	NewServingClient         func(namespace string) (clientservingv1.KnServingClient, error)
	NewServingV1beta1Client  func(namespace string) (clientservingv1beta1.KnServingClient, error)
	NewGitopsServingClient   func(namespace string, dir string) (clientservingv1.KnServingClient, error)
	NewSourcesClient         func(namespace string) (clientsourcesv1.KnSourcesClient, error)
	NewSourcesV1beta2Client  func(namespace string) (clientsourcesv1beta2.KnSourcesClient, error)
	NewEventingClient        func(namespace string) (clienteventingv1.KnEventingClient, error)
	NewMessagingClient       func(namespace string) (clientmessagingv1.KnMessagingClient, error)
	NewDynamicClient         func(namespace string) (clientdynamic.KnDynamicClient, error)
	NewEventingV1beta2Client func(namespace string) (clienteventingv1beta2.KnEventingV1Beta2Client, error)

	// General global options
	LogHTTP bool

	// Memorizes the loaded config
	clientcmd.ClientConfig
	// contains filtered or unexported fields
}

KnParams for creating commands. Useful for inserting mocks for testing.

func (*KnParams) CurrentNamespace

func (params *KnParams) CurrentNamespace() (string, error)

CurrentNamespace returns the current namespace which is either provided as option or picked up from kubeconfig

func (*KnParams) GetNamespace

func (params *KnParams) GetNamespace(cmd *cobra.Command) (string, error)

GetNamespace returns namespace from command specified by flag

func (*KnParams) Initialize

func (params *KnParams) Initialize()

Initialize will initialize the default factories for the clients.

func (*KnParams) RestConfig

func (params *KnParams) RestConfig() (*rest.Config, error)

RestConfig returns REST config, which can be to use to create specific clientset

type WaitFlags

type WaitFlags struct {
	// Timeout in seconds for how long to wait for a command to return
	TimeoutInSeconds int
	// If set then apply resources and wait for completion
	Wait bool
	// Duration in seconds for waiting between intermediate false ready conditions
	ErrorWindowInSeconds int
}

Flags for tuning wait behaviour

func (*WaitFlags) AddConditionWaitFlags

func (p *WaitFlags) AddConditionWaitFlags(command *cobra.Command, waitTimeoutDefault int, action, what, until string)

Add flags which influence the wait/no-wait behaviour when creating, updating, waiting for resources. If the action is not `wait`, set `waitDefault` argument if the default behaviour is synchronous. Use `what` for describing what is waited for.

Jump to

Keyboard shortcuts

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