Enable linter revive and resolve found errors: part 1

Signed-off-by: Xun Jiang <blackpiglet@gmail.com>
This commit is contained in:
Xun Jiang
2023-04-25 23:15:15 +08:00
parent a0b0b7cd9b
commit 180cc4e31d
40 changed files with 150 additions and 171 deletions
+9 -9
View File
@@ -40,8 +40,8 @@ import (
kubeutil "github.com/vmware-tanzu/velero/pkg/util/kube"
)
// InstallOptions collects all the options for installing Velero into a Kubernetes cluster.
type InstallOptions struct {
// Options collects all the options for installing Velero into a Kubernetes cluster.
type Options struct {
Namespace string
Image string
BucketName string
@@ -82,7 +82,7 @@ type InstallOptions struct {
}
// BindFlags adds command line values to the options struct.
func (o *InstallOptions) BindFlags(flags *pflag.FlagSet) {
func (o *Options) BindFlags(flags *pflag.FlagSet) {
flags.StringVar(&o.ProviderName, "provider", o.ProviderName, "Provider name for backup and volume storage")
flags.StringVar(&o.BucketName, "bucket", o.BucketName, "Name of the object storage bucket where backups should be stored")
flags.StringVar(&o.SecretFile, "secret-file", o.SecretFile, "File containing credentials for backup and volume provider. If not specified, --no-secret must be used for confirmation. Optional.")
@@ -121,8 +121,8 @@ func (o *InstallOptions) BindFlags(flags *pflag.FlagSet) {
}
// NewInstallOptions instantiates a new, default InstallOptions struct.
func NewInstallOptions() *InstallOptions {
return &InstallOptions{
func NewInstallOptions() *Options {
return &Options{
Namespace: velerov1api.DefaultNamespace,
Image: velero.DefaultVeleroImage(),
BackupStorageConfig: flag.NewMap(),
@@ -148,7 +148,7 @@ func NewInstallOptions() *InstallOptions {
}
// AsVeleroOptions translates the values provided at the command line into values used to instantiate Kubernetes resources
func (o *InstallOptions) AsVeleroOptions() (*install.VeleroOptions, error) {
func (o *Options) AsVeleroOptions() (*install.VeleroOptions, error) {
var secretData []byte
if o.SecretFile != "" && !o.NoSecret {
realPath, err := filepath.Abs(o.SecretFile)
@@ -264,7 +264,7 @@ This is useful as a starting point for more customized installations.
}
// Run executes a command in the context of the provided arguments.
func (o *InstallOptions) Run(c *cobra.Command, f client.Factory) error {
func (o *Options) Run(c *cobra.Command, f client.Factory) error {
var resources *unstructured.UnstructuredList
if o.CRDsOnly {
resources = install.AllCRDs()
@@ -327,13 +327,13 @@ func (o *InstallOptions) Run(c *cobra.Command, f client.Factory) error {
}
// Complete completes options for a command.
func (o *InstallOptions) Complete(args []string, f client.Factory) error {
func (o *Options) Complete(args []string, f client.Factory) error {
o.Namespace = f.Namespace()
return nil
}
// Validate validates options provided to a command.
func (o *InstallOptions) Validate(c *cobra.Command, args []string, f client.Factory) error {
func (o *Options) Validate(c *cobra.Command, args []string, f client.Factory) error {
if err := output.ValidateFlags(c); err != nil {
return err
}
+2 -2
View File
@@ -311,7 +311,7 @@ func (s *nodeAgentServer) markInProgressPVBsFailed(client ctrlclient.Client) {
continue
}
if err := controller.UpdatePVBStatusToFailed(client, s.ctx, &pvbs.Items[i],
if err := controller.UpdatePVBStatusToFailed(s.ctx, client, &pvbs.Items[i],
fmt.Sprintf("get a podvolumebackup with status %q during the server starting, mark it as %q", velerov1api.PodVolumeBackupPhaseInProgress, velerov1api.PodVolumeBackupPhaseFailed),
time.Now()); err != nil {
s.logger.WithError(errors.WithStack(err)).Errorf("failed to patch podvolumebackup %q", pvb.GetName())
@@ -347,7 +347,7 @@ func (s *nodeAgentServer) markInProgressPVRsFailed(client ctrlclient.Client) {
continue
}
if err := controller.UpdatePVRStatusToFailed(client, s.ctx, &pvrs.Items[i],
if err := controller.UpdatePVRStatusToFailed(s.ctx, client, &pvrs.Items[i],
fmt.Sprintf("get a podvolumerestore with status %q during the server starting, mark it as %q", velerov1api.PodVolumeRestorePhaseInProgress, velerov1api.PodVolumeRestorePhaseFailed),
time.Now()); err != nil {
s.logger.WithError(errors.WithStack(err)).Errorf("failed to patch podvolumerestore %q", pvr.GetName())
+1 -1
View File
@@ -28,7 +28,7 @@ import (
"github.com/vmware-tanzu/velero/pkg/builder"
)
type ServerStatusGetter interface {
type Getter interface {
GetServerStatus(kbClient kbclient.Client) (*velerov1api.ServerStatusRequest, error)
}
+1 -1
View File
@@ -65,7 +65,7 @@ func NewCommand(f client.Factory) *cobra.Command {
return c
}
func printVersion(w io.Writer, clientOnly bool, kbClient kbclient.Client, serverStatusGetter serverstatus.ServerStatusGetter) {
func printVersion(w io.Writer, clientOnly bool, kbClient kbclient.Client, serverStatusGetter serverstatus.Getter) {
fmt.Fprintln(w, "Client:")
fmt.Fprintf(w, "\tVersion: %s\n", buildinfo.Version)
fmt.Fprintf(w, "\tGit commit: %s\n", buildinfo.FormattedGitSHA())