Aller au contenu

Schedule Spec (cue)#

Generating cue spec#

The following definition has been generated from velero code with cue:

cd $(mktemp -d)
go mod init cue-velero
go get github.com/vmware-tanzu/velero@v1.9.2
go get k8s.io/api/...
cue get go github.com/vmware-tanzu/velero/pkg/apis/velero/v1

# This will generate a directory ./cue.mod/gen/github.com/vmware-tanzu/velero/pkg/apis/velero/v1/
# containing cue definitions infered from go code.
# Get the content of ./cue.mod/gen/github.com/vmware-tanzu/velero/pkg/apis/velero/v1/schedule_types_go_gen.cue

Spec#

// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go github.com/vmware-tanzu/velero/pkg/apis/velero/v1

package v1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// ScheduleSpec defines the specification for a Velero schedule
#ScheduleSpec: {
    // Template is the definition of the Backup to be run
    // on the provided schedule
    template: #BackupSpec @go(Template)

    // Schedule is a Cron expression defining when to run
    // the Backup.
    schedule: string @go(Schedule)

    // UseOwnerReferencesBackup specifies whether to use
    // OwnerReferences on backups created by this Schedule.
    // +optional
    // +nullable
    useOwnerReferencesInBackup?: null | bool @go(UseOwnerReferencesInBackup,*bool)
}

// SchedulePhase is a string representation of the lifecycle phase
// of a Velero schedule
// +kubebuilder:validation:Enum=New;Enabled;FailedValidation
#SchedulePhase: string // #enumSchedulePhase

#enumSchedulePhase:
    #SchedulePhaseNew |
    #SchedulePhaseEnabled |
    #SchedulePhaseFailedValidation

// SchedulePhaseNew means the schedule has been created but not
// yet processed by the ScheduleController
#SchedulePhaseNew: #SchedulePhase & "New"

// SchedulePhaseEnabled means the schedule has been validated and
// will now be triggering backups according to the schedule spec.
#SchedulePhaseEnabled: #SchedulePhase & "Enabled"

// SchedulePhaseFailedValidation means the schedule has failed
// the controller's validations and therefore will not trigger backups.
#SchedulePhaseFailedValidation: #SchedulePhase & "FailedValidation"

// ScheduleStatus captures the current state of a Velero schedule
#ScheduleStatus: {
    // Phase is the current phase of the Schedule
    // +optional
    phase?: #SchedulePhase @go(Phase)

    // LastBackup is the last time a Backup was run for this
    // Schedule schedule
    // +optional
    // +nullable
    lastBackup?: null | metav1.#Time @go(LastBackup,*metav1.Time)

    // ValidationErrors is a slice of all validation errors (if
    // applicable)
    // +optional
    validationErrors?: [...string] @go(ValidationErrors,[]string)
}

// Schedule is a Velero resource that represents a pre-scheduled or
// periodic Backup that should be run.
#Schedule: {
    metav1.#TypeMeta

    // +optional
    metadata: metav1.#ObjectMeta @go(ObjectMeta)

    // +optional
    spec?: #ScheduleSpec @go(Spec)

    // +optional
    status?: #ScheduleStatus @go(Status)
}

// ScheduleList is a list of Schedules.
#ScheduleList: {
    metav1.#TypeMeta

    // +optional
    metadata?: metav1.#ListMeta @go(ListMeta)
    items: [...#Schedule] @go(Items,[]Schedule)
}