Owner reference in backup when created from schedule (#3127)
* added useOwnerReferencesInBackup to crd velerio.io_schedules Signed-off-by: matheusjuvelino <matheus.juvelino@outlook.com> * added UseOwnerReferencesInBackup property to schedule.go Signed-off-by: matheusjuvelino <matheus.juvelino@outlook.com> * deepcopy schedule configured for reference the property UseOwnerReferencesInBackup Signed-off-by: matheusjuvelino <matheus.juvelino@outlook.com> * added UseOwnerReferencesInBackup property verification to modify OwnerReferences from backup Signed-off-by: matheusjuvelino <matheus.juvelino@outlook.com> * created changelog Signed-off-by: matheusjuvelino <matheus.juvelino@outlook.com> * removed deepcopy schedule configured for reference the property UseOwnerReferencesInBackup Signed-off-by: matheusjuvelino <matheus.juvelino@outlook.com> * running make update Signed-off-by: matheusjuvelino <matheus.juvelino@outlook.com> * running make update Signed-off-by: matheusjuvelino <matheus.juvelino@outlook.com> * updated the year at the top of the schedule.go file for 2020 Signed-off-by: matheusjuvelino <matheus.juvelino@outlook.com>pull/3185/head
parent
f1ec10a518
commit
309d3dcf0a
|
@ -0,0 +1 @@
|
|||
Owner reference in backup when created from schedule
|
|
@ -369,6 +369,11 @@ spec:
|
|||
type: string
|
||||
type: array
|
||||
type: object
|
||||
useOwnerReferencesInBackup:
|
||||
description: UseOwnerReferencesBackup specifies whether to use OwnerReferences
|
||||
on backups created by this Schedule.
|
||||
nullable: true
|
||||
type: boolean
|
||||
required:
|
||||
- schedule
|
||||
- template
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2017 the Velero contributors.
|
||||
Copyright 2020 the Velero contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -32,6 +32,12 @@ type ScheduleSpec struct {
|
|||
// Schedule is a Cron expression defining when to run
|
||||
// the Backup.
|
||||
Schedule string `json:"schedule"`
|
||||
|
||||
// UseOwnerReferencesBackup specifies whether to use
|
||||
// OwnerReferences on backups created by this Schedule.
|
||||
// +optional
|
||||
// +nullable
|
||||
UseOwnerReferencesInBackup *bool `json:"useOwnerReferencesInBackup,omitempty"`
|
||||
}
|
||||
|
||||
// SchedulePhase is a string representation of the lifecycle phase
|
||||
|
|
|
@ -1390,6 +1390,11 @@ func (in *ScheduleList) DeepCopyObject() runtime.Object {
|
|||
func (in *ScheduleSpec) DeepCopyInto(out *ScheduleSpec) {
|
||||
*out = *in
|
||||
in.Template.DeepCopyInto(&out.Template)
|
||||
if in.UseOwnerReferencesInBackup != nil {
|
||||
in, out := &in.UseOwnerReferencesInBackup, &out.UseOwnerReferencesInBackup
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
|
||||
"github.com/vmware-tanzu/velero/pkg/util/boolptr"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -88,6 +90,18 @@ func (b *BackupBuilder) FromSchedule(schedule *velerov1api.Schedule) *BackupBuil
|
|||
b.ObjectMeta(WithAnnotationsMap(schedule.Annotations))
|
||||
}
|
||||
|
||||
if boolptr.IsSetToTrue(schedule.Spec.UseOwnerReferencesInBackup) {
|
||||
b.object.SetOwnerReferences([]metav1.OwnerReference{
|
||||
{
|
||||
APIVersion: velerov1api.SchemeGroupVersion.String(),
|
||||
Kind: "Schedule",
|
||||
Name: schedule.Name,
|
||||
UID: schedule.UID,
|
||||
Controller: boolptr.True(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue