From 3e0ca1d9067125916cd45ca1d05a7e96588f7898 Mon Sep 17 00:00:00 2001 From: jessicatoscani Date: Fri, 4 Aug 2023 16:33:29 +0200 Subject: [PATCH] lint --- cmd/cmd.go | 20 ---------- cmd/config.go | 9 +---- cmd/flags.go | 102 ----------------------------------------------- cmd/icmp_code.go | 4 -- cmd/root.go | 4 -- cmd/zone.go | 10 ----- go.sum | 6 --- 7 files changed, 2 insertions(+), 153 deletions(-) delete mode 100644 cmd/flags.go diff --git a/cmd/cmd.go b/cmd/cmd.go index 463e22356..98e437bd5 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -107,26 +107,6 @@ func cmdShowHelpFlags(flags *pflag.FlagSet, prefix string) { fmt.Print(buf) } -func getCommaflag(p string) []string { - if p == "" { - return nil - } - - p = strings.Trim(p, ",") - args := strings.Split(p, ",") - - res := []string{} - - for _, arg := range args { - if arg == "" { - continue - } - res = append(res, strings.TrimSpace(arg)) - } - - return res -} - // cliCommandSettings represents a CLI command settings. type cliCommandSettings struct { outputFunc func(o output.Outputter, err error) error diff --git a/cmd/config.go b/cmd/config.go index 1183f720b..2bb6fd295 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -265,20 +265,15 @@ func chooseZone(client *egoscale.Client, zones []string) (string, error) { if zones == nil { ctx := exoapi.WithEndpoint(gContext, exoapi.NewReqEndpoint(defaultEnvironment, defaultZone)) - zonesResp, err := client.ListZones(ctx) + zones, err := client.ListZones(ctx) if err != nil { return "", err } - if len(zonesResp) == 0 { + if len(zones) == 0 { return "", fmt.Errorf("no zones were found") } - zones = make([]string, len(zonesResp)) - for i, z := range zonesResp { - zones[i] = z - } - } prompt := promptui.Select{ diff --git a/cmd/flags.go b/cmd/flags.go deleted file mode 100644 index e5eab6902..000000000 --- a/cmd/flags.go +++ /dev/null @@ -1,102 +0,0 @@ -package cmd - -import ( - "fmt" - "net" - "strconv" - - "github.com/spf13/cobra" -) - -// nilValue is returned by a flag when the value is not set -const nilValue = "nil" - -// XXX use reflect to factor those out. -// e.g. getCustomFlag(cmd *cobra.Command, name string, out interface{}) error {} - -type int64PtrValue struct { - *int64 -} - -func (v *int64PtrValue) Set(val string) error { - r, err := strconv.ParseInt(val, 10, 64) - if err != nil { - return err - } - v.int64 = &r - return nil -} - -func (v *int64PtrValue) Type() string { - return "int64" -} - -func (v *int64PtrValue) String() string { - if v.int64 == nil { - return nilValue - } - return strconv.FormatInt(*v.int64, 10) -} - -func getInt64CustomFlag(cmd *cobra.Command, name string) (int64PtrValue, error) { - it := cmd.Flags().Lookup(name) - if it != nil { - r := it.Value.(*int64PtrValue) - if r != nil { - return *r, nil - } - } - return int64PtrValue{}, fmt.Errorf("unable to get flag %q", name) -} - -// ip flag -type ipValue struct { - IP *net.IP -} - -func (v *ipValue) Set(val string) error { - if val == "" { - return nil - } - - ip := net.ParseIP(val) - if ip == nil { - return fmt.Errorf("no a valid IP address: got %q", val) - } - - v.IP = &ip - - return nil -} - -func (v *ipValue) Value() net.IP { - if v.IP == nil { - return net.IP{} - } - - return *v.IP -} - -func (v *ipValue) Type() string { - return "IP" -} - -func (v *ipValue) String() string { - if v.IP == nil || *v.IP == nil { - return nilValue - } - - return v.IP.String() -} - -// getIPValue finds the value of a command by name -func getIPValue(cmd *cobra.Command, name string) (*ipValue, error) { - it := cmd.Flags().Lookup(name) - if it != nil { - r := it.Value.(*ipValue) - if r != nil { - return r, nil - } - } - return nil, fmt.Errorf("unable to get flag %q", name) -} diff --git a/cmd/icmp_code.go b/cmd/icmp_code.go index 822c04b68..5c9bbc7a4 100644 --- a/cmd/icmp_code.go +++ b/cmd/icmp_code.go @@ -60,7 +60,3 @@ func (i icmpCode) StringFormatted() string { } return cases.Title(language.Und).String(res) } - -func (i icmpCode) icmpType() icmpType { - return icmpType(i >> 8) -} diff --git a/cmd/root.go b/cmd/root.go index db31f523d..d6650dca8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -33,12 +33,8 @@ var gAccountName string var gListAlias = []string{"ls"} var gRemoveAlias = []string{"rm"} var gDeleteAlias = []string{"del"} -var gRevokeAlias = []string{"rvk"} var gShowAlias = []string{"get"} var gCreateAlias = []string{"add"} -var gUploadAlias = []string{"up"} -var gDissociateAlias = []string{"disassociate", "dissoc"} -var gAssociateAlias = []string{"assoc"} var RootCmd = &cobra.Command{ Use: "exo", diff --git a/cmd/zone.go b/cmd/zone.go index 00860bf64..88f6e8ea7 100644 --- a/cmd/zone.go +++ b/cmd/zone.go @@ -25,16 +25,6 @@ var ( string(oapi.ZoneNameDeFra1), string(oapi.ZoneNameDeMuc1), } - - zoneHelp = "zone NAME|ID " + func() string { - zonesList := "(" - - for _, zone := range allZones { - zonesList += zone + "|" - } - - return zonesList[:len(zonesList)-1] + ")" - }() ) type zoneListItemOutput struct { diff --git a/go.sum b/go.sum index 2d0a72de0..996b1c6a9 100644 --- a/go.sum +++ b/go.sum @@ -166,8 +166,6 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go. github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= -github.com/exoscale/egoscale v0.100.1 h1:iXsV1Ei7daqe/6FYSCSDyrFs1iUG1l1X9qNh2uMw6z0= -github.com/exoscale/egoscale v0.100.1/go.mod h1:BAb9p4rmyU+Wl400CJZO5270H2sXtdsZjLcm5xMKkz4= github.com/exoscale/egoscale v0.100.3 h1:zyl/pdmGbpoYUndVkV9DAkFMiO8/4S0DIAk0R1K53J4= github.com/exoscale/egoscale v0.100.3/go.mod h1:szh4hWSVh+ylgfti4AFR4mkRaCfUyUXSKS3PihlcOco= github.com/exoscale/openapi-cli-generator v1.1.0 h1:fYjmPqHR5vxlOBrbvde7eo7bISNQIFxsGn4A5/acwKA= @@ -206,8 +204,6 @@ github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSG github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/goccy/go-json v0.7.8/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -519,8 +515,6 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=