Set schedule labels to subsequent backups

Signed-off-by: Zsolt Varga <zsolt.varga@console.hu>
This commit is contained in:
Zsolt Varga
2018-09-03 15:01:03 +02:00
parent 283a1349bd
commit 211aa7b7fd
3 changed files with 53 additions and 3 deletions

View File

@@ -370,15 +370,25 @@ func getBackup(item *api.Schedule, timestamp time.Time) *api.Backup {
ObjectMeta: metav1.ObjectMeta{
Namespace: item.Namespace,
Name: fmt.Sprintf("%s-%s", item.Name, timestamp.Format("20060102150405")),
Labels: map[string]string{
"ark-schedule": item.Name,
},
},
}
// add schedule labels and 'ark-schedule' label to the backup
addLabelsToBackup(item, backup)
return backup
}
func addLabelsToBackup(item *api.Schedule, backup *api.Backup) {
labels := item.Labels
if labels == nil {
labels = make(map[string]string)
}
labels["ark-schedule"] = item.Name
backup.Labels = labels
}
func patchSchedule(original, updated *api.Schedule, client arkv1client.SchedulesGetter) (*api.Schedule, error) {
origBytes, err := json.Marshal(original)
if err != nil {