k8sutil

package
v0.0.0-...-4d57693 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package k8sutil contains utilities for manipulating Kubernetes objects

credit: https://github.com/stefanprodan/kustomizer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildObjectsFromYMLs

func BuildObjectsFromYMLs(filePaths []string) ([]*unstructured.Unstructured, error)

func BuildSortableObjectsFromYMLs

func BuildSortableObjectsFromYMLs(filePaths []string) ([]*unstructured.Unstructured, error)

func DescribeObj

func DescribeObj(obj client.Object) string

DescribeObj returns a string format of the provided object that may be used for logging purposes

func EnsureKubernetesObject

func EnsureKubernetesObject(object *unstructured.Unstructured) error

EnsureKubernetesObject returns error if the provided unstructured instance is not a Kubernetes schema

func EnsureKustomizeObject

func EnsureKustomizeObject(object *unstructured.Unstructured) error

EnsureKustomizeObject returns error if the provided unstructured instance is not a Kustomize schema

func Equals

func Equals(i, j schema.GroupKind) bool

func IsExtensionYML

func IsExtensionYML(f string) bool

IsExtensionYML returns true if provided file has yaml extension

func IsKubernetesObject

func IsKubernetesObject(object *unstructured.Unstructured) bool

IsKubernetesObject returns true if the provided unstructured instance resembles a Kubernetes schema

func IsKustomizeObject

func IsKustomizeObject(object *unstructured.Unstructured) bool

IsKustomizeObject returns true if the provided unstructured instance resembles a Kustomize schema

func IsLessThan

func IsLessThan(i, j schema.GroupKind) bool

func IsNilUnstructured

func IsNilUnstructured(given *unstructured.Unstructured) bool

func MaybeAppend

func MaybeAppend(list []client.Object, add client.Object) []client.Object

func MaybeAppendList

func MaybeAppendList(list []client.Object, add []client.Object) []client.Object

func ObjKey

func ObjKey(obj client.Object) string

ObjKey returns a string that can be used as a key to store objects of type client.Object

func ReadKubernetesObjects

func ReadKubernetesObjects(r io.Reader) ([]*unstructured.Unstructured, error)

ReadKubernetesObjects decodes the YAML or JSON documents from the provided reader into unstructured Kubernetes API objects

func ScanForYMLsFromDir

func ScanForYMLsFromDir(dir string) ([]string, error)

ScanForYMLsFromDir scans for files present in the provided directory & its sub-directories if any

func ScanForYMLsFromPaths

func ScanForYMLsFromPaths(paths []string) ([]string, error)

func ToTyped

func ToTyped(src *unstructured.Unstructured, dest interface{}) error

ToTyped transforms the provided unstructured instance to dest instance

func ToUnstructured

func ToUnstructured(src metav1.Object, dest *unstructured.Unstructured) error

ToUnstructured transforms the provided object instance to unstructured

Types

type SortableMetas

type SortableMetas []object.ObjMetadata

func (SortableMetas) Len

func (a SortableMetas) Len() int

func (SortableMetas) Less

func (a SortableMetas) Less(i, j int) bool

func (SortableMetas) Swap

func (a SortableMetas) Swap(i, j int)

type SortableUnstructureds

type SortableUnstructureds []*unstructured.Unstructured

func (SortableUnstructureds) Len

func (a SortableUnstructureds) Len() int

func (SortableUnstructureds) Less

func (a SortableUnstructureds) Less(i, j int) bool

func (SortableUnstructureds) Swap

func (a SortableUnstructureds) Swap(i, j int)

Jump to

Keyboard shortcuts

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