Skip to content

Commit

Permalink
Fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
vcheung-stripe committed Oct 18, 2024
1 parent 3e64ad8 commit fabfd65
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func newFixturesCmd(cfg *config.Config) *FixturesCmd {
func (fc *FixturesCmd) runFixturesCmd(cmd *cobra.Command, args []string) error {
version.CheckLatestVersion()

if err := stripe.ValidateAPIBaseUrl(fc.apiBaseURL); err != nil {
if err := stripe.ValidateAPIBaseURL(fc.apiBaseURL); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Stripe account.`,
// Normally, this function would be listed alphabetically with the others declared in this file,
// but since it's acting as the core functionality for the cmd above, I'm keeping it close.
func (lc *listenCmd) runListenCmd(cmd *cobra.Command, args []string) error {
if err := stripe.ValidateAPIBaseUrl(lc.apiBaseURL); err != nil {
if err := stripe.ValidateAPIBaseURL(lc.apiBaseURL); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/logs/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func withSIGTERMCancel(ctx context.Context, onCancel func()) context.Context {
}

func (tailCmd *TailCmd) runTailCmd(cmd *cobra.Command, args []string) error {
if err := stripe.ValidateAPIBaseUrl(tailCmd.apiBaseURL); err != nil {
if err := stripe.ValidateAPIBaseURL(tailCmd.apiBaseURL); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/plugin/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (ic *InstallCmd) installPluginByName(cmd *cobra.Command, arg string) error
}

func (ic *InstallCmd) runInstallCmd(cmd *cobra.Command, args []string) error {
if err := stripe.ValidateAPIBaseUrl(ic.apiBaseURL); err != nil {
if err := stripe.ValidateAPIBaseURL(ic.apiBaseURL); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/plugin/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewUpgradeCmd(config *config.Config) *UpgradeCmd {
}

func (uc *UpgradeCmd) runUpgradeCmd(cmd *cobra.Command, args []string) error {
if err := stripe.ValidateAPIBaseUrl(uc.apiBaseURL); err != nil {
if err := stripe.ValidateAPIBaseURL(uc.apiBaseURL); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/resource/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type OperationCmd struct {
}

func (oc *OperationCmd) runOperationCmd(cmd *cobra.Command, args []string) error {
if err := stripe.ValidateAPIBaseUrl(oc.APIBaseURL); err != nil {
if err := stripe.ValidateAPIBaseURL(oc.APIBaseURL); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ needed to create the triggered event as well as the corresponding API objects.
func (tc *triggerCmd) runTriggerCmd(cmd *cobra.Command, args []string) error {
version.CheckLatestVersion()

if err := stripe.ValidateAPIBaseUrl(tc.apiBaseURL); err != nil {
if err := stripe.ValidateAPIBaseURL(tc.apiBaseURL); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/requests/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var confirmationCommands = map[string]bool{http.MethodDelete: true}

// RunRequestsCmd is the interface exposed for the CLI to run network requests through
func (rb *Base) RunRequestsCmd(cmd *cobra.Command, args []string) error {
if err := stripe.ValidateAPIBaseUrl(rb.APIBaseURL); err != nil {
if err := stripe.ValidateAPIBaseURL(rb.APIBaseURL); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/stripe/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const devDashboardBaseURLRegexp = `http(s)?:\/\/[A-Za-z0-9\-]+manage-mydev.dev.s
var errInvalidAPIBaseURL = errors.New("invalid API base URL")
var errInvalidDashboardBaseURL = errors.New("invalid dashboard base URL")

// ValidateAPIBaseUrl returns an error if apiBaseURL isn't allowed
func ValidateAPIBaseUrl(apiBaseURL string) error {
// ValidateAPIBaseURL returns an error if apiBaseURL isn't allowed
func ValidateAPIBaseURL(apiBaseURL string) error {
if apiBaseURL == DefaultAPIBaseURL {
return nil
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/stripe/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import (
)

func TestValidateAPIBaseURLWorks(t *testing.T) {
assert.Nil(t, ValidateAPIBaseUrl("https://api.stripe.com"))
assert.Nil(t, ValidateAPIBaseUrl("https://qa-api.stripe.com"))
assert.Nil(t, ValidateAPIBaseUrl("http://foo-api-mydev.dev.stripe.me"))
assert.Nil(t, ValidateAPIBaseUrl("https://foo-lv5r9y--api-mydev.dev.stripe.me/"))
assert.Nil(t, ValidateAPIBaseURL("https://api.stripe.com"))
assert.Nil(t, ValidateAPIBaseURL("https://qa-api.stripe.com"))
assert.Nil(t, ValidateAPIBaseURL("http://foo-api-mydev.dev.stripe.me"))
assert.Nil(t, ValidateAPIBaseURL("https://foo-lv5r9y--api-mydev.dev.stripe.me/"))

assert.Error(t, ValidateAPIBaseUrl("https://example.com"))
assert.Error(t, ValidateAPIBaseUrl("https://unknowndomain"))
assert.Error(t, ValidateAPIBaseUrl("http://127.0.0.1:1337 "))
assert.Error(t, ValidateAPIBaseUrl("localhost"))
assert.Error(t, ValidateAPIBaseUrl("anything_else"))
assert.Error(t, ValidateAPIBaseURL("https://example.com"))
assert.Error(t, ValidateAPIBaseURL("https://unknowndomain"))
assert.Error(t, ValidateAPIBaseURL("http://127.0.0.1:1337 "))
assert.Error(t, ValidateAPIBaseURL("localhost"))
assert.Error(t, ValidateAPIBaseURL("anything_else"))
}

func TestValidateDashboardBaseURLWorks(t *testing.T) {
Expand Down

0 comments on commit fabfd65

Please sign in to comment.