Skip to content

Commit

Permalink
refactor: remove unused constants in describe commands (#974)
Browse files Browse the repository at this point in the history
The JSON keys became unused in #650.
  • Loading branch information
apricote authored Feb 5, 2025
1 parent 4006127 commit 0cdd108
Show file tree
Hide file tree
Showing 17 changed files with 2 additions and 37 deletions.
7 changes: 2 additions & 5 deletions internal/cmd/base/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ import (
type DescribeCmd[T any] struct {
ResourceNameSingular string // e.g. "server"
ShortDescription string
// key in API response JSON to use for extracting object from response body for JSON output.
JSONKeyGetByID string // e.g. "server"
JSONKeyGetByName string // e.g. "servers"
NameSuggestions func(client hcapi2.Client) func() []string
AdditionalFlags func(*cobra.Command)
NameSuggestions func(client hcapi2.Client) func() []string
AdditionalFlags func(*cobra.Command)
// Fetch is called to fetch the resource to describe.
// The first returned interface is the resource itself as a hcloud struct, the second is the schema for the resource.
Fetch func(s state.State, cmd *cobra.Command, idOrName string) (T, any, error)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/certificate/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.Certificate]{
ResourceNameSingular: "certificate",
ShortDescription: "Describe an certificate",
JSONKeyGetByID: "certificate",
JSONKeyGetByName: "certificates",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.Certificate().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.Certificate, any, error) {
cert, _, err := s.Client().Certificate().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/datacenter/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.Datacenter]{
ResourceNameSingular: "datacenter",
ShortDescription: "Describe an datacenter",
JSONKeyGetByID: "datacenter",
JSONKeyGetByName: "datacenters",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.Datacenter().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.Datacenter, any, error) {
dc, _, err := s.Client().Datacenter().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/firewall/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.Firewall]{
ResourceNameSingular: "firewall",
ShortDescription: "Describe an firewall",
JSONKeyGetByID: "firewall",
JSONKeyGetByName: "firewalls",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.Firewall().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.Firewall, any, error) {
fw, _, err := s.Client().Firewall().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/floatingip/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.FloatingIP]{
ResourceNameSingular: "Floating IP",
ShortDescription: "Describe an Floating IP",
JSONKeyGetByID: "floating_ip",
JSONKeyGetByName: "floating_ips",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.FloatingIP().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.FloatingIP, any, error) {
ip, _, err := s.Client().FloatingIP().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/image/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.Image]{
ResourceNameSingular: "image",
ShortDescription: "Describe an image",
JSONKeyGetByID: "image",
JSONKeyGetByName: "images",
AdditionalFlags: func(cmd *cobra.Command) {
cmd.Flags().StringP("architecture", "a", string(hcloud.ArchitectureX86), "architecture of the image, default is x86")
_ = cmd.RegisterFlagCompletionFunc("architecture", cmpl.SuggestCandidates(string(hcloud.ArchitectureX86), string(hcloud.ArchitectureARM)))
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/iso/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.ISO]{
ResourceNameSingular: "iso",
ShortDescription: "Describe a iso",
JSONKeyGetByID: "iso",
JSONKeyGetByName: "isos",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.Location().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.ISO, any, error) {
iso, _, err := s.Client().ISO().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/loadbalancer/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.LoadBalancer]{
ResourceNameSingular: "Load Balancer",
ShortDescription: "Describe a Load Balancer",
JSONKeyGetByID: "load_balancer",
JSONKeyGetByName: "load_balancers",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.LoadBalancer().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.LoadBalancer, any, error) {
lb, _, err := s.Client().LoadBalancer().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/loadbalancertype/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.LoadBalancerType]{
ResourceNameSingular: "Load Balancer Type",
ShortDescription: "Describe a Load Balancer type",
JSONKeyGetByID: "load_balancer_type",
JSONKeyGetByName: "load_balancer_types",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.LoadBalancerType().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.LoadBalancerType, any, error) {
lbt, _, err := s.Client().LoadBalancerType().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/location/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.Location]{
ResourceNameSingular: "location",
ShortDescription: "Describe a location",
JSONKeyGetByID: "location",
JSONKeyGetByName: "locations",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.Location().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.Location, any, error) {
l, _, err := s.Client().Location().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/network/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.Network]{
ResourceNameSingular: "network",
ShortDescription: "Describe a network",
JSONKeyGetByID: "network",
JSONKeyGetByName: "networks",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.Network().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.Network, any, error) {
n, _, err := s.Client().Network().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/placementgroup/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.PlacementGroup]{
ResourceNameSingular: "placement group",
ShortDescription: "Describe a placement group",
JSONKeyGetByID: "placement_group",
JSONKeyGetByName: "placement_groups",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.PlacementGroup().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.PlacementGroup, any, error) {
pg, _, err := s.Client().PlacementGroup().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/primaryip/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.PrimaryIP]{
ResourceNameSingular: "Primary IP",
ShortDescription: "Describe an Primary IP",
JSONKeyGetByID: "primary_ip",
JSONKeyGetByName: "primary_ips",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.PrimaryIP().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.PrimaryIP, any, error) {
ip, _, err := s.Client().PrimaryIP().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/server/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.Server]{
ResourceNameSingular: "server",
ShortDescription: "Describe a server",
JSONKeyGetByID: "server",
JSONKeyGetByName: "servers",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.Server().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.Server, any, error) {
srv, _, err := s.Client().Server().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/servertype/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.ServerType]{
ResourceNameSingular: "serverType",
ShortDescription: "Describe a server type",
JSONKeyGetByID: "server_type",
JSONKeyGetByName: "server_types",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.ServerType().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.ServerType, any, error) {
st, _, err := s.Client().ServerType().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/sshkey/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.SSHKey]{
ResourceNameSingular: "SSH Key",
ShortDescription: "Describe a SSH Key",
JSONKeyGetByID: "ssh_key",
JSONKeyGetByName: "ssh_keys",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.SSHKey().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.SSHKey, any, error) {
key, _, err := s.Client().SSHKey().Get(s, idOrName)
Expand Down
2 changes: 0 additions & 2 deletions internal/cmd/volume/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
var DescribeCmd = base.DescribeCmd[*hcloud.Volume]{
ResourceNameSingular: "volume",
ShortDescription: "Describe an Volume",
JSONKeyGetByID: "volume",
JSONKeyGetByName: "volumes",
NameSuggestions: func(c hcapi2.Client) func() []string { return c.Volume().Names },
Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.Volume, any, error) {
v, _, err := s.Client().Volume().Get(s, idOrName)
Expand Down

0 comments on commit 0cdd108

Please sign in to comment.