Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clusterfile and other Object Validation #1269

Open
fanux opened this issue Mar 23, 2022 · 0 comments
Open

Clusterfile and other Object Validation #1269

fanux opened this issue Mar 23, 2022 · 0 comments
Assignees
Labels
Clusterfile kind/feature Category issues or PRs related to feature request

Comments

@fanux
Copy link
Collaborator

fanux commented Mar 23, 2022

https://book.kubebuilder.io/reference/markers/crd-validation.html

Example:

// BackupCronJobSpec defines the desired state of BackupCronJob
type BackupCronJobSpec struct {
	// Important: Run "make" to regenerate code after modifying this file

	// InstanceName is the backup target instance name, usually a
	// resource object name
	// +kubebuilder:validation:MinLength=1
	InstanceName string `json:"instanceName"`
	// InstanceKind is the backup target kind, i.e., 'StatefulSet' or
	// custom resource kind
	// +kubebuilder:validation:MinLength=1
	InstanceKind string `json:"instanceKind"`
	// InstanceAPIGroup is the backup target API group, i.e., 'apps' for
	// StatefulSet or custom resource API group
	// +optional
	InstanceAPIGroup string `json:"instanceAPIGroup,omitempty"`
	// InstanceAPIVersion is the backup target API version, i.e., 'apps/v1'
	// would be 'v1'
	// +kubebuilder:validation:MinLength=1
	InstanceAPIVersion string `json:"instanceAPIVersion"`
	// Schedule is a Cron expression defining when to run
	// the Backup
	// +kubebuilder:validation:Pattern=`(@(annually|yearly|monthly|weekly|daily|hourly))|(@every (\d+(m|h))+)|((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5})`
	Schedule string `json:"schedule"`
	// TTL is a time.Duration-parseable string describing how long
	// the Backup should be retained for, i.e., 1d0h, minimum TTL is 1h.
	// +kubebuilder:validation:Pattern=`(?:\s*\d+\s*[YyMmDdHh])+`
	TTL string `json:"ttl"`
	// Repos is backup storage repo name
	// +optional
	// +kubebuilder:validation:Optional
	Repo string `json:"repo,omitempty"`
	// Hooks represent custom behaviors that should be executed at different phases of the backup.
	// +optional
	Hooks velerov1.BackupHooks `json:"hooks,omitempty"`
}
// SchedulePhase is a string representation of the lifecycle phase
// of an OPCC backupcronjob
// +kubebuilder:validation:Enum=New;Enabled;FailedValidation
type SchedulePhase string

const (
	// 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"
)
@fanux fanux added the kind/feature Category issues or PRs related to feature request label Mar 23, 2022
@fanux fanux self-assigned this Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clusterfile kind/feature Category issues or PRs related to feature request
Projects
None yet
Development

No branches or pull requests

2 participants