Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix golagnci lint warnings #110

Merged
merged 25 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6a78834
Update workflows to allow manual trigger
AkshaySainiDell Mar 4, 2024
bc619c8
Fix gofumpt warnings
AkshaySainiDell Mar 4, 2024
45652b7
Fix gofumpt warnings
AkshaySainiDell Mar 4, 2024
8e34bd1
Fix golangci-lint warnings in api package
AkshaySainiDell Mar 4, 2024
628e043
Fix golangci-lint warning in inttests package
AkshaySainiDell Mar 4, 2024
1676549
Fix golangci-lint warnings in types dir
AkshaySainiDell Mar 7, 2024
7620cdd
Fix golangci-lint warnings in fs related files
AkshaySainiDell Mar 8, 2024
15dd57e
Fix golangci-lint warnings in api and deploy
AkshaySainiDell Mar 13, 2024
a26855a
Fix golangci-lint warnings in device and fault_set
AkshaySainiDell Mar 13, 2024
14c7cdf
Fix golangci-lint warnings in sdc and sds
AkshaySainiDell Mar 13, 2024
2075970
Fix golangci-lint warnings in snapshot_policy and storagepool
AkshaySainiDell Mar 13, 2024
d54e68e
Fix golangci-lint warnings in node and replication
AkshaySainiDell Mar 13, 2024
da786da
Fix golangci-lint warnings in service
AkshaySainiDell Mar 13, 2024
4b73d43
Fix golangci-lint warnings in sso_user_test
AkshaySainiDell Mar 13, 2024
ec74820
Fix golangci-lint warnings in system_limit_test
AkshaySainiDell Mar 13, 2024
5a0b9e1
Fix golangci-lint warnings in system_test
AkshaySainiDell Mar 13, 2024
f60d2bd
Fix golangci-lint warnings in template
AkshaySainiDell Mar 13, 2024
e447147
Fix golangci-lint warnings in tree_quota_test
AkshaySainiDell Mar 13, 2024
e02b53e
Fix golangci-lint warnings in tree_quota_test
AkshaySainiDell Mar 13, 2024
7f06a0e
Fix golangci-lint warnings in user
AkshaySainiDell Mar 13, 2024
52a8d64
Fix golangci-lint warnings in volume and vtree
AkshaySainiDell Mar 13, 2024
91c6c1b
Merge branch 'main' into fix-golanci-lint-warnings
AkshaySainiDell Apr 25, 2024
b2216d5
Update service.go
AkshaySainiDell Apr 25, 2024
4029c29
Fix remaining linting issues
AkshaySainiDell Apr 25, 2024
cdd1e75
Fix remaining linting issues
AkshaySainiDell Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Workflow
on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
workflow_dispatch:
jobs:
code-check:
name: Check Go formatting, linting, vetting
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [main]
pull_request:
branches: ["**"]
workflow_dispatch:

permissions:
contents: read
Expand All @@ -14,17 +15,17 @@ jobs:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
cache: false
- name: Checkout the code
uses: actions/checkout@v3.2.0
uses: actions/checkout@v4.1.0
- name: Vendor packages
run: |
go mod vendor
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.53
version: latest
skip-cache: true
26 changes: 11 additions & 15 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ type Client struct {
}

// Cluster defines struct for Cluster
type Cluster struct {
}
type Cluster struct{}

// ConfigConnect defines struct for ConfigConnect
type ConfigConnect struct {
Expand All @@ -73,7 +72,6 @@ type ClientPersistent struct {

// GetVersion returns version
func (c *Client) GetVersion() (string, error) {

resp, err := c.api.DoAndGetResponseBody(
context.Background(), http.MethodGet, "/api/version", nil, nil, c.configConnect.Version)
if err != nil {
Expand Down Expand Up @@ -108,7 +106,6 @@ func (c *Client) GetVersion() (string, error) {

// updateVersion updates version
func (c *Client) updateVersion() error {

version, err := c.GetVersion()
if err != nil {
return err
Expand All @@ -132,7 +129,6 @@ func updateHeaders(version string) {

// Authenticate controls authentication to client
func (c *Client) Authenticate(configConnect *ConfigConnect) (Cluster, error) {

configConnect.Version = c.configConnect.Version
c.configConnect = configConnect

Expand Down Expand Up @@ -187,8 +183,8 @@ func basicAuth(username, password string) string {

func (c *Client) getJSONWithRetry(
method, uri string,
body, resp interface{}) error {

body, resp interface{},
) error {
headers := make(map[string]string, 2)
headers[api.HeaderKeyAccept] = accHeader
headers[api.HeaderKeyContentType] = conHeader
Expand Down Expand Up @@ -240,8 +236,8 @@ func extractString(resp *http.Response) (string, error) {

func (c *Client) getStringWithRetry(
method, uri string,
body interface{}) (string, error) {

body interface{},
) (string, error) {
headers := make(map[string]string, 2)
headers[api.HeaderKeyAccept] = accHeader
headers[api.HeaderKeyContentType] = conHeader
Expand Down Expand Up @@ -333,8 +329,8 @@ func NewClientWithArgs(
version string,
timeout int64,
insecure,
useCerts bool) (client *Client, err error) {

useCerts bool,
) (client *Client, err error) {
if showHTTP {
debug = true
}
Expand Down Expand Up @@ -401,8 +397,8 @@ func withFields(fields map[string]interface{}, message string) error {
}

func withFieldsE(
fields map[string]interface{}, message string, inner error) error {

fields map[string]interface{}, message string, inner error,
) error {
if fields == nil {
fields = make(map[string]interface{})
}
Expand All @@ -429,8 +425,8 @@ func withFieldsE(

func doLog(
l func(args ...interface{}),
msg string) {

msg string,
) {
if debug {
l(msg)
}
Expand Down
43 changes: 20 additions & 23 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ var (

// Client is an API client.
type Client interface {

// Do sends an HTTP request to the API.
Do(
ctx context.Context,
Expand Down Expand Up @@ -136,11 +135,11 @@ type ClientOptions struct {

// New returns a new API client.
func New(
ctx context.Context,
_ context.Context,
host string,
opts ClientOptions,
debug bool) (Client, error) {

debug bool,
) (Client, error) {
if host == "" {
return nil, errNewClient
}
Expand Down Expand Up @@ -193,8 +192,8 @@ func (c *client) Get(
ctx context.Context,
path string,
headers map[string]string,
resp interface{}) error {

resp interface{},
) error {
return c.DoWithHeaders(
ctx, http.MethodGet, path, headers, nil, resp, "")
}
Expand All @@ -203,8 +202,8 @@ func (c *client) Post(
ctx context.Context,
path string,
headers map[string]string,
body, resp interface{}) error {

body, resp interface{},
) error {
return c.DoWithHeaders(
ctx, http.MethodPost, path, headers, body, resp, "")
}
Expand All @@ -213,8 +212,8 @@ func (c *client) Put(
ctx context.Context,
path string,
headers map[string]string,
body, resp interface{}) error {

body, resp interface{},
) error {
return c.DoWithHeaders(
ctx, http.MethodPut, path, headers, body, resp, "")
}
Expand All @@ -223,17 +222,17 @@ func (c *client) Delete(
ctx context.Context,
path string,
headers map[string]string,
resp interface{}) error {

resp interface{},
) error {
return c.DoWithHeaders(
ctx, http.MethodDelete, path, headers, nil, resp, "")
}

func (c *client) Do(
ctx context.Context,
method, path string,
body, resp interface{}) error {

body, resp interface{},
) error {
return c.DoWithHeaders(ctx, method, path, nil, body, resp, "")
}

Expand All @@ -249,8 +248,8 @@ func (c *client) DoWithHeaders(
ctx context.Context,
method, uri string,
headers map[string]string,
body, resp interface{}, version string) error {

body, resp interface{}, version string,
) error {
res, err := c.DoAndGetResponseBody(
ctx, method, uri, headers, body, version)
if err != nil {
Expand Down Expand Up @@ -289,8 +288,8 @@ func (c *client) DoAndGetResponseBody(
ctx context.Context,
method, uri string,
headers map[string]string,
body interface{}, version string) (*http.Response, error) {

body interface{}, version string,
) (*http.Response, error) {
var (
err error
req *http.Request
Expand Down Expand Up @@ -388,7 +387,6 @@ func (c *client) DoAndGetResponseBody(
} else {
req.SetBasicAuth("", c.token)
}

}

} else {
Expand Down Expand Up @@ -423,10 +421,9 @@ func (c *client) GetToken() string {
}

func (c *client) ParseJSONError(r *http.Response) error {

jsonError := &types.Error{}

//Starting in 4.0, response may be in html; so we cannot always use a json decoder
// Starting in 4.0, response may be in html; so we cannot always use a json decoder
if strings.Contains(r.Header.Get("Content-Type"), "html") {
jsonError.HTTPStatusCode = r.StatusCode
jsonError.Message = r.Status
Expand All @@ -447,8 +444,8 @@ func (c *client) ParseJSONError(r *http.Response) error {

func (c *client) doLog(
l func(args ...interface{}),
msg string) {

msg string,
) {
if c.debug {
l(msg)
}
Expand Down
13 changes: 6 additions & 7 deletions api/api_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func isBinOctetBody(h http.Header) bool {
}

func logRequest(
ctx context.Context,
_ context.Context,
req *http.Request,
lf func(func(args ...interface{}), string)) {

lf func(func(args ...interface{}), string),
) {
log.SetLevel(log.DebugLevel)

w := &bytes.Buffer{}
Expand All @@ -44,7 +44,6 @@ func logRequest(
fmt.Fprintln(w, " -------------------------")

buf, err := dumpRequest(req, !isBinOctetBody(req.Header))

if err != nil {
return
}
Expand All @@ -59,10 +58,10 @@ func logRequest(
}

func logResponse(
ctx context.Context,
_ context.Context,
res *http.Response,
lf func(func(args ...interface{}), string)) {

_ func(func(args ...interface{}), string),
) {
log.SetLevel(log.DebugLevel)

w := &bytes.Buffer{}
Expand Down
5 changes: 2 additions & 3 deletions api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func TestClientLogin(t *testing.T) {
default:
t.Fatal("Expecting endpoint /api/login got", req.RequestURI)
}

},
))
defer server.Close()
Expand Down Expand Up @@ -167,7 +166,7 @@ func (s stubTypeWithMetaData) MetaData() http.Header {
}

func Test_addMetaData(t *testing.T) {
var tests = []struct {
tests := []struct {
name string
givenHeader map[string]string
expectedHeader map[string]string
Expand Down Expand Up @@ -201,7 +200,7 @@ func Test_addMetaData(t *testing.T) {
}
}

func Test_updateHeaders(t *testing.T) {
func Test_updateHeaders(_ *testing.T) {
var wg sync.WaitGroup
for i := 0; i < 3; i++ {
wg.Add(1)
Expand Down
Loading