mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-07-30 03:52:42 +00:00
Run the E2E test on kind / setup-test-matrix (push) Successful in 4s
e2e-test-kind.yaml / extract (push) Failing after 13s
Run the E2E test on kind / get-go-version (push) Failing after 14s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Successful in 14s
Main CI / get-go-version (push) Successful in 16s
Main CI / Build (push) Failing after 2m46s
* Support overriding Schedule annotations via template.metadata.annotations Adds an Annotations field to BackupSpec.Metadata, mirroring the existing Labels override. When Schedule.Spec.Template.Metadata.Annotations is set, it is used for the resulting Backup's annotations instead of copying Schedule.Annotations directly, allowing users to opt out of unwanted annotations (e.g. ArgoCD tracking annotations) being propagated from Schedule to Backup. Fixes #5836 Signed-off-by: Lubron Zhan <lubronzhan@gmail.com> * Rename changelog fragment to match PR number 10045 Signed-off-by: Lubron Zhan <lubronzhan@gmail.com> --------- Signed-off-by: Lubron Zhan <lubronzhan@gmail.com> Co-authored-by: Daniel Jiang <daniel.jiang@broadcom.com>
85 lines
2.7 KiB
Go
85 lines
2.7 KiB
Go
/*
|
|
Copyright 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.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package builder
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
|
)
|
|
|
|
func TestBackupFromSchedule(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
schedule *velerov1api.Schedule
|
|
expectedLabels map[string]string
|
|
expectedAnnotations map[string]string
|
|
}{
|
|
{
|
|
name: "no schedule labels/annotations and no template overrides",
|
|
schedule: ForSchedule("velero", "test").
|
|
Result(),
|
|
expectedLabels: map[string]string{velerov1api.ScheduleNameLabel: "test"},
|
|
expectedAnnotations: nil,
|
|
},
|
|
{
|
|
name: "schedule labels/annotations are copied when no template override is set",
|
|
schedule: ForSchedule("velero", "test").
|
|
ObjectMeta(
|
|
WithLabels("schedule-label", "schedule-value"),
|
|
WithAnnotations("schedule-annotation", "schedule-value"),
|
|
).
|
|
Result(),
|
|
expectedLabels: map[string]string{
|
|
"schedule-label": "schedule-value",
|
|
velerov1api.ScheduleNameLabel: "test",
|
|
},
|
|
expectedAnnotations: map[string]string{"schedule-annotation": "schedule-value"},
|
|
},
|
|
{
|
|
name: "template.metadata.labels/annotations override schedule labels/annotations",
|
|
schedule: ForSchedule("velero", "test").
|
|
ObjectMeta(
|
|
WithLabels("schedule-label", "schedule-value"),
|
|
WithAnnotations("schedule-annotation", "schedule-value"),
|
|
).
|
|
Template(velerov1api.BackupSpec{
|
|
Metadata: velerov1api.Metadata{
|
|
Labels: map[string]string{"template-label": "template-value"},
|
|
Annotations: map[string]string{"template-annotation": "template-value"},
|
|
},
|
|
}).
|
|
Result(),
|
|
expectedLabels: map[string]string{
|
|
"template-label": "template-value",
|
|
velerov1api.ScheduleNameLabel: "test",
|
|
},
|
|
expectedAnnotations: map[string]string{"template-annotation": "template-value"},
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
backup := ForBackup("velero", "test-backup").FromSchedule(test.schedule).Result()
|
|
assert.Equal(t, test.expectedLabels, backup.GetLabels())
|
|
assert.Equal(t, test.expectedAnnotations, backup.GetAnnotations())
|
|
})
|
|
}
|
|
}
|