Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shaynafinocchiaro committed Feb 21, 2024
1 parent f642dc3 commit 6a6de60
Show file tree
Hide file tree
Showing 49 changed files with 199 additions and 199 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
run:
timeout: 20m
issue-exit-code: 0 # we will change this later
tests: true
skip-dirs-use-default: true
modules-download-mode: readonly
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,7 @@ package:
.PHONY: download-csm-common
download-csm-common:
curl -O -L https://raw.githubusercontent.com/dell/csm/main/config/csm-common.mk

.PHONY: lint
lint:
golangci-lint run --fix
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/cluster_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewClusterInfoCmd() *cobra.Command {
Use: "cluster-info",
Short: "Display the state of resources within the cluster",
Long: `Prints table of resources within the cluster, including their readiness`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
cmdArgs := []string{"kubectl", "get", "deploy", "-n", "karavi"}
if v, _ := cmd.Flags().GetBool("watch"); v {
cmdArgs = append(cmdArgs, "--watch")
Expand Down
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewGenerateCmd() *cobra.Command {
Use: "generate",
Short: "Generate resources for use with Karavi",
Long: `Generates resources for use with Karavi`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Usage()
if err != nil {
reportErrorAndExit(JSONOutput, os.Stderr, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/generate_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewAdminCmd() *cobra.Command {
Use: "admin",
Short: "Generate admin token for use with CSM Authorization",
Long: `Generate admin token for use with CSM Authorization`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
err := cmd.Usage()
if err != nil {
reportErrorAndExit(JSONOutput, os.Stderr, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/generate_admin_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewAdminTokenCmd() *cobra.Command {
Use: "token",
Short: "Generate tokens for an admin.",
Long: `Generates tokens for an admin.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
adminName, err := cmd.Flags().GetString("name")
if err != nil {
reportErrorAndExit(JSONOutput, cmd.ErrOrStderr(), err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/karavictl/cmd/generate_admin_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ func TestGenerateAdminToken(t *testing.T) {
}
t.Run("it requests creation of admin token", func(t *testing.T) {
defer afterFn()
JSONOutput = func(w io.Writer, _ interface{}) error {
JSONOutput = func(_ io.Writer, _ interface{}) error {
return nil
}
osExit = func(code int) {
osExit = func(_ int) {
}
var gotOutput bytes.Buffer

Expand Down
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/generate_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewGenerateTokenCmd() *cobra.Command {
Use: "token",
Short: "Generate tokens for a tenant.",
Long: `Generates tokens for a tenant.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
addr, err := cmd.Flags().GetString("addr")
if err != nil {
reportErrorAndExit(JSONOutput, cmd.ErrOrStderr(), err)
Expand Down
7 changes: 3 additions & 4 deletions cmd/karavictl/cmd/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ import (
"errors"
"fmt"
"io"
"karavi-authorization/internal/role-service/roles"
"karavi-authorization/pb"
"log"
"net"
"net/url"
"os"
"strings"
"time"

"karavi-authorization/internal/role-service/roles"
"karavi-authorization/pb"

pscale "github.com/dell/goisilon"
pmax "github.com/dell/gopowermax/v2"
"github.com/dell/goscaleio"
Expand Down Expand Up @@ -60,7 +59,7 @@ func NewRoleCmd() *cobra.Command {
Use: "role",
Short: "Manage roles",
Long: `Manage roles`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
if err := cmd.Usage(); err != nil {
reportErrorAndExit(JSONOutput, cmd.ErrOrStderr(), fmt.Errorf("error: %+v", err))
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/role_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewRoleCreateCmd() *cobra.Command {
Use: "create",
Short: "Create one or more CSM roles",
Long: `Creates one or more CSM roles`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
outFormat := "failed to create role: %+v\n"

// parse flags
Expand Down
20 changes: 10 additions & 10 deletions cmd/karavictl/cmd/role_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ func TestRoleCreateHandler(t *testing.T) {
t.Run("it requests creation of a role", func(t *testing.T) {
defer afterFn()
var gotCalled bool
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return &mocks.FakeClient{
PostFn: func(ctx context.Context, path string, headers map[string]string, query url.Values, body, resp interface{}) error {
PostFn: func(_ context.Context, _ string, _ map[string]string, _ url.Values, _, _ interface{}) error {
gotCalled = true
return nil
},
}, nil
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
JSONOutput = func(w io.Writer, _ interface{}) error {
JSONOutput = func(_ io.Writer, _ interface{}) error {
return nil
}
osExit = func(code int) {
osExit = func(_ int) {
}
var gotOutput bytes.Buffer

Expand All @@ -70,10 +70,10 @@ func TestRoleCreateHandler(t *testing.T) {
})
t.Run("it requires a valid role server connection", func(t *testing.T) {
defer afterFn()
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return nil, errors.New("failed to create role: test server error")
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotCode int
Expand Down Expand Up @@ -106,14 +106,14 @@ func TestRoleCreateHandler(t *testing.T) {
})
t.Run("it handles server errors", func(t *testing.T) {
defer afterFn()
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return &mocks.FakeClient{
PostFn: func(ctx context.Context, path string, headers map[string]string, query url.Values, body, resp interface{}) error {
PostFn: func(_ context.Context, _ string, _ map[string]string, _ url.Values, _, _ interface{}) error {
return errors.New("failed to create role: test error")
},
}, nil
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotCode int
Expand Down
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/role_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewRoleDeleteCmd() *cobra.Command {
Use: "delete",
Short: "Delete one or more CSM roles",
Long: `Delete one or mroe CSM roles`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down
20 changes: 10 additions & 10 deletions cmd/karavictl/cmd/role_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ func TestRoleDeleteHandler(t *testing.T) {
t.Run("it requests creation of a role", func(t *testing.T) {
defer afterFn()
var gotCalled bool
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return &mocks.FakeClient{
DeleteFn: func(ctx context.Context, path string, headers map[string]string, query url.Values, body, resp interface{}) error {
DeleteFn: func(_ context.Context, _ string, _ map[string]string, _ url.Values, _, _ interface{}) error {
gotCalled = true
return nil
},
}, nil
}
JSONOutput = func(w io.Writer, _ interface{}) error {
JSONOutput = func(_ io.Writer, _ interface{}) error {
return nil
}
osExit = func(code int) {
osExit = func(_ int) {
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotOutput bytes.Buffer
Expand All @@ -72,7 +72,7 @@ func TestRoleDeleteHandler(t *testing.T) {

t.Run("it requires a valid role server connection", func(t *testing.T) {
defer afterFn()
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return nil, errors.New("failed to delete role: test server error")
}
var gotCode int
Expand All @@ -82,7 +82,7 @@ func TestRoleDeleteHandler(t *testing.T) {
done <- struct{}{}
done <- struct{}{} // we can't let this function return
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotOutput bytes.Buffer
Expand All @@ -109,9 +109,9 @@ func TestRoleDeleteHandler(t *testing.T) {

t.Run("it handles server errors", func(t *testing.T) {
defer afterFn()
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return &mocks.FakeClient{
DeleteFn: func(ctx context.Context, path string, headers map[string]string, query url.Values, body, resp interface{}) error {
DeleteFn: func(_ context.Context, _ string, _ map[string]string, _ url.Values, _, _ interface{}) error {
return errors.New("failed to delete role: test error")
},
}, nil
Expand All @@ -123,7 +123,7 @@ func TestRoleDeleteHandler(t *testing.T) {
done <- struct{}{}
done <- struct{}{} // we can't let this function return
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotOutput bytes.Buffer
Expand Down
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/role_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewRoleGetCmd() *cobra.Command {
Use: "get",
Short: "Get CSM role",
Long: `Get CSM role`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down
18 changes: 9 additions & 9 deletions cmd/karavictl/cmd/role_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func TestRoleGetHandler(t *testing.T) {
t.Fatal(err)
}

CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return &mocks.FakeClient{
GetFn: func(ctx context.Context, path string, headers map[string]string, query url.Values, resp interface{}) error {
GetFn: func(_ context.Context, _ string, _ map[string]string, _ url.Values, resp interface{}) error {
b64Content := base64.StdEncoding.EncodeToString([]byte(b))
jsonStr := fmt.Sprintf(`{"role": "%s"}`, b64Content)
err = json.Unmarshal([]byte(jsonStr), resp)
Expand All @@ -71,9 +71,9 @@ func TestRoleGetHandler(t *testing.T) {
}, nil
}

osExit = func(code int) {
osExit = func(_ int) {
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotOutput bytes.Buffer
Expand All @@ -94,7 +94,7 @@ func TestRoleGetHandler(t *testing.T) {

t.Run("it requires a valid role server connection", func(t *testing.T) {
defer afterFn()
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return nil, errors.New("failed to get role: test server error")
}

Expand All @@ -105,7 +105,7 @@ func TestRoleGetHandler(t *testing.T) {
done <- struct{}{}
done <- struct{}{} // we can't let this function return
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotOutput bytes.Buffer
Expand All @@ -132,14 +132,14 @@ func TestRoleGetHandler(t *testing.T) {

t.Run("it handles server errors", func(t *testing.T) {
defer afterFn()
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return &mocks.FakeClient{
GetFn: func(ctx context.Context, path string, headers map[string]string, query url.Values, resp interface{}) error {
GetFn: func(_ context.Context, _ string, _ map[string]string, _ url.Values, _ interface{}) error {
return errors.New("failed to get role: test error")
},
}, nil
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotCode int
Expand Down
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/role_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewRoleListCmd() *cobra.Command {
Use: "list",
Short: "List CSM roles",
Long: `List CSM roles`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down
18 changes: 9 additions & 9 deletions cmd/karavictl/cmd/role_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func TestRoleListHandler(t *testing.T) {
t.Fatal(err)
}

CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return &mocks.FakeClient{
GetFn: func(ctx context.Context, path string, headers map[string]string, query url.Values, resp interface{}) error {
GetFn: func(_ context.Context, _ string, _ map[string]string, _ url.Values, resp interface{}) error {
b64Content := base64.StdEncoding.EncodeToString([]byte(b))
jsonStr := fmt.Sprintf(`{"roles": "%s"}`, b64Content)
err = json.Unmarshal([]byte(jsonStr), resp)
Expand All @@ -70,9 +70,9 @@ func TestRoleListHandler(t *testing.T) {
}, nil
}

osExit = func(code int) {
osExit = func(_ int) {
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotOutput bytes.Buffer
Expand All @@ -93,7 +93,7 @@ func TestRoleListHandler(t *testing.T) {

t.Run("it requires a valid role server connection", func(t *testing.T) {
defer afterFn()
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return nil, errors.New("failed to list roles: test server error")
}
var gotCode int
Expand All @@ -103,7 +103,7 @@ func TestRoleListHandler(t *testing.T) {
done <- struct{}{}
done <- struct{}{} // we can't let this function return
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotOutput bytes.Buffer
Expand All @@ -130,9 +130,9 @@ func TestRoleListHandler(t *testing.T) {

t.Run("it handles server errors", func(t *testing.T) {
defer afterFn()
CreateHTTPClient = func(addr string, insecure bool) (api.Client, error) {
CreateHTTPClient = func(_ string, _ bool) (api.Client, error) {
return &mocks.FakeClient{
GetFn: func(ctx context.Context, path string, headers map[string]string, query url.Values, resp interface{}) error {
GetFn: func(_ context.Context, _ string, _ map[string]string, _ url.Values, _ interface{}) error {
return errors.New("failed to list roles: test error")
},
}, nil
Expand All @@ -144,7 +144,7 @@ func TestRoleListHandler(t *testing.T) {
done <- struct{}{}
done <- struct{}{} // we can't let this function return
}
ReadAccessAdminToken = func(afile string) (string, string, error) {
ReadAccessAdminToken = func(_ string) (string, string, error) {
return "AUnumberTokenIsNotWorkingman", "AUnumberTokenIsNotWorkingman", nil
}
var gotOutput bytes.Buffer
Expand Down
2 changes: 1 addition & 1 deletion cmd/karavictl/cmd/role_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewRoleUpdateCmd() *cobra.Command {
Use: "update",
Short: "Update the quota of one or more CSM roles",
Long: `Updates the quota of one or more CSM roles`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down
Loading

0 comments on commit 6a6de60

Please sign in to comment.