util

package
v0.37.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Copyright 2020-2021 The UnDistro authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChartNameByFile added in v0.32.0

func ChartNameByFile(name string) string

func ContainsIntInSlice added in v0.36.24

func ContainsIntInSlice(numbers []int, number int) bool

func ContainsStringInSlice

func ContainsStringInSlice(ss []string, str string) bool

func CreateOrUpdate

func CreateOrUpdate(ctx context.Context, r client.Client, o client.Object) (bool, error)

func GetCaFromSecret added in v0.34.0

func GetCaFromSecret(ctx context.Context, c client.Client, secretName, dataField, ns string) (crt []byte, err error)

func GetFromConfigMap added in v0.34.8

func GetFromConfigMap(ctx context.Context, c client.Client, name, ns, dataField string, o interface{}) (interface{}, error)

func IsMgmtCluster added in v0.34.0

func IsMgmtCluster(clusterName string) bool

func LastCondition added in v0.36.3

func LastCondition(conditons []metav1.Condition) metav1.Condition

func MergeMaps

func MergeMaps(a, b map[string]interface{}) map[string]interface{}

MergeMaps merges map b into given map a and returns the result. It allows overwrites of map values with flat values, and vice versa. This is copied from https://github.com/helm/helm/blob/v3.3.0/pkg/cli/values/options.go#L88, as the public chartutil.CoalesceTables function does not allow overwriting maps with flat values.

func ObjectKeyFromString

func ObjectKeyFromString(str string) client.ObjectKey

func Ordinalize

func Ordinalize(n int) string

Ordinalize takes an int and returns the ordinalized version of it. Eg. 1 --> 1st, 103 --> 103rd

func RandomString added in v0.34.0

func RandomString(length int) string

func ReleaseRevision

func ReleaseRevision(rel *release.Release) int

ReleaseRevision returns the revision of the given release.Release.

func RemoveDuplicateTaints added in v0.18.9

func RemoveDuplicateTaints(taints []corev1.Taint) []corev1.Taint

func Slugify added in v0.34.0

func Slugify(text string) string

Slugify a string. The result will only contain lowercase letters, digits and dashes. It will not begin or end with a dash, and it will not contain runs of multiple dashes.

It is NOT forced into being ASCII, but may contain any Unicode characters, with the above restrictions.

func Slugifyf added in v0.34.0

func Slugifyf(format string, a ...interface{}) string

Slugifyf slugfy a formated string

func ToUnstructured

func ToUnstructured(rawyaml []byte) ([]unstructured.Unstructured, error)

ToUnstructured takes a YAML and converts it to a list of Unstructured objects

func ValuesChecksum

func ValuesChecksum(values chartutil.Values) string

ValuesChecksum calculates and returns the SHA1 checksum for the given chartutil.Values.

Types

type LocalClusterType added in v0.35.0

type LocalClusterType int8
const (
	NonLocal LocalClusterType = iota
	NodeRetrieveError
	Kind
	Minikube
)

func IsLocalCluster added in v0.32.0

func IsLocalCluster(ctx context.Context, c client.Client) (LocalClusterType, error)

// Asserts whether the current cluster is local, and the kind of local cluster. Each type is mapped to the enum <LocalClusterType>.

Jump to

Keyboard shortcuts

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