Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

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

- name: Setup Go
uses: actions/setup-go@v6
Expand All @@ -30,7 +30,7 @@ jobs:
cache: false

- name: Lint
uses: golangci/golangci-lint-action@v8
uses: golangci/golangci-lint-action@v9
with:
args: --build-tags integration --timeout=5m

Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:

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

- name: Setup Go
uses: actions/setup-go@v6
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.22
FROM alpine:3.23
LABEL maintainer="metal-stack authors <info@metal-stack.io>"
COPY bin/metalctlv2-linux-amd64 /metalctl
ENTRYPOINT ["/metalctl"]
2 changes: 1 addition & 1 deletion cmd/admin/v2/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (c *image) Update(rq *adminv2.ImageServiceUpdateRequest) (*apiv2.Image, err

req := &adminv2.ImageServiceUpdateRequest{
Id: viper.GetString("id"),
Url: pointer.Pointer(viper.GetString("url")),
Url: new(viper.GetString("url")),
Description: pointer.PointerOrNil(viper.GetString("description")),
ExpiresAt: expiresAt,
Features: imageFeaturesFromString(viper.GetStringSlice("features")),
Expand Down
1 change: 0 additions & 1 deletion cmd/admin/v2/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (c *tenant) List() ([]*apiv2.Tenant, error) {
req := &adminv2.TenantServiceListRequest{
Name: pointer.PointerOrNil(viper.GetString("name")),
Login: pointer.PointerOrNil(viper.GetString("id")),
Email: pointer.PointerOrNil(viper.GetString("email")),
}

resp, err := c.c.Client.Adminv2().Tenant().List(ctx, req)
Expand Down
3 changes: 1 addition & 2 deletions cmd/admin/v2/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"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"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -57,7 +56,7 @@ func (c *token) List() ([]*apiv2.Token, error) {
req := &adminv2.TokenServiceListRequest{}

if viper.IsSet("user") {
req.User = pointer.Pointer(viper.GetString("user"))
req.User = new(viper.GetString("user"))
}

resp, err := c.c.Client.Adminv2().Token().List(ctx, req)
Expand Down
7 changes: 3 additions & 4 deletions cmd/api/v2/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/metal-stack/cli/pkg/helpers"
"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/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -70,11 +69,11 @@ func newIPCmd(c *config.Config) *cobra.Command {
CreateRequestFromCLI: func() (*apiv2.IPServiceCreateRequest, error) {
return &apiv2.IPServiceCreateRequest{
Project: c.GetProject(),
Name: pointer.Pointer(viper.GetString("name")),
Description: pointer.Pointer(viper.GetString("description")),
Name: new(viper.GetString("name")),
Description: new(viper.GetString("description")),
Network: viper.GetString("network"),
// Labels: viper.GetStringSlice("tags"), // FIXME implement
Type: pointer.Pointer(ipStaticToType(viper.GetBool("static"))),
Type: new(ipStaticToType(viper.GetBool("static"))),
AddressFamily: addressFamilyToType(viper.GetString("addressfamily")),
}, nil
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/api/v2/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ func (c *project) Convert(r *apiv2.Project) (string, *apiv2.ProjectServiceCreate
Description: r.Description,
}, &apiv2.ProjectServiceUpdateRequest{
Project: r.Uuid,
Name: pointer.Pointer(r.Name),
Description: pointer.Pointer(r.Description),
Name: new(r.Name),
Description: new(r.Description),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/api/v2/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func newTokenCmd(c *config.Config) *cobra.Command {
return nil, fmt.Errorf("unknown role: %s", roleString)
}

adminRole = pointer.Pointer(apiv2.AdminRole(role))
adminRole = new(apiv2.AdminRole(role))
}

return &apiv2.TokenServiceCreateRequest{
Expand Down
1 change: 0 additions & 1 deletion cmd/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (c *Test[R]) TestCmd(t *testing.T) {
}

for _, format := range outputFormats(c) {
format := format
t.Run(fmt.Sprintf("%v", format.Args()), func(t *testing.T) {
_, out, conf := c.newMockConfig(t)

Expand Down
2 changes: 1 addition & 1 deletion cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (c *Config) NewRequestContext() (context.Context, context.CancelFunc) {
timeout = pointer.Pointer(30 * time.Second)
}
if viper.IsSet("timeout") {
timeout = pointer.Pointer(viper.GetDuration("timeout"))
timeout = new(viper.GetDuration("timeout"))
}

return context.WithTimeout(context.Background(), *timeout)
Expand Down
5 changes: 2 additions & 3 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
"github.com/metal-stack/cli/cmd/config"
"github.com/metal-stack/metal-lib/pkg/genericcli"
"github.com/metal-stack/metal-lib/pkg/pointer"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"google.golang.org/protobuf/types/known/durationpb"
Expand Down Expand Up @@ -69,7 +68,7 @@ func (l *login) login() error {
if viper.IsSet("context") {
newCtx.Name = viper.GetString("context")
}
newCtx.ApiURL = pointer.Pointer(l.c.GetApiURL())
newCtx.ApiURL = new(l.c.GetApiURL())
ctxs.Contexts = append(ctxs.Contexts, &newCtx)
ctx = &newCtx
}
Expand Down Expand Up @@ -131,7 +130,7 @@ func (l *login) login() error {
tokenResp, err := mc.Apiv2().Token().Create(context.Background(), &apiv2.TokenServiceCreateRequest{
Description: "admin access issues by metal cli",
Expires: durationpb.New(3 * time.Hour),
AdminRole: pointer.Pointer(apiv2.AdminRole((apiv2.AdminRole_value[viper.GetString("admin-role")]))),
AdminRole: new(apiv2.AdminRole((apiv2.AdminRole_value[viper.GetString("admin-role")]))),
})
if err != nil {
return fmt.Errorf("unable to issue admin token: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"context"
"log/slog"
"os"

Expand All @@ -16,7 +17,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"github.com/spf13/viper"
"golang.org/x/net/context"
)

func Execute() {
Expand Down
7 changes: 1 addition & 6 deletions cmd/tableprinters/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/fatih/color"
"github.com/metal-stack/api/go/enum"
apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
"github.com/metal-stack/metal-lib/pkg/pointer"
)

func (t *TablePrinter) HealthTable(data []*apiv2.Health, wide bool) ([]string, [][]string, error) {
Expand All @@ -31,13 +30,11 @@ func (t *TablePrinter) HealthTable(data []*apiv2.Health, wide bool) ([]string, [
)

for _, h := range data {
h := h
for _, s := range h.Services {
s := s

name, err := enum.GetStringValue(s.Name)
if err != nil {
name = pointer.Pointer("service status unknown")
name = new("service status unknown")
}
message := "All systems operational"
if s.Message != "" {
Expand All @@ -53,7 +50,6 @@ func (t *TablePrinter) HealthTable(data []*apiv2.Health, wide bool) ([]string, [

var partitions []partitionStatus
for id, p := range s.Partitions {
p := p

partitions = append(partitions, partitionStatus{
ID: id,
Expand All @@ -66,7 +62,6 @@ func (t *TablePrinter) HealthTable(data []*apiv2.Health, wide bool) ([]string, [
})

for i, status := range partitions {
status := status

prefix := "├"
if i == len(partitions)-1 {
Expand Down
1 change: 0 additions & 1 deletion cmd/tableprinters/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func (t *TablePrinter) IPTable(data []*apiv2.IP, wide bool) ([]string, [][]strin
}

for _, ip := range data {
ip := ip

var t string

Expand Down
49 changes: 25 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,66 +1,67 @@
module github.com/metal-stack/cli

go 1.25
go 1.26

require (
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.18.0
github.com/google/go-cmp v0.7.0
github.com/metal-stack/api v0.0.35
github.com/metal-stack/api v0.0.51
github.com/metal-stack/metal-lib v0.23.5
github.com/metal-stack/v v1.0.3
github.com/spf13/afero v1.15.0
github.com/spf13/cobra v1.10.1
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
golang.org/x/net v0.46.0
google.golang.org/protobuf v1.36.10
golang.org/x/net v0.50.0
google.golang.org/protobuf v1.36.11
sigs.k8s.io/yaml v1.6.0
)

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 // indirect
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260209202127-80ab13bee0bf.1 // indirect
connectrpc.com/connect v1.19.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/clipperhouse/uax29/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/clipperhouse/displaywidth v0.6.2 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-openapi/errors v0.22.3 // indirect
github.com/go-openapi/strfmt v0.24.0 // indirect
github.com/go-openapi/errors v0.22.6 // indirect
github.com/go-openapi/strfmt v0.25.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/goccy/go-yaml v1.18.0 // indirect
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/goccy/go-yaml v1.19.2 // indirect
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.18.1 // indirect
github.com/klauspost/connect-compress/v2 v2.1.0 // indirect
github.com/klauspost/compress v1.18.4 // indirect
github.com/klauspost/connect-compress/v2 v2.1.1 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.20 // indirect
github.com/minio/minlz v1.0.1 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
github.com/olekukonko/errors v1.1.0 // indirect
github.com/olekukonko/ll v0.1.2 // indirect
github.com/olekukonko/tablewriter v1.1.0 // indirect
github.com/olekukonko/errors v1.2.0 // indirect
github.com/olekukonko/ll v0.1.6 // indirect
github.com/olekukonko/tablewriter v1.1.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/stretchr/objx v0.5.3 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.mongodb.org/mongo-driver v1.17.4 // indirect
go.mongodb.org/mongo-driver v1.17.9 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/text v0.34.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.34.1 // indirect
k8s.io/apimachinery v0.35.1 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
)
Loading