diff --git a/cmd/filesystemlayout.go b/cmd/filesystemlayout.go index 93e8f330..b9d7706e 100644 --- a/cmd/filesystemlayout.go +++ b/cmd/filesystemlayout.go @@ -70,7 +70,7 @@ func newFilesystemLayoutCmd(c *config) *cobra.Command { return genericcli.NewCmds(cmdsConfig, tryCmd, matchCmd) } -func (c fslCmd) Get(id string) (*models.V1FilesystemLayoutResponse, error) { +func (c *fslCmd) Get(id string) (*models.V1FilesystemLayoutResponse, error) { resp, err := c.client.Filesystemlayout().GetFilesystemLayout(fsmodel.NewGetFilesystemLayoutParams().WithID(id), nil) if err != nil { return nil, err @@ -79,7 +79,7 @@ func (c fslCmd) Get(id string) (*models.V1FilesystemLayoutResponse, error) { return resp.Payload, nil } -func (c fslCmd) List() ([]*models.V1FilesystemLayoutResponse, error) { +func (c *fslCmd) List() ([]*models.V1FilesystemLayoutResponse, error) { resp, err := c.client.Filesystemlayout().ListFilesystemLayouts(fsmodel.NewListFilesystemLayoutsParams(), nil) if err != nil { return nil, err @@ -88,7 +88,7 @@ func (c fslCmd) List() ([]*models.V1FilesystemLayoutResponse, error) { return resp.Payload, nil } -func (c fslCmd) Delete(id string) (*models.V1FilesystemLayoutResponse, error) { +func (c *fslCmd) Delete(id string) (*models.V1FilesystemLayoutResponse, error) { resp, err := c.client.Filesystemlayout().DeleteFilesystemLayout(fsmodel.NewDeleteFilesystemLayoutParams().WithID(id), nil) if err != nil { return nil, err @@ -97,7 +97,7 @@ func (c fslCmd) Delete(id string) (*models.V1FilesystemLayoutResponse, error) { return resp.Payload, nil } -func (c fslCmd) Create(rq *models.V1FilesystemLayoutCreateRequest) (*models.V1FilesystemLayoutResponse, error) { +func (c *fslCmd) Create(rq *models.V1FilesystemLayoutCreateRequest) (*models.V1FilesystemLayoutResponse, error) { resp, err := c.client.Filesystemlayout().CreateFilesystemLayout(fsmodel.NewCreateFilesystemLayoutParams().WithBody(rq), nil) if err != nil { var r *fsmodel.CreateFilesystemLayoutConflict @@ -110,7 +110,7 @@ func (c fslCmd) Create(rq *models.V1FilesystemLayoutCreateRequest) (*models.V1Fi return resp.Payload, nil } -func (c fslCmd) Update(rq *models.V1FilesystemLayoutUpdateRequest) (*models.V1FilesystemLayoutResponse, error) { +func (c *fslCmd) Update(rq *models.V1FilesystemLayoutUpdateRequest) (*models.V1FilesystemLayoutResponse, error) { resp, err := c.client.Filesystemlayout().UpdateFilesystemLayout(fsmodel.NewUpdateFilesystemLayoutParams().WithBody(rq), nil) if err != nil { return nil, err @@ -119,7 +119,7 @@ func (c fslCmd) Update(rq *models.V1FilesystemLayoutUpdateRequest) (*models.V1Fi return resp.Payload, nil } -func (c fslCmd) Convert(r *models.V1FilesystemLayoutResponse) (string, *models.V1FilesystemLayoutCreateRequest, *models.V1FilesystemLayoutUpdateRequest, error) { +func (c *fslCmd) Convert(r *models.V1FilesystemLayoutResponse) (string, *models.V1FilesystemLayoutCreateRequest, *models.V1FilesystemLayoutUpdateRequest, error) { if r.ID == nil { return "", nil, nil, fmt.Errorf("id is nil") } diff --git a/cmd/firewall.go b/cmd/firewall.go index dee6e2d6..cb6562ff 100644 --- a/cmd/firewall.go +++ b/cmd/firewall.go @@ -22,7 +22,7 @@ type firewallCmd struct { } func newFirewallCmd(c *config) *cobra.Command { - w := firewallCmd{ + w := &firewallCmd{ config: c, } @@ -125,7 +125,7 @@ ingress: return genericcli.NewCmds(cmdsConfig, firewallSSHCmd) } -func (c firewallCmd) Get(id string) (*models.V1FirewallResponse, error) { +func (c *firewallCmd) Get(id string) (*models.V1FirewallResponse, error) { resp, err := c.client.Firewall().FindFirewall(firewall.NewFindFirewallParams().WithID(id), nil) if err != nil { return nil, err @@ -134,7 +134,7 @@ func (c firewallCmd) Get(id string) (*models.V1FirewallResponse, error) { return resp.Payload, nil } -func (c firewallCmd) List() ([]*models.V1FirewallResponse, error) { +func (c *firewallCmd) List() ([]*models.V1FirewallResponse, error) { var macs []string if viper.IsSet("mac") { macs = pointer.WrapInSlice(viper.GetString("mac")) @@ -158,11 +158,11 @@ func (c firewallCmd) List() ([]*models.V1FirewallResponse, error) { return resp.Payload, nil } -func (c firewallCmd) Delete(_ string) (*models.V1FirewallResponse, error) { +func (c *firewallCmd) Delete(_ string) (*models.V1FirewallResponse, error) { return nil, fmt.Errorf("firewall entity does not support delete operation, use machine delete") } -func (c firewallCmd) Create(rq *models.V1FirewallCreateRequest) (*models.V1FirewallResponse, error) { +func (c *firewallCmd) Create(rq *models.V1FirewallCreateRequest) (*models.V1FirewallResponse, error) { resp, err := c.client.Firewall().AllocateFirewall(firewall.NewAllocateFirewallParams().WithBody(rq), nil) if err != nil { return nil, err @@ -171,11 +171,11 @@ func (c firewallCmd) Create(rq *models.V1FirewallCreateRequest) (*models.V1Firew return resp.Payload, nil } -func (c firewallCmd) Update(rq any) (*models.V1FirewallResponse, error) { +func (c *firewallCmd) Update(rq any) (*models.V1FirewallResponse, error) { return nil, fmt.Errorf("firewall entity does not support update operation, use machine update") } -func (c firewallCmd) Convert(r *models.V1FirewallResponse) (string, *models.V1FirewallCreateRequest, any, error) { +func (c *firewallCmd) Convert(r *models.V1FirewallResponse) (string, *models.V1FirewallCreateRequest, any, error) { if r.ID == nil { return "", nil, nil, fmt.Errorf("id is nil") } diff --git a/cmd/ip.go b/cmd/ip.go index af7070e0..c09f33a0 100644 --- a/cmd/ip.go +++ b/cmd/ip.go @@ -28,7 +28,7 @@ type ipCmd struct { } func newIPCmd(c *config) *cobra.Command { - w := ipCmd{ + w := &ipCmd{ config: c, } @@ -86,7 +86,7 @@ func newIPCmd(c *config) *cobra.Command { return genericcli.NewCmds(cmdsConfig, issuesCmd) } -func (c ipCmd) Get(id string) (*models.V1IPResponse, error) { +func (c *ipCmd) Get(id string) (*models.V1IPResponse, error) { resp, err := c.client.IP().FindIP(ip.NewFindIPParams().WithID(id), nil) if err != nil { return nil, err @@ -95,7 +95,7 @@ func (c ipCmd) Get(id string) (*models.V1IPResponse, error) { return resp.Payload, nil } -func (c ipCmd) List() ([]*models.V1IPResponse, error) { +func (c *ipCmd) List() ([]*models.V1IPResponse, error) { resp, err := c.client.IP().FindIPs(ip.NewFindIPsParams().WithBody(&models.V1IPFindRequest{ Ipaddress: viper.GetString("ipaddress"), Name: viper.GetString("name"), @@ -113,7 +113,7 @@ func (c ipCmd) List() ([]*models.V1IPResponse, error) { return resp.Payload, nil } -func (c ipCmd) Delete(id string) (*models.V1IPResponse, error) { +func (c *ipCmd) Delete(id string) (*models.V1IPResponse, error) { resp, err := c.client.IP().FreeIP(ip.NewFreeIPParams().WithID(id), nil) if err != nil { return nil, err @@ -122,7 +122,7 @@ func (c ipCmd) Delete(id string) (*models.V1IPResponse, error) { return resp.Payload, nil } -func (c ipCmd) Create(rq *ipAllocateRequest) (*models.V1IPResponse, error) { +func (c *ipCmd) Create(rq *ipAllocateRequest) (*models.V1IPResponse, error) { if rq.SpecificIP == "" { resp, err := c.client.IP().AllocateIP(ip.NewAllocateIPParams().WithBody(rq.V1IPAllocateRequest), nil) if err != nil { @@ -148,7 +148,7 @@ func (c ipCmd) Create(rq *ipAllocateRequest) (*models.V1IPResponse, error) { return resp.Payload, nil } -func (c ipCmd) Update(rq *models.V1IPUpdateRequest) (*models.V1IPResponse, error) { +func (c *ipCmd) Update(rq *models.V1IPUpdateRequest) (*models.V1IPResponse, error) { resp, err := c.client.IP().UpdateIP(ip.NewUpdateIPParams().WithBody(rq), nil) if err != nil { return nil, err @@ -157,7 +157,7 @@ func (c ipCmd) Update(rq *models.V1IPUpdateRequest) (*models.V1IPResponse, error return resp.Payload, nil } -func (c ipCmd) Convert(r *models.V1IPResponse) (string, *ipAllocateRequest, *models.V1IPUpdateRequest, error) { +func (c *ipCmd) Convert(r *models.V1IPResponse) (string, *ipAllocateRequest, *models.V1IPUpdateRequest, error) { if r.Ipaddress == nil { return "", nil, nil, fmt.Errorf("ipaddress is nil") } diff --git a/cmd/machine.go b/cmd/machine.go index 2d1a585d..cbcbc163 100644 --- a/cmd/machine.go +++ b/cmd/machine.go @@ -98,7 +98,7 @@ func (c *machineCmd) listCmdFlags(cmd *cobra.Command, lastEventErrorThresholdDef } func newMachineCmd(c *config) *cobra.Command { - w := machineCmd{ + w := &machineCmd{ config: c, } @@ -538,7 +538,7 @@ MODE can be omitted or one of: genericcli.Must(cmd.RegisterFlagCompletionFunc("filesystemlayout", c.comp.FilesystemLayoutListCompletion)) } -func (c machineCmd) Get(id string) (*models.V1MachineResponse, error) { +func (c *machineCmd) Get(id string) (*models.V1MachineResponse, error) { resp, err := c.client.Machine().FindMachine(machine.NewFindMachineParams().WithID(id), nil) if err != nil { return nil, err @@ -547,7 +547,7 @@ func (c machineCmd) Get(id string) (*models.V1MachineResponse, error) { return resp.Payload, nil } -func (c machineCmd) List() ([]*models.V1MachineResponse, error) { +func (c *machineCmd) List() ([]*models.V1MachineResponse, error) { resp, err := c.client.Machine().FindMachines(machine.NewFindMachinesParams().WithBody(machineFindRequestFromCLI()), nil) if err != nil { return nil, err @@ -587,7 +587,7 @@ func machineFindRequestFromCLI() *models.V1MachineFindRequest { } } -func (c machineCmd) Delete(id string) (*models.V1MachineResponse, error) { +func (c *machineCmd) Delete(id string) (*models.V1MachineResponse, error) { if viper.GetBool("remove-from-database") { if !viper.GetBool(forceFlag) { return nil, fmt.Errorf("remove-from-database is set but you forgot to add --%s", forceFlag) @@ -609,7 +609,7 @@ func (c machineCmd) Delete(id string) (*models.V1MachineResponse, error) { return resp.Payload, nil } -func (c machineCmd) Create(rq *models.V1MachineAllocateRequest) (*models.V1MachineResponse, error) { +func (c *machineCmd) Create(rq *models.V1MachineAllocateRequest) (*models.V1MachineResponse, error) { resp, err := c.client.Machine().AllocateMachine(machine.NewAllocateMachineParams().WithBody(rq), nil) if err != nil { return nil, err @@ -618,7 +618,7 @@ func (c machineCmd) Create(rq *models.V1MachineAllocateRequest) (*models.V1Machi return resp.Payload, nil } -func (c machineCmd) Update(rq *models.V1MachineUpdateRequest) (*models.V1MachineResponse, error) { +func (c *machineCmd) Update(rq *models.V1MachineUpdateRequest) (*models.V1MachineResponse, error) { resp, err := c.client.Machine().UpdateMachine(machine.NewUpdateMachineParams().WithBody(rq), nil) if err != nil { return nil, err @@ -627,7 +627,7 @@ func (c machineCmd) Update(rq *models.V1MachineUpdateRequest) (*models.V1Machine return resp.Payload, nil } -func (c machineCmd) Convert(r *models.V1MachineResponse) (string, *models.V1MachineAllocateRequest, *models.V1MachineUpdateRequest, error) { +func (c *machineCmd) Convert(r *models.V1MachineResponse) (string, *models.V1MachineAllocateRequest, *models.V1MachineUpdateRequest, error) { if r.ID == nil { return "", nil, nil, fmt.Errorf("ipaddress is nil") } diff --git a/cmd/network.go b/cmd/network.go index 85801f68..11d0531a 100644 --- a/cmd/network.go +++ b/cmd/network.go @@ -23,7 +23,7 @@ type networkCmd struct { } func newNetworkCmd(c *config) *cobra.Command { - w := networkCmd{ + w := &networkCmd{ config: c, childCLI: genericcli.NewGenericCLI[*models.V1NetworkAllocateRequest, any, *models.V1NetworkResponse](networkChildCRUD{config: c}).WithFS(c.fs), } @@ -157,7 +157,7 @@ func newNetworkCmd(c *config) *cobra.Command { ) } -func (c networkCmd) Get(id string) (*models.V1NetworkResponse, error) { +func (c *networkCmd) Get(id string) (*models.V1NetworkResponse, error) { resp, err := c.client.Network().FindNetwork(network.NewFindNetworkParams().WithID(id), nil) if err != nil { return nil, err @@ -166,7 +166,7 @@ func (c networkCmd) Get(id string) (*models.V1NetworkResponse, error) { return resp.Payload, nil } -func (c networkCmd) List() ([]*models.V1NetworkResponse, error) { +func (c *networkCmd) List() ([]*models.V1NetworkResponse, error) { resp, err := c.client.Network().FindNetworks(network.NewFindNetworksParams().WithBody(&models.V1NetworkFindRequest{ ID: viper.GetString("id"), Name: viper.GetString("name"), @@ -187,7 +187,7 @@ func (c networkCmd) List() ([]*models.V1NetworkResponse, error) { return resp.Payload, nil } -func (c networkCmd) Delete(id string) (*models.V1NetworkResponse, error) { +func (c *networkCmd) Delete(id string) (*models.V1NetworkResponse, error) { resp, err := c.client.Network().DeleteNetwork(network.NewDeleteNetworkParams().WithID(id), nil) if err != nil { return nil, err @@ -196,7 +196,7 @@ func (c networkCmd) Delete(id string) (*models.V1NetworkResponse, error) { return resp.Payload, nil } -func (c networkCmd) Create(rq *models.V1NetworkCreateRequest) (*models.V1NetworkResponse, error) { +func (c *networkCmd) Create(rq *models.V1NetworkCreateRequest) (*models.V1NetworkResponse, error) { resp, err := c.client.Network().CreateNetwork(network.NewCreateNetworkParams().WithBody(rq), nil) if err != nil { var r *network.CreateNetworkConflict @@ -209,7 +209,7 @@ func (c networkCmd) Create(rq *models.V1NetworkCreateRequest) (*models.V1Network return resp.Payload, nil } -func (c networkCmd) Update(rq *models.V1NetworkUpdateRequest) (*models.V1NetworkResponse, error) { +func (c *networkCmd) Update(rq *models.V1NetworkUpdateRequest) (*models.V1NetworkResponse, error) { resp, err := c.client.Network().UpdateNetwork(network.NewUpdateNetworkParams().WithBody(rq).WithForce(pointer.Pointer(viper.GetBool(forceFlag))), nil) if err != nil { return nil, err @@ -218,7 +218,7 @@ func (c networkCmd) Update(rq *models.V1NetworkUpdateRequest) (*models.V1Network return resp.Payload, nil } -func (c networkCmd) Convert(r *models.V1NetworkResponse) (string, *models.V1NetworkCreateRequest, *models.V1NetworkUpdateRequest, error) { +func (c *networkCmd) Convert(r *models.V1NetworkResponse) (string, *models.V1NetworkCreateRequest, *models.V1NetworkUpdateRequest, error) { if r.ID == nil { return "", nil, nil, fmt.Errorf("id is nil") } diff --git a/cmd/partition.go b/cmd/partition.go index 96785d8e..a251adb5 100644 --- a/cmd/partition.go +++ b/cmd/partition.go @@ -21,7 +21,7 @@ type partitionCmd struct { } func newPartitionCmd(c *config) *cobra.Command { - w := partitionCmd{ + w := &partitionCmd{ config: c, } @@ -59,15 +59,17 @@ func newPartitionCmd(c *config) *cobra.Command { partitionCapacityCmd.Flags().StringP("id", "", "", "filter on partition id. [optional]") partitionCapacityCmd.Flags().StringP("size", "", "", "filter on size id. [optional]") + partitionCapacityCmd.Flags().StringP("project-id", "", "", "consider project-specific counts, e.g. size reservations. [optional]") partitionCapacityCmd.Flags().StringSlice("sort-by", []string{}, fmt.Sprintf("order by (comma separated) column(s), sort direction can be changed by appending :asc or :desc behind the column identifier. possible values: %s", strings.Join(sorters.PartitionCapacitySorter().AvailableKeys(), "|"))) genericcli.Must(partitionCapacityCmd.RegisterFlagCompletionFunc("id", c.comp.PartitionListCompletion)) + genericcli.Must(partitionCapacityCmd.RegisterFlagCompletionFunc("project-id", c.comp.ProjectListCompletion)) genericcli.Must(partitionCapacityCmd.RegisterFlagCompletionFunc("size", c.comp.SizeListCompletion)) genericcli.Must(partitionCapacityCmd.RegisterFlagCompletionFunc("sort-by", cobra.FixedCompletions(sorters.PartitionCapacitySorter().AvailableKeys(), cobra.ShellCompDirectiveNoFileComp))) return genericcli.NewCmds(cmdsConfig, partitionCapacityCmd) } -func (c partitionCmd) Get(id string) (*models.V1PartitionResponse, error) { +func (c *partitionCmd) Get(id string) (*models.V1PartitionResponse, error) { resp, err := c.client.Partition().FindPartition(partition.NewFindPartitionParams().WithID(id), nil) if err != nil { return nil, err @@ -76,7 +78,7 @@ func (c partitionCmd) Get(id string) (*models.V1PartitionResponse, error) { return resp.Payload, nil } -func (c partitionCmd) List() ([]*models.V1PartitionResponse, error) { +func (c *partitionCmd) List() ([]*models.V1PartitionResponse, error) { resp, err := c.client.Partition().ListPartitions(partition.NewListPartitionsParams(), nil) if err != nil { return nil, err @@ -85,7 +87,7 @@ func (c partitionCmd) List() ([]*models.V1PartitionResponse, error) { return resp.Payload, nil } -func (c partitionCmd) Delete(id string) (*models.V1PartitionResponse, error) { +func (c *partitionCmd) Delete(id string) (*models.V1PartitionResponse, error) { resp, err := c.client.Partition().DeletePartition(partition.NewDeletePartitionParams().WithID(id), nil) if err != nil { return nil, err @@ -94,7 +96,7 @@ func (c partitionCmd) Delete(id string) (*models.V1PartitionResponse, error) { return resp.Payload, nil } -func (c partitionCmd) Create(rq *models.V1PartitionCreateRequest) (*models.V1PartitionResponse, error) { +func (c *partitionCmd) Create(rq *models.V1PartitionCreateRequest) (*models.V1PartitionResponse, error) { resp, err := c.client.Partition().CreatePartition(partition.NewCreatePartitionParams().WithBody(rq), nil) if err != nil { var r *partition.CreatePartitionConflict @@ -107,7 +109,7 @@ func (c partitionCmd) Create(rq *models.V1PartitionCreateRequest) (*models.V1Par return resp.Payload, nil } -func (c partitionCmd) Update(rq *models.V1PartitionUpdateRequest) (*models.V1PartitionResponse, error) { +func (c *partitionCmd) Update(rq *models.V1PartitionUpdateRequest) (*models.V1PartitionResponse, error) { resp, err := c.client.Partition().UpdatePartition(partition.NewUpdatePartitionParams().WithBody(rq), nil) if err != nil { return nil, err @@ -116,7 +118,7 @@ func (c partitionCmd) Update(rq *models.V1PartitionUpdateRequest) (*models.V1Par return resp.Payload, nil } -func (c partitionCmd) Convert(r *models.V1PartitionResponse) (string, *models.V1PartitionCreateRequest, *models.V1PartitionUpdateRequest, error) { +func (c *partitionCmd) Convert(r *models.V1PartitionResponse) (string, *models.V1PartitionCreateRequest, *models.V1PartitionUpdateRequest, error) { if r.ID == nil { return "", nil, nil, fmt.Errorf("id is nil") } @@ -161,8 +163,9 @@ func partitionResponseToUpdate(r *models.V1PartitionResponse) *models.V1Partitio func (c *partitionCmd) partitionCapacity() error { resp, err := c.client.Partition().PartitionCapacity(partition.NewPartitionCapacityParams().WithBody(&models.V1PartitionCapacityRequest{ - ID: viper.GetString("id"), - Sizeid: viper.GetString("size"), + ID: viper.GetString("id"), + Sizeid: viper.GetString("size"), + Projectid: pointer.PointerOrNil(viper.GetString("project-id")), }), nil) if err != nil { return err diff --git a/cmd/partition_test.go b/cmd/partition_test.go index a5fd4d18..8d2d4c55 100644 --- a/cmd/partition_test.go +++ b/cmd/partition_test.go @@ -347,15 +347,16 @@ Total 1 3 0 2 | 5 { name: "capacity with filters", cmd: func(want []*models.V1PartitionCapacity) []string { - args := []string{"partition", "capacity", "--id", "1", "--size", "size-1"} + args := []string{"partition", "capacity", "--id", "1", "--size", "size-1", "--project-id", "123"} assertExhaustiveArgs(t, args, "sort-by") return args }, mocks: &client.MetalMockFns{ Partition: func(mock *mock.Mock) { mock.On("PartitionCapacity", testcommon.MatchIgnoreContext(t, partition.NewPartitionCapacityParams().WithBody(&models.V1PartitionCapacityRequest{ - ID: "1", - Sizeid: "size-1", + ID: "1", + Sizeid: "size-1", + Projectid: pointer.Pointer("123"), })), nil).Return(&partition.PartitionCapacityOK{ Payload: []*models.V1PartitionCapacity{ { diff --git a/cmd/project.go b/cmd/project.go index 18e0052d..9ea48dc0 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -19,7 +19,7 @@ type projectCmd struct { } func newProjectCmd(c *config) *cobra.Command { - w := projectCmd{ + w := &projectCmd{ config: c, } @@ -57,7 +57,7 @@ func newProjectCmd(c *config) *cobra.Command { return genericcli.NewCmds(cmdsConfig) } -func (c projectCmd) Get(id string) (*models.V1ProjectResponse, error) { +func (c *projectCmd) Get(id string) (*models.V1ProjectResponse, error) { resp, err := c.client.Project().FindProject(projectmodel.NewFindProjectParams().WithID(id), nil) if err != nil { return nil, err @@ -66,7 +66,7 @@ func (c projectCmd) Get(id string) (*models.V1ProjectResponse, error) { return resp.Payload, nil } -func (c projectCmd) List() ([]*models.V1ProjectResponse, error) { +func (c *projectCmd) List() ([]*models.V1ProjectResponse, error) { resp, err := c.client.Project().FindProjects(projectmodel.NewFindProjectsParams().WithBody(&models.V1ProjectFindRequest{ ID: viper.GetString("id"), Name: viper.GetString("name"), @@ -79,7 +79,7 @@ func (c projectCmd) List() ([]*models.V1ProjectResponse, error) { return resp.Payload, nil } -func (c projectCmd) Delete(id string) (*models.V1ProjectResponse, error) { +func (c *projectCmd) Delete(id string) (*models.V1ProjectResponse, error) { resp, err := c.client.Project().DeleteProject(projectmodel.NewDeleteProjectParams().WithID(id), nil) if err != nil { return nil, err @@ -88,7 +88,7 @@ func (c projectCmd) Delete(id string) (*models.V1ProjectResponse, error) { return resp.Payload, nil } -func (c projectCmd) Create(rq *models.V1ProjectCreateRequest) (*models.V1ProjectResponse, error) { +func (c *projectCmd) Create(rq *models.V1ProjectCreateRequest) (*models.V1ProjectResponse, error) { resp, err := c.client.Project().CreateProject(projectmodel.NewCreateProjectParams().WithBody(rq), nil) if err != nil { var r *projectmodel.CreateProjectConflict @@ -101,7 +101,7 @@ func (c projectCmd) Create(rq *models.V1ProjectCreateRequest) (*models.V1Project return resp.Payload, nil } -func (c projectCmd) Update(rq *models.V1ProjectUpdateRequest) (*models.V1ProjectResponse, error) { +func (c *projectCmd) Update(rq *models.V1ProjectUpdateRequest) (*models.V1ProjectResponse, error) { resp, err := c.client.Project().FindProject(projectmodel.NewFindProjectParams().WithID(rq.Meta.ID), nil) if err != nil { return nil, err @@ -117,7 +117,7 @@ func (c projectCmd) Update(rq *models.V1ProjectUpdateRequest) (*models.V1Project return updateResp.Payload, nil } -func (c projectCmd) Convert(r *models.V1ProjectResponse) (string, *models.V1ProjectCreateRequest, *models.V1ProjectUpdateRequest, error) { +func (c *projectCmd) Convert(r *models.V1ProjectResponse) (string, *models.V1ProjectCreateRequest, *models.V1ProjectUpdateRequest, error) { if r.Meta == nil { return "", nil, nil, fmt.Errorf("meta is nil") } diff --git a/cmd/size.go b/cmd/size.go index 84eca979..10448f24 100644 --- a/cmd/size.go +++ b/cmd/size.go @@ -23,7 +23,7 @@ type sizeCmd struct { } func newSizeCmd(c *config) *cobra.Command { - w := sizeCmd{ + w := &sizeCmd{ config: c, } @@ -82,7 +82,7 @@ func newSizeCmd(c *config) *cobra.Command { return genericcli.NewCmds(cmdsConfig, newSizeImageConstraintCmd(c), reservationsCmd, suggestCmd) } -func (c sizeCmd) Get(id string) (*models.V1SizeResponse, error) { +func (c *sizeCmd) Get(id string) (*models.V1SizeResponse, error) { resp, err := c.client.Size().FindSize(size.NewFindSizeParams().WithID(id), nil) if err != nil { return nil, err @@ -91,7 +91,7 @@ func (c sizeCmd) Get(id string) (*models.V1SizeResponse, error) { return resp.Payload, nil } -func (c sizeCmd) List() ([]*models.V1SizeResponse, error) { +func (c *sizeCmd) List() ([]*models.V1SizeResponse, error) { resp, err := c.client.Size().ListSizes(size.NewListSizesParams(), nil) if err != nil { return nil, err @@ -100,7 +100,7 @@ func (c sizeCmd) List() ([]*models.V1SizeResponse, error) { return resp.Payload, nil } -func (c sizeCmd) Delete(id string) (*models.V1SizeResponse, error) { +func (c *sizeCmd) Delete(id string) (*models.V1SizeResponse, error) { resp, err := c.client.Size().DeleteSize(size.NewDeleteSizeParams().WithID(id), nil) if err != nil { return nil, err @@ -109,7 +109,7 @@ func (c sizeCmd) Delete(id string) (*models.V1SizeResponse, error) { return resp.Payload, nil } -func (c sizeCmd) Create(rq *models.V1SizeCreateRequest) (*models.V1SizeResponse, error) { +func (c *sizeCmd) Create(rq *models.V1SizeCreateRequest) (*models.V1SizeResponse, error) { resp, err := c.client.Size().CreateSize(size.NewCreateSizeParams().WithBody(rq), nil) if err != nil { var r *size.CreateSizeConflict @@ -122,7 +122,7 @@ func (c sizeCmd) Create(rq *models.V1SizeCreateRequest) (*models.V1SizeResponse, return resp.Payload, nil } -func (c sizeCmd) Update(rq *models.V1SizeUpdateRequest) (*models.V1SizeResponse, error) { +func (c *sizeCmd) Update(rq *models.V1SizeUpdateRequest) (*models.V1SizeResponse, error) { resp, err := c.client.Size().UpdateSize(size.NewUpdateSizeParams().WithBody(rq), nil) if err != nil { return nil, err @@ -131,7 +131,7 @@ func (c sizeCmd) Update(rq *models.V1SizeUpdateRequest) (*models.V1SizeResponse, return resp.Payload, nil } -func (c sizeCmd) Convert(r *models.V1SizeResponse) (string, *models.V1SizeCreateRequest, *models.V1SizeUpdateRequest, error) { +func (c *sizeCmd) Convert(r *models.V1SizeResponse) (string, *models.V1SizeCreateRequest, *models.V1SizeUpdateRequest, error) { if r.ID == nil { return "", nil, nil, fmt.Errorf("id is nil") } diff --git a/cmd/size_reservations.go b/cmd/size_reservations.go index 184381eb..0923ea52 100644 --- a/cmd/size_reservations.go +++ b/cmd/size_reservations.go @@ -19,7 +19,7 @@ type sizeReservationsCmd struct { } func newSizeReservationsCmd(c *config) *cobra.Command { - w := sizeReservationsCmd{ + w := &sizeReservationsCmd{ config: c, } @@ -124,7 +124,7 @@ func newSizeReservationsCmd(c *config) *cobra.Command { return genericcli.NewCmds(cmdsConfig, usageCmd) } -func (c sizeReservationsCmd) Get(id string) (*models.V1SizeReservationResponse, error) { +func (c *sizeReservationsCmd) Get(id string) (*models.V1SizeReservationResponse, error) { resp, err := c.client.Size().GetSizeReservation(sizemodel.NewGetSizeReservationParams().WithID(id), nil) if err != nil { return nil, err @@ -133,7 +133,7 @@ func (c sizeReservationsCmd) Get(id string) (*models.V1SizeReservationResponse, return resp.Payload, nil } -func (c sizeReservationsCmd) List() ([]*models.V1SizeReservationResponse, error) { +func (c *sizeReservationsCmd) List() ([]*models.V1SizeReservationResponse, error) { resp, err := c.client.Size().FindSizeReservations(sizemodel.NewFindSizeReservationsParams().WithBody(&models.V1SizeReservationListRequest{ ID: viper.GetString("id"), Partitionid: viper.GetString("partition"), @@ -147,7 +147,7 @@ func (c sizeReservationsCmd) List() ([]*models.V1SizeReservationResponse, error) return resp.Payload, nil } -func (c sizeReservationsCmd) Delete(id string) (*models.V1SizeReservationResponse, error) { +func (c *sizeReservationsCmd) Delete(id string) (*models.V1SizeReservationResponse, error) { resp, err := c.client.Size().DeleteSizeReservation(sizemodel.NewDeleteSizeReservationParams().WithID(id), nil) if err != nil { return nil, err @@ -156,7 +156,7 @@ func (c sizeReservationsCmd) Delete(id string) (*models.V1SizeReservationRespons return resp.Payload, nil } -func (c sizeReservationsCmd) Create(rq *models.V1SizeReservationCreateRequest) (*models.V1SizeReservationResponse, error) { +func (c *sizeReservationsCmd) Create(rq *models.V1SizeReservationCreateRequest) (*models.V1SizeReservationResponse, error) { resp, err := c.client.Size().CreateSizeReservation(sizemodel.NewCreateSizeReservationParams().WithBody(rq), nil) if err != nil { var r *sizemodel.CreateSizeReservationConflict @@ -169,7 +169,7 @@ func (c sizeReservationsCmd) Create(rq *models.V1SizeReservationCreateRequest) ( return resp.Payload, nil } -func (c sizeReservationsCmd) Update(rq *models.V1SizeReservationUpdateRequest) (*models.V1SizeReservationResponse, error) { +func (c *sizeReservationsCmd) Update(rq *models.V1SizeReservationUpdateRequest) (*models.V1SizeReservationResponse, error) { resp, err := c.client.Size().UpdateSizeReservation(sizemodel.NewUpdateSizeReservationParams().WithBody(rq), nil) if err != nil { return nil, err @@ -178,7 +178,7 @@ func (c sizeReservationsCmd) Update(rq *models.V1SizeReservationUpdateRequest) ( return resp.Payload, nil } -func (c sizeReservationsCmd) Convert(r *models.V1SizeReservationResponse) (string, *models.V1SizeReservationCreateRequest, *models.V1SizeReservationUpdateRequest, error) { +func (c *sizeReservationsCmd) Convert(r *models.V1SizeReservationResponse) (string, *models.V1SizeReservationCreateRequest, *models.V1SizeReservationUpdateRequest, error) { if r.ID == nil { return "", nil, nil, fmt.Errorf("id is nil") } diff --git a/cmd/sizeimageconstraint.go b/cmd/sizeimageconstraint.go index e46aba43..54d4849d 100644 --- a/cmd/sizeimageconstraint.go +++ b/cmd/sizeimageconstraint.go @@ -19,7 +19,7 @@ type sizeImageConstraintCmd struct { } func newSizeImageConstraintCmd(c *config) *cobra.Command { - w := sizeImageConstraintCmd{ + w := &sizeImageConstraintCmd{ config: c, } @@ -52,7 +52,7 @@ func newSizeImageConstraintCmd(c *config) *cobra.Command { return genericcli.NewCmds(cmdsConfig, tryCmd) } -func (c sizeImageConstraintCmd) Get(id string) (*models.V1SizeImageConstraintResponse, error) { +func (c *sizeImageConstraintCmd) Get(id string) (*models.V1SizeImageConstraintResponse, error) { resp, err := c.client.Sizeimageconstraint().FindSizeImageConstraint(sizemodel.NewFindSizeImageConstraintParams().WithID(id), nil) if err != nil { return nil, err @@ -61,7 +61,7 @@ func (c sizeImageConstraintCmd) Get(id string) (*models.V1SizeImageConstraintRes return resp.Payload, nil } -func (c sizeImageConstraintCmd) List() ([]*models.V1SizeImageConstraintResponse, error) { +func (c *sizeImageConstraintCmd) List() ([]*models.V1SizeImageConstraintResponse, error) { resp, err := c.client.Sizeimageconstraint().ListSizeImageConstraints(sizemodel.NewListSizeImageConstraintsParams(), nil) if err != nil { return nil, err @@ -70,7 +70,7 @@ func (c sizeImageConstraintCmd) List() ([]*models.V1SizeImageConstraintResponse, return resp.Payload, nil } -func (c sizeImageConstraintCmd) Delete(id string) (*models.V1SizeImageConstraintResponse, error) { +func (c *sizeImageConstraintCmd) Delete(id string) (*models.V1SizeImageConstraintResponse, error) { resp, err := c.client.Sizeimageconstraint().DeleteSizeImageConstraint(sizemodel.NewDeleteSizeImageConstraintParams().WithID(id), nil) if err != nil { return nil, err @@ -79,7 +79,7 @@ func (c sizeImageConstraintCmd) Delete(id string) (*models.V1SizeImageConstraint return resp.Payload, nil } -func (c sizeImageConstraintCmd) Create(rq *models.V1SizeImageConstraintCreateRequest) (*models.V1SizeImageConstraintResponse, error) { +func (c *sizeImageConstraintCmd) Create(rq *models.V1SizeImageConstraintCreateRequest) (*models.V1SizeImageConstraintResponse, error) { resp, err := c.client.Sizeimageconstraint().CreateSizeImageConstraint(sizemodel.NewCreateSizeImageConstraintParams().WithBody(rq), nil) if err != nil { var r *sizemodel.CreateSizeImageConstraintConflict @@ -92,7 +92,7 @@ func (c sizeImageConstraintCmd) Create(rq *models.V1SizeImageConstraintCreateReq return resp.Payload, nil } -func (c sizeImageConstraintCmd) Update(rq *models.V1SizeImageConstraintUpdateRequest) (*models.V1SizeImageConstraintResponse, error) { +func (c *sizeImageConstraintCmd) Update(rq *models.V1SizeImageConstraintUpdateRequest) (*models.V1SizeImageConstraintResponse, error) { resp, err := c.client.Sizeimageconstraint().UpdateSizeImageConstraint(sizemodel.NewUpdateSizeImageConstraintParams().WithBody(rq), nil) if err != nil { return nil, err @@ -101,7 +101,7 @@ func (c sizeImageConstraintCmd) Update(rq *models.V1SizeImageConstraintUpdateReq return resp.Payload, nil } -func (c sizeImageConstraintCmd) Convert(r *models.V1SizeImageConstraintResponse) (string, *models.V1SizeImageConstraintCreateRequest, *models.V1SizeImageConstraintUpdateRequest, error) { +func (c *sizeImageConstraintCmd) Convert(r *models.V1SizeImageConstraintResponse) (string, *models.V1SizeImageConstraintCreateRequest, *models.V1SizeImageConstraintUpdateRequest, error) { if r.ID == nil { return "", nil, nil, fmt.Errorf("id is nil") } diff --git a/cmd/switch.go b/cmd/switch.go index 1d2950dd..3ffb163c 100644 --- a/cmd/switch.go +++ b/cmd/switch.go @@ -23,7 +23,7 @@ type switchCmd struct { } func newSwitchCmd(c *config) *cobra.Command { - w := switchCmd{ + w := &switchCmd{ config: c, } @@ -208,7 +208,7 @@ Operational steps to replace a switch: return genericcli.NewCmds(cmdsConfig, switchDetailCmd, switchMachinesCmd, switchReplaceCmd, switchMigrateCmd, switchSSHCmd, switchConsoleCmd, switchPortCmd) } -func (c switchCmd) Get(id string) (*models.V1SwitchResponse, error) { +func (c *switchCmd) Get(id string) (*models.V1SwitchResponse, error) { resp, err := c.client.SwitchOperations().FindSwitch(switch_operations.NewFindSwitchParams().WithID(id), nil) if err != nil { return nil, err @@ -217,7 +217,7 @@ func (c switchCmd) Get(id string) (*models.V1SwitchResponse, error) { return resp.Payload, nil } -func (c switchCmd) List() ([]*models.V1SwitchResponse, error) { +func (c *switchCmd) List() ([]*models.V1SwitchResponse, error) { resp, err := c.client.SwitchOperations().FindSwitches(switch_operations.NewFindSwitchesParams().WithBody(&models.V1SwitchFindRequest{ ID: viper.GetString("id"), Name: viper.GetString("name"), @@ -233,7 +233,7 @@ func (c switchCmd) List() ([]*models.V1SwitchResponse, error) { return resp.Payload, nil } -func (c switchCmd) Delete(id string) (*models.V1SwitchResponse, error) { +func (c *switchCmd) Delete(id string) (*models.V1SwitchResponse, error) { resp, err := c.client.SwitchOperations().DeleteSwitch(switch_operations.NewDeleteSwitchParams().WithID(id).WithForce(pointer.Pointer(viper.GetBool("force"))), nil) if err != nil { return nil, err @@ -242,11 +242,11 @@ func (c switchCmd) Delete(id string) (*models.V1SwitchResponse, error) { return resp.Payload, nil } -func (c switchCmd) Create(rq any) (*models.V1SwitchResponse, error) { +func (c *switchCmd) Create(rq any) (*models.V1SwitchResponse, error) { return nil, fmt.Errorf("switch entity does not support create operation") } -func (c switchCmd) Update(rq *models.V1SwitchUpdateRequest) (*models.V1SwitchResponse, error) { +func (c *switchCmd) Update(rq *models.V1SwitchUpdateRequest) (*models.V1SwitchResponse, error) { resp, err := c.client.SwitchOperations().UpdateSwitch(switch_operations.NewUpdateSwitchParams().WithBody(rq), nil) if err != nil { return nil, err @@ -255,7 +255,7 @@ func (c switchCmd) Update(rq *models.V1SwitchUpdateRequest) (*models.V1SwitchRes return resp.Payload, nil } -func (c switchCmd) Convert(r *models.V1SwitchResponse) (string, any, *models.V1SwitchUpdateRequest, error) { +func (c *switchCmd) Convert(r *models.V1SwitchResponse) (string, any, *models.V1SwitchUpdateRequest, error) { if r.ID == nil { return "", nil, nil, fmt.Errorf("id is nil") } @@ -384,7 +384,7 @@ func (c *switchCmd) switchReplace(args []string) error { return c.describePrinter.Print(uresp) } -func (c switchCmd) switchMigrate(args []string) error { +func (c *switchCmd) switchMigrate(args []string) error { if count := len(args); count != 2 { return fmt.Errorf("invalid number of arguments were provided; 2 are required, %d were passed", count) } diff --git a/cmd/tenant.go b/cmd/tenant.go index 714a7597..958c2fbe 100644 --- a/cmd/tenant.go +++ b/cmd/tenant.go @@ -19,7 +19,7 @@ type tenantCmd struct { } func newTenantCmd(c *config) *cobra.Command { - w := tenantCmd{ + w := &tenantCmd{ config: c, } @@ -57,7 +57,7 @@ func newTenantCmd(c *config) *cobra.Command { return genericcli.NewCmds(cmdsConfig) } -func (c tenantCmd) Get(id string) (*models.V1TenantResponse, error) { +func (c *tenantCmd) Get(id string) (*models.V1TenantResponse, error) { resp, err := c.client.Tenant().GetTenant(tenantmodel.NewGetTenantParams().WithID(id), nil) if err != nil { return nil, err @@ -66,7 +66,7 @@ func (c tenantCmd) Get(id string) (*models.V1TenantResponse, error) { return resp.Payload, nil } -func (c tenantCmd) List() ([]*models.V1TenantResponse, error) { +func (c *tenantCmd) List() ([]*models.V1TenantResponse, error) { var annotations map[string]string if viper.IsSet("annotations") { var err error @@ -88,7 +88,7 @@ func (c tenantCmd) List() ([]*models.V1TenantResponse, error) { return resp.Payload, nil } -func (c tenantCmd) Delete(id string) (*models.V1TenantResponse, error) { +func (c *tenantCmd) Delete(id string) (*models.V1TenantResponse, error) { resp, err := c.client.Tenant().DeleteTenant(tenantmodel.NewDeleteTenantParams().WithID(id), nil) if err != nil { return nil, err @@ -97,7 +97,7 @@ func (c tenantCmd) Delete(id string) (*models.V1TenantResponse, error) { return resp.Payload, nil } -func (c tenantCmd) Create(rq *models.V1TenantCreateRequest) (*models.V1TenantResponse, error) { +func (c *tenantCmd) Create(rq *models.V1TenantCreateRequest) (*models.V1TenantResponse, error) { resp, err := c.client.Tenant().CreateTenant(tenantmodel.NewCreateTenantParams().WithBody(rq), nil) if err != nil { var r *tenantmodel.CreateTenantConflict @@ -110,7 +110,7 @@ func (c tenantCmd) Create(rq *models.V1TenantCreateRequest) (*models.V1TenantRes return resp.Payload, nil } -func (c tenantCmd) Update(rq *models.V1TenantUpdateRequest) (*models.V1TenantResponse, error) { +func (c *tenantCmd) Update(rq *models.V1TenantUpdateRequest) (*models.V1TenantResponse, error) { if rq.Meta == nil { return nil, fmt.Errorf("tenant meta is nil") } @@ -130,7 +130,7 @@ func (c tenantCmd) Update(rq *models.V1TenantUpdateRequest) (*models.V1TenantRes return updateResp.Payload, nil } -func (c tenantCmd) Convert(r *models.V1TenantResponse) (string, *models.V1TenantCreateRequest, *models.V1TenantUpdateRequest, error) { +func (c *tenantCmd) Convert(r *models.V1TenantResponse) (string, *models.V1TenantCreateRequest, *models.V1TenantUpdateRequest, error) { if r.Meta == nil { return "", nil, nil, fmt.Errorf("meta is nil") } diff --git a/docs/metalctl_partition_capacity.md b/docs/metalctl_partition_capacity.md index 04d55101..a75f691b 100644 --- a/docs/metalctl_partition_capacity.md +++ b/docs/metalctl_partition_capacity.md @@ -9,10 +9,11 @@ metalctl partition capacity [flags] ### Options ``` - -h, --help help for capacity - --id string filter on partition id. [optional] - --size string filter on size id. [optional] - --sort-by strings order by (comma separated) column(s), sort direction can be changed by appending :asc or :desc behind the column identifier. possible values: description|id|name + -h, --help help for capacity + --id string filter on partition id. [optional] + --project-id string consider project-specific counts, e.g. size reservations. [optional] + --size string filter on size id. [optional] + --sort-by strings order by (comma separated) column(s), sort direction can be changed by appending :asc or :desc behind the column identifier. possible values: description|id|name ``` ### Options inherited from parent commands diff --git a/go.mod b/go.mod index 66e64247..12ad6d40 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/go-openapi/strfmt v0.23.0 github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 - github.com/metal-stack/metal-go v0.39.1 + github.com/metal-stack/metal-go v0.39.2 github.com/metal-stack/metal-lib v0.19.0 github.com/metal-stack/updater v1.2.2 github.com/metal-stack/v v1.0.3 diff --git a/go.sum b/go.sum index 900404ac..57a0e7ce 100644 --- a/go.sum +++ b/go.sum @@ -244,8 +244,8 @@ github.com/mdlayher/sdnotify v1.0.0 h1:Ma9XeLVN/l0qpyx1tNeMSeTjCPH6NtuD6/N9XdTlQ github.com/mdlayher/sdnotify v1.0.0/go.mod h1:HQUmpM4XgYkhDLtd+Uad8ZFK1T9D5+pNxnXQjCeJlGE= github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos= github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ= -github.com/metal-stack/metal-go v0.39.1 h1:oarRe7KbcvsOfjCLbXwlVVHJfX5AMlWxoCQrRpmbdrA= -github.com/metal-stack/metal-go v0.39.1/go.mod h1:ltItf/Md/z588c7Dr3X6iemCeOFh3rJ8nDL5Dpb9zFQ= +github.com/metal-stack/metal-go v0.39.2 h1:E2iZ8f7Qo/z2ClbtICYu4iKn91zFv0RonFmuPlbC6tk= +github.com/metal-stack/metal-go v0.39.2/go.mod h1:ltItf/Md/z588c7Dr3X6iemCeOFh3rJ8nDL5Dpb9zFQ= github.com/metal-stack/metal-lib v0.19.0 h1:4yBnp/jPGgX9KeCje3A4MFL2oDjgjOjgsIK391LltRI= github.com/metal-stack/metal-lib v0.19.0/go.mod h1:fCMaWwVGA/xAoGvBk72/nfzqBkHly0iOzrWpc55Fau4= github.com/metal-stack/security v0.9.0 h1:FYBXJfNJwUw2E0HBa+jay37XF7b6EikEuf4Mw8u04EY=