job

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// K8uplabel is a label that is required for the operator to differentiate
	// batchv1.job objects managed by k8up from others.
	K8uplabel = "k8upjob"
	// K8upExclusive is needed to determine if a given job is considered exclusive or not.
	K8upExclusive = "k8upjob/exclusive"
)

Variables

This section is empty.

Functions

func FindStatusCondition added in v2.6.0

func FindStatusCondition(conditions []batchv1.JobCondition, conditionType batchv1.JobConditionType) *batchv1.JobCondition

FindStatusCondition finds the condition with the given type in the batchv1.JobCondition slice. Returns nil if not found.

func HasFailed added in v2.6.0

func HasFailed(conditions []batchv1.JobCondition) bool

func HasStarted added in v2.6.0

func HasStarted(conditions []batchv1.JobCondition) bool

func HasSucceeded added in v2.6.0

func HasSucceeded(conditions []batchv1.JobCondition) bool

func MutateBatchJob added in v2.6.0

func MutateBatchJob(batchJob *batchv1.Job, jobObj k8upv1.JobObject, config Config) error

MutateBatchJob mutates the given Job with generic spec applicable to all K8up-spawned Jobs.

func ReconcileJobStatus added in v2.6.0

func ReconcileJobStatus(ctx context.Context, key types.NamespacedName, client client.Client, obj k8upv1.JobObject) error

func SetFailed added in v2.6.0

func SetFailed(ctx context.Context, name, ns string, typ k8upv1.JobType, objStatus *k8upv1.Status, message string)

func SetSucceeded added in v2.6.0

func SetSucceeded(ctx context.Context, name, ns string, typ k8upv1.JobType, objStatus *k8upv1.Status, message string)

func Sha256Hash added in v2.6.0

func Sha256Hash(v string) string

Sha256Hash returns the SHA256 hash string of the given string Returns empty string if v is empty. The returned hash is shortened to 63 characters to fit into a label.

func UpdateStatus added in v2.6.0

func UpdateStatus(ctx context.Context, batchJob *batchv1.Job, obj k8upv1.JobObject)

UpdateStatus retrieves status of batchJob and sets status of obj accordingly.

Types

type Config

type Config struct {
	Client     client.Client
	Obj        k8upv1.JobObject
	Repository string
}

Config represents the whole context for a given job. It contains everything that is necessary to handle the job.

func NewConfig

func NewConfig(client client.Client, obj k8upv1.JobObject, repository string) Config

NewConfig returns a new configuration.

func (*Config) SetConditionFalseWithMessage

func (c *Config) SetConditionFalseWithMessage(ctx context.Context, condition k8upv1.ConditionType, reason k8upv1.ConditionReason, message string, args ...interface{})

SetConditionFalseWithMessage tells the K8s controller at once that the status of the given Condition is now "False" and provides the given message. The arguments `message` and `args` follow the fmt.Sprintf() syntax.

func (*Config) SetConditionTrue

func (c *Config) SetConditionTrue(ctx context.Context, condition k8upv1.ConditionType, reason k8upv1.ConditionReason)

SetConditionTrue tells the K8s controller at once that the status of the given Conditions is now "True"

func (*Config) SetConditionTrueWithMessage

func (c *Config) SetConditionTrueWithMessage(ctx context.Context, condition k8upv1.ConditionType, reason k8upv1.ConditionReason, message string, args ...interface{})

SetConditionTrueWithMessage tells the K8s controller at once that the status of the given Condition is now "True" and provides the given message. The arguments `message` and `args` follow the fmt.Sprintf() syntax.

func (*Config) SetConditionUnknownWithMessage

func (c *Config) SetConditionUnknownWithMessage(ctx context.Context, condition k8upv1.ConditionType, reason k8upv1.ConditionReason, message string, args ...interface{})

SetConditionUnknownWithMessage tells the K8s controller at once that the status of the given Conditions is "Unknown"

func (*Config) SetFinished

func (c *Config) SetFinished(ctx context.Context, namespace, name string)

SetFinished marks the job as finished and updates the status.

func (*Config) SetStarted

func (c *Config) SetStarted(ctx context.Context, message string, args ...interface{})

SetStarted marks the job as started and updates the status. The arguments `message` and `args` follow the fmt.Sprintf() syntax.

Jump to

Keyboard shortcuts

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