controller

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: 0

Documentation

Index

Constants

View Source
const (
	ShellProvisionerRepo = "ghcr.io/forge-build/forge-provisioner-shell"
	ShellProvisionerTag  = "latest"

	ForgeCoreNamespace = "forge-core"
)

Variables

View Source
var HasBuildNameLabel = predicate.NewPredicateFuncs(func(obj client.Object) bool {
	if _, ok := obj.GetLabels()[buildv1.BuildNameLabel]; ok {
		return true
	}
	return false
})
View Source
var HasProvisionerIDLabel = predicate.NewPredicateFuncs(func(obj client.Object) bool {
	if _, ok := obj.GetLabels()[buildv1.ProvisionerIDLabel]; ok {
		return true
	}
	return false
})
View Source
var InNamespace = func(namespace string) predicate.Predicate {
	return predicate.NewPredicateFuncs(func(obj client.Object) bool {
		return namespace == obj.GetNamespace()
	})
}

InNamespace is a predicate.Predicate that returns true if the specified client.Object is in the desired namespace.

View Source
var IsBeingTerminated = predicate.NewPredicateFuncs(func(obj client.Object) bool {
	return obj.GetDeletionTimestamp() != nil
})

IsBeingTerminated is a predicate.Predicate that returns true if the specified client.Object is being terminated, i.e. its DeletionTimestamp property is set to non nil value.

View Source
var JobHasAnyCondition = predicate.NewPredicateFuncs(func(obj client.Object) bool {
	if job, ok := obj.(*batchv1.Job); ok {
		return len(job.Status.Conditions) > 0
	}
	return false
})

JobHasAnyCondition is a predicate.Predicate that returns true if the specified client.Object is a v1.Job with any v1.JobConditionType.

View Source
var ManagedByForgeProvisionerShell = predicate.NewPredicateFuncs(func(obj client.Object) bool {
	if managedBy, ok := obj.GetLabels()[buildv1.ManagedByLabel]; ok {
		return managedBy == shell.ForgeProvisionerShellName
	}
	return false
})

ManagedByForgeProvisionerShell is a predicate.Predicate that returns true if the specified client.Object is managed by Forge.

Functions

func GetTerminatedContainersStatusesByPod

func GetTerminatedContainersStatusesByPod(pod *corev1.Pod) map[string]*corev1.ContainerStateTerminated

func IsPodControlledByJobNotFound

func IsPodControlledByJobNotFound(err error) bool

func Reconcile

func Reconcile(ctx context.Context, client client.Client, build *buildv1.Build, spec *buildv1.ProvisionerSpec) (_ ctrl.Result, err error)

Types

type ShellJobController

type ShellJobController struct {
	Logger logr.Logger
	client.Client
	Clientset *kubernetes.Clientset
	Namespace string
	// contains filtered or unexported fields
}

ShellJobController watches Kubernetes jobs and reports back to the Build

func (*ShellJobController) GetTerminatedContainersStatusesByJob

func (r *ShellJobController) GetTerminatedContainersStatusesByJob(ctx context.Context, job *batchv1.Job) (map[string]*corev1.ContainerStateTerminated, error)

func (*ShellJobController) SetupWithManager

func (r *ShellJobController) SetupWithManager(mgr ctrl.Manager) error

Jump to

Keyboard shortcuts

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