Skip to content

Commit

Permalink
golint
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed Aug 12, 2024
1 parent c6d6d09 commit de9854a
Show file tree
Hide file tree
Showing 220 changed files with 325 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ linters:
# - errcheck
- exhaustive
# - gocritic
# - golint
- golint
- gci
- gomodguard
- gosec
Expand Down
1 change: 1 addition & 0 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hetznercloud/cli/internal/state/config"
)

// NewRootCommand creates the root command.
func NewRootCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "hcloud",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hetznercloud/cli/internal/state"
)

// NewCommand creates the command for 'hcloud all'
func NewCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "all",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/all/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var allCmds = []base.ListCmd{
sshkey.ListCmd,
}

// ListCmd is the command for 'hcloud all list'
var ListCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {

Expand Down
1 change: 1 addition & 0 deletions internal/cmd/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hetznercloud/cli/internal/state"
)

// NewCommand creates the command for 'hcloud certificate'
func NewCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "certificate",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/certificate/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// CreateCmd is the command for 'hcloud certificate create'
var CreateCmd = base.CreateCmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/certificate/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// DeleteCmd is the command for 'hcloud certificate delete'
var DeleteCmd = base.DeleteCmd{
ResourceNameSingular: "certificate",
ResourceNamePlural: "certificates",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/certificate/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// DescribeCmd is the command for 'hcloud certificate describe'
var DescribeCmd = base.DescribeCmd{
ResourceNameSingular: "certificate",
ShortDescription: "Describe an certificate",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/certificate/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// LabelCmds are the command for 'hcloud certificate add-label' and 'hcloud certificate remove-label'
var LabelCmds = base.LabelCmds{
ResourceNameSingular: "certificate",
ShortDescriptionAdd: "Add a label to an certificate",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/certificate/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud/schema"
)

// ListCmd is the command for 'hcloud certificate list'
var ListCmd = base.ListCmd{
ResourceNamePlural: "Certificates",
JSONKeyGetByName: "certificates",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/certificate/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// UpdateCmd is the command for 'hcloud certificate update'
var UpdateCmd = base.UpdateCmd{
ResourceNameSingular: "certificate",
ShortDescription: "Update a certificate",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
// source <(hcloud completion zsh)`
// )

// NewCommand creates the command for 'hcloud completion'
func NewCommand(_ state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "completion <shell>",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/config/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hetznercloud/cli/internal/state/config"
)

// NewAddCommand creates the command for 'hcloud config add'
func NewAddCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "add <key> <value>...",
Expand Down
2 changes: 2 additions & 0 deletions internal/cmd/config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
// embed is used to embed the help text into the binary
_ "embed"

"github.com/spf13/cobra"
Expand All @@ -15,6 +16,7 @@ var nonPreferenceOptions string
//go:embed helptext/preferences.txt
var preferenceOptions string

// NewCommand creates the command for 'hcloud config'
func NewCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "config",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/config/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hetznercloud/cli/internal/state/config"
)

// NewGetCommand creates the command for 'hcloud config get'
func NewGetCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "get <key>",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/config/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

var outputColumns = []string{"key", "value"}

// NewListCommand creates the command for 'hcloud config list'.
func NewListCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/config/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hetznercloud/cli/internal/state/config"
)

// NewRemoveCommand creates a new command for 'hcloud config remove'
func NewRemoveCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "remove <key> <value>...",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/config/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hetznercloud/cli/internal/state/config"
)

// NewSetCommand creates a new command for 'hcloud config set'
func NewSetCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "set <key> <value>...",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/config/unset.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hetznercloud/cli/internal/state/config"
)

// NewUnsetCommand creates a new command for 'hcloud config unset'
func NewUnsetCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "unset <key>",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/context/active.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hetznercloud/cli/internal/state"
)

// NewActiveCommand creates the command for 'hcloud context active'
func NewActiveCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "active",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hetznercloud/cli/internal/state"
)

// NewCommand creates the command for 'hcloud context'
func NewCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "context",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/context/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hetznercloud/cli/internal/state/config"
)

// NewCreateCommand creates the command for 'hcloud context create'
func NewCreateCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "create <name>",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/context/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hetznercloud/cli/internal/state/config"
)

// NewDeleteCommand creates the command for 'hcloud context delete'
func NewDeleteCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "delete <context>",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/context/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type presentation struct {
Active string
}

// NewListCommand creates the command for 'hcloud context list'
func NewListCommand(s state.State) *cobra.Command {
cols := newListOutputTable().Columns()
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/context/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hetznercloud/cli/internal/state/config"
)

// NewUseCommand creates the command for 'hcloud context use'
func NewUseCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "use <context>",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/datacenter/datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hetznercloud/cli/internal/state"
)

// NewCommand creates the command for 'hcloud datacenter'
func NewCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "datacenter",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/datacenter/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// DescribeCmd is the command for 'hcloud datacenter describe'
var DescribeCmd = base.DescribeCmd{
ResourceNameSingular: "datacenter",
ShortDescription: "Describe an datacenter",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/datacenter/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud/schema"
)

// ListCmd is the command for 'hcloud datacenter list'
var ListCmd = base.ListCmd{
ResourceNamePlural: "Datacenters",
JSONKeyGetByName: "datacenters",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/add_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// AddRuleCmd is the command for 'hcloud firewall add-rule'
var AddRuleCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/apply_to_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// ApplyToResourceCmd is the command for 'hcloud firewall apply-to-resource'
var ApplyToResourceCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud/schema"
)

// CreateCmd is the command for 'hcloud firewall create'
var CreateCmd = base.CreateCmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// DeleteCmd is the command for 'hcloud firewall delete'
var DeleteCmd = base.DeleteCmd{
ResourceNameSingular: "firewall",
ResourceNamePlural: "firewalls",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/delete_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// DeleteRuleCmd is the command for 'hcloud firewall delete-rule'
var DeleteRuleCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// DescribeCmd is the command for 'hcloud firewall describe'
var DescribeCmd = base.DescribeCmd{
ResourceNameSingular: "firewall",
ShortDescription: "Describe an firewall",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/hetznercloud/cli/internal/state"
)

// NewCommand creates the command for 'hcloud firewall'
func NewCommand(s state.State) *cobra.Command {
cmd := &cobra.Command{
Use: "firewall",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// LabelCmds are the command for 'hcloud firewall add-label' and 'hcloud firewall remove-label'
var LabelCmds = base.LabelCmds{
ResourceNameSingular: "firewall",
ShortDescriptionAdd: "Add a label to an firewall",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud/schema"
)

// ListCmd is the command for 'hcloud firewall list'
var ListCmd = base.ListCmd{
ResourceNamePlural: "Firewalls",
JSONKeyGetByName: "firewalls",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/remove_from_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// RemoveFromResourceCmd is the command for 'hcloud firewall remove-from-resource'
var RemoveFromResourceCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/replace_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// ReplaceRulesCmd is the command for 'hcloud firewall replace-rules'
var ReplaceRulesCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// UpdateCmd is the command for 'hcloud firewall update'
var UpdateCmd = base.UpdateCmd{
ResourceNameSingular: "Firewall",
ShortDescription: "Update a firewall",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/firewall/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net"
)

// ValidateFirewallIP checks if the given IP is a valid IP address or CIDR block and returns the net.IPNet
func ValidateFirewallIP(ip string) (*net.IPNet, error) {
i, n, err := net.ParseCIDR(ip)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/firewall/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestValidateFirewallIP(t *testing.T) {
{
name: "Missing CIDR notation (IPv6)",
ip: "fe80::",
//nolint:revive
//nolint:revive,golint
err: fmt.Errorf("invalid CIDR address: fe80::"),
},
{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/floatingip/assign.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hetznercloud/cli/internal/state"
)

// AssignCmd is the command for 'hcloud floating-ip assign'
var AssignCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
return &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/floatingip/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// CreateCmd is the command for 'hcloud floating-ip create'
var CreateCmd = base.CreateCmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/floatingip/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// DeleteCmd is the command for 'hcloud floating-ip delete'
var DeleteCmd = base.DeleteCmd{
ResourceNameSingular: "Floating IP",
ResourceNamePlural: "Floating IPs",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/floatingip/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

// DescribeCmd is the command for 'hcloud floating-ip describe'
var DescribeCmd = base.DescribeCmd{
ResourceNameSingular: "Floating IP",
ShortDescription: "Describe an Floating IP",
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/floatingip/disable_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hetznercloud/cli/internal/state"
)

// DisableProtectionCmd is the command for 'hcloud floating-ip disable-protection'
var DisableProtectionCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
return &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/floatingip/enable_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func changeProtection(s state.State, cmd *cobra.Command,
return nil
}

// EnableProtectionCmd is the command for 'hcloud floating-ip enable-protection'
var EnableProtectionCmd = base.Cmd{
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
return &cobra.Command{
Expand Down
Loading

0 comments on commit de9854a

Please sign in to comment.