utils

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreCommitStatusesPassing added in v0.6.0

func AreCommitStatusesPassing(commitStatuses []promoterv1alpha1.ChangeRequestPolicyCommitStatusPhase) bool

func GetChangeTransferPolicyName

func GetChangeTransferPolicyName(promotionStrategyName, environmentBranch string) string

func GetEnvironmentByBranch

func GetEnvironmentByBranch(promotionStrategy promoterv1alpha1.PromotionStrategy, branch string) (int, *promoterv1alpha1.Environment)

func GetGitRepositoryFromObjectKey added in v0.1.0

func GetGitRepositoryFromObjectKey(ctx context.Context, k8sClient client.Client, objectKey client.ObjectKey) (*promoterv1alpha1.GitRepository, error)

GetGitRepositoryFromObjectKey returns the GitRepository object from the repository reference

func GetPullRequestName

func GetPullRequestName(repoOwner, repoName, pcProposedBranch, pcActiveBranch string) string

func GetScmProviderAndSecretFromRepositoryReference

func GetScmProviderAndSecretFromRepositoryReference(ctx context.Context, k8sClient client.Client, controllerNamespace string, repositoryRef promoterv1alpha1.ObjectReference, obj metav1.Object) (promoterv1alpha1.GenericScmProvider, *v1.Secret, error)

func GetScmProviderFromGitRepository

func GetScmProviderFromGitRepository(ctx context.Context, k8sClient client.Client, repositoryRef *promoterv1alpha1.GitRepository, obj metav1.Object) (promoterv1alpha1.GenericScmProvider, error)

func HandleReconciliationResult added in v0.8.0

func HandleReconciliationResult(
	ctx context.Context,
	startTime time.Time,
	obj StatusConditionUpdater,
	client client.Client,
	recorder record.EventRecorder,
	err *error,
)

HandleReconciliationResult handles reconciliation results for any object with status conditions.

func KubeSafeLabel

func KubeSafeLabel(name string) string

KubeSafeLabel Creates a safe label buy truncating from the beginning of 'name' to a max of 63 characters, if the name starts with a hyphen it will be removed. We truncate from beginning so that we can keep the unique hash at the end of the name.

func KubeSafeUniqueName

func KubeSafeUniqueName(ctx context.Context, name string) string

KubeSafeUniqueName Creates a safe name by replacing all non-alphanumeric characters with a hyphen and truncating to a max of 255 characters, then appending a hash of the name.

func RenderStringTemplate added in v0.1.0

func RenderStringTemplate(templateStr string, data any) (string, error)

func TruncateString

func TruncateString(str string, length int) string

func TruncateStringFromBeginning

func TruncateStringFromBeginning(str string, length int) string

Truncate from front of string

Types

type StatusConditionUpdater added in v0.8.0

type StatusConditionUpdater interface {
	client.Object
	GetConditions() *[]metav1.Condition
}

StatusConditionUpdater defines the interface for objects that can have their status conditions updated

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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