Skip to content

Commit

Permalink
Allow sorting IPs by creation date. (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Jul 30, 2024
1 parent ad8a8bb commit e616e8a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 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
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"}})
}
2 changes: 1 addition & 1 deletion docs/metalctl_network_ip_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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

0 comments on commit e616e8a

Please sign in to comment.