util

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultErrorExitCode = 1
)

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(err error)

func GetAPIVersionKindFromTrait

func GetAPIVersionKindFromTrait(td corev1alpha2.TraitDefinition) (string, string)

func GetAPIVersionKindFromWorkload

func GetAPIVersionKindFromWorkload(td corev1alpha2.WorkloadDefinition) (string, string)

func GetComponent

func GetComponent(ctx context.Context, c client.Client, componentName string, namespace string) (corev1alpha2.Component, error)

func GetKubeClient

func GetKubeClient() error

GetKubeClient creates a Kubernetes config and client for a given kubeconfig context.

func GetKubeConfig

func GetKubeConfig() string

func GetTraitAPIVersionKind

func GetTraitAPIVersionKind(ctx context.Context, c client.Client, namespace string, name string) (string, string, error)

GetTraitNameAndAlias return the name and alias of a TraitDefinition by a string which might be the trait name, the trait alias, or invalid name

func GetTraitDefinitionByAlias

func GetTraitDefinitionByAlias(ctx context.Context, c client.Client, traitAlias string) (corev1alpha2.TraitDefinition, error)

func GetTraitDefinitionByName

func GetTraitDefinitionByName(ctx context.Context, c client.Client, namespace string, traitName string) (corev1alpha2.TraitDefinition, error)

func GetWorkloadDefinitionByAlias

func GetWorkloadDefinitionByAlias(ctx context.Context, c client.Client, traitAlias string) (corev1alpha2.WorkloadDefinition, error)

func GetWorkloadDefinitionByName

func GetWorkloadDefinitionByName(ctx context.Context, c client.Client, namespace string, name string) (corev1alpha2.WorkloadDefinition, error)

func GetWorkloadNameAliasKind

func GetWorkloadNameAliasKind(ctx context.Context, c client.Client, namespace string, workloadName string) (string, string, string)

func HomeDir

func HomeDir() string

func IsCoreCRDExist

func IsCoreCRDExist(cxt context.Context, c client.Client, object runtime.Object) error

func IsNamespaceExist

func IsNamespaceExist(c client.Client, namespace string) bool

func NewNamespace

func NewNamespace(c client.Client, namespace string) error

func Print

func Print(msg string)

func PrintErrorMessage

func PrintErrorMessage(errorMessage string, exitCode int)

func PrintFlags

func PrintFlags(cmd *cobra.Command, subcmds []*cobra.Command)

Types

type Factory

type Factory interface {
	genericclioptions.RESTClientGetter
}

func NewFactory

func NewFactory(clientGetter genericclioptions.RESTClientGetter) Factory

type IOStreams

type IOStreams struct {
	// In think, os.Stdin
	In io.Reader
	// Out think, os.Stdout
	Out io.Writer
	// ErrOut think, os.Stderr
	ErrOut io.Writer
}

IOStreams provides the standard names for iostreams. This is useful for embedding and for unit testing. Inconsistent and different names make it hard to read and review code

func NewTestIOStreams

func NewTestIOStreams() (IOStreams, *bytes.Buffer, *bytes.Buffer, *bytes.Buffer)

NewTestIOStreams returns a valid IOStreams and in, out, errout buffers for unit tests

func (*IOStreams) Error

func (i *IOStreams) Error(a ...interface{})

func (*IOStreams) Errorf

func (i *IOStreams) Errorf(format string, a ...interface{})

func (*IOStreams) Info

func (i *IOStreams) Info(a ...interface{})

func (*IOStreams) Infof

func (i *IOStreams) Infof(format string, a ...interface{})

func (*IOStreams) Infonln

func (i *IOStreams) Infonln(a ...interface{})

Infonln compared to Info(), won't print new line

Jump to

Keyboard shortcuts

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