Skip to content

Commit d1d39bf

Browse files
WKS-2301 - Bump dependencies
1 parent 171eb9b commit d1d39bf

29 files changed

+517
-545
lines changed

.github/workflows/analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
go-version-file: go.mod
2020

2121
- name: Static Code Analysis
22-
uses: golangci/golangci-lint-action@v6
22+
uses: golangci/golangci-lint-action@v9
2323
with:
2424
version: latest

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
unit-tests:
1515
name: Unit tests
1616
runs-on: ubuntu-latest
17+
permissions:
18+
checks: write
19+
pull-requests: write
1720
steps:
1821

1922
- name: Checkout code

.golangci.yml

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,58 @@
1-
# Options for analysis running
2-
# More info could be found at https://golangci-lint.run/usage/configuration/
1+
version: "2"
32
run:
4-
# timeout for analysis, e.g. 30s, 5m, default is 1m
5-
timeout: 5m
6-
modules-download-mode: readonly
7-
8-
# List of useful linters could be found at https://github.com/golangci/awesome-go-linters
3+
modules-download-mode: readonly
94
linters:
10-
disable-all: true
11-
enable:
12-
- errcheck
13-
- copyloopvar
14-
# - depguard
15-
# - gci
16-
- gofumpt
17-
- goimports
18-
- gosimple
19-
- govet
20-
- ineffassign
21-
- makezero
22-
- misspell
23-
- noctx
24-
- nolintlint
25-
# - revive
26-
- rowserrcheck
27-
- sqlclosecheck
28-
- staticcheck
29-
# - stylecheck
30-
- unconvert
31-
- unused
32-
- wastedassign
33-
- gosec
34-
35-
linters-settings:
36-
staticcheck:
37-
# https://staticcheck.io/docs/options#checks
38-
checks: [ "all","-SA1019","-SA1029" ]
5+
default: none
6+
enable:
7+
- copyloopvar
8+
- errcheck
9+
- gosec
10+
- govet
11+
- ineffassign
12+
- makezero
13+
- misspell
14+
- noctx
15+
- nolintlint
16+
- rowserrcheck
17+
- sqlclosecheck
18+
- staticcheck
19+
- unconvert
20+
- unused
21+
- wastedassign
22+
settings:
3923
gosec:
40-
excludes: ["G204", "G301", "G302", "G304", "G306", "G601", "G101"]
41-
exclude-generated: true
42-
config:
43-
global:
44-
nosec: true
45-
24+
excludes:
25+
- G204
26+
- G301
27+
- G302
28+
- G304
29+
- G306
30+
- G601
31+
- G101
32+
config:
33+
global:
34+
nosec: true
35+
staticcheck:
36+
checks:
37+
- all
38+
- -SA1019
39+
- -SA1029
40+
exclusions:
41+
generated: lax
42+
paths:
43+
- third_party$
44+
- builtin$
45+
- examples$
4646
issues:
47-
exclude-use-default: false
48-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
49-
max-issues-per-linter: 0
50-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
51-
max-same-issues: 0
47+
max-issues-per-linter: 0
48+
max-same-issues: 0
49+
formatters:
50+
enable:
51+
- gofumpt
52+
- goimports
53+
exclusions:
54+
generated: lax
55+
paths:
56+
- third_party$
57+
- builtin$
58+
- examples$

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ GOIMPORTS:
3434
########## ANALYSE ##########
3535

3636
GOLANGCI_LINT = ${TOOLS_DIR}/golangci-lint
37-
GOLANGCI_LINT_VERSION = 1.62.2
37+
GOLANGCI_LINT_VERSION = 2.9.0
3838

3939
verify: GOLANGCI_LINT
4040
echo $(GO_SOURCES)
41-
$(GOLANGCI_LINT) run --out-format tab --config "${WORKSPACE_ROOT}/.golangci.yml"
41+
$(GOLANGCI_LINT) run --config "${WORKSPACE_ROOT}/.golangci.yml"
4242

4343
GOLANGCI_LINT:
4444
${GOLANGCI_LINT} --version 2>/dev/null | grep ${GOLANGCI_LINT_VERSION} || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${TOOLS_DIR} v${GOLANGCI_LINT_VERSION}
4545

4646
########## BUILD ##########
4747
prereq::
4848
$(GOCMD) install github.com/jstemmer/go-junit-report@v1.0.0
49-
GOBIN=${TOOLS_DIR} $(GOCMD) install go.uber.org/mock/mockgen@v0.5.0
49+
GOBIN=${TOOLS_DIR} $(GOCMD) install go.uber.org/mock/mockgen@v0.6.0
5050

5151
########## TEST ##########
5252

cli/cli.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package cli provides the CLI entry point for JFrog platform services.
12
package cli
23

34
import (

commands/add_secret_cmd.go

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

34
import (

commands/common/cmd_api.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package common provides shared utilities for JFrog platform services commands.
12
package common
23

34
import (
@@ -19,53 +20,53 @@ import (
1920
type apiVersion int
2021

2122
const (
22-
ApiVersionV1 apiVersion = iota + 1
23-
ApiVersionV2 apiVersion = 2
23+
APIVersionV1 apiVersion = iota + 1
24+
APIVersionV2 apiVersion = 2
2425
)
2526

26-
type ApiContentHandler func(content []byte) error
27+
type APIContentHandler func(content []byte) error
2728

28-
type ApiError struct {
29+
type APIError struct {
2930
StatusCode int
3031
Message string
3132
}
3233

33-
func (e *ApiError) Error() string {
34+
func (e *APIError) Error() string {
3435
return e.Message
3536
}
3637

37-
func apiError(status int, message string, args ...any) *ApiError {
38-
return &ApiError{
38+
func apiError(status int, message string, args ...any) *APIError {
39+
return &APIError{
3940
StatusCode: status,
4041
Message: fmt.Sprintf(message, args...),
4142
}
4243
}
4344

44-
type ApiCallParams struct {
45+
type APICallParams struct {
4546
Method string
46-
ServerUrl string
47+
ServerURL string
4748
ServerToken string
4849
Body []byte
4950
Query map[string]string
5051
Path []string
5152
ProjectKey string
52-
ApiVersion apiVersion
53+
APIVersion apiVersion
5354
OkStatuses []int
54-
OnContent ApiContentHandler
55+
OnContent APIContentHandler
5556
}
5657

57-
func CallWorkerApi(c model.IntFlagProvider, params ApiCallParams) error {
58+
func CallWorkerAPI(c model.IntFlagProvider, params APICallParams) error {
5859
timeout, err := model.GetTimeoutParameter(c)
5960
if err != nil {
6061
return apiError(http.StatusInternalServerError, "%+v", err)
6162
}
6263

63-
apiVersion := ApiVersionV1
64-
if params.ApiVersion != 0 {
65-
apiVersion = params.ApiVersion
64+
apiVersion := APIVersionV1
65+
if params.APIVersion != 0 {
66+
apiVersion = params.APIVersion
6667
}
6768

68-
apiEndpoint := fmt.Sprintf("%sworker/api/v%d/%s", utils.AddTrailingSlashIfNeeded(params.ServerUrl), apiVersion, strings.Join(params.Path, "/"))
69+
apiEndpoint := fmt.Sprintf("%sworker/api/v%d/%s", utils.AddTrailingSlashIfNeeded(params.ServerURL), apiVersion, strings.Join(params.Path, "/"))
6970

7071
q := url.Values{}
7172

@@ -108,14 +109,14 @@ func CallWorkerApi(c model.IntFlagProvider, params ApiCallParams) error {
108109

109110
if slices.Index(params.OkStatuses, res.StatusCode) == -1 {
110111
// We the response contains json content, we will print it
111-
_ = processApiResponse(res, printJsonOrLogError)
112+
_ = processAPIResponse(res, printJSONOrLogError)
112113
return apiError(res.StatusCode, "command %s %s returned an unexpected status code %d", params.Method, apiEndpoint, res.StatusCode)
113114
}
114115

115-
return processApiResponse(res, params.OnContent)
116+
return processAPIResponse(res, params.OnContent)
116117
}
117118

118-
func processApiResponse(res *http.Response, doWithContent func(content []byte) error) error {
119+
func processAPIResponse(res *http.Response, doWithContent func(content []byte) error) error {
119120
var err error
120121
var responseBytes []byte
121122

commands/common/cmd_api_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ import (
1414
"github.com/stretchr/testify/require"
1515
)
1616

17-
func TestCallWorkerApi(t *testing.T) {
17+
func TestCallWorkerAPI(t *testing.T) {
1818
tests := []struct {
1919
name string
2020
stub *ServerStub
21-
params ApiCallParams
21+
params APICallParams
2222
ctx model.IntFlagProvider
2323
wantErr string
2424
}{
2525
{
2626
name: "success",
2727
stub: NewServerStub(t).WithGetAllEndpoint(),
28-
params: ApiCallParams{
28+
params: APICallParams{
2929
Method: "GET",
3030
Path: []string{"workers"},
3131
OkStatuses: []int{http.StatusOK},
@@ -34,7 +34,7 @@ func TestCallWorkerApi(t *testing.T) {
3434
{
3535
name: "unexpected status",
3636
stub: NewServerStub(t).WithGetAllEndpoint(),
37-
params: ApiCallParams{
37+
params: APICallParams{
3838
Method: "GET",
3939
Path: []string{"workers"},
4040
OkStatuses: []int{http.StatusNoContent},
@@ -44,7 +44,7 @@ func TestCallWorkerApi(t *testing.T) {
4444
{
4545
name: "cancel on timeout",
4646
stub: NewServerStub(t).WithDelay(time.Second).WithGetAllEndpoint(),
47-
params: ApiCallParams{
47+
params: APICallParams{
4848
Method: "GET",
4949
Path: []string{"workers"},
5050
OkStatuses: []int{http.StatusNoContent},
@@ -58,7 +58,7 @@ func TestCallWorkerApi(t *testing.T) {
5858
WithGetAllEndpoint().
5959
WithQueryParam("a", "1").
6060
WithQueryParam("b", "2"),
61-
params: ApiCallParams{
61+
params: APICallParams{
6262
Method: "GET",
6363
Path: []string{"workers"},
6464
OkStatuses: []int{http.StatusOK},
@@ -70,7 +70,7 @@ func TestCallWorkerApi(t *testing.T) {
7070
stub: NewServerStub(t).
7171
WithGetAllEndpoint().
7272
WithProjectKey("projectKey"),
73-
params: ApiCallParams{
73+
params: APICallParams{
7474
Method: "GET",
7575
Path: []string{"workers"},
7676
OkStatuses: []int{http.StatusOK},
@@ -83,7 +83,7 @@ func TestCallWorkerApi(t *testing.T) {
8383
WithGetAllEndpoint().
8484
WithQueryParam("a", "1").
8585
WithProjectKey("projectKey"),
86-
params: ApiCallParams{
86+
params: APICallParams{
8787
Method: "GET",
8888
Path: []string{"workers"},
8989
OkStatuses: []int{http.StatusOK},
@@ -94,7 +94,7 @@ func TestCallWorkerApi(t *testing.T) {
9494
{
9595
name: "process response",
9696
stub: NewServerStub(t).WithGetAllEndpoint().WithWorkers(&model.WorkerDetails{Key: "wk-0"}),
97-
params: ApiCallParams{
97+
params: APICallParams{
9898
Method: "GET",
9999
Path: []string{"workers"},
100100
OkStatuses: []int{http.StatusOK},
@@ -120,15 +120,15 @@ func TestCallWorkerApi(t *testing.T) {
120120
t.Run(tt.name, func(t *testing.T) {
121121
s, token := NewMockWorkerServer(t, tt.stub.WithT(t))
122122

123-
tt.params.ServerUrl = s.BaseUrl()
123+
tt.params.ServerURL = s.BaseUrl()
124124
tt.params.ServerToken = token
125125

126126
ctx := tt.ctx
127127
if ctx == nil {
128128
ctx = IntFlagMap{}
129129
}
130130

131-
err := CallWorkerApi(ctx, tt.params)
131+
err := CallWorkerAPI(ctx, tt.params)
132132
if tt.wantErr == "" {
133133
assert.NoError(t, err)
134134
} else {

commands/common/cmd_commons.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/jfrog/jfrog-cli-platform-services/model"
1111
)
1212

13-
func PrettifyJson(in []byte) []byte {
13+
func PrettifyJSON(in []byte) []byte {
1414
var out bytes.Buffer
1515
if err := json.Indent(&out, in, "", " "); err != nil {
1616
return in

commands/common/cmd_io.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ func Print(message string, args ...any) error {
3737
return err
3838
}
3939

40-
func PrintJson(data []byte) error {
41-
_, err := cliOut.Write(PrettifyJson(data))
40+
func PrintJSON(data []byte) error {
41+
_, err := cliOut.Write(PrettifyJSON(data))
4242
return err
4343
}
4444

45-
func printJsonOrLogError(data []byte) error {
46-
if _, writeErr := cliOut.Write(PrettifyJson(data)); writeErr != nil {
45+
func printJSONOrLogError(data []byte) error {
46+
if _, writeErr := cliOut.Write(PrettifyJSON(data)); writeErr != nil {
4747
log.Warn(fmt.Sprintf("Write error: %+v (data:%s)", writeErr, string(data)))
4848
}
4949
return nil

0 commit comments

Comments
 (0)