util

package
v0.0.0-...-53bbf1f Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: Apache-2.0 Imports: 24 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoCluster is returned when the cluster
	// label could not be found on the object passed in.
	ErrNoCluster = fmt.Errorf("no %q label present", buildv1.BuildNameLabel)

	// ErrUnstructuredFieldNotFound determines that a field
	// in an unstructured object could not be found.
	ErrUnstructuredFieldNotFound = fmt.Errorf("field not found")
)

Functions

func BuildToInfrastructureMapFunc

func BuildToInfrastructureMapFunc(ctx context.Context, gvk schema.GroupVersionKind, c client.Client, providerBuild client.Object) handler.MapFunc

BuildToInfrastructureMapFunc returns a handler.ToRequestsFunc that watches for Build events and returns reconciliation requests for an infrastructure provider object.

func CalculateCRDName

func CalculateCRDName(group, kind string) string

CalculateCRDName generates a CRD name based on group and kind according to the naming conventions in the contract.

func EnsureCredentialsSecret

func EnsureCredentialsSecret(ctx context.Context, client client.Client, build *buildv1.Build, creds SSHCredentials, provider string) error

EnsureCredentialsSecret ensures that the Build has a secret with the SSH credentials.

func GetBuildByName

func GetBuildByName(ctx context.Context, c client.Client, namespace, name string) (*buildv1.Build, error)

GetBuildByName finds and return a Build object using the specified params.

func GetGVKMetadata

GetGVKMetadata retrieves a CustomResourceDefinition metadata from the API server using partial object metadata.

This function is greatly more efficient than GetCRDWithContract and should be preferred in most cases.

func GetOwnerBuild

func GetOwnerBuild(ctx context.Context, c client.Client, obj metav1.ObjectMeta) (*buildv1.Build, error)

GetOwnerBuild returns the Build object owning the current resource.

func GetProvisionerByID

func GetProvisionerByID(build *buildv1.Build, id string) (*buildv1.ProvisionerSpec, error)

func GetSecretFromSecretReference

func GetSecretFromSecretReference(ctx context.Context, c client.Client, secretRef corev1.SecretReference) (*corev1.Secret, error)

GetSecretFromSecretReference returns the secret data from the secret reference.

func HasPaused

func HasPaused(o metav1.Object) bool

HasPaused returns true if the object has the `paused` annotation.

func HasWatchLabel

func HasWatchLabel(o metav1.Object, labelValue string) bool

HasWatchLabel returns true if the object has a label with the WatchLabel key matching the given value.

func IsNil

func IsNil(i interface{}) bool

IsNil returns an error if the passed interface is equal to nil or if it has an interface value of nil.

func IsPaused

func IsPaused(build *buildv1.Build, o metav1.Object) bool

IsPaused returns true if the Cluster is paused or the object has the `paused` annotation.

func UnstructuredUnmarshalField

func UnstructuredUnmarshalField(obj *unstructured.Unstructured, v interface{}, fields ...string) error

UnstructuredUnmarshalField is a wrapper around json and unstructured objects to decode and copy a specific field value into an object.

Types

type KubeAwareAPIVersions

type KubeAwareAPIVersions []string

KubeAwareAPIVersions is a sortable slice of kube-like version strings.

Kube-like version strings are starting with a v, followed by a major version, optional "alpha" or "beta" strings followed by a minor version (e.g. v1, v2beta1). Versions will be sorted based on GA/alpha/beta first and then major and minor versions. e.g. v2, v1, v1beta2, v1beta1, v1alpha1.

func (KubeAwareAPIVersions) Len

func (k KubeAwareAPIVersions) Len() int

func (KubeAwareAPIVersions) Less

func (k KubeAwareAPIVersions) Less(i, j int) bool

func (KubeAwareAPIVersions) Swap

func (k KubeAwareAPIVersions) Swap(i, j int)

type SSHCredentials

type SSHCredentials struct {
	Host       string
	Username   string
	Password   string
	PrivateKey string
	PublicKey  string
}

Directories

Path Synopsis
Package annotations implements annotation helper functions.
Package annotations implements annotation helper functions.
Package conversion implements conversion utilities.
Package conversion implements conversion utilities.
Package predicates implements predicate utilities.
Package predicates implements predicate utilities.

Jump to

Keyboard shortcuts

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