utils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ComponentPlanDiffIgnorePaths = []string{
	"metadata.generation",
	"metadata.resourceVersion",
	"metadata.labels.helm.sh/chart",
	"spec.template.metadata.labels.helm.sh/chart",
}

ComponentPlanDiffIgnorePaths is the list of paths to ignore when comparing These fields will almost certainly change when componentplan is updated, and displaying these changes will only result in more invalid information, so they need to be ignored

Functions

func AddOrSwapString

func AddOrSwapString(strings []string, str string) (bool, []string)

AddOrSwapString Add an element to the string array, swap it with the last element if it is in the array, or append it directly to the end if it does not exist. Gives whether the array has changed

Example:
[], "a" -> true, []string{"a"}
["a"], "b" -> true, []string{"a", "b"}
["a", "b"], "a" -> true, []string{"b", "a"}
["a", "b", "a"], "a" -> false, []string{"a", "b", "a"}

func AddString

func AddString(finalizers []string, f string) []string

func ContainString

func ContainString(finalizers []string, f string) bool

func Decode

func Decode(b []byte) (res []string, err error)

Decode decodes the bytes of data into string slice Data must contain a base64 encoded gzipped string of string slice, otherwise an error is returned.

func GetCronJobImage

func GetCronJobImage(obj *unstructured.Unstructured) (image []string)

func GetDeploymentImage

func GetDeploymentImage(obj *unstructured.Unstructured) (image []string)

func GetJobImage

func GetJobImage(obj *unstructured.Unstructured) (image []string)

func GetPodImage

func GetPodImage(obj *unstructured.Unstructured) (image []string)

func GetResourcesAndImages

func GetResourcesAndImages(ctx context.Context, logger logr.Logger, c client.Client, data, namespace string) (resources []v1alpha1.Resource, images []string, err error)

GetResourcesAndImages get resource slices, image lists from manifests

func GetStatefulSetImage

func GetStatefulSetImage(obj *unstructured.Unstructured) (image []string)

func GzipData

func GzipData(data string) ([]byte, error)

GzipData encodes data returning a gzipped []byte representation, or error.

func IgnoreNotFound

func IgnoreNotFound(err error) error

IgnoreNotFound returns the supplied error, or nil if the error indicates a Kubernetes resource was not found.

func OmitManagedFields

func OmitManagedFields(o runtime.Object) runtime.Object

func ParseContainerImage

func ParseContainerImage(containers []corev1.Container) (image []string)

func ParseValues

func ParseValues(dir string, reference *apiextensionsv1.JSON) (fileName string, err error)

ParseValues parses Values

func ParseValuesReference

func ParseValuesReference(ctx context.Context, cli client.Client, ns, dir string, reference *v1alpha1.ValuesReference) (fileName string, err error)

ParseValuesReference parses ValuesReference

func RemoveString

func RemoveString(finalziers []string, f string) []string

func ResourceDiffStr

func ResourceDiffStr(ctx context.Context, source, exist *unstructured.Unstructured, ignorePaths []string, c client.Client) (string, error)

func SplitYAML

func SplitYAML(yamlData []byte) ([]*unstructured.Unstructured, error)

SplitYAML splits a YAML file into unstructured objects. Returns list of all unstructured objects found in the yaml. If an error occurs, returns objects that have been parsed so far too. inspire by github.com/argoproj/gitops-engine/pkg/utils/kube

func SplitYAMLToString

func SplitYAMLToString(yamlData []byte) ([]string, error)

SplitYAMLToString splits a YAML file into strings. Returns list of yamls found in the yaml. If an error occurs, returns objects that have been parsed so far too. inspire by github.com/argoproj/gitops-engine/pkg/utils/kube

Types

This section is empty.

Jump to

Keyboard shortcuts

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