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

Update golangci lint config #669

Merged
merged 3 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 7 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ linters-settings:
capital: true
goimports:
local-prefixes: "github.com/auth0/auth0-cli"
revive:
rules:
- name: package-comments
severity: warning
disabled: true

issues:
exclude-use-default: false
fix: true
exclude:
- "should have a package comment"
- "package comment should be of the form"
- "should have comment"
- "be unexported"
- "error strings should not be capitalized or end with punctuation or a newline"
- "blank-imports"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ install-with-cover: ## Install the cli binary for the native platform with cover

lint: $(GO_BIN)/golangci-lint ## Run go linter checks
${call print, "Running golangci-lint over project"}
@golangci-lint run -v -c .golangci.yml ./...
@golangci-lint run -v --fix -c .golangci.yml ./...

check-vuln: $(GO_BIN)/govulncheck ## Check go vulnerabilities
${call print, "Running govulncheck over project"}
Expand Down
4 changes: 1 addition & 3 deletions internal/auth/authutil/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
// BuildLoginURL constructs a URL + query string that can be used to
// initiate a user-facing login-flow from the CLI.
func BuildLoginURL(domain, clientID, callbackURL, state, connectionName, audience, prompt string, scopes []string) (string, error) {
var path string = "/authorize"

q := url.Values{}
q.Add("client_id", clientID)
q.Add("response_type", "code")
Expand All @@ -35,7 +33,7 @@ func BuildLoginURL(domain, clientID, callbackURL, state, connectionName, audienc
u := &url.URL{
Scheme: "https",
Host: domain,
Path: path,
Path: "/authorize",
RawQuery: q.Encode(),
}

Expand Down
3 changes: 1 addition & 2 deletions internal/cli/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ func TestAPICmdInputs_FromArgs(t *testing.T) {
if testCase.expectedError != "" {
assert.EqualError(t, err, testCase.expectedError)
return
} else {
assert.NoError(t, err)
}

assert.NoError(t, err)
assert.Equal(t, testCase.expectedMethod, actualInputs.Method)
assert.Equal(t, testCase.expectedURL, actualInputs.URL.String())
})
Expand Down
32 changes: 16 additions & 16 deletions internal/cli/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ func apisCmd(cli *cli) *cobra.Command {

cmd.SetUsageTemplate(resourceUsageTemplate())
cmd.AddCommand(listApisCmd(cli))
cmd.AddCommand(createApiCmd(cli))
cmd.AddCommand(showApiCmd(cli))
cmd.AddCommand(updateApiCmd(cli))
cmd.AddCommand(deleteApiCmd(cli))
cmd.AddCommand(openApiCmd(cli))
cmd.AddCommand(createAPICmd(cli))
cmd.AddCommand(showAPICmd(cli))
cmd.AddCommand(updateAPICmd(cli))
cmd.AddCommand(deleteAPICmd(cli))
cmd.AddCommand(openAPICmd(cli))
cmd.AddCommand(scopesCmd(cli))

return cmd
Expand Down Expand Up @@ -142,7 +142,7 @@ func listApisCmd(cli *cli) *cobra.Command {
apis = append(apis, item.(*management.ResourceServer))
}

cli.renderer.ApiList(apis)
cli.renderer.APIList(apis)

return nil
},
Expand All @@ -154,7 +154,7 @@ func listApisCmd(cli *cli) *cobra.Command {
return cmd
}

func showApiCmd(cli *cli) *cobra.Command {
func showAPICmd(cli *cli) *cobra.Command {
var inputs struct {
ID string
}
Expand Down Expand Up @@ -187,7 +187,7 @@ func showApiCmd(cli *cli) *cobra.Command {
return fmt.Errorf("Unable to get an API with Id '%s': %w", inputs.ID, err)
}

cli.renderer.ApiShow(api, cli.json)
cli.renderer.APIShow(api, cli.json)
return nil
},
}
Expand All @@ -197,7 +197,7 @@ func showApiCmd(cli *cli) *cobra.Command {
return cmd
}

func createApiCmd(cli *cli) *cobra.Command {
func createAPICmd(cli *cli) *cobra.Command {
var inputs struct {
Name string
Identifier string
Expand Down Expand Up @@ -267,7 +267,7 @@ func createApiCmd(cli *cli) *cobra.Command {
return fmt.Errorf("An unexpected error occurred while attempting to create an API with name '%s' and identifier '%s': %w", inputs.Name, inputs.Identifier, err)
}

cli.renderer.ApiCreate(api)
cli.renderer.APICreate(api)
return nil
},
}
Expand All @@ -282,7 +282,7 @@ func createApiCmd(cli *cli) *cobra.Command {
return cmd
}

func updateApiCmd(cli *cli) *cobra.Command {
func updateAPICmd(cli *cli) *cobra.Command {
var inputs struct {
ID string
Name string
Expand Down Expand Up @@ -375,7 +375,7 @@ func updateApiCmd(cli *cli) *cobra.Command {
return fmt.Errorf("An unexpected error occurred while trying to update an API with Id '%s': %w", inputs.ID, err)
}

cli.renderer.ApiUpdate(api)
cli.renderer.APIUpdate(api)
return nil
},
}
Expand All @@ -389,7 +389,7 @@ func updateApiCmd(cli *cli) *cobra.Command {
return cmd
}

func deleteApiCmd(cli *cli) *cobra.Command {
func deleteAPICmd(cli *cli) *cobra.Command {
var inputs struct {
ID string
}
Expand Down Expand Up @@ -439,7 +439,7 @@ func deleteApiCmd(cli *cli) *cobra.Command {
return cmd
}

func openApiCmd(cli *cli) *cobra.Command {
func openAPICmd(cli *cli) *cobra.Command {
var inputs struct {
ID string
}
Expand Down Expand Up @@ -480,7 +480,7 @@ func openApiCmd(cli *cli) *cobra.Command {
}
}

openManageURL(cli, cli.config.DefaultTenant, formatApiSettingsPath(inputs.ID))
openManageURL(cli, cli.config.DefaultTenant, formatAPISettingsPath(inputs.ID))
return nil
},
}
Expand Down Expand Up @@ -532,7 +532,7 @@ func listScopesCmd(cli *cli) *cobra.Command {
return cmd
}

func formatApiSettingsPath(id string) string {
func formatAPISettingsPath(id string) string {
if len(id) == 0 {
return ""
}
Expand Down
3 changes: 1 addition & 2 deletions internal/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,8 @@ func openEditorFlag(cmd *cobra.Command, f *Flag, value *string, defaultValue str
if shouldAsk(cmd, f, false) { // Always open the editor on update
if isUpdate {
return openUpdateEditor(cmd, f, value, defaultValue, filename)
} else {
return openCreateEditor(cmd, f, value, defaultValue, filename, infoFn, tempFileFn)
}
return openCreateEditor(cmd, f, value, defaultValue, filename, infoFn, tempFileFn)
}

return nil
Expand Down
10 changes: 5 additions & 5 deletions internal/cli/log_streams_datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (

datadogRegionOptions = []string{"eu", "us", "us3", "us5"}

datadogApiKey = Flag{
datadogAPIKey = Flag{
Name: "Datadog API Key",
LongForm: "api-key",
ShortForm: "k",
Expand Down Expand Up @@ -60,7 +60,7 @@ func createLogStreamsDatadogCmd(cli *cli) *cobra.Command {
return err
}

if err := datadogApiKey.AskPassword(cmd, &inputs.DatadogAPIKey, nil); err != nil {
if err := datadogAPIKey.AskPassword(cmd, &inputs.DatadogAPIKey, nil); err != nil {
return err
}

Expand All @@ -87,7 +87,7 @@ func createLogStreamsDatadogCmd(cli *cli) *cobra.Command {

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
logStreamName.RegisterString(cmd, &inputs.Name, "")
datadogApiKey.RegisterString(cmd, &inputs.DatadogAPIKey, "")
datadogAPIKey.RegisterString(cmd, &inputs.DatadogAPIKey, "")
datadogRegion.RegisterString(cmd, &inputs.DatadogRegion, "")

return cmd
Expand Down Expand Up @@ -146,7 +146,7 @@ func updateLogStreamsDatadogCmd(cli *cli) *cobra.Command {
return err
}

if err := datadogApiKey.AskPasswordU(cmd, &inputs.DatadogAPIKey, datadogSink.APIKey); err != nil {
if err := datadogAPIKey.AskPasswordU(cmd, &inputs.DatadogAPIKey, datadogSink.APIKey); err != nil {
return err
}

Expand Down Expand Up @@ -178,7 +178,7 @@ func updateLogStreamsDatadogCmd(cli *cli) *cobra.Command {

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
logStreamName.RegisterStringU(cmd, &inputs.Name, "")
datadogApiKey.RegisterStringU(cmd, &inputs.DatadogAPIKey, "")
datadogAPIKey.RegisterStringU(cmd, &inputs.DatadogAPIKey, "")
datadogRegion.RegisterStringU(cmd, &inputs.DatadogRegion, "")

return cmd
Expand Down
78 changes: 39 additions & 39 deletions internal/cli/log_streams_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ var (
func createLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command {
var inputs struct {
Name string
HttpEndpoint string
HttpContentType string
HttpContentFormat string
HttpAuthorization string
HTTPEndpoint string
HTTPContentType string
HTTPContentFormat string
HTTPAuthorization string
}

cmd := &cobra.Command{
Expand All @@ -74,19 +74,19 @@ func createLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command {
return err
}

if err := httpEndpoint.Ask(cmd, &inputs.HttpEndpoint, nil); err != nil {
if err := httpEndpoint.Ask(cmd, &inputs.HTTPEndpoint, nil); err != nil {
return err
}

if err := httpContentType.Ask(cmd, &inputs.HttpContentType, nil); err != nil {
if err := httpContentType.Ask(cmd, &inputs.HTTPContentType, nil); err != nil {
return err
}

if err := httpContentFormat.Select(cmd, &inputs.HttpContentFormat, httpContentFormatOptions, nil); err != nil {
if err := httpContentFormat.Select(cmd, &inputs.HTTPContentFormat, httpContentFormatOptions, nil); err != nil {
return err
}

if err := httpAuthorization.AskPassword(cmd, &inputs.HttpAuthorization, nil); err != nil {
if err := httpAuthorization.AskPassword(cmd, &inputs.HTTPAuthorization, nil); err != nil {
return err
}

Expand All @@ -95,16 +95,16 @@ func createLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command {
Type: auth0.String(string(logStreamTypeHTTP)),
}
sink := &management.LogStreamSinkHTTP{
Endpoint: &inputs.HttpEndpoint,
Endpoint: &inputs.HTTPEndpoint,
}
if inputs.HttpAuthorization != "" {
sink.Authorization = &inputs.HttpAuthorization
if inputs.HTTPAuthorization != "" {
sink.Authorization = &inputs.HTTPAuthorization
}
if inputs.HttpContentType != "" {
sink.ContentType = &inputs.HttpContentType
if inputs.HTTPContentType != "" {
sink.ContentType = &inputs.HTTPContentType
}
if inputs.HttpContentFormat != "" {
sink.ContentFormat = apiHTTPContentFormatFor(inputs.HttpContentFormat)
if inputs.HTTPContentFormat != "" {
sink.ContentFormat = apiHTTPContentFormatFor(inputs.HTTPContentFormat)
}
newLogStream.Sink = sink

Expand All @@ -122,10 +122,10 @@ func createLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command {

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
logStreamName.RegisterString(cmd, &inputs.Name, "")
httpEndpoint.RegisterString(cmd, &inputs.HttpEndpoint, "")
httpContentType.RegisterString(cmd, &inputs.HttpContentType, "")
httpContentFormat.RegisterString(cmd, &inputs.HttpContentFormat, "")
httpAuthorization.RegisterString(cmd, &inputs.HttpAuthorization, "")
httpEndpoint.RegisterString(cmd, &inputs.HTTPEndpoint, "")
httpContentType.RegisterString(cmd, &inputs.HTTPContentType, "")
httpContentFormat.RegisterString(cmd, &inputs.HTTPContentFormat, "")
httpAuthorization.RegisterString(cmd, &inputs.HTTPAuthorization, "")

return cmd
}
Expand All @@ -134,10 +134,10 @@ func updateLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command {
var inputs struct {
ID string
Name string
HttpEndpoint string
HttpContentType string
HttpContentFormat string
HttpAuthorization string
HTTPEndpoint string
HTTPContentType string
HTTPContentFormat string
HTTPAuthorization string
}

cmd := &cobra.Command{
Expand Down Expand Up @@ -183,16 +183,16 @@ func updateLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command {

httpSink := oldLogStream.Sink.(*management.LogStreamSinkHTTP)

if err := httpEndpoint.AskU(cmd, &inputs.HttpEndpoint, httpSink.Endpoint); err != nil {
if err := httpEndpoint.AskU(cmd, &inputs.HTTPEndpoint, httpSink.Endpoint); err != nil {
return err
}
if err := httpContentType.AskU(cmd, &inputs.HttpContentType, httpSink.ContentType); err != nil {
if err := httpContentType.AskU(cmd, &inputs.HTTPContentType, httpSink.ContentType); err != nil {
return err
}
if err := httpContentFormat.SelectU(cmd, &inputs.HttpContentFormat, httpContentFormatOptions, httpSink.ContentFormat); err != nil {
if err := httpContentFormat.SelectU(cmd, &inputs.HTTPContentFormat, httpContentFormatOptions, httpSink.ContentFormat); err != nil {
return err
}
if err := httpAuthorization.AskPasswordU(cmd, &inputs.HttpAuthorization, httpSink.Authorization); err != nil {
if err := httpAuthorization.AskPasswordU(cmd, &inputs.HTTPAuthorization, httpSink.Authorization); err != nil {
return err
}

Expand All @@ -201,17 +201,17 @@ func updateLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command {
if inputs.Name != "" {
updatedLogStream.Name = &inputs.Name
}
if inputs.HttpEndpoint != "" {
httpSink.Endpoint = &inputs.HttpEndpoint
if inputs.HTTPEndpoint != "" {
httpSink.Endpoint = &inputs.HTTPEndpoint
}
if inputs.HttpAuthorization != "" {
httpSink.Authorization = &inputs.HttpAuthorization
if inputs.HTTPAuthorization != "" {
httpSink.Authorization = &inputs.HTTPAuthorization
}
if inputs.HttpContentType != "" {
httpSink.ContentType = &inputs.HttpContentType
if inputs.HTTPContentType != "" {
httpSink.ContentType = &inputs.HTTPContentType
}
if inputs.HttpContentFormat != "" {
httpSink.ContentFormat = apiHTTPContentFormatFor(inputs.HttpContentFormat)
if inputs.HTTPContentFormat != "" {
httpSink.ContentFormat = apiHTTPContentFormatFor(inputs.HTTPContentFormat)
}

updatedLogStream.Sink = httpSink
Expand All @@ -230,10 +230,10 @@ func updateLogStreamsCustomWebhookCmd(cli *cli) *cobra.Command {

cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
logStreamName.RegisterStringU(cmd, &inputs.Name, "")
httpEndpoint.RegisterStringU(cmd, &inputs.HttpEndpoint, "")
httpContentType.RegisterStringU(cmd, &inputs.HttpContentType, "")
httpContentFormat.RegisterStringU(cmd, &inputs.HttpContentFormat, "")
httpAuthorization.RegisterStringU(cmd, &inputs.HttpAuthorization, "")
httpEndpoint.RegisterStringU(cmd, &inputs.HTTPEndpoint, "")
httpContentType.RegisterStringU(cmd, &inputs.HTTPContentType, "")
httpContentFormat.RegisterStringU(cmd, &inputs.HTTPContentFormat, "")
httpAuthorization.RegisterStringU(cmd, &inputs.HTTPAuthorization, "")

return cmd
}
Expand Down
Loading