Skip to content

Commit 8c82a94

Browse files
authored
chore: bump to Go 1.26, modernize, add dependabot config (#395)
* chore: bump to Go 1.26, add dependabot config Bump the Go version to 1.26 and add a dependabot configuration for automated dependency updates (both Go modules and GitHub Actions). Also removed the pinned golangci-lint version so it always uses the latest from the action, avoiding manual maintenance on every release. The release workflow now skips dependabot PRs since those don't need snapshot builds. * refactor: modernize codebase with Go 1.26 idioms Ran `go fix ./...` to apply Go 1.26 modernizations across the codebase: - `interface{}` -> `any` - `pkg.NewT(val)` / `internal.Ptr(val)` -> `new(val)` - removed unused imports Also fixed lint issues caught by the unpinned golangci-lint: - gosec G704 nolint in client.go - stale nolint directive in search_version.go - `WriteString(fmt.Sprintf(...))` -> `fmt.Fprintf(...)` in mcp.go * chore: bumped dependencies
1 parent df2abf7 commit 8c82a94

66 files changed

Lines changed: 323 additions & 306 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
7+
commit-message:
8+
prefix: "chore(gha-deps)"
9+
groups:
10+
github-actions:
11+
patterns:
12+
- "*"
13+
14+
- package-ecosystem: gomod
15+
directory: /
16+
schedule:
17+
interval: daily
18+
commit-message:
19+
prefix: "chore(go-deps)"
20+
groups:
21+
go-dependencies:
22+
patterns:
23+
- "*"

.github/workflows/lint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,3 @@ jobs:
3737
uses: golangci/golangci-lint-action@v9
3838
with:
3939
args: --verbose
40-
version: v2.7

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ concurrency:
99
jobs:
1010
goreleaser:
1111
name: Release
12+
if: github.actor != 'dependabot[bot]'
1213
runs-on: ubuntu-latest
1314
permissions:
1415
id-token: write

client/client.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func New(wraps *http.Client, session session.Session) Client {
2424
return &client{wraps: wraps, session: session}
2525
}
2626

27-
func (c *client) Mutate(ctx context.Context, mutation interface{}, variables map[string]interface{}, opts ...graphql.RequestOption) error {
27+
func (c *client) Mutate(ctx context.Context, mutation any, variables map[string]any, opts ...graphql.RequestOption) error {
2828
apiClient, err := c.apiClient(ctx)
2929
if err != nil {
3030
return nil
@@ -34,7 +34,7 @@ func (c *client) Mutate(ctx context.Context, mutation interface{}, variables map
3434
return c.determineClientError(ctx, apiClient, opts, err)
3535
}
3636

37-
func (c *client) Query(ctx context.Context, query interface{}, variables map[string]interface{}, opts ...graphql.RequestOption) error {
37+
func (c *client) Query(ctx context.Context, query any, variables map[string]any, opts ...graphql.RequestOption) error {
3838
apiClient, err := c.apiClient(ctx)
3939
if err != nil {
4040
return nil
@@ -58,15 +58,15 @@ func (c *client) determineClientError(ctx context.Context, client *graphql.Clien
5858
ID string `graphql:"id" json:"id"`
5959
}
6060
}
61-
queryErr := client.Query(ctx, &query, map[string]interface{}{}, opts...)
61+
queryErr := client.Query(ctx, &query, map[string]any{}, opts...)
6262
if queryErr == nil && query.Viewer != nil {
6363
return fmt.Errorf("unauthorized: You're logged in. Maybe you don't have access to the resource?")
6464
}
6565

6666
return fmt.Errorf("unauthorized: You can re-login using `spacectl profile login`")
6767
}
6868

69-
func (c *client) URL(format string, a ...interface{}) string {
69+
func (c *client) URL(format string, a ...any) string {
7070
endpoint := c.session.Endpoint()
7171

7272
endpointURL, err := url.Parse(endpoint)
@@ -110,7 +110,7 @@ func (c *client) Do(req *http.Request) (*http.Response, error) {
110110
req.URL.Host = u.Host
111111

112112
// execute request
113-
resp, err := httpC.Do(req)
113+
resp, err := httpC.Do(req) //nolint:gosec // URL is constructed from user-configured Spacelift endpoint, not untrusted input
114114
if err != nil {
115115
return nil, fmt.Errorf("error executing request: %w", err)
116116
}

client/interface.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
// Client abstracts away Spacelift's client API.
1111
type Client interface {
1212
// Query executes a single GraphQL query request.
13-
Query(context.Context, interface{}, map[string]interface{}, ...graphql.RequestOption) error
13+
Query(context.Context, any, map[string]any, ...graphql.RequestOption) error
1414

1515
// Mutate executes a single GraphQL mutation request.
16-
Mutate(context.Context, interface{}, map[string]interface{}, ...graphql.RequestOption) error
16+
Mutate(context.Context, any, map[string]any, ...graphql.RequestOption) error
1717

1818
// URL returns a full URL given a formatted path.
19-
URL(string, ...interface{}) string
19+
URL(string, ...any) string
2020

2121
// Do executes an authenticated http request to the Spacelift API
2222
Do(r *http.Request) (*http.Response, error)

client/session/api_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (g *apiKey) exchange(ctx context.Context) error {
5555
APIKeyUser user `graphql:"apiKeyUser(id: $id, secret: $secret)"`
5656
}
5757

58-
variables := map[string]interface{}{
58+
variables := map[string]any{
5959
"id": graphql.ID(g.keyID),
6060
"secret": graphql.String(g.keySecret),
6161
}

client/session/api_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (a *apiToken) isFresh() bool {
7777
return a.timer().Add(timePadding).Before(a.tokenValidUntil)
7878
}
7979

80-
func (a *apiToken) mutate(ctx context.Context, m interface{}, variables map[string]interface{}) error {
80+
func (a *apiToken) mutate(ctx context.Context, m any, variables map[string]any) error {
8181
return graphql.NewClient(a.Endpoint(), a.client).Mutate(ctx, m, variables)
8282
}
8383

client/session/github_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (g *gitHubToken) exchange(ctx context.Context) error {
5454
APIKeyUser user `graphql:"oauthUser(token: $token)"`
5555
}
5656

57-
variables := map[string]interface{}{"token": graphql.String(g.accessToken)}
57+
variables := map[string]any{"token": graphql.String(g.accessToken)}
5858

5959
if err := g.mutate(ctx, &mutation, variables); err != nil {
6060
return fmt.Errorf("could not exchange access token for Spacelift one: %w", err)

go.mod

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
module github.com/spacelift-io/spacectl
22

3-
go 1.25.0
3+
go 1.26.1
44

55
require (
66
github.com/Masterminds/semver/v3 v3.4.0
77
github.com/ProtonMail/gopenpgp/v2 v2.9.0
8-
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7
8+
github.com/charmbracelet/bubbles v1.0.0
99
github.com/charmbracelet/bubbletea v1.3.10
1010
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
1111
github.com/cheggaaa/pb/v3 v3.1.7
12-
github.com/cli/cli/v2 v2.83.2
12+
github.com/cli/cli/v2 v2.88.1
1313
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf
1414
github.com/golang-jwt/jwt/v4 v4.5.2
1515
github.com/manifoldco/promptui v0.9.0
16-
github.com/mark3labs/mcp-go v0.43.2
16+
github.com/mark3labs/mcp-go v0.45.0
1717
github.com/mattn/go-isatty v0.0.20
1818
github.com/mholt/archiver/v3 v3.5.1
19-
github.com/onsi/gomega v1.38.3
19+
github.com/onsi/gomega v1.39.1
2020
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
2121
github.com/pkg/errors v0.9.1
22-
github.com/pterm/pterm v0.12.82
22+
github.com/pterm/pterm v0.12.83
2323
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
24-
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466
24+
github.com/shurcooL/graphql v0.0.0-20240915155400-7ee5256398cf
2525
github.com/stretchr/testify v1.11.1
26-
github.com/urfave/cli/v3 v3.6.1
27-
golang.org/x/oauth2 v0.34.0
28-
golang.org/x/sync v0.19.0
29-
golang.org/x/term v0.38.0
26+
github.com/urfave/cli/v3 v3.7.0
27+
golang.org/x/oauth2 v0.36.0
28+
golang.org/x/sync v0.20.0
29+
golang.org/x/term v0.41.0
3030
)
3131

3232
require (
@@ -40,13 +40,16 @@ require (
4040
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
4141
github.com/bahlo/generic-list-go v0.2.0 // indirect
4242
github.com/buger/jsonparser v1.1.1 // indirect
43-
github.com/charmbracelet/colorprofile v0.3.1 // indirect
44-
github.com/charmbracelet/x/ansi v0.10.1 // indirect
45-
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
46-
github.com/charmbracelet/x/term v0.2.1 // indirect
43+
github.com/charmbracelet/colorprofile v0.4.1 // indirect
44+
github.com/charmbracelet/x/ansi v0.11.6 // indirect
45+
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
46+
github.com/charmbracelet/x/term v0.2.2 // indirect
4747
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
4848
github.com/cli/go-gh/v2 v2.13.0 // indirect
4949
github.com/cli/safeexec v1.0.1 // indirect
50+
github.com/clipperhouse/displaywidth v0.9.0 // indirect
51+
github.com/clipperhouse/stringish v0.1.1 // indirect
52+
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
5053
github.com/cloudflare/circl v1.6.3 // indirect
5154
github.com/containerd/console v1.0.5 // indirect
5255
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
@@ -57,7 +60,7 @@ require (
5760
github.com/golang/snappy v1.0.0 // indirect
5861
github.com/google/go-cmp v0.7.0 // indirect
5962
github.com/google/uuid v1.6.0 // indirect
60-
github.com/gookit/color v1.5.4 // indirect
63+
github.com/gookit/color v1.6.0 // indirect
6164
github.com/invopop/jsonschema v0.13.0 // indirect
6265
github.com/klauspost/compress v1.18.1 // indirect
6366
github.com/klauspost/pgzip v1.2.1 // indirect
@@ -66,25 +69,25 @@ require (
6669
github.com/mailru/easyjson v0.9.0 // indirect
6770
github.com/mattn/go-colorable v0.1.14 // indirect
6871
github.com/mattn/go-localereader v0.0.1 // indirect
69-
github.com/mattn/go-runewidth v0.0.16 // indirect
72+
github.com/mattn/go-runewidth v0.0.20 // indirect
7073
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
7174
github.com/muesli/cancelreader v0.2.2 // indirect
7275
github.com/muesli/termenv v0.16.0 // indirect
7376
github.com/nwaples/rardecode v1.0.0 // indirect
7477
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
7578
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
7679
github.com/rivo/uniseg v0.4.7 // indirect
77-
github.com/spf13/cast v1.9.2 // indirect
80+
github.com/spf13/cast v1.10.0 // indirect
7881
github.com/ulikunitz/xz v0.5.14 // indirect
7982
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
8083
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
8184
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
8285
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
8386
go.yaml.in/yaml/v3 v3.0.4 // indirect
84-
golang.org/x/crypto v0.45.0 // indirect
85-
golang.org/x/net v0.47.0 // indirect
86-
golang.org/x/sys v0.39.0 // indirect
87-
golang.org/x/text v0.31.0 // indirect
87+
golang.org/x/crypto v0.48.0 // indirect
88+
golang.org/x/net v0.49.0 // indirect
89+
golang.org/x/sys v0.42.0 // indirect
90+
golang.org/x/text v0.34.0 // indirect
8891
gopkg.in/yaml.v3 v3.0.1 // indirect
8992
)
9093

0 commit comments

Comments
 (0)