utils

package
v0.0.0-...-6dcaeb9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 20 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LabelsJuju is a common set
	LabelsJuju = map[string]string{
		constants.LabelKubernetesAppManaged: "juju",
	}

	// LabelsJujuModelOperatorDisableWebhook is a set of labels needed on a
	// given object to disable admission webhook validation.
	LabelsJujuModelOperatorDisableWebhook = map[string]string{
		constants.LabelJujuModelOperatorDisableWebhook: "true",
	}
)

Functions

func AnnotationCharmModifiedVersionKey

func AnnotationCharmModifiedVersionKey(legacy bool) string

AnnotationCharmModifiedVersionKey returns the key used in annotations to describe the charm modified version.

func AnnotationControllerIsControllerKey

func AnnotationControllerIsControllerKey(legacy bool) string

AnnotationControllerIsControllerKey returns the key used in annotations to describe if this pod is a controller pod.

func AnnotationControllerUUIDKey

func AnnotationControllerUUIDKey(legacy bool) string

AnnotationControllerUUIDKey returns the key used in annotations to describe the controller UUID.

func AnnotationDisableNameKey

func AnnotationDisableNameKey(legacy bool) string

AnnotationDisableNameKey returns the key used in annotations to describe the disabled name prefix.

func AnnotationJujuStorageKey

func AnnotationJujuStorageKey(legacy bool) string

AnnotationJujuStorageKey returns the key used in annotations to describe the storage UUID.

func AnnotationKeyApplicationUUID

func AnnotationKeyApplicationUUID(legacy bool) string

AnnotationKeyApplicationUUID is the key of annotation for recording pvc unique ID.

func AnnotationModelUUIDKey

func AnnotationModelUUIDKey(legacy bool) string

AnnotationModelUUIDKey returns the key used in annotations to describe the model UUID.

func AnnotationUnitKey

func AnnotationUnitKey(legacy bool) string

AnnotationUnitKey returns the key used in annotations to describe the Juju unit.

func AnnotationVersionKey

func AnnotationVersionKey(legacy bool) string

AnnotationVersionKey returns the key used in annotations to describe the Juju version. Legacy controls if the key returns is a legacy annotation key or newer style.

func AnnotationsForStorage

func AnnotationsForStorage(name string, legacy bool) annotations.Annotation

AnnotationsForStorage provides the annotations that should be placed on a storage object. The annotations returned by this function are storage specific only and should be combined with other annotations where appropriate.

func AnnotationsForVersion

func AnnotationsForVersion(vers string, legacy bool) annotations.Annotation

AnnotationsForVersion provides the annotations that should be placed on an object that requires juju version information. The annotations returned by this function are version specific and may need to be combined with other annotations for a complete set.

func CreateDockerConfigJSON

func CreateDockerConfigJSON(username, password, imagePath string) ([]byte, error)

func ExtractRegistryURL

func ExtractRegistryURL(imagePath string) (string, error)

ExtractRegistryName returns the registry URL part of an images path

func GetSvcAddresses

func GetSvcAddresses(svc *core.Service, includeClusterIP bool) []network.ProviderAddress

GetSvcAddresses returns the network addresses for the given service.

func HasLabels

func HasLabels(src, has labels.Set) bool

HasLabels returns true if the src contains the labels in has

func IntPtr

func IntPtr(i int) *int

Returns a ptr for the supplied integer.

func IsLegacyModelLabels

func IsLegacyModelLabels(namespace, model string, namespaceI core.NamespaceInterface) (bool, error)

IsLegacyModelLabels checks to see if the provided model is running on an older labeling scheme or a newer one.

func LabelForKeyValue

func LabelForKeyValue(key, value string) labels.Set

LabelForKeyValue returns a Kubernetes label set for the supplied key value.

func LabelsForApp

func LabelsForApp(name string, legacy bool) labels.Set

LabelsForApp returns the labels that should be on a k8s object for a given application name

func LabelsForModel

func LabelsForModel(name string, legacy bool) labels.Set

LabelsForModel returns the labels that should be on a k8s object for a given model name

func LabelsForOperator

func LabelsForOperator(name, target string, legacy bool) labels.Set

LabelsForOperator returns the labels that should be placed on a juju operator Takes the operator name, type and a legacy flag to indicate these labels are being used on a model that is operating in "legacy" label mode

func LabelsForStorage

func LabelsForStorage(name string, legacy bool) labels.Set

LabelsForStorage return the labels that should be placed on a k8s storage object. Takes the storage name and a legacy flat.

func LabelsMerge

func LabelsMerge(a labels.Set, merges ...labels.Set) labels.Set

LabelsMerge merges one or more sets of labels together into a new set. For duplicate keys the last key found is used.

func LabelsToSelector

func LabelsToSelector(ls labels.Set) labels.Selector

LabelsToSelector transforms the supplied label set to a valid Kubernetes label selector

func MakeK8sDomain

func MakeK8sDomain(components ...string) string

MakeK8sDomain builds and returns a Kubernetes resource domain for the provided components. Func is idempotent

func NewPreconditionDeleteOptions

func NewPreconditionDeleteOptions(uid k8stypes.UID) metav1.DeleteOptions

func NewUIDPreconditions

func NewUIDPreconditions(uid k8stypes.UID) *metav1.Preconditions

func PurifyResource

func PurifyResource(resource interface{ SetResourceVersion(string) })

PurifyResource purifies read only fields before creating/updating the resource.

func RandomPrefix

func RandomPrefix() (string, error)

RandomPrefix returns a random string for storage related annotations.

func ResourceTagsToAnnotations

func ResourceTagsToAnnotations(in map[string]string, legacy bool) annotations.Annotation

ResourceTagsToAnnotations creates annotations from the resource tags.

func RunCleanUps

func RunCleanUps(cleanUps []func())

RunCleanUps runs the functions provided in the cleanUps slice in reverse order. This is a utility function for Kubernetes to help remove resources created when there is an error

func SelectorLabelsForApp

func SelectorLabelsForApp(name string, legacy bool) labels.Set

SelectorLabelsForApp returns the pod selector labels that should be on a k8s object for a given application name

func StorageNameFromLabels

func StorageNameFromLabels(labels labels.Set) string

StorageNameFromLabels returns the juju storage name used in the provided label set. First checks for the key LabelJujuStorageName and then defaults over to the key LegacyLabelStorageName. If neither key exists an empty string is returned.

Types

type AnnotationKeySupplier

type AnnotationKeySupplier func() string

type DockerConfig

type DockerConfig map[string]DockerConfigEntry

DockerConfig represents the config file used by the docker CLI.

type DockerConfigEntry

type DockerConfigEntry struct {
	Username string
	Password string
	Email    string
}

DockerConfigEntry represents an Auth entry in the dockerconfigjson.

type DockerConfigJSON

type DockerConfigJSON struct {
	Auths DockerConfig `json:"auths"`
}

DockerConfigJSON represents ~/.docker/config.json file info.

type RandomPrefixFunc

type RandomPrefixFunc func() (string, error)

RandomPrefixFunc defines a function used to generate a random hex string.

Jump to

Keyboard shortcuts

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