Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Aug 2, 2024
2 parents 6d903e2 + e616e8a commit 95fc117
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
cache: false

- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
args: --build-tags integration -p bugs -p unused --timeout=5m

Expand Down
1 change: 1 addition & 0 deletions cmd/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (c ipCmd) List() ([]*models.V1IPResponse, error) {
return nil, err
}

// actually filtered client side because server side would require a reql filter for addressfamilies
if viper.IsSet("addressfamily") {
af := viper.GetString("addressfamily")
var result []*models.V1IPResponse
Expand Down
4 changes: 4 additions & 0 deletions cmd/sorters/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sorters

import (
"net/netip"
"time"

"github.com/metal-stack/metal-go/api/models"
"github.com/metal-stack/metal-lib/pkg/multisort"
Expand Down Expand Up @@ -32,5 +33,8 @@ func IPSorter() *multisort.Sorter[*models.V1IPResponse] {
"type": func(a, b *models.V1IPResponse, descending bool) multisort.CompareResult {
return multisort.Compare(p.SafeDeref(a.Type), p.SafeDeref(b.Type), descending)
},
"age": func(a, b *models.V1IPResponse, descending bool) multisort.CompareResult {
return multisort.Compare(time.Time(a.Created).Unix(), time.Time(b.Created).Unix(), descending)
},
}, multisort.Keys{{ID: "ipaddress"}})
}
6 changes: 5 additions & 1 deletion cmd/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/metal-stack/metal-go/api/models"
"github.com/metal-stack/metal-lib/pkg/genericcli"
"github.com/metal-stack/metal-lib/pkg/genericcli/printers"
"github.com/metal-stack/metal-lib/pkg/pointer"
"github.com/metal-stack/metalctl/cmd/sorters"
"github.com/metal-stack/metalctl/cmd/tableprinters"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -59,6 +60,9 @@ func newSwitchCmd(c *config) *cobra.Command {
genericcli.Must(cmd.RegisterFlagCompletionFunc("os-vendor", c.comp.SwitchOSVendorListCompletion))
genericcli.Must(cmd.RegisterFlagCompletionFunc("os-version", c.comp.SwitchOSVersionListCompletion))
},
DeleteCmdMutateFn: func(cmd *cobra.Command) {
cmd.Flags().Bool("force", false, "forcefully delete the switch accepting the risk that it still has machines connected to it")
},
}

switchDetailCmd := &cobra.Command{
Expand Down Expand Up @@ -222,7 +226,7 @@ func (c switchCmd) List() ([]*models.V1SwitchResponse, error) {
}

func (c switchCmd) Delete(id string) (*models.V1SwitchResponse, error) {
resp, err := c.client.SwitchOperations().DeleteSwitch(switch_operations.NewDeleteSwitchParams().WithID(id), nil)
resp, err := c.client.SwitchOperations().DeleteSwitch(switch_operations.NewDeleteSwitchParams().WithID(id).WithForce(pointer.Pointer(viper.GetBool("force"))), nil)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ ID PARTITION RACK OS METALCORE IP MODE LAST S
},
mocks: &client.MetalMockFns{
SwitchOperations: func(mock *mock.Mock) {
mock.On("DeleteSwitch", testcommon.MatchIgnoreContext(t, switch_operations.NewDeleteSwitchParams().WithID(*switch1.ID)), nil).Return(&switch_operations.DeleteSwitchOK{
mock.On("DeleteSwitch", testcommon.MatchIgnoreContext(t, switch_operations.NewDeleteSwitchParams().WithID(*switch1.ID).WithForce(pointer.Pointer(false))), nil).Return(&switch_operations.DeleteSwitchOK{
Payload: switch1,
}, nil)
},
Expand Down Expand Up @@ -387,7 +387,7 @@ ID PARTITION RACK OS METALCORE IP MODE LAST S
},
mocks: &client.MetalMockFns{
SwitchOperations: func(mock *mock.Mock) {
mock.On("DeleteSwitch", testcommon.MatchIgnoreContext(t, switch_operations.NewDeleteSwitchParams().WithID(*switch1.ID)), nil).Return(&switch_operations.DeleteSwitchOK{
mock.On("DeleteSwitch", testcommon.MatchIgnoreContext(t, switch_operations.NewDeleteSwitchParams().WithID(*switch1.ID).WithForce(pointer.Pointer(false))), nil).Return(&switch_operations.DeleteSwitchOK{
Payload: switch1,
}, nil)
},
Expand Down
2 changes: 1 addition & 1 deletion docs/metalctl_network_ip_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ metalctl network ip list [flags]
--network string network to filter [optional]
--prefix string prefix to filter [optional]
--project string project to filter [optional]
--sort-by strings sort by (comma separated) column(s), sort direction can be changed by appending :asc or :desc behind the column identifier. possible values: description|id|ipaddress|name|network|type
--sort-by strings sort by (comma separated) column(s), sort direction can be changed by appending :asc or :desc behind the column identifier. possible values: age|description|id|ipaddress|name|network|type
--tags strings tags to filter [optional]
--type string type to filter [optional]
```
Expand Down
1 change: 1 addition & 0 deletions docs/metalctl_switch_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ metalctl switch delete <id> [flags]
the file can also contain multiple documents and perform a bulk operation.
--force forcefully delete the switch accepting the risk that it still has machines connected to it
-h, --help help for delete
--skip-security-prompts skips security prompt for bulk operations
--timestamps when used with --file (bulk operation): prints timestamps in-between the operations
Expand Down

0 comments on commit 95fc117

Please sign in to comment.