Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: Setup Go
uses: actions/setup-go@v6
uses: actions/setup-go@v7
with:
go-version-file: 'go.mod'

Expand All @@ -67,19 +67,19 @@ jobs:
make cli GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }}

- name: Log in to the container registry
uses: docker/login-action@v3
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
if: ${{ matrix.os == 'linux' && matrix.arch == 'amd64' }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4
if: ${{ matrix.os == 'linux' && matrix.arch == 'amd64' }}

- name: Build and push image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v7
with:
context: .
push: true
Expand Down
2 changes: 2 additions & 0 deletions cmd/admin/v2/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
adminv2 "github.com/metal-stack/api/go/metalstack/admin/v2"
apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
"github.com/metal-stack/cli/cmd/config"
"github.com/metal-stack/cli/cmd/sorters"
"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"
Expand All @@ -32,6 +33,7 @@ func newComponentCmd(c *config.Config) *cobra.Command {
Description: "list status of components, e.g. microservices connected to the metal-apiserver",
DescribePrinter: func() printers.Printer { return c.DescribePrinter },
ListPrinter: func() printers.Printer { return c.ListPrinter },
Sorter: sorters.ComponentSorter(),
OnlyCmds: genericcli.OnlyCmds(genericcli.DescribeCmd, genericcli.ListCmd, genericcli.DeleteCmd),
ListCmdMutateFn: func(cmd *cobra.Command) {
cmd.Flags().String("uuid", "", "lists only component with this uuid")
Expand Down
30 changes: 15 additions & 15 deletions cmd/admin/v2/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,27 +214,27 @@ func (c *image) List() ([]*apiv2.Image, error) {

func (c *image) Convert(r *apiv2.Image) (string, *adminv2.ImageServiceCreateRequest, *adminv2.ImageServiceUpdateRequest, error) {
return r.Id, &adminv2.ImageServiceCreateRequest{
Image: &apiv2.Image{
Id: r.Id,
Url: r.Url,
Name: r.Name,
Description: r.Description,
Features: r.Features,
Meta: r.Meta,
Classification: r.Classification,
ExpiresAt: r.ExpiresAt,
},
}, &adminv2.ImageServiceUpdateRequest{
UpdateMeta: helpers.UpdateMetaFromMeta(r.Meta),
Labels: helpers.UpdateLabelsFromMeta(r.Meta),
Image: &apiv2.Image{
Id: r.Id,
Url: &r.Url,
Url: r.Url,
Name: r.Name,
Description: r.Description,
Features: r.Features,
Meta: r.Meta,
Classification: r.Classification,
ExpiresAt: r.ExpiresAt,
}, nil
},
}, &adminv2.ImageServiceUpdateRequest{
UpdateMeta: helpers.UpdateMetaFromMeta(r.Meta),
Labels: helpers.UpdateLabelsFromMeta(r.Meta),
Id: r.Id,
Url: &r.Url,
Name: r.Name,
Description: r.Description,
Features: r.Features,
Classification: r.Classification,
ExpiresAt: r.ExpiresAt,
}, nil
}

func (c *image) Update(rq *adminv2.ImageServiceUpdateRequest) (*apiv2.Image, error) {
Expand Down
44 changes: 22 additions & 22 deletions cmd/admin/v2/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,31 +228,31 @@ func (t *token) Convert(r *apiv2.Token) (string, *adminv2.TokenServiceCreateRequ
}

return r.Uuid, &adminv2.TokenServiceCreateRequest{
User: &r.User,
TokenCreateRequest: &apiv2.TokenServiceCreateRequest{
Description: r.GetDescription(),
Permissions: perms,
ProjectRoles: r.GetProjectRoles(),
TenantRoles: r.GetTenantRoles(),
Expires: durationpb.New(time.Until(r.GetExpires().AsTime())),
Labels: pointer.SafeDeref(r.Meta).Labels,
},
}, &apiv2.TokenServiceUpdateRequest{
Uuid: r.Uuid,
Description: pointer.PointerOrNil(r.Description),
User: &r.User,
TokenCreateRequest: &apiv2.TokenServiceCreateRequest{
Description: r.GetDescription(),
Permissions: perms,
ProjectRoles: r.ProjectRoles,
TenantRoles: r.TenantRoles,
AdminRole: r.AdminRole,
Labels: &apiv2.UpdateLabels{
Strategy: &apiv2.UpdateLabels_Replace{
Replace: &apiv2.Labels{
Labels: pointer.SafeDeref(pointer.SafeDeref(r.Meta).Labels).Labels,
},
ProjectRoles: r.GetProjectRoles(),
TenantRoles: r.GetTenantRoles(),
Expires: durationpb.New(time.Until(r.GetExpires().AsTime())),
Labels: pointer.SafeDeref(r.Meta).Labels,
},
}, &apiv2.TokenServiceUpdateRequest{
Uuid: r.Uuid,
Description: pointer.PointerOrNil(r.Description),
Permissions: perms,
ProjectRoles: r.ProjectRoles,
TenantRoles: r.TenantRoles,
AdminRole: r.AdminRole,
Labels: &apiv2.UpdateLabels{
Strategy: &apiv2.UpdateLabels_Replace{
Replace: &apiv2.Labels{
Labels: pointer.SafeDeref(pointer.SafeDeref(r.Meta).Labels).Labels,
},
},
UpdateMeta: helpers.UpdateMetaFromMeta(r.Meta),
}, nil
},
UpdateMeta: helpers.UpdateMetaFromMeta(r.Meta),
}, nil
}

func (t *token) Update(rq *apiv2.TokenServiceUpdateRequest) (*apiv2.Token, error) {
Expand Down
16 changes: 8 additions & 8 deletions cmd/api/v2/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ func (c *project) Delete(id string) (*apiv2.Project, error) {

func (c *project) Convert(r *apiv2.Project) (string, *apiv2.ProjectServiceCreateRequest, *apiv2.ProjectServiceUpdateRequest, error) {
return r.Uuid, &apiv2.ProjectServiceCreateRequest{
Login: r.Tenant,
Name: r.Name,
Description: r.Description,
}, &apiv2.ProjectServiceUpdateRequest{
Project: r.Uuid,
Name: new(r.Name),
Description: new(r.Description),
}, nil
Login: r.Tenant,
Name: r.Name,
Description: r.Description,
}, &apiv2.ProjectServiceUpdateRequest{
Project: r.Uuid,
Name: new(r.Name),
Description: new(r.Description),
}, nil
}

func (c *project) Update(rq *apiv2.ProjectServiceUpdateRequest) (*apiv2.Project, error) {
Expand Down
32 changes: 16 additions & 16 deletions cmd/api/v2/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,20 @@ func (c *token) Convert(r *apiv2.Token) (string, *apiv2.TokenServiceCreateReques
}

return r.Uuid, &apiv2.TokenServiceCreateRequest{
Description: r.GetDescription(),
Permissions: perms,
ProjectRoles: r.GetProjectRoles(),
TenantRoles: r.GetTenantRoles(),
Expires: durationpb.New(time.Until(r.GetExpires().AsTime())),
Labels: pointer.SafeDeref(r.Meta).Labels,
}, &apiv2.TokenServiceUpdateRequest{
Uuid: r.Uuid,
Description: pointer.PointerOrNil(r.Description),
Permissions: perms,
ProjectRoles: r.ProjectRoles,
TenantRoles: r.TenantRoles,
AdminRole: r.AdminRole,
Labels: helpers.UpdateLabelsFromMeta(r.Meta),
UpdateMeta: helpers.UpdateMetaFromMeta(r.Meta),
}, nil
Description: r.GetDescription(),
Permissions: perms,
ProjectRoles: r.GetProjectRoles(),
TenantRoles: r.GetTenantRoles(),
Expires: durationpb.New(time.Until(r.GetExpires().AsTime())),
Labels: pointer.SafeDeref(r.Meta).Labels,
}, &apiv2.TokenServiceUpdateRequest{
Uuid: r.Uuid,
Description: pointer.PointerOrNil(r.Description),
Permissions: perms,
ProjectRoles: r.ProjectRoles,
TenantRoles: r.TenantRoles,
AdminRole: r.AdminRole,
Labels: helpers.UpdateLabelsFromMeta(r.Meta),
UpdateMeta: helpers.UpdateMetaFromMeta(r.Meta),
}, nil
}
23 changes: 23 additions & 0 deletions cmd/sorters/component.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package sorters

import (
apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
"github.com/metal-stack/metal-lib/pkg/multisort"
)

func ComponentSorter() *multisort.Sorter[*apiv2.Component] {
return multisort.New(multisort.FieldMap[*apiv2.Component]{
"type": func(a, b *apiv2.Component, descending bool) multisort.CompareResult {
return multisort.Compare(a.Type, b.Type, descending)
},
"identifier": func(a, b *apiv2.Component, descending bool) multisort.CompareResult {
return multisort.Compare(a.Identifier, b.Identifier, descending)
},
"started": func(a, b *apiv2.Component, descending bool) multisort.CompareResult {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe by expiration would also be useful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return multisort.Compare(a.StartedAt.AsTime().String(), b.StartedAt.AsTime().String(), descending)
},
"expiration": func(a, b *apiv2.Component, descending bool) multisort.CompareResult {
return multisort.Compare(a.Token.Expires.String(), b.Token.Expires.String(), descending)
},
}, multisort.Keys{{ID: "type", Descending: true}, {ID: "identifier", Descending: true}})
}
1 change: 1 addition & 0 deletions docs/admin/metalctlv2_admin_component_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ metalctlv2 admin component list [flags]
```
-h, --help help for list
--identifier string lists only component with this identifier
--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: identifier|started|type
--type string lists only component of this type
--uuid string lists only component with this uuid
```
Expand Down
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/metal-stack/cli

go 1.26.5
go 1.27

require (
connectrpc.com/connect v1.20.0
Expand All @@ -9,14 +9,14 @@ require (
github.com/fatih/color v1.19.0
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.0
github.com/metal-stack/api v0.5.0
github.com/metal-stack/api v0.5.1
github.com/metal-stack/metal-lib v0.26.3
github.com/metal-stack/v v1.0.3
github.com/spf13/afero v1.15.0
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.12.0
google.golang.org/grpc v1.83.0
github.com/stretchr/testify v1.12.1
google.golang.org/grpc v1.83.1
google.golang.org/protobuf v1.36.12
sigs.k8s.io/yaml v1.6.0
)
Expand All @@ -36,12 +36,12 @@ require (
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/coder/websocket v1.8.15 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/creachadair/msync v0.10.0 // indirect
github.com/creachadair/msync v0.10.1 // indirect
github.com/dblohm7/wingoes v0.0.0-20260526185140-fb298caac7ca // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/fxamacker/cbor/v2 v2.9.2 // indirect
github.com/fxamacker/cbor/v2 v2.9.3 // indirect
github.com/gaissmai/bart v0.29.0 // indirect
github.com/go-json-experiment/json v0.0.0-20260623181947-01eb4420fa68 // indirect
github.com/go-json-experiment/json v0.0.0-20260820222146-c27c302e5fc3 // indirect
github.com/go-openapi/errors v0.22.8 // indirect
github.com/go-openapi/strfmt v0.27.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
Expand All @@ -61,7 +61,7 @@ require (
github.com/klauspost/connect-compress/v2 v2.1.1 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/mattn/go-runewidth v0.0.27 // indirect
github.com/mattn/go-runewidth v0.0.28 // indirect
github.com/mdlayher/netlink v1.11.2 // indirect
github.com/mdlayher/socket v0.6.1 // indirect
github.com/minio/minlz v1.2.0 // indirect
Expand Down Expand Up @@ -92,7 +92,7 @@ require (
go4.org/mem v0.0.0-20240501181205-ae6ca9944745 // indirect
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
golang.org/x/crypto v0.55.0 // indirect
golang.org/x/exp v0.0.0-20260813180055-c1d0aacb2297 // indirect
golang.org/x/exp v0.0.0-20260820142414-ca536658362e // indirect
golang.org/x/net v0.58.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sync v0.22.0 // indirect
Expand All @@ -102,12 +102,12 @@ require (
golang.org/x/time v0.15.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
golang.zx2c4.com/wireguard/windows v1.0.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260810153831-ec0a7760b754 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260810153831-ec0a7760b754 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260819154853-08b0e4226688 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gvisor.dev/gvisor v0.0.0-20260224225140-573d5e7127a8 // indirect
k8s.io/apimachinery v0.36.3 // indirect
k8s.io/apimachinery v0.36.4 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
tailscale.com v1.102.2 // indirect
tailscale.com v1.102.3 // indirect
)
Loading