Replace github.com/robfig/cron/v3 by github.com/netresearch/go-cron

Replace k8s.io/utils/pointer with k8s.io/utils/ptr

Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
This commit is contained in:
Xun Jiang
2026-06-04 15:05:55 +08:00
parent 90fd9706cd
commit e395b6ea6b
6 changed files with 36 additions and 36 deletions
+1 -1
View File
@@ -29,13 +29,13 @@ require (
github.com/kopia/kopia v0.16.0
github.com/kubernetes-csi/external-snapshot-metadata v1.0.0
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.4.0
github.com/netresearch/go-cron v0.15.0
github.com/onsi/ginkgo/v2 v2.28.3
github.com/onsi/gomega v1.40.0
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.23.2
github.com/prometheus/client_model v0.6.2
github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.9.4
github.com/spf13/afero v1.15.0
github.com/spf13/cobra v1.10.2
+2 -2
View File
@@ -353,6 +353,8 @@ github.com/mxk/go-vss v1.2.1 h1:shspH0qgqZ9l5sfIRsXS5BgZXz25/BY+ZQsW0HlD0fM=
github.com/mxk/go-vss v1.2.1/go.mod h1:ZQ4yFxCG54vqPnCd+p2IxAe5jwZdz56wSjbwzBXiFd8=
github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A=
github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM=
github.com/netresearch/go-cron v0.15.0 h1:pu+dhMZjBao9m5IpYe0o+zcNFlP94Z7TDHrORQk+/t0=
github.com/netresearch/go-cron v0.15.0/go.mod h1:79iktHfV90py3jcaFUtWcGSKbZXRev+WwoLMyV5eMvo=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
@@ -386,8 +388,6 @@ github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTU
github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc=
github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
+21 -21
View File
@@ -29,7 +29,7 @@ import (
"github.com/stretchr/testify/assert"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"github.com/vmware-tanzu/velero/pkg/label"
@@ -669,7 +669,7 @@ func TestFilterPVCsByVolumePolicy(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "pvc-1", Namespace: "ns-1"},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-1",
StorageClassName: pointer.String("sc-1"),
StorageClassName: ptr.To("sc-1"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -677,7 +677,7 @@ func TestFilterPVCsByVolumePolicy(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "pvc-2", Namespace: "ns-1"},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-2",
StorageClassName: pointer.String("sc-1"),
StorageClassName: ptr.To("sc-1"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -709,7 +709,7 @@ func TestFilterPVCsByVolumePolicy(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "pvc-csi", Namespace: "ns-1"},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-csi",
StorageClassName: pointer.String("sc-1"),
StorageClassName: ptr.To("sc-1"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -717,7 +717,7 @@ func TestFilterPVCsByVolumePolicy(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "pvc-nfs", Namespace: "ns-1"},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-nfs",
StorageClassName: pointer.String("sc-nfs"),
StorageClassName: ptr.To("sc-nfs"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -760,7 +760,7 @@ volumePolicies:
ObjectMeta: metav1.ObjectMeta{Name: "pvc-nfs-1", Namespace: "ns-1"},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-nfs-1",
StorageClassName: pointer.String("sc-nfs"),
StorageClassName: ptr.To("sc-nfs"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -768,7 +768,7 @@ volumePolicies:
ObjectMeta: metav1.ObjectMeta{Name: "pvc-nfs-2", Namespace: "ns-1"},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-nfs-2",
StorageClassName: pointer.String("sc-nfs"),
StorageClassName: ptr.To("sc-nfs"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -818,7 +818,7 @@ volumePolicies:
},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-linstor",
StorageClassName: pointer.String("sc-linstor"),
StorageClassName: ptr.To("sc-linstor"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -830,7 +830,7 @@ volumePolicies:
},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-nfs",
StorageClassName: pointer.String("sc-nfs"),
StorageClassName: ptr.To("sc-nfs"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -943,7 +943,7 @@ func TestFilterPVCsByVolumePolicyWithVolumeHelper(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "pvc-csi", Namespace: "ns-1"},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-csi",
StorageClassName: pointer.String("sc-csi"),
StorageClassName: ptr.To("sc-csi"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -951,7 +951,7 @@ func TestFilterPVCsByVolumePolicyWithVolumeHelper(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "pvc-nfs", Namespace: "ns-1"},
Spec: corev1api.PersistentVolumeClaimSpec{
VolumeName: "pv-nfs",
StorageClassName: pointer.String("sc-nfs"),
StorageClassName: ptr.To("sc-nfs"),
},
Status: corev1api.PersistentVolumeClaimStatus{Phase: corev1api.ClaimBound},
},
@@ -1365,7 +1365,7 @@ func TestWaitForVGSAssociatedVS(t *testing.T) {
},
Spec: snapshotv1api.VolumeSnapshotSpec{
Source: snapshotv1api.VolumeSnapshotSource{
PersistentVolumeClaimName: pointer.String(pvcName),
PersistentVolumeClaimName: ptr.To(pvcName),
},
},
}
@@ -1373,7 +1373,7 @@ func TestWaitForVGSAssociatedVS(t *testing.T) {
if hasStatus {
vs.Status = &snapshotv1api.VolumeSnapshotStatus{}
if hasVGSName {
vs.Status.VolumeGroupSnapshotName = pointer.String(vgs.Name)
vs.Status.VolumeGroupSnapshotName = ptr.To(vgs.Name)
}
}
@@ -1527,12 +1527,12 @@ func TestUpdateVGSCreatedVS(t *testing.T) {
},
},
Status: &snapshotv1api.VolumeSnapshotStatus{
ReadyToUse: pointer.Bool(true),
ReadyToUse: ptr.To(true),
VolumeGroupSnapshotName: vgsNamePtr,
},
Spec: snapshotv1api.VolumeSnapshotSpec{
Source: snapshotv1api.VolumeSnapshotSource{
PersistentVolumeClaimName: pointer.String(pvcName),
PersistentVolumeClaimName: ptr.To(pvcName),
},
},
}
@@ -1547,7 +1547,7 @@ func TestUpdateVGSCreatedVS(t *testing.T) {
}{
{
name: "should update owned VS",
vs: makeVS("vs-owned", true, pointer.String(vgs.Name), "pvc-1"),
vs: makeVS("vs-owned", true, ptr.To(vgs.Name), "pvc-1"),
expectOwnerCleared: true,
expectFinalizersCleared: true,
expectLabelPatched: true,
@@ -1640,7 +1640,7 @@ func TestPatchVGSCDeletionPolicy(t *testing.T) {
Namespace: "ns",
},
Status: &volumegroupsnapshotv1beta2.VolumeGroupSnapshotStatus{
BoundVolumeGroupSnapshotContentName: pointer.String("test-vgsc"),
BoundVolumeGroupSnapshotContentName: ptr.To("test-vgsc"),
},
}
@@ -1695,14 +1695,14 @@ func TestDeleteVGSAndVGSC(t *testing.T) {
}{
{
name: "deletes both VGSC and VGS",
vgs: makeVGS("test-vgs", "ns", pointer.String("test-vgsc")),
vgs: makeVGS("test-vgs", "ns", ptr.To("test-vgsc")),
existingVGSC: makeVGSC("test-vgsc"),
expectVGSCDelete: true,
expectVGSDelete: true,
},
{
name: "VGSC not found, still deletes VGS",
vgs: makeVGS("test-vgs", "ns", pointer.String("missing-vgsc")),
vgs: makeVGS("test-vgs", "ns", ptr.To("missing-vgsc")),
existingVGSC: nil,
expectVGSCDelete: false,
expectVGSDelete: true,
@@ -1768,7 +1768,7 @@ func TestFindExistingVSForBackup(t *testing.T) {
},
Spec: snapshotv1api.VolumeSnapshotSpec{
Source: snapshotv1api.VolumeSnapshotSource{
PersistentVolumeClaimName: pointer.String(pvc),
PersistentVolumeClaimName: ptr.To(pvc),
},
},
}
@@ -2121,7 +2121,7 @@ func TestPVCRequestSize(t *testing.T) {
Name: "testVSC",
},
Status: &snapshotv1api.VolumeSnapshotContentStatus{
RestoreSize: pointer.Int64(rsQty.Value()),
RestoreSize: ptr.To(rsQty.Value()),
},
}
+1 -1
View File
@@ -21,8 +21,8 @@ import (
"fmt"
"time"
cron "github.com/netresearch/go-cron"
"github.com/pkg/errors"
cron "github.com/robfig/cron/v3"
"github.com/sirupsen/logrus"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+6 -6
View File
@@ -20,14 +20,14 @@ import (
"testing"
"time"
cron "github.com/robfig/cron/v3"
cron "github.com/netresearch/go-cron"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
testclocks "k8s.io/utils/clock/testing"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
@@ -94,7 +94,7 @@ func TestReconcileOfSchedule(t *testing.T) {
},
{
name: "schedule with phase New and SkipImmediately gets validated and does not trigger a backup",
schedule: newScheduleBuilder(velerov1.SchedulePhaseNew).CronSchedule("@every 5m").SkipImmediately(pointer.Bool(true)).Result(),
schedule: newScheduleBuilder(velerov1.SchedulePhaseNew).CronSchedule("@every 5m").SkipImmediately(ptr.To(true)).Result(),
fakeClockTime: "2017-01-01 12:00:00",
expectedPhase: string(velerov1.SchedulePhaseEnabled),
expectedLastSkipped: "2017-01-01 12:00:00",
@@ -123,7 +123,7 @@ func TestReconcileOfSchedule(t *testing.T) {
},
{
name: "schedule that's already run but has SkippedImmediately=false gets LastBackup updated",
schedule: newScheduleBuilder(velerov1.SchedulePhaseEnabled).CronSchedule("@every 5m").LastBackupTime("2000-01-01 00:00:00").SkipImmediately(pointer.Bool(false)).Result(),
schedule: newScheduleBuilder(velerov1.SchedulePhaseEnabled).CronSchedule("@every 5m").LastBackupTime("2000-01-01 00:00:00").SkipImmediately(ptr.To(false)).Result(),
fakeClockTime: "2017-01-01 12:00:00",
expectedBackupCreate: builder.ForBackup("ns", "name-20170101120000").ObjectMeta(builder.WithLabels(velerov1.ScheduleNameLabel, "name")).Result(),
expectedLastBackup: "2017-01-01 12:00:00",
@@ -138,7 +138,7 @@ func TestReconcileOfSchedule(t *testing.T) {
},
{
name: "schedule that's already run but has SkippedImmediately=true do not get LastBackup updated",
schedule: newScheduleBuilder(velerov1.SchedulePhaseEnabled).CronSchedule("@every 5m").LastBackupTime("2000-01-01 00:00:00").SkipImmediately(pointer.Bool(true)).Result(),
schedule: newScheduleBuilder(velerov1.SchedulePhaseEnabled).CronSchedule("@every 5m").LastBackupTime("2000-01-01 00:00:00").SkipImmediately(ptr.To(true)).Result(),
fakeClockTime: "2017-01-01 12:00:00",
expectedLastBackup: "2000-01-01 00:00:00",
expectedLastSkipped: "2017-01-01 12:00:00",
@@ -216,7 +216,7 @@ func TestReconcileOfSchedule(t *testing.T) {
// we expect reconcile to flip SkipImmediately to false if it's true or the server is configured to skip immediately and the schedule doesn't have it set
if scheduleb4reconcile.Spec.SkipImmediately != nil && *scheduleb4reconcile.Spec.SkipImmediately ||
test.reconcilerSkipImmediately && scheduleb4reconcile.Spec.SkipImmediately == nil {
assert.Equal(t, schedule.Spec.SkipImmediately, pointer.Bool(false))
assert.Equal(t, schedule.Spec.SkipImmediately, ptr.To(false))
}
backups := &velerov1.BackupList{}
+5 -5
View File
@@ -34,7 +34,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/fake"
clientTesting "k8s.io/client-go/testing"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
clientFake "sigs.k8s.io/controller-runtime/pkg/client/fake"
velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
@@ -1413,7 +1413,7 @@ func Test_csiSnapshotExposer_createBackupPVC(t *testing.T) {
Kind: backup.Kind,
Name: backup.Name,
UID: backup.UID,
Controller: pointer.BoolPtr(true),
Controller: ptr.To(true),
},
},
},
@@ -1424,7 +1424,7 @@ func Test_csiSnapshotExposer_createBackupPVC(t *testing.T) {
VolumeMode: &volumeMode,
DataSource: dataSource,
DataSourceRef: nil,
StorageClassName: pointer.String("fake-storage-class"),
StorageClassName: ptr.To("fake-storage-class"),
Resources: corev1api.VolumeResourceRequirements{
Requests: corev1api.ResourceList{
corev1api.ResourceStorage: resource.MustParse("1Gi"),
@@ -1444,7 +1444,7 @@ func Test_csiSnapshotExposer_createBackupPVC(t *testing.T) {
Kind: backup.Kind,
Name: backup.Name,
UID: backup.UID,
Controller: pointer.BoolPtr(true),
Controller: ptr.To(true),
},
},
},
@@ -1455,7 +1455,7 @@ func Test_csiSnapshotExposer_createBackupPVC(t *testing.T) {
VolumeMode: &volumeMode,
DataSource: dataSource,
DataSourceRef: nil,
StorageClassName: pointer.String("fake-storage-class"),
StorageClassName: ptr.To("fake-storage-class"),
Resources: corev1api.VolumeResourceRequirements{
Requests: corev1api.ResourceList{
corev1api.ResourceStorage: resource.MustParse("1Gi"),