diff --git a/hack/update-fmt.sh b/hack/update-fmt.sh index af589a761..a9d020c30 100755 --- a/hack/update-fmt.sh +++ b/hack/update-fmt.sh @@ -33,7 +33,7 @@ if ! command -v goimports > /dev/null; then exit 1 fi -files="$(find . -type f -name '*.go' -not -path './vendor/*' -not -path './site/*' -not -path './pkg/generated/*' -not -name 'zz_generated*')" +files="$(find . -type f -name '*.go' -not -path './.go/*' -not -path './vendor/*' -not -path './site/*' -not -path '*/generated/*' -not -name 'zz_generated*' -not -path '*/mocks/*')" echo "${ACTION} gofmt" for file in ${files}; do output=$(gofmt "${MODE}" -s "${file}") diff --git a/pkg/backup/delete_helpers.go b/pkg/backup/delete_helpers.go index aa6f55fd4..fa4cbb744 100644 --- a/pkg/backup/delete_helpers.go +++ b/pkg/backup/delete_helpers.go @@ -21,21 +21,21 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" + velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" "github.com/vmware-tanzu/velero/pkg/label" ) // NewDeleteBackupRequest creates a DeleteBackupRequest for the backup identified by name and uid. -func NewDeleteBackupRequest(name string, uid string) *v1.DeleteBackupRequest { - return &v1.DeleteBackupRequest{ +func NewDeleteBackupRequest(name string, uid string) *velerov1api.DeleteBackupRequest { + return &velerov1api.DeleteBackupRequest{ ObjectMeta: metav1.ObjectMeta{ GenerateName: name + "-", Labels: map[string]string{ - v1.BackupNameLabel: label.GetValidName(name), - v1.BackupUIDLabel: uid, + velerov1api.BackupNameLabel: label.GetValidName(name), + velerov1api.BackupUIDLabel: uid, }, }, - Spec: v1.DeleteBackupRequestSpec{ + Spec: velerov1api.DeleteBackupRequestSpec{ BackupName: name, }, } @@ -45,6 +45,6 @@ func NewDeleteBackupRequest(name string, uid string) *v1.DeleteBackupRequest { // find DeleteBackupRequests for the backup identified by name and uid. func NewDeleteBackupRequestListOptions(name, uid string) metav1.ListOptions { return metav1.ListOptions{ - LabelSelector: fmt.Sprintf("%s=%s,%s=%s", v1.BackupNameLabel, label.GetValidName(name), v1.BackupUIDLabel, uid), + LabelSelector: fmt.Sprintf("%s=%s,%s=%s", velerov1api.BackupNameLabel, label.GetValidName(name), velerov1api.BackupUIDLabel, uid), } } diff --git a/pkg/cmd/cli/plugin/add.go b/pkg/cmd/cli/plugin/add.go index 50e7f1f0b..943c240cc 100644 --- a/pkg/cmd/cli/plugin/add.go +++ b/pkg/cmd/cli/plugin/add.go @@ -24,7 +24,7 @@ import ( jsonpatch "github.com/evanphx/json-patch" "github.com/pkg/errors" "github.com/spf13/cobra" - "k8s.io/api/core/v1" + corev1api "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -42,8 +42,8 @@ const ( func NewAddCommand(f client.Factory) *cobra.Command { var ( - imagePullPolicies = []string{string(v1.PullAlways), string(v1.PullIfNotPresent), string(v1.PullNever)} - imagePullPolicyFlag = flag.NewEnum(string(v1.PullIfNotPresent), imagePullPolicies...) + imagePullPolicies = []string{string(corev1api.PullAlways), string(corev1api.PullIfNotPresent), string(corev1api.PullNever)} + imagePullPolicyFlag = flag.NewEnum(string(corev1api.PullIfNotPresent), imagePullPolicies...) ) c := &cobra.Command{ @@ -74,14 +74,14 @@ func NewAddCommand(f client.Factory) *cobra.Command { } if !volumeExists { - volume := v1.Volume{ + volume := corev1api.Volume{ Name: pluginsVolumeName, - VolumeSource: v1.VolumeSource{ - EmptyDir: &v1.EmptyDirVolumeSource{}, + VolumeSource: corev1api.VolumeSource{ + EmptyDir: &corev1api.EmptyDirVolumeSource{}, }, } - volumeMount := v1.VolumeMount{ + volumeMount := corev1api.VolumeMount{ Name: pluginsVolumeName, MountPath: "/plugins", } @@ -105,7 +105,7 @@ func NewAddCommand(f client.Factory) *cobra.Command { } // add the plugin as an init container - plugin := *builder.ForPluginContainer(args[0], v1.PullPolicy(imagePullPolicyFlag.String())).Result() + plugin := *builder.ForPluginContainer(args[0], corev1api.PullPolicy(imagePullPolicyFlag.String())).Result() veleroDeploy.Spec.Template.Spec.InitContainers = append(veleroDeploy.Spec.Template.Spec.InitContainers, plugin) diff --git a/pkg/test/fake_namespace.go b/pkg/test/fake_namespace.go index c0df7e5e5..b14e13696 100644 --- a/pkg/test/fake_namespace.go +++ b/pkg/test/fake_namespace.go @@ -18,7 +18,7 @@ package test import ( "github.com/stretchr/testify/mock" - "k8s.io/api/core/v1" + corev1api "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/watch" @@ -31,14 +31,14 @@ type FakeNamespaceClient struct { var _ corev1.NamespaceInterface = &FakeNamespaceClient{} -func (c *FakeNamespaceClient) List(options metav1.ListOptions) (*v1.NamespaceList, error) { +func (c *FakeNamespaceClient) List(options metav1.ListOptions) (*corev1api.NamespaceList, error) { args := c.Called(options) - return args.Get(0).(*v1.NamespaceList), args.Error(1) + return args.Get(0).(*corev1api.NamespaceList), args.Error(1) } -func (c *FakeNamespaceClient) Create(obj *v1.Namespace) (*v1.Namespace, error) { +func (c *FakeNamespaceClient) Create(obj *corev1api.Namespace) (*corev1api.Namespace, error) { args := c.Called(obj) - return args.Get(0).(*v1.Namespace), args.Error(1) + return args.Get(0).(*corev1api.Namespace), args.Error(1) } func (c *FakeNamespaceClient) Watch(options metav1.ListOptions) (watch.Interface, error) { @@ -46,14 +46,14 @@ func (c *FakeNamespaceClient) Watch(options metav1.ListOptions) (watch.Interface return args.Get(0).(watch.Interface), args.Error(1) } -func (c *FakeNamespaceClient) Get(name string, opts metav1.GetOptions) (*v1.Namespace, error) { +func (c *FakeNamespaceClient) Get(name string, opts metav1.GetOptions) (*corev1api.Namespace, error) { args := c.Called(name, opts) - return args.Get(0).(*v1.Namespace), args.Error(1) + return args.Get(0).(*corev1api.Namespace), args.Error(1) } -func (c *FakeNamespaceClient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*v1.Namespace, error) { +func (c *FakeNamespaceClient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*corev1api.Namespace, error) { args := c.Called(name, pt, data, subresources) - return args.Get(0).(*v1.Namespace), args.Error(1) + return args.Get(0).(*corev1api.Namespace), args.Error(1) } func (c *FakeNamespaceClient) Delete(name string, opts *metav1.DeleteOptions) error { @@ -61,17 +61,17 @@ func (c *FakeNamespaceClient) Delete(name string, opts *metav1.DeleteOptions) er return args.Error(1) } -func (c *FakeNamespaceClient) Finalize(item *v1.Namespace) (*v1.Namespace, error) { +func (c *FakeNamespaceClient) Finalize(item *corev1api.Namespace) (*corev1api.Namespace, error) { args := c.Called(item) - return args.Get(0).(*v1.Namespace), args.Error(1) + return args.Get(0).(*corev1api.Namespace), args.Error(1) } -func (c *FakeNamespaceClient) Update(namespace *v1.Namespace) (*v1.Namespace, error) { +func (c *FakeNamespaceClient) Update(namespace *corev1api.Namespace) (*corev1api.Namespace, error) { args := c.Called(namespace) - return args.Get(0).(*v1.Namespace), args.Error(1) + return args.Get(0).(*corev1api.Namespace), args.Error(1) } -func (c *FakeNamespaceClient) UpdateStatus(namespace *v1.Namespace) (*v1.Namespace, error) { +func (c *FakeNamespaceClient) UpdateStatus(namespace *corev1api.Namespace) (*corev1api.Namespace, error) { args := c.Called(namespace) - return args.Get(0).(*v1.Namespace), args.Error(1) + return args.Get(0).(*corev1api.Namespace), args.Error(1) }