diff --git a/.gitignore b/.gitignore index 4e5d868..166e791 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ key.* completions *.csv +.idea diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..da2495e --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,101 @@ +linters-settings: + depguard: + rules: + main: + deny: + - pkg: "io/ioutil" + # https://go.dev/doc/go1.16#ioutil + desc: io/ioutil package has been deprecated. + dupl: + threshold: 100 + funlen: + lines: 100 + statements: 50 + gci: + sections: + - standard + - default + - prefix(github.com/spacelift-io/backend) + goconst: + min-len: 2 + min-occurrences: 2 + gocritic: + enabled-tags: + - diagnostic + - performance + disabled-checks: + - ifElseChain + - wrapperFunc + - hugeParam + - rangeValCopy + - appendCombine + - commentedOutCode + - sloppyReassign + - filepathJoin + - evalOrder + - equalFold + - returnAfterHttpError + - preferStringWriter + - sprintfQuotedString + - preferFprint + gofmt: + simplify: true + goimports: + local-prefixes: github.com/spacelift-io/backend + govet: + check-shadowing: false + enable: + - nilness + nolintlint: + require-explanation: false # don't require an explanation for nolint directives + require-specific: false # don't require nolint directives to be specific about which linter is being skipped + revive: + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: increment-decrement + - name: var-declaration + - name: package-comments + - name: range + - name: time-naming + - name: errorf + - name: unreachable-code + - name: redefines-builtin-id + staticcheck: + checks: [ "all", "-SA1019"] + + errorlint: + errorf: false + errorf-multi: false + asserts: false + comparison: true + +linters: + disable-all: true + enable: + - asasalint + - bodyclose + - depguard + - errorlint + - gci + - gocheckcompilerdirectives + - gocritic + - gofmt + - goimports + - goprintffuncname + - gosec + - gosimple + - govet + - ineffassign + - makezero + - noctx + - nolintlint + - staticcheck + - revive + - typecheck + - unconvert + - wastedassign + - unparam diff --git a/browserauth/browserauth.go b/browserauth/browserauth.go index 1c5747e..7a9b16b 100644 --- a/browserauth/browserauth.go +++ b/browserauth/browserauth.go @@ -212,13 +212,13 @@ func (h *Handler) extractToken(r *http.Request) error { } // Decrypt the token AES key using our private key - key, err := rsa.DecryptOAEP(sha512.New(), rand.Reader, h.key, []byte(encKey), nil) + key, err := rsa.DecryptOAEP(sha512.New(), rand.Reader, h.key, encKey, nil) if err != nil { return errors.Wrap(err, "could not decrypt key") } // Decrypt the token using the decrypted AES key - jwt, err := internal.DecryptAES(key, []byte(encToken)) + jwt, err := internal.DecryptAES(key, encToken) if err != nil { return errors.Wrap(err, "could not decrypt session token") } diff --git a/client/client.go b/client/client.go index f40ac29..ff6f3ba 100644 --- a/client/client.go +++ b/client/client.go @@ -8,9 +8,8 @@ import ( "strings" "github.com/shurcooL/graphql" - "golang.org/x/oauth2" - "github.com/spacelift-io/spacectl/client/session" + "golang.org/x/oauth2" ) type client struct { diff --git a/client/session/from_environment.go b/client/session/from_environment.go index 79ff3ac..584fdae 100644 --- a/client/session/from_environment.go +++ b/client/session/from_environment.go @@ -17,11 +17,11 @@ const ( // EnvSpaceliftAPIKeyEndpoint represents the name of the environment variable // pointing to the Spacelift API endpoint. - EnvSpaceliftAPIKeyEndpoint = "SPACELIFT_API_KEY_ENDPOINT" + EnvSpaceliftAPIKeyEndpoint = "SPACELIFT_API_KEY_ENDPOINT" //nolint: gosec // EnvSpaceliftAPIKeyID represents the name of the environment variable // pointing to the Spacelift API key ID. - EnvSpaceliftAPIKeyID = "SPACELIFT_API_KEY_ID" + EnvSpaceliftAPIKeyID = "SPACELIFT_API_KEY_ID" //nolint: gosec // EnvSpaceliftAPIKeySecret represents the name of the environment variable // pointing to the Spacelift API key secret. diff --git a/client/session/profile_manager_test.go b/client/session/profile_manager_test.go index 10db044..0445cbc 100644 --- a/client/session/profile_manager_test.go +++ b/client/session/profile_manager_test.go @@ -8,14 +8,13 @@ import ( "testing" "github.com/franela/goblin" - . "github.com/onsi/gomega" - + "github.com/onsi/gomega" "github.com/spacelift-io/spacectl/client/session" ) func TestProfileManager(t *testing.T) { g := goblin.Goblin(t) - RegisterFailHandler(func(m string, _ ...int) { g.Fail(m) }) + gomega.RegisterFailHandler(func(m string, _ ...int) { g.Fail(m) }) g.Describe("ProfileManager", func() { var testDirectory string @@ -44,7 +43,7 @@ func TestProfileManager(t *testing.T) { g.Describe("NewProfileManager", func() { g.Describe("profiles directory doesn't exist", func() { g.It("creates directory", func() { - Expect(profilesDirectory).Should(BeADirectory()) + gomega.Expect(profilesDirectory).Should(gomega.BeADirectory()) }) }) @@ -52,12 +51,12 @@ func TestProfileManager(t *testing.T) { g.It("initializes profiles map", func() { configFilename := path.Join(profilesDirectory, session.ConfigFileName) err := os.WriteFile(configFilename, []byte("{}"), 0600) - Expect(err).ShouldNot(HaveOccurred()) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) manager, err = session.NewProfileManager(profilesDirectory) - Expect(err).ShouldNot(HaveOccurred()) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) - Expect(manager.Configuration.Profiles).ToNot(BeNil()) + gomega.Expect(manager.Configuration.Profiles).ToNot(gomega.BeNil()) }) }) }) @@ -67,7 +66,7 @@ func TestProfileManager(t *testing.T) { g.It("returns nil", func() { profile := manager.Current() - Expect(profile).To(BeNil()) + gomega.Expect(profile).To(gomega.BeNil()) }) }) }) @@ -84,12 +83,12 @@ func TestProfileManager(t *testing.T) { } err := manager.Create(testProfile) - Expect(err).To(BeNil()) + gomega.Expect(err).To(gomega.BeNil()) currentProfile := manager.Current() - Expect(currentProfile).NotTo(BeNil()) - Expect(currentProfile.Alias).To(Equal(testProfile.Alias)) + gomega.Expect(currentProfile).NotTo(gomega.BeNil()) + gomega.Expect(currentProfile.Alias).To(gomega.Equal(testProfile.Alias)) }) g.It("rejects invalid credential types", func() { @@ -104,7 +103,7 @@ func TestProfileManager(t *testing.T) { err := manager.Create(testProfile) - Expect(err).Should(MatchError(fmt.Sprintf("'%d' is an invalid credential type", credentialType))) + gomega.Expect(err).Should(gomega.MatchError(fmt.Sprintf("'%d' is an invalid credential type", credentialType))) }) g.Describe("All credential types", func() { @@ -114,7 +113,7 @@ func TestProfileManager(t *testing.T) { err := manager.Create(testProfile) - Expect(err).Should(MatchError("'Endpoint' must be provided")) + gomega.Expect(err).Should(gomega.MatchError("'Endpoint' must be provided")) }) } }) @@ -129,15 +128,15 @@ func TestProfileManager(t *testing.T) { } err := manager.Create(testProfile) - Expect(err).To(BeNil()) + gomega.Expect(err).To(gomega.BeNil()) savedProfile, err := manager.Get(testProfile.Alias) - Expect(err).To(BeNil()) - Expect(savedProfile).ToNot(BeNil()) - Expect(savedProfile.Credentials.Type).To(Equal(testProfile.Credentials.Type)) - Expect(savedProfile.Credentials.Endpoint).To(Equal(testProfile.Credentials.Endpoint)) - Expect(savedProfile.Credentials.AccessToken).To(Equal(testProfile.Credentials.AccessToken)) + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(savedProfile).ToNot(gomega.BeNil()) + gomega.Expect(savedProfile.Credentials.Type).To(gomega.Equal(testProfile.Credentials.Type)) + gomega.Expect(savedProfile.Credentials.Endpoint).To(gomega.Equal(testProfile.Credentials.Endpoint)) + gomega.Expect(savedProfile.Credentials.AccessToken).To(gomega.Equal(testProfile.Credentials.AccessToken)) }) g.It("rejects GitHub credentials if no access token is specified", func() { @@ -151,7 +150,7 @@ func TestProfileManager(t *testing.T) { err := manager.Create(testProfile) - Expect(err).Should(MatchError("'AccessToken' must be provided for GitHub token credentials")) + gomega.Expect(err).Should(gomega.MatchError("'AccessToken' must be provided for GitHub token credentials")) }) }) @@ -165,16 +164,16 @@ func TestProfileManager(t *testing.T) { } err := manager.Create(testProfile) - Expect(err).To(BeNil()) + gomega.Expect(err).To(gomega.BeNil()) savedProfile, err := manager.Get(testProfile.Alias) - Expect(err).To(BeNil()) - Expect(savedProfile).ToNot(BeNil()) - Expect(savedProfile.Credentials.Type).To(Equal(testProfile.Credentials.Type)) - Expect(savedProfile.Credentials.Endpoint).To(Equal(testProfile.Credentials.Endpoint)) - Expect(savedProfile.Credentials.KeyID).To(Equal(testProfile.Credentials.KeyID)) - Expect(savedProfile.Credentials.KeySecret).To(Equal(testProfile.Credentials.KeySecret)) + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(savedProfile).ToNot(gomega.BeNil()) + gomega.Expect(savedProfile.Credentials.Type).To(gomega.Equal(testProfile.Credentials.Type)) + gomega.Expect(savedProfile.Credentials.Endpoint).To(gomega.Equal(testProfile.Credentials.Endpoint)) + gomega.Expect(savedProfile.Credentials.KeyID).To(gomega.Equal(testProfile.Credentials.KeyID)) + gomega.Expect(savedProfile.Credentials.KeySecret).To(gomega.Equal(testProfile.Credentials.KeySecret)) }) g.It("rejects credentials if no KeyID is specified", func() { @@ -189,7 +188,7 @@ func TestProfileManager(t *testing.T) { err := manager.Create(testProfile) - Expect(err).Should(MatchError("'KeyID' must be provided for API Key credentials")) + gomega.Expect(err).Should(gomega.MatchError("'KeyID' must be provided for API Key credentials")) }) g.It("rejects credentials if no KeySecret is specified", func() { @@ -204,20 +203,20 @@ func TestProfileManager(t *testing.T) { err := manager.Create(testProfile) - Expect(err).Should(MatchError("'KeySecret' must be provided for API Key credentials")) + gomega.Expect(err).Should(gomega.MatchError("'KeySecret' must be provided for API Key credentials")) }) }) g.It("fails if profile alias is not specified", func() { err := manager.Create(&session.Profile{Alias: ""}) - Expect(err).Should(MatchError("a profile alias must be specified")) + gomega.Expect(err).Should(gomega.MatchError("a profile alias must be specified")) }) g.It("fails if profile is nil", func() { err := manager.Create(nil) - Expect(err).Should(MatchError("profile must not be nil")) + gomega.Expect(err).Should(gomega.MatchError("profile must not be nil")) }) g.It("rejects invalid profile aliases", func() { @@ -233,7 +232,7 @@ func TestProfileManager(t *testing.T) { testProfile := createValidProfile(profileAlias) err := manager.Create(testProfile) - Expect(err).Should(MatchError(fmt.Sprintf("'%s' is not a valid profile alias", profileAlias))) + gomega.Expect(err).Should(gomega.MatchError(fmt.Sprintf("'%s' is not a valid profile alias", profileAlias))) } }) }) @@ -241,42 +240,42 @@ func TestProfileManager(t *testing.T) { g.Describe("Get", func() { g.It("can get a profile", func() { profileAlias := "test-profile" - Expect(manager.Create(&session.Profile{ + gomega.Expect(manager.Create(&session.Profile{ Alias: profileAlias, Credentials: createValidGitHubCredentials(), - })).To(Succeed()) + })).To(gomega.Succeed()) testProfile, err := manager.Get(profileAlias) - Expect(err).To(BeNil()) - Expect(testProfile.Alias).To(Equal(profileAlias)) + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(testProfile.Alias).To(gomega.Equal(profileAlias)) }) g.It("returns nil if profile does not exist", func() { profileAlias := "non-existent" profile, err := manager.Get(profileAlias) - Expect(err).Should(BeNil()) - Expect(profile).Should(BeNil()) + gomega.Expect(err).Should(gomega.BeNil()) + gomega.Expect(profile).Should(gomega.BeNil()) }) g.It("returns error if profile alias is empty", func() { _, err := manager.Get("") - Expect(err).Should(MatchError("a profile alias must be specified")) + gomega.Expect(err).Should(gomega.MatchError("a profile alias must be specified")) }) }) g.Describe("Select", func() { g.It("can set the current profile", func() { - Expect(manager.Create(createValidProfile("profile1"))).To(Succeed()) - Expect(manager.Create(createValidProfile("profile2"))).To(Succeed()) + gomega.Expect(manager.Create(createValidProfile("profile1"))).To(gomega.Succeed()) + gomega.Expect(manager.Create(createValidProfile("profile2"))).To(gomega.Succeed()) - Expect(manager.Select("profile1")).To(Succeed()) + gomega.Expect(manager.Select("profile1")).To(gomega.Succeed()) currentProfile := manager.Current() - Expect(currentProfile).NotTo(BeNil()) - Expect(currentProfile.Alias).To(Equal("profile1")) + gomega.Expect(currentProfile).NotTo(gomega.BeNil()) + gomega.Expect(currentProfile.Alias).To(gomega.Equal("profile1")) }) g.It("returns error if profile to select does not exist", func() { @@ -284,51 +283,51 @@ func TestProfileManager(t *testing.T) { err := manager.Select(profileAlias) - Expect(err).Should(MatchError(fmt.Sprintf("could not find a profile named '%s'", "non-existent"))) + gomega.Expect(err).Should(gomega.MatchError(fmt.Sprintf("could not find a profile named '%s'", "non-existent"))) }) }) g.Describe("Delete", func() { g.It("can delete a profile", func() { - Expect(manager.Create(createValidProfile("profile1"))).To(Succeed()) + gomega.Expect(manager.Create(createValidProfile("profile1"))).To(gomega.Succeed()) - Expect(manager.Delete("profile1")).To(Succeed()) + gomega.Expect(manager.Delete("profile1")).To(gomega.Succeed()) profile, err := manager.Get("profile1") - Expect(err).To(BeNil()) - Expect(profile).To(BeNil()) + gomega.Expect(err).To(gomega.BeNil()) + gomega.Expect(profile).To(gomega.BeNil()) }) g.It("returns error if profile does not exist", func() { err := manager.Delete("non-existent") - Expect(err).Should(MatchError(fmt.Sprintf("no profile named '%s' exists", "non-existent"))) + gomega.Expect(err).Should(gomega.MatchError(fmt.Sprintf("no profile named '%s' exists", "non-existent"))) }) g.It("returns error if profile alias is empty", func() { err := manager.Delete("") - Expect(err).Should(MatchError("a profile alias must be specified")) + gomega.Expect(err).Should(gomega.MatchError("a profile alias must be specified")) }) g.It("unsets profile if it is the current profile", func() { - Expect(manager.Create(createValidProfile("profile1"))).To(Succeed()) + gomega.Expect(manager.Create(createValidProfile("profile1"))).To(gomega.Succeed()) - Expect(manager.Delete("profile1")).To(Succeed()) + gomega.Expect(manager.Delete("profile1")).To(gomega.Succeed()) current := manager.Current() - Expect(current).To(BeNil()) + gomega.Expect(current).To(gomega.BeNil()) }) g.It("does not unset profile if it is not the current profile", func() { - Expect(manager.Create(createValidProfile("profile1"))).To(Succeed()) - Expect(manager.Create(createValidProfile("profile2"))).To(Succeed()) + gomega.Expect(manager.Create(createValidProfile("profile1"))).To(gomega.Succeed()) + gomega.Expect(manager.Create(createValidProfile("profile2"))).To(gomega.Succeed()) - Expect(manager.Delete("profile1")).To(Succeed()) + gomega.Expect(manager.Delete("profile1")).To(gomega.Succeed()) current := manager.Current() - Expect(current).NotTo(BeNil()) - Expect(current.Alias).To(Equal("profile2")) + gomega.Expect(current).NotTo(gomega.BeNil()) + gomega.Expect(current.Alias).To(gomega.Equal("profile2")) }) }) @@ -336,13 +335,13 @@ func TestProfileManager(t *testing.T) { g.It("returns empty when no profiles exist", func() { profiles := manager.GetAll() - Expect(profiles).To(BeEmpty()) + gomega.Expect(profiles).To(gomega.BeEmpty()) }) g.It("returns all profiles", func() { - Expect(manager.Create(createValidProfile("profile-1"))).To(Succeed()) - Expect(manager.Create(createValidProfile("profile-2"))).To(Succeed()) - Expect(manager.Create(createValidProfile("profile-3"))).To(Succeed()) + gomega.Expect(manager.Create(createValidProfile("profile-1"))).To(gomega.Succeed()) + gomega.Expect(manager.Create(createValidProfile("profile-2"))).To(gomega.Succeed()) + gomega.Expect(manager.Create(createValidProfile("profile-3"))).To(gomega.Succeed()) profiles := manager.GetAll() @@ -351,10 +350,10 @@ func TestProfileManager(t *testing.T) { return profiles[i].Alias < profiles[j].Alias }) - Expect(len(profiles)).To(Equal(3)) - Expect(profiles[0].Alias).To(Equal("profile-1")) - Expect(profiles[1].Alias).To(Equal("profile-2")) - Expect(profiles[2].Alias).To(Equal("profile-3")) + gomega.Expect(len(profiles)).To(gomega.Equal(3)) + gomega.Expect(profiles[0].Alias).To(gomega.Equal("profile-1")) + gomega.Expect(profiles[1].Alias).To(gomega.Equal("profile-2")) + gomega.Expect(profiles[2].Alias).To(gomega.Equal("profile-3")) }) }) }) diff --git a/internal/cmd/authenticated/client.go b/internal/cmd/authenticated/client.go index 8810ef9..7f60838 100644 --- a/internal/cmd/authenticated/client.go +++ b/internal/cmd/authenticated/client.go @@ -7,10 +7,9 @@ import ( "net/http" "os" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/client" "github.com/spacelift-io/spacectl/client/session" + "github.com/urfave/cli/v2" ) const ( diff --git a/internal/cmd/draw/data/workerpools.go b/internal/cmd/draw/data/workerpools.go index fdeabe8..c8247b3 100644 --- a/internal/cmd/draw/data/workerpools.go +++ b/internal/cmd/draw/data/workerpools.go @@ -9,7 +9,6 @@ import ( "github.com/pkg/browser" "github.com/pkg/errors" "github.com/shurcooL/graphql" - "github.com/spacelift-io/spacectl/client/structs" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" ) diff --git a/internal/cmd/module/create_version.go b/internal/cmd/module/create_version.go index d4ec993..417dab0 100644 --- a/internal/cmd/module/create_version.go +++ b/internal/cmd/module/create_version.go @@ -4,9 +4,8 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func createVersion(cliCtx *cli.Context) error { diff --git a/internal/cmd/module/list.go b/internal/cmd/module/list.go index 1ca8e71..12ba768 100644 --- a/internal/cmd/module/list.go +++ b/internal/cmd/module/list.go @@ -7,10 +7,9 @@ import ( "strings" "github.com/pkg/errors" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func listModules() cli.ActionFunc { diff --git a/internal/cmd/module/local_preview.go b/internal/cmd/module/local_preview.go index b55fb19..f617723 100644 --- a/internal/cmd/module/local_preview.go +++ b/internal/cmd/module/local_preview.go @@ -14,11 +14,10 @@ import ( "github.com/charmbracelet/lipgloss" "github.com/mholt/archiver/v3" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "golang.org/x/sync/errgroup" - "github.com/spacelift-io/spacectl/internal" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" + "golang.org/x/sync/errgroup" ) func localPreview() cli.ActionFunc { diff --git a/internal/cmd/module/module.go b/internal/cmd/module/module.go index 83aea0a..bf6c8ab 100644 --- a/internal/cmd/module/module.go +++ b/internal/cmd/module/module.go @@ -1,10 +1,9 @@ package module import ( - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) // Command encapsulates the module command subtree. diff --git a/internal/cmd/module/search_version.go b/internal/cmd/module/search_version.go index 177af14..26761e2 100644 --- a/internal/cmd/module/search_version.go +++ b/internal/cmd/module/search_version.go @@ -5,10 +5,9 @@ import ( "github.com/pkg/errors" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func listVersions() cli.ActionFunc { diff --git a/internal/cmd/profile/export_token.go b/internal/cmd/profile/export_token.go index a5c59fd..02dacb5 100644 --- a/internal/cmd/profile/export_token.go +++ b/internal/cmd/profile/export_token.go @@ -5,9 +5,8 @@ import ( "fmt" "net/http" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" + "github.com/urfave/cli/v2" ) func exportTokenCommand() *cli.Command { diff --git a/internal/cmd/profile/flags.go b/internal/cmd/profile/flags.go index aa3372b..22c91aa 100644 --- a/internal/cmd/profile/flags.go +++ b/internal/cmd/profile/flags.go @@ -4,9 +4,8 @@ import ( "fmt" "time" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/client/session" + "github.com/urfave/cli/v2" ) var bindHost string diff --git a/internal/cmd/profile/list_command.go b/internal/cmd/profile/list_command.go index 7697311..8f32b67 100644 --- a/internal/cmd/profile/list_command.go +++ b/internal/cmd/profile/list_command.go @@ -4,10 +4,9 @@ import ( "fmt" "sort" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/client/session" "github.com/spacelift-io/spacectl/internal/cmd" + "github.com/urfave/cli/v2" ) type profileListOutput struct { diff --git a/internal/cmd/profile/login_command.go b/internal/cmd/profile/login_command.go index 9480e9d..12c9b26 100644 --- a/internal/cmd/profile/login_command.go +++ b/internal/cmd/profile/login_command.go @@ -13,11 +13,10 @@ import ( "github.com/manifoldco/promptui" "github.com/pkg/browser" "github.com/pkg/errors" - "github.com/urfave/cli/v2" - "golang.org/x/term" - "github.com/spacelift-io/spacectl/browserauth" "github.com/spacelift-io/spacectl/client/session" + "github.com/urfave/cli/v2" + "golang.org/x/term" ) func loginCommand() *cli.Command { @@ -88,7 +87,7 @@ func loginAction(ctx *cli.Context) error { func getCredentialsType(ctx *cli.Context) (session.CredentialsType, error) { if ctx.IsSet(flagMethod.Name) { got := methodToCredentialsType[ctx.String(flagMethod.Name)] - return session.CredentialsType(got), nil + return got, nil } prompt := promptui.Select{ @@ -143,7 +142,7 @@ func loginUsingAPIKey(reader *bufio.Reader, creds *session.StoredCredentials) er creds.KeyID = strings.TrimSpace(keyID) fmt.Print("Enter API key secret: ") - keySecret, err := term.ReadPassword(int(syscall.Stdin)) + keySecret, err := term.ReadPassword(int(syscall.Stdin)) //nolint: unconvert if err != nil { return err } @@ -157,7 +156,7 @@ func loginUsingAPIKey(reader *bufio.Reader, creds *session.StoredCredentials) er func loginUsingGitHubAccessToken(creds *session.StoredCredentials) error { fmt.Print("Enter GitHub access token: ") - accessToken, err := term.ReadPassword(int(syscall.Stdin)) + accessToken, err := term.ReadPassword(int(syscall.Stdin)) //nolint: unconvert if err != nil { return err } @@ -168,7 +167,7 @@ func loginUsingGitHubAccessToken(creds *session.StoredCredentials) error { return nil } -func loginUsingWebBrowser(ctx *cli.Context, creds *session.StoredCredentials) error { +func loginUsingWebBrowser(_ *cli.Context, creds *session.StoredCredentials) error { // Begin the interactive browser auth flow handler, err := browserauth.BeginWithBindAddress(creds, bindHost, bindPort) if err != nil { diff --git a/internal/cmd/profile/profile.go b/internal/cmd/profile/profile.go index f3ecd2e..0566d75 100644 --- a/internal/cmd/profile/profile.go +++ b/internal/cmd/profile/profile.go @@ -3,9 +3,8 @@ package profile import ( "fmt" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/client/session" + "github.com/urfave/cli/v2" ) var ( diff --git a/internal/cmd/profile/usage_view_csv_command.go b/internal/cmd/profile/usage_view_csv_command.go index 6b14c3a..9d4119e 100644 --- a/internal/cmd/profile/usage_view_csv_command.go +++ b/internal/cmd/profile/usage_view_csv_command.go @@ -8,10 +8,9 @@ import ( "os" "path/filepath" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func usageViewCSVCommand() *cli.Command { diff --git a/internal/cmd/provider/add_gpg_key.go b/internal/cmd/provider/add_gpg_key.go index aba84c3..2525834 100644 --- a/internal/cmd/provider/add_gpg_key.go +++ b/internal/cmd/provider/add_gpg_key.go @@ -6,10 +6,9 @@ import ( "github.com/ProtonMail/gopenpgp/v2/crypto" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" "github.com/spacelift-io/spacectl/internal/cmd/provider/internal" + "github.com/urfave/cli/v2" ) func addGPGKey() cli.ActionFunc { @@ -81,7 +80,7 @@ func generateGPGKey(cliCtx *cli.Context, keyName, keyPath string) (string, error return key.GetArmoredPublicKey() } -func importGPGKey(cliCtx *cli.Context, keyPath string) (string, error) { +func importGPGKey(_ *cli.Context, keyPath string) (string, error) { // #nosec G304 bytes, err := os.ReadFile(keyPath) if err != nil { diff --git a/internal/cmd/provider/create_version.go b/internal/cmd/provider/create_version.go index e1978e3..e8b8059 100644 --- a/internal/cmd/provider/create_version.go +++ b/internal/cmd/provider/create_version.go @@ -6,10 +6,9 @@ import ( "github.com/pkg/errors" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" "github.com/spacelift-io/spacectl/internal/cmd/provider/internal" + "github.com/urfave/cli/v2" ) func createVersion() cli.ActionFunc { diff --git a/internal/cmd/provider/delete_version.go b/internal/cmd/provider/delete_version.go index fc1a7cb..6a9637a 100644 --- a/internal/cmd/provider/delete_version.go +++ b/internal/cmd/provider/delete_version.go @@ -4,10 +4,9 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" "github.com/spacelift-io/spacectl/internal/cmd/provider/internal" + "github.com/urfave/cli/v2" ) func deleteVersion() cli.ActionFunc { diff --git a/internal/cmd/provider/list_gpg_keys.go b/internal/cmd/provider/list_gpg_keys.go index cd0ac24..9cc8b59 100644 --- a/internal/cmd/provider/list_gpg_keys.go +++ b/internal/cmd/provider/list_gpg_keys.go @@ -3,11 +3,10 @@ package provider import ( "fmt" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" "github.com/spacelift-io/spacectl/internal/cmd/provider/internal" + "github.com/urfave/cli/v2" ) func listGPGKeys() cli.ActionFunc { diff --git a/internal/cmd/provider/list_versions.go b/internal/cmd/provider/list_versions.go index 6a13b6c..aa079de 100644 --- a/internal/cmd/provider/list_versions.go +++ b/internal/cmd/provider/list_versions.go @@ -4,11 +4,10 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" "github.com/spacelift-io/spacectl/internal/cmd/provider/internal" + "github.com/urfave/cli/v2" ) func listVersions() cli.ActionFunc { diff --git a/internal/cmd/provider/provider.go b/internal/cmd/provider/provider.go index 2abd9de..7302e22 100644 --- a/internal/cmd/provider/provider.go +++ b/internal/cmd/provider/provider.go @@ -1,10 +1,9 @@ package provider import ( - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) // Command encapsulates the provider command subtree. diff --git a/internal/cmd/provider/publish_version.go b/internal/cmd/provider/publish_version.go index cd6f7c1..bed6862 100644 --- a/internal/cmd/provider/publish_version.go +++ b/internal/cmd/provider/publish_version.go @@ -4,10 +4,9 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" "github.com/spacelift-io/spacectl/internal/cmd/provider/internal" + "github.com/urfave/cli/v2" ) func publishVersion() cli.ActionFunc { diff --git a/internal/cmd/provider/revoke_gpg_key.go b/internal/cmd/provider/revoke_gpg_key.go index e9d0533..79eaf58 100644 --- a/internal/cmd/provider/revoke_gpg_key.go +++ b/internal/cmd/provider/revoke_gpg_key.go @@ -3,10 +3,9 @@ package provider import ( "fmt" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" "github.com/spacelift-io/spacectl/internal/cmd/provider/internal" + "github.com/urfave/cli/v2" ) func revokeGPGKey() cli.ActionFunc { diff --git a/internal/cmd/provider/revoke_version.go b/internal/cmd/provider/revoke_version.go index 19ee0a3..a4db708 100644 --- a/internal/cmd/provider/revoke_version.go +++ b/internal/cmd/provider/revoke_version.go @@ -4,10 +4,9 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" "github.com/spacelift-io/spacectl/internal/cmd/provider/internal" + "github.com/urfave/cli/v2" ) func revokeVersion() cli.ActionFunc { diff --git a/internal/cmd/run_external_dependency/mark_completed.go b/internal/cmd/run_external_dependency/mark_completed.go index 4858189..5d5aae1 100644 --- a/internal/cmd/run_external_dependency/mark_completed.go +++ b/internal/cmd/run_external_dependency/mark_completed.go @@ -5,9 +5,8 @@ import ( "slices" "strings" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func markRunExternalDependencyAsCompleted(cliCtx *cli.Context) error { diff --git a/internal/cmd/run_external_dependency/run_external_dependency.go b/internal/cmd/run_external_dependency/run_external_dependency.go index b35be30..89affd7 100644 --- a/internal/cmd/run_external_dependency/run_external_dependency.go +++ b/internal/cmd/run_external_dependency/run_external_dependency.go @@ -1,10 +1,9 @@ package runexternaldependency import ( - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) // Command encapsulates the run external dependency command subtree. diff --git a/internal/cmd/stack/dependencies.go b/internal/cmd/stack/dependencies.go index ca54080..250b5f8 100644 --- a/internal/cmd/stack/dependencies.go +++ b/internal/cmd/stack/dependencies.go @@ -5,10 +5,9 @@ import ( "github.com/pkg/errors" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func dependenciesOn(cliCtx *cli.Context) error { diff --git a/internal/cmd/stack/environment.go b/internal/cmd/stack/environment.go index 2c80f82..fed1586 100644 --- a/internal/cmd/stack/environment.go +++ b/internal/cmd/stack/environment.go @@ -9,12 +9,10 @@ import ( "strings" "github.com/pkg/errors" - "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) // ConfigType is a type of configuration element. @@ -140,6 +138,7 @@ func (e *listEnvCommand) listEnv(cliCtx *cli.Context) error { var elements []listEnvElementOutput for _, config := range query.Stack.RuntimeConfig { + config := config var contextName *string if config.Context != nil { contextName = &config.Context.ContextName @@ -207,7 +206,7 @@ func (e *configElement) toConfigElementOutput(contextName *string) (listEnvEleme if err != nil { message := fmt.Sprintf("failed to decode base64-encoded file with id %s", e.ID) - return listEnvElementOutput{}, errors.Wrapf(err, message) + return listEnvElementOutput{}, errors.Wrap(err, message) } stringValue := string(result) diff --git a/internal/cmd/stack/environment_test.go b/internal/cmd/stack/environment_test.go index e991c92..19bb4ca 100644 --- a/internal/cmd/stack/environment_test.go +++ b/internal/cmd/stack/environment_test.go @@ -21,6 +21,7 @@ func TestTrimmedValue(t *testing.T) { } for _, testCase := range testTable { + testCase := testCase o := listEnvElementOutput{ Value: &testCase.input, } diff --git a/internal/cmd/stack/list.go b/internal/cmd/stack/list.go index 90b920f..bcaf7b5 100644 --- a/internal/cmd/stack/list.go +++ b/internal/cmd/stack/list.go @@ -7,10 +7,9 @@ import ( "strings" "github.com/pkg/errors" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func listStacks() cli.ActionFunc { diff --git a/internal/cmd/stack/local_preview.go b/internal/cmd/stack/local_preview.go index 183fc2b..65accb8 100644 --- a/internal/cmd/stack/local_preview.go +++ b/internal/cmd/stack/local_preview.go @@ -9,10 +9,9 @@ import ( "github.com/mholt/archiver/v3" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func localPreview() cli.ActionFunc { @@ -34,7 +33,7 @@ func localPreview() cli.ActionFunc { ctx := context.Background() - var packagePath *string = nil + var packagePath *string if cliCtx.Bool(flagProjectRootOnly.Name) { root, err := getGitRepositorySubdir() if err != nil { diff --git a/internal/cmd/stack/open_command.go b/internal/cmd/stack/open_command.go index 3a393c0..807879a 100644 --- a/internal/cmd/stack/open_command.go +++ b/internal/cmd/stack/open_command.go @@ -11,10 +11,9 @@ import ( "github.com/pkg/browser" "github.com/pkg/errors" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/client/structs" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func openCommandInBrowser(cliCtx *cli.Context) error { @@ -202,7 +201,7 @@ func searchStacks(ctx context.Context, p *stackSearchParams) ([]stack, error) { } variables := map[string]interface{}{"input": structs.SearchInput{ - First: graphql.NewInt(graphql.Int(p.count)), + First: graphql.NewInt(graphql.Int(p.count)), //nolint: gosec Predicates: &conditions, }} diff --git a/internal/cmd/stack/outputs.go b/internal/cmd/stack/outputs.go index d7671bc..66e6f51 100644 --- a/internal/cmd/stack/outputs.go +++ b/internal/cmd/stack/outputs.go @@ -6,10 +6,9 @@ import ( "github.com/pkg/errors" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) type output struct { diff --git a/internal/cmd/stack/run_cancel.go b/internal/cmd/stack/run_cancel.go index ef73ba5..295f9d4 100644 --- a/internal/cmd/stack/run_cancel.go +++ b/internal/cmd/stack/run_cancel.go @@ -5,9 +5,8 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func runCancel() cli.ActionFunc { diff --git a/internal/cmd/stack/run_changes.go b/internal/cmd/stack/run_changes.go index 8cdda2c..60a6369 100644 --- a/internal/cmd/stack/run_changes.go +++ b/internal/cmd/stack/run_changes.go @@ -3,10 +3,9 @@ package stack import ( "github.com/pkg/errors" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func runChanges(cliCtx *cli.Context) error { diff --git a/internal/cmd/stack/run_confirm.go b/internal/cmd/stack/run_confirm.go index d8c4694..283d55f 100644 --- a/internal/cmd/stack/run_confirm.go +++ b/internal/cmd/stack/run_confirm.go @@ -5,10 +5,9 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func runConfirm() cli.ActionFunc { diff --git a/internal/cmd/stack/run_discard.go b/internal/cmd/stack/run_discard.go index 1ced6b0..99f41fa 100644 --- a/internal/cmd/stack/run_discard.go +++ b/internal/cmd/stack/run_discard.go @@ -5,9 +5,8 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func runDiscard() cli.ActionFunc { diff --git a/internal/cmd/stack/run_list.go b/internal/cmd/stack/run_list.go index c18f45f..ff2056d 100644 --- a/internal/cmd/stack/run_list.go +++ b/internal/cmd/stack/run_list.go @@ -7,10 +7,9 @@ import ( "time" "github.com/pkg/errors" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func runList(cliCtx *cli.Context) error { diff --git a/internal/cmd/stack/run_logs.go b/internal/cmd/stack/run_logs.go index 17ace7a..fc77a00 100644 --- a/internal/cmd/stack/run_logs.go +++ b/internal/cmd/stack/run_logs.go @@ -7,10 +7,9 @@ import ( "github.com/pkg/errors" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/client/structs" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) // actionOnRunState is a function that can be executed on a run state. @@ -176,7 +175,7 @@ func runStateLogs(ctx context.Context, stack, run string, state structs.RunState "run": graphql.ID(run), "state": state, "token": token, - "stateVersion": graphql.Int(version), + "stateVersion": graphql.Int(version), //nolint: gosec } var backOff time.Duration diff --git a/internal/cmd/stack/run_replan.go b/internal/cmd/stack/run_replan.go index 5b7d550..34d2040 100644 --- a/internal/cmd/stack/run_replan.go +++ b/internal/cmd/stack/run_replan.go @@ -6,9 +6,8 @@ import ( "github.com/manifoldco/promptui" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) const rocketEmoji = "\U0001F680" diff --git a/internal/cmd/stack/run_retry.go b/internal/cmd/stack/run_retry.go index 8023233..f6ab31d 100644 --- a/internal/cmd/stack/run_retry.go +++ b/internal/cmd/stack/run_retry.go @@ -4,9 +4,8 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func runRetry(cliCtx *cli.Context) error { diff --git a/internal/cmd/stack/run_review.go b/internal/cmd/stack/run_review.go index 8d7fa67..6ba82f2 100644 --- a/internal/cmd/stack/run_review.go +++ b/internal/cmd/stack/run_review.go @@ -5,10 +5,9 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/client/enums" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) type runReviewMutation struct { diff --git a/internal/cmd/stack/run_trigger.go b/internal/cmd/stack/run_trigger.go index f6a7dc1..27a5d50 100644 --- a/internal/cmd/stack/run_trigger.go +++ b/internal/cmd/stack/run_trigger.go @@ -5,11 +5,10 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/client/structs" "github.com/spacelift-io/spacectl/internal" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func runTrigger(spaceliftType, humanType string) cli.ActionFunc { diff --git a/internal/cmd/stack/set_current_commit.go b/internal/cmd/stack/set_current_commit.go index 433de07..20aea5a 100644 --- a/internal/cmd/stack/set_current_commit.go +++ b/internal/cmd/stack/set_current_commit.go @@ -6,9 +6,8 @@ import ( "fmt" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func setCurrentCommit(cliCtx *cli.Context) error { diff --git a/internal/cmd/stack/show.go b/internal/cmd/stack/show.go index b7fef66..c86ecfc 100644 --- a/internal/cmd/stack/show.go +++ b/internal/cmd/stack/show.go @@ -8,10 +8,9 @@ import ( "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) const ( diff --git a/internal/cmd/stack/stack.go b/internal/cmd/stack/stack.go index d4c76fe..da7af3e 100644 --- a/internal/cmd/stack/stack.go +++ b/internal/cmd/stack/stack.go @@ -1,10 +1,9 @@ package stack import ( - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) // Command encapsulates the stack command subtree. diff --git a/internal/cmd/stack/stack_selector.go b/internal/cmd/stack/stack_selector.go index f128615..4f2053a 100644 --- a/internal/cmd/stack/stack_selector.go +++ b/internal/cmd/stack/stack_selector.go @@ -8,9 +8,8 @@ import ( "github.com/manifoldco/promptui" "github.com/pkg/errors" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) var errNoStackFound = errors.New("no stack found") diff --git a/internal/cmd/stack/task_command.go b/internal/cmd/stack/task_command.go index 3ae6389..3dfd5c1 100644 --- a/internal/cmd/stack/task_command.go +++ b/internal/cmd/stack/task_command.go @@ -6,10 +6,9 @@ import ( "strings" "github.com/shurcooL/graphql" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) func taskCommand(cliCtx *cli.Context) error { diff --git a/internal/cmd/whoami/whoami.go b/internal/cmd/whoami/whoami.go index d46e0b3..34e42b8 100644 --- a/internal/cmd/whoami/whoami.go +++ b/internal/cmd/whoami/whoami.go @@ -6,11 +6,10 @@ import ( "os" "github.com/pkg/errors" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/client/session" "github.com/spacelift-io/spacectl/internal/cmd" "github.com/spacelift-io/spacectl/internal/cmd/authenticated" + "github.com/urfave/cli/v2" ) // Command returns the logged-in user's information. diff --git a/internal/cmd/workerpools/watch.go b/internal/cmd/workerpools/watch.go index 9b36c90..11b2331 100644 --- a/internal/cmd/workerpools/watch.go +++ b/internal/cmd/workerpools/watch.go @@ -5,11 +5,10 @@ import ( "strings" "github.com/manifoldco/promptui" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/authenticated" "github.com/spacelift-io/spacectl/internal/cmd/draw" "github.com/spacelift-io/spacectl/internal/cmd/draw/data" + "github.com/urfave/cli/v2" ) func watch(cliCtx *cli.Context) error { diff --git a/internal/cmd/workerpools/worker.go b/internal/cmd/workerpools/worker.go index 31e3b7d..7123d86 100644 --- a/internal/cmd/workerpools/worker.go +++ b/internal/cmd/workerpools/worker.go @@ -66,7 +66,7 @@ func (c *listWorkersCommand) listWorkers(cliCtx *cli.Context) error { } if query.Pool == nil { - return errors.New(fmt.Sprintf("workerpool with id %s not found", workerPoolID)) + return fmt.Errorf("workerpool with id %s not found", workerPoolID) } switch outputFormat { diff --git a/main.go b/main.go index d1911fb..d7604aa 100644 --- a/main.go +++ b/main.go @@ -5,8 +5,6 @@ import ( "os" "time" - "github.com/urfave/cli/v2" - "github.com/spacelift-io/spacectl/internal/cmd/completion" "github.com/spacelift-io/spacectl/internal/cmd/module" "github.com/spacelift-io/spacectl/internal/cmd/profile" @@ -16,6 +14,7 @@ import ( versioncmd "github.com/spacelift-io/spacectl/internal/cmd/version" "github.com/spacelift-io/spacectl/internal/cmd/whoami" "github.com/spacelift-io/spacectl/internal/cmd/workerpools" + "github.com/urfave/cli/v2" ) var version = "dev"