Skip to content

Commit

Permalink
Fix bool comparison and whitespace linting
Browse files Browse the repository at this point in the history
  • Loading branch information
optik-aper committed Oct 24, 2023
1 parent e99c8f5 commit 23c3586
Show file tree
Hide file tree
Showing 22 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cmd/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var accountCmd = &cobra.Command{
printer.Account(account)
},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Backups() *cobra.Command {
Aliases: []string{"b"},
Short: "Display backups",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/bareMetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func BareMetal() *cobra.Command {
Long: bareMetalLong,
Example: bareMetalExample,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func Billing() *cobra.Command {
Long: billingLong,
Example: billingExample,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/blockStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func BlockStorageCmd() *cobra.Command {
Short: "block storage commands",
Long: `block-storage is used to interact with the block-storage api`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func Database() *cobra.Command { //nolint:funlen
Long: databaseLong,
Example: databaseExample,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func DNS() *cobra.Command {
Short: "dns is used to access dns commands",
Long: ``,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Firewall() *cobra.Command {
Long: ``,
Aliases: []string{"fw"},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func Instance() *cobra.Command { //nolint: funlen,gocyclo
Long: instanceLong,
Example: instanceExample,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ISO() *cobra.Command {
Short: "iso is used to access iso commands",
Long: ``,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func Kubernetes() *cobra.Command { //nolint: funlen
Long: kubernetesLong,
Example: kubernetesExample,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/loadBalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func LoadBalancer() *cobra.Command { //nolint: funlen
Long: lbLong,
Example: lbExample,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Network() *cobra.Command {
Long: netLong,
Deprecated: "Use vpc instead.",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/objectStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func ObjectStorageCmd() *cobra.Command {
Short: "object storage commands",
Long: `object-storage is used to interact with the object-storage api`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/reservedIP.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func ReservedIP() *cobra.Command {
Long: reservedIPLong,
Example: reservedIPExample,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ import (
)

const (
userAgent = "vultr-cli/" + version
perPageDefault int = 100
apiKeyError string = `
userAgent = "vultr-cli/" + version
perPageDefault int = 100
//nolint: gosec
apiKeyError string = `
Please export your VULTR API key as an environment variable or add 'api-key' to your config file, eg:
export VULTR_API_KEY='<api_key_from_vultr_account>'
`
Expand Down Expand Up @@ -124,7 +125,6 @@ func initConfig() context.Context {
if token == "" {
client = govultr.NewClient(nil)
ctx = context.WithValue(ctx, ctxAuthKey{}, false)

} else {
config := &oauth2.Config{}
ts := config.TokenSource(ctx, &oauth2.Token{AccessToken: token})
Expand Down
2 changes: 1 addition & 1 deletion cmd/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Script() *cobra.Command {
Short: "startup script commands",
Long: `script is used to access startup script commands`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Snapshot() *cobra.Command {
Short: "snapshot commands",
Long: `snapshot is used to access snapshot commands`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/sshKey.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func SSHKey() *cobra.Command {
Short: "ssh-key commands",
Long: `ssh-key is used to access SSH key commands`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func User() *cobra.Command {
Short: "user commands",
Long: `user is used to access user commands`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func VPC() *cobra.Command {
Long: vpcLong,
Example: vpcExample,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/vpc2.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func VPC2() *cobra.Command {
Long: vpc2Long,
Example: vpc2Example,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Context().Value(ctxAuthKey{}).(bool) == false {
if !cmd.Context().Value(ctxAuthKey{}).(bool) {
return errors.New(apiKeyError)
}
return nil
Expand Down

0 comments on commit 23c3586

Please sign in to comment.