Skip to content

Commit ac3103e

Browse files
chore: fix lint
1 parent c388416 commit ac3103e

46 files changed

Lines changed: 414 additions & 179 deletions

Some content is hidden

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

.github/workflows/ci.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: image-build-push
2+
3+
on:
4+
push:
5+
6+
concurrency:
7+
cancel-in-progress: true
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
image-build-push:
15+
permissions:
16+
contents: read
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: checkout repository
20+
uses: actions/checkout@v6
21+
22+
- name: Install asdf & tools
23+
uses: asdf-vm/actions/install@v4
24+
25+
- uses: actions/cache@v5
26+
with:
27+
path: |
28+
~/.asdf/installs/golang
29+
~/.asdf/plugins/golang
30+
~/.asdf/installs/golang/*/packages/pkg/mod
31+
~/.cache/go-build
32+
~/.cache/golangci-lint
33+
key: ${{ runner.os }}-golangci-${{ hashFiles('**/go.sum') }}
34+
35+
- name: Run golangci-lint
36+
run: |
37+
set -x
38+
golangci-lint cache status
39+
golangci-lint run --timeout=10m
40+
41+
- name: Test
42+
run: |
43+
set -x
44+
go test -tags dev ./...
45+
46+
- name: Build
47+
run: |
48+
set -x
49+
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -extldflags '-static'" -o nodeops main.go
50+
ldd createos || true

.golangci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
version: "2"
2+
3+
linters:
4+
enable:
5+
- errcheck
6+
- govet
7+
- ineffassign
8+
- staticcheck
9+
- unused
10+
- bodyclose
11+
- gocritic
12+
- misspell
13+
- noctx
14+
- prealloc
15+
- revive
16+
- unconvert
17+
- unparam
18+
- whitespace
19+
- gosec
20+
- copyloopvar
21+
- errorlint
22+
23+
formatters:
24+
enable:
25+
- gofmt
26+
- goimports
27+
settings:
28+
goimports:
29+
local-prefixes:
30+
- github.com/NodeOps-app/createos-cli
31+
32+
linters-settings:
33+
errcheck:
34+
check-type-assertions: true
35+
check-blank: true
36+
govet:
37+
enable-all: true
38+
disable:
39+
- fieldalignment
40+
revive:
41+
rules:
42+
- name: exported
43+
disabled: false
44+
- name: error-return
45+
disabled: false
46+
- name: error-strings
47+
disabled: false
48+
- name: indent-error-flow
49+
disabled: false
50+
gosec:
51+
excludes:
52+
- G304
53+
54+
issues:
55+
exclude-rules:
56+
- path: _test\.go
57+
linters:
58+
- errcheck
59+
- gocritic
60+
max-issues-per-linter: 0
61+
max-same-issues: 0
62+
63+
run:
64+
timeout: 5m

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
golang 1.26.0
2+
golangci-lint 2.11.3

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build clean install run test help
1+
.PHONY: build clean install run test lint lint-fix fmt deps help
22

33
# Binary name
44
BINARY_NAME=createos
@@ -63,7 +63,12 @@ fmt:
6363
# Run linter
6464
lint:
6565
@echo "Running linter..."
66-
golangci-lint run
66+
golangci-lint run ./...
67+
68+
# Run linter and auto-fix issues
69+
lint-fix:
70+
@echo "Running linter with auto-fix..."
71+
golangci-lint run --fix ./...
6772

6873
# Show help
6974
help:
@@ -77,4 +82,5 @@ help:
7782
@echo " deps - Download and tidy dependencies"
7883
@echo " fmt - Format code"
7984
@echo " lint - Run linter"
85+
@echo " lint-fix - Run linter and auto-fix issues"
8086
@echo " help - Show this help message"

cmd/auth/login.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
// Package auth provides authentication commands.
12
package auth
23

34
import (
45
"fmt"
56
"time"
67

7-
"github.com/NodeOps-app/createos-cli/internal/config"
8-
internaloauth "github.com/NodeOps-app/createos-cli/internal/oauth"
98
"github.com/pterm/pterm"
109
"github.com/urfave/cli/v2"
10+
11+
"github.com/NodeOps-app/createos-cli/internal/config"
12+
internaloauth "github.com/NodeOps-app/createos-cli/internal/oauth"
1113
)
1214

1315
const (

cmd/auth/logout.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ package auth
33
import (
44
"fmt"
55

6-
"github.com/NodeOps-app/createos-cli/internal/config"
76
"github.com/pterm/pterm"
87
"github.com/urfave/cli/v2"
8+
9+
"github.com/NodeOps-app/createos-cli/internal/config"
910
)
1011

1112
// NewLogoutCommand creates the logout command
1213
func NewLogoutCommand() *cli.Command {
1314
return &cli.Command{
1415
Name: "logout",
1516
Usage: "Sign out from CreateOS",
16-
Action: func(c *cli.Context) error {
17+
Action: func(_ *cli.Context) error {
1718
if !config.IsLoggedIn() {
1819
return fmt.Errorf("you're not signed in")
1920
}

cmd/auth/whoami.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"fmt"
55
"time"
66

7-
"github.com/NodeOps-app/createos-cli/internal/api"
87
"github.com/pterm/pterm"
98
"github.com/urfave/cli/v2"
9+
10+
"github.com/NodeOps-app/createos-cli/internal/api"
1011
)
1112

1213
// NewWhoamiCommand creates the whoami command
@@ -15,7 +16,7 @@ func NewWhoamiCommand() *cli.Command {
1516
Name: "whoami",
1617
Usage: "Show the currently authenticated user",
1718
Action: func(c *cli.Context) error {
18-
client, ok := c.App.Metadata[api.ClientKey].(*api.ApiClient)
19+
client, ok := c.App.Metadata[api.ClientKey].(*api.APIClient)
1920
if !ok {
2021
return fmt.Errorf("you're not signed in — run 'createos login' to get started")
2122
}
@@ -51,4 +52,3 @@ func NewWhoamiCommand() *cli.Command {
5152
},
5253
}
5354
}
54-

cmd/oauth/clients.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package oauth provides OAuth client management commands.
12
package oauth
23

34
import "github.com/urfave/cli/v2"

cmd/oauth/create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package oauth
33
import (
44
"fmt"
55

6-
"github.com/NodeOps-app/createos-cli/internal/api"
76
"github.com/pterm/pterm"
87
"github.com/urfave/cli/v2"
8+
9+
"github.com/NodeOps-app/createos-cli/internal/api"
910
)
1011

1112
func newCreateCommand() *cli.Command {

cmd/oauth/helpers.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"net/url"
66
"strings"
77

8-
"github.com/NodeOps-app/createos-cli/internal/api"
98
"github.com/pterm/pterm"
109
"github.com/urfave/cli/v2"
10+
11+
"github.com/NodeOps-app/createos-cli/internal/api"
1112
)
1213

13-
func getClient(c *cli.Context) (*api.ApiClient, error) {
14-
client, ok := c.App.Metadata[api.ClientKey].(*api.ApiClient)
14+
func getClient(c *cli.Context) (*api.APIClient, error) {
15+
client, ok := c.App.Metadata[api.ClientKey].(*api.APIClient)
1516
if !ok {
1617
return nil, fmt.Errorf("you're not signed in — run 'createos login' to get started")
1718
}

0 commit comments

Comments
 (0)