Skip to content

Commit 78ad1ed

Browse files
Add DeletedAt to server type (#134)
* Add DeletedAt to server type * fix lint
1 parent 18b5cd7 commit 78ad1ed

File tree

5 files changed

+104
-101
lines changed

5 files changed

+104
-101
lines changed

.github/workflows/push-pr-lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
with:
1313
go-version-file: go.mod
1414
- name: golangci-lint
15-
uses: golangci/golangci-lint-action@v6
15+
uses: golangci/golangci-lint-action@v7
1616
with:
1717
args: --config .golangci.yml --timeout 2m
18-
version: v1.60.1
18+
version: v2.0.2
1919

2020
build-test:
2121
runs-on: ubuntu-latest

.golangci.yml

Lines changed: 98 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,111 @@
1-
# golangci.com configuration
2-
# https://github.com/golangci/golangci/wiki/Configuration
3-
1+
version: "2"
42
run:
53
build-tags:
64
- testtools
7-
8-
linters-settings:
9-
govet:
10-
settings:
11-
printf:
12-
funcs:
13-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
14-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
15-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
16-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
17-
gocyclo:
18-
min-complexity: 12
19-
dupl:
20-
threshold: 100
21-
goconst:
22-
min-len: 2
23-
min-occurrences: 2
24-
misspell:
25-
locale: US
26-
lll:
27-
line-length: 140
28-
goimports:
29-
local-prefixes: github.com/golangci/golangci-lint
30-
gocritic:
31-
enabled-tags:
32-
- performance
33-
- style
34-
- experimental
35-
disabled-checks:
36-
- wrapperFunc
37-
gofumpt:
38-
extra-rules: true
39-
405
linters:
6+
default: none
417
enable:
42-
- errcheck
43-
- gosimple
44-
- govet
45-
- gofmt
46-
- gocyclo
47-
- ineffassign
48-
- stylecheck
49-
- misspell
50-
- staticcheck
51-
- unused
52-
- prealloc
53-
- typecheck
54-
# additional linters
558
- bodyclose
56-
- gocritic
57-
- err113
58-
- goimports
59-
- revive
60-
- misspell
61-
- noctx
62-
- stylecheck
63-
- gosec
649
- contextcheck
6510
- durationcheck
11+
- err113
12+
- errcheck
6613
- errchkjson
67-
# - errorlint
6814
- gochecksumtype
15+
- gocritic
16+
- gocyclo
17+
- gosec
18+
- govet
19+
- ineffassign
20+
- misspell
6921
- nilerr
22+
- noctx
23+
- prealloc
7024
- reassign
25+
- revive
26+
- staticcheck
27+
- unused
7128
- whitespace
72-
enable-all: false
73-
disable-all: true
74-
75-
issues:
76-
exclude-files:
77-
- "(.*/)*.*_test.go"
78-
exclude-dirs:
79-
- internal/fixtures
80-
exclude-rules:
81-
- linters:
82-
- gosec
83-
text: "weak cryptographic primitive"
84-
85-
- linters:
86-
- stylecheck
87-
text: "ST1016"
88-
exclude:
89-
# Default excludes from `golangci-lint run --help` with EXC0002 removed
90-
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
91-
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
92-
# EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments
93-
# - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
94-
# EXC0003 golint: False positive when tests are defined in package 'test'
95-
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
96-
# EXC0004 govet: Common false positives
97-
- (possible misuse of unsafe.Pointer|should have signature)
98-
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
99-
- ineffective break statement. Did you mean to break out of the outer loop
100-
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
101-
- Use of unsafe calls should be audited
102-
# EXC0007 gosec: Too many false-positives for parametrized shell calls
103-
- Subprocess launch(ed with variable|ing should be audited)
104-
# EXC0008 gosec: Duplicated errcheck checks
105-
- (G104|G307)
106-
# EXC0009 gosec: Too many issues in popular repos
107-
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
108-
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
109-
- Potential file inclusion via variable
29+
settings:
30+
dupl:
31+
threshold: 100
32+
goconst:
33+
min-len: 2
34+
min-occurrences: 2
35+
gocritic:
36+
disabled-checks:
37+
- wrapperFunc
38+
enabled-tags:
39+
- performance
40+
- style
41+
- experimental
42+
gocyclo:
43+
min-complexity: 12
44+
govet:
45+
settings:
46+
printf:
47+
funcs:
48+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
49+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
50+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
51+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
52+
lll:
53+
line-length: 140
54+
misspell:
55+
locale: US
56+
exclusions:
57+
generated: lax
58+
presets:
59+
- comments
60+
- common-false-positives
61+
- legacy
62+
- std-error-handling
63+
rules:
64+
- linters:
65+
- gosec
66+
text: weak cryptographic primitive
67+
- linters:
68+
- staticcheck
69+
text: ST1016
70+
- path: (.+)\.go$
71+
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
72+
- path: (.+)\.go$
73+
text: func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
74+
- path: (.+)\.go$
75+
text: (possible misuse of unsafe.Pointer|should have signature)
76+
- path: (.+)\.go$
77+
text: ineffective break statement. Did you mean to break out of the outer loop
78+
- path: (.+)\.go$
79+
text: Use of unsafe calls should be audited
80+
- path: (.+)\.go$
81+
text: Subprocess launch(ed with variable|ing should be audited)
82+
- path: (.+)\.go$
83+
text: (G104|G307)
84+
- path: (.+)\.go$
85+
text: (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
86+
- path: (.+)\.go$
87+
text: Potential file inclusion via variable
88+
paths:
89+
- (.*/)*.*_test.go
90+
- internal/fixtures
91+
- third_party$
92+
- builtin$
93+
- examples$
94+
formatters:
95+
enable:
96+
- gofmt
97+
- goimports
98+
settings:
99+
gofumpt:
100+
extra-rules: true
101+
goimports:
102+
local-prefixes:
103+
- github.com/golangci/golangci-lint
104+
exclusions:
105+
generated: lax
106+
paths:
107+
- (.*/)*.*_test.go
108+
- internal/fixtures
109+
- third_party$
110+
- builtin$
111+
- examples$

ginauth/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type AuthError struct {
3535
func NewAuthenticationError(msg string) *AuthError {
3636
return &AuthError{
3737
HTTPErrorCode: http.StatusUnauthorized,
38-
//nolint:goerr113 // it must be dynamic here
38+
//nolint:err113 // it must be dynamic here
3939
err: errors.New(msg),
4040
}
4141
}
@@ -55,7 +55,7 @@ func NewAuthenticationErrorFrom(err error) *AuthError {
5555
func NewAuthorizationError(msg string) *AuthError {
5656
return &AuthError{
5757
HTTPErrorCode: http.StatusForbidden,
58-
//nolint:goerr113 // it must be dynamic here
58+
//nolint:err113 // it must be dynamic here
5959
err: errors.New(msg),
6060
}
6161
}

ginjwt/jwt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (m *Middleware) VerifyToken(c *gin.Context) (ginauth.ClaimMetadata, error)
148148

149149
authHeaderParts := strings.SplitN(authHeader, " ", expectedAuthHeaderParts)
150150

151-
if !(len(authHeaderParts) == expectedAuthHeaderParts && strings.EqualFold(authHeaderParts[0], "bearer")) {
151+
if len(authHeaderParts) != expectedAuthHeaderParts || !strings.EqualFold(authHeaderParts[0], "bearer") {
152152
return ginauth.ClaimMetadata{}, ginauth.NewAuthenticationError("invalid authorization header, expected format: \"Bearer token\"")
153153
}
154154

types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func (c Components) ByNameModel(cSlug string, cModels []string) *Component {
6464
// Server is a generic server type
6565
type Server struct {
6666
UpdatedAt time.Time `json:"updated,omitempty"`
67+
DeletedAt *time.Time `json:"deleted_at,omitempty"`
6768
BIOSCfg map[string]string `json:"bios_cfg,omitempty"`
6869
ID string `json:"id,omitempty"`
6970
Facility string `json:"facility,omitempty"`

0 commit comments

Comments
 (0)