Fix for issues caught by go-lint (#327)

Error list visible [here](https://github.com/alcionai/corso/actions/runs/2653381666)
This commit is contained in:
Vaibhav Kamra 2022-07-12 10:19:32 -07:00 committed by GitHub
parent 80db9a56c7
commit efe4319080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 13 deletions

View File

@ -36,7 +36,7 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
case detailsCommand: case detailsCommand:
c, fs = utils.AddCommand(parent, exchangeDetailsCmd) c, fs = utils.AddCommand(parent, exchangeDetailsCmd)
fs.StringVar(&backupDetailsID, "backup-details", "", "ID of the backup details to be shown.") fs.StringVar(&backupDetailsID, "backup-details", "", "ID of the backup details to be shown.")
c.MarkFlagRequired("backup-details") cobra.CheckErr(c.MarkFlagRequired("backup-details"))
} }
return c return c
} }

View File

@ -65,7 +65,9 @@ func Handle() {
restore.AddCommands(corsoCmd) restore.AddCommands(corsoCmd)
ctx, log := logger.Seed(context.Background()) ctx, log := logger.Seed(context.Background())
defer log.Sync() // flush all logs in the buffer defer func() {
_ = log.Sync() // flush all logs in the buffer
}()
if err := corsoCmd.ExecuteContext(ctx); err != nil { if err := corsoCmd.ExecuteContext(ctx); err != nil {
fmt.Println(err) fmt.Println(err)

View File

@ -26,14 +26,14 @@ var repoCmd = &cobra.Command{
Use: "repo", Use: "repo",
Short: "Manage your repositories", Short: "Manage your repositories",
Long: `Initialize, configure, and connect to your account backup repositories.`, Long: `Initialize, configure, and connect to your account backup repositories.`,
Run: handleRepoCmd, RunE: handleRepoCmd,
Args: cobra.NoArgs, Args: cobra.NoArgs,
} }
// Handler for flat calls to `corso repo`. // Handler for flat calls to `corso repo`.
// Produces the same output as `corso repo --help`. // Produces the same output as `corso repo --help`.
func handleRepoCmd(cmd *cobra.Command, args []string) { func handleRepoCmd(cmd *cobra.Command, args []string) error {
cmd.Help() return cmd.Help()
} }
// The repo init subcommand. // The repo init subcommand.

View File

@ -38,7 +38,7 @@ func addS3Commands(parent *cobra.Command) *cobra.Command {
} }
fs.StringVar(&accessKey, "access-key", "", "Access key ID (replaces the AWS_ACCESS_KEY_ID env variable).") fs.StringVar(&accessKey, "access-key", "", "Access key ID (replaces the AWS_ACCESS_KEY_ID env variable).")
fs.StringVar(&bucket, "bucket", "", "Name of the S3 bucket (required).") fs.StringVar(&bucket, "bucket", "", "Name of the S3 bucket (required).")
c.MarkFlagRequired("bucket") cobra.CheckErr(c.MarkFlagRequired("bucket"))
fs.StringVar(&endpoint, "endpoint", "s3.amazonaws.com", "Server endpoint for S3 communication.") fs.StringVar(&endpoint, "endpoint", "s3.amazonaws.com", "Server endpoint for S3 communication.")
fs.StringVar(&prefix, "prefix", "", "Prefix applied to objects in the bucket.") fs.StringVar(&prefix, "prefix", "", "Prefix applied to objects in the bucket.")
return c return c

View File

@ -34,7 +34,7 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
fs.StringVar(&folder, "folder", "", "Name of the mail folder being restored") fs.StringVar(&folder, "folder", "", "Name of the mail folder being restored")
fs.StringVar(&mail, "mail", "", "ID of the mail message being restored") fs.StringVar(&mail, "mail", "", "ID of the mail message being restored")
fs.StringVar(&backupID, "backup", "", "ID of the backup to restore") fs.StringVar(&backupID, "backup", "", "ID of the backup to restore")
c.MarkFlagRequired("backup") cobra.CheckErr(c.MarkFlagRequired("backup"))
fs.StringVar(&user, "user", "", "ID of the user whose exchange data will get restored") fs.StringVar(&user, "user", "", "ID of the user whose exchange data will get restored")
} }
return c return c

View File

@ -25,12 +25,12 @@ var restoreCmd = &cobra.Command{
Use: restoreCommand, Use: restoreCommand,
Short: "Restore your service data", Short: "Restore your service data",
Long: `Restore the data stored in one of your M365 services.`, Long: `Restore the data stored in one of your M365 services.`,
Run: handleRestoreCmd, RunE: handleRestoreCmd,
Args: cobra.NoArgs, Args: cobra.NoArgs,
} }
// Handler for flat calls to `corso restore`. // Handler for flat calls to `corso restore`.
// Produces the same output as `corso restore --help`. // Produces the same output as `corso restore --help`.
func handleRestoreCmd(cmd *cobra.Command, args []string) { func handleRestoreCmd(cmd *cobra.Command, args []string) error {
cmd.Help() return cmd.Help()
} }

View File

@ -35,7 +35,7 @@ func CloseRepo(ctx context.Context, r *repository.Repository) {
// (ex: corso backup restore exchange) is expected to no-op. // (ex: corso backup restore exchange) is expected to no-op.
func HasNoFlagsAndShownHelp(cmd *cobra.Command) bool { func HasNoFlagsAndShownHelp(cmd *cobra.Command) bool {
if cmd.Flags().NFlag() == 0 { if cmd.Flags().NFlag() == 0 {
cmd.Help() cobra.CheckErr(cmd.Help())
return true return true
} }
return false return false

View File

@ -86,7 +86,7 @@ func (suite *WrapperIntegrationSuite) TestCloseAfterWrap() {
k, err := openKopiaRepo(t, ctx) k, err := openKopiaRepo(t, ctx)
require.NoError(t, err) require.NoError(t, err)
k.wrap() require.NoError(t, k.wrap())
assert.Equal(t, 2, k.refCount) assert.Equal(t, 2, k.refCount)

View File

@ -16,7 +16,7 @@ func TestEnvvarsSuite(t *testing.T) {
suite.Run(t, new(EnvvarsTestSuite)) suite.Run(t, new(EnvvarsTestSuite))
} }
func (suite EnvvarsTestSuite) TestRunOnAny() { func (suite *EnvvarsTestSuite) TestRunOnAny() {
env_variable := "TEST_ENVVARS_SUITE" env_variable := "TEST_ENVVARS_SUITE"
os.Setenv(env_variable, "1") os.Setenv(env_variable, "1")
table := []struct { table := []struct {