utils

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply added in v0.18.0

func Apply(ctx context.Context, rcg genericclioptions.RESTClientGetter, opts *runclient.Options, root, manifestPath string) (string, error)

Apply is the equivalent of 'kubectl apply --server-side -f'. If the given manifest is a kustomization.yaml, then apply performs the equivalent of 'kubectl apply --server-side -k'.

func CompatibleVersion added in v0.8.1

func CompatibleVersion(binary, target string) bool

CompatibleVersion returns if the provided binary version is compatible with the given target version. At present, this is true if the target version is equal to the MINOR range of the binary, or if the binary version is a prerelease.

func ContainsEqualFoldItemString added in v0.5.5

func ContainsEqualFoldItemString(s []string, e string) (string, bool)

func ContainsItemString

func ContainsItemString(s []string, e string) bool

func ExecKubectlCommand

func ExecKubectlCommand(ctx context.Context, mode ExecMode, kubeConfigPath string, kubeContext string, args ...string) (string, error)

func ExtractCRDs added in v0.13.0

func ExtractCRDs(inManifestPath, outManifestPath string) error

func IsAPINamespaced added in v0.39.0

func IsAPINamespaced(obj runtime.Object, scheme *runtime.Scheme, restmapper apimeta.RESTMapper) (bool, error)

IsAPINamespaced returns true if the object is namespace scoped. For unstructured objects the gvk is found from the object itself.

func IsAPINamespacedWithGVK added in v0.39.0

func IsAPINamespacedWithGVK(gk schema.GroupVersionKind, scheme *runtime.Scheme, restmapper apimeta.RESTMapper) (bool, error)

IsAPINamespacedWithGVK returns true if the object having the provided GVK is namespace scoped.

func KubeConfig added in v0.5.7

func MakeDependsOn

func MakeDependsOn(deps []string) []meta.NamespacedObjectReference

func NewScheme added in v0.16.2

func NewScheme() *apiruntime.Scheme

Create the Scheme, methods for serializing and deserializing API objects which can be shared by tests.

func ParseNamespacedName added in v0.16.0

func ParseNamespacedName(input string) types.NamespacedName

ParseNamespacedName extracts the NamespacedName of a resource based on the '<namespace>/<name>' format

func ParseObjectKindName

func ParseObjectKindName(input string) (kind, name string)

ParseObjectKindName extracts the kind and name of a resource based on the '<kind>/<name>' format

func ParseObjectKindNameNamespace added in v0.12.0

func ParseObjectKindNameNamespace(input string) (kind, name, namespace string)

ParseObjectKindNameNamespace extracts the kind, name and namespace of a resource based on the '<kind>/<name>.<namespace>' format

func SplitKubeConfigPath

func SplitKubeConfigPath(path string) []string

SplitKubeConfigPath splits the given KUBECONFIG path based on the runtime OS target.

Ref: https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#the-kubeconfig-environment-variable

func TruncateHex added in v0.40.0

func TruncateHex(str string) string

TruncateHex will replace any hexadecimal notation between 40 and 128 characters (SHA-1 up to SHA-512) within the given string with a truncated version of 8 characters.

func ValidateComponents added in v0.5.8

func ValidateComponents(components []string) error

Types

type ExecMode

type ExecMode string
const (
	ModeOS       ExecMode = "os.stderr|stdout"
	ModeStderrOS ExecMode = "os.stderr"
	ModeCapture  ExecMode = "capture.stderr|stdout"
)

Jump to

Keyboard shortcuts

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