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
17 changes: 8 additions & 9 deletions cmd/admin/v1/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"
"time"

"connectrpc.com/connect"
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"
Expand Down Expand Up @@ -52,12 +51,12 @@ func (c *image) Get(id string) (*apiv2.Image, error) {

req := &apiv2.ImageServiceGetRequest{Id: id}

resp, err := c.c.Client.Apiv2().Image().Get(ctx, connect.NewRequest(req))
resp, err := c.c.Client.Apiv2().Image().Get(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to get image: %w", err)
}

return resp.Msg.Image, nil
return resp.Image, nil
}

func (c *image) Create(rq *adminv2.ImageServiceCreateRequest) (*apiv2.Image, error) {
Expand All @@ -82,12 +81,12 @@ func (c *image) Create(rq *adminv2.ImageServiceCreateRequest) (*apiv2.Image, err
},
}

resp, err := c.c.Client.Adminv2().Image().Create(ctx, connect.NewRequest(req))
resp, err := c.c.Client.Adminv2().Image().Create(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to get image: %w", err)
}

return resp.Msg.Image, nil
return resp.Image, nil
}

func (c *image) Delete(id string) (*apiv2.Image, error) {
Expand All @@ -96,12 +95,12 @@ func (c *image) Delete(id string) (*apiv2.Image, error) {

req := &adminv2.ImageServiceDeleteRequest{Id: id}

resp, err := c.c.Client.Adminv2().Image().Delete(ctx, connect.NewRequest(req))
resp, err := c.c.Client.Adminv2().Image().Delete(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to delete image: %w", err)
}

return resp.Msg.Image, nil
return resp.Image, nil
}
func (c *image) List() ([]*apiv2.Image, error) {
panic("unimplemented")
Expand Down Expand Up @@ -157,12 +156,12 @@ func (c *image) Update(rq *adminv2.ImageServiceUpdateRequest) (*apiv2.Image, err
},
}

resp, err := c.c.Client.Adminv2().Image().Update(ctx, connect.NewRequest(req))
resp, err := c.c.Client.Adminv2().Image().Update(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to get image: %w", err)
}

return resp.Msg.Image, nil
return resp.Image, nil
}

func imageFeaturesFromString(features []string) []apiv2.ImageFeature {
Expand Down
7 changes: 3 additions & 4 deletions cmd/admin/v1/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v1
import (
"fmt"

"connectrpc.com/connect"
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"
Expand Down Expand Up @@ -61,12 +60,12 @@ func (c *token) List() ([]*apiv2.Token, error) {
req.User = pointer.Pointer(viper.GetString("user"))
}

resp, err := c.c.Client.Adminv2().Token().List(ctx, connect.NewRequest(req))
resp, err := c.c.Client.Adminv2().Token().List(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to list tokens: %w", err)
}

return resp.Msg.GetTokens(), nil
return resp.GetTokens(), nil
}

func (t *token) Create(rq any) (*apiv2.Token, error) {
Expand All @@ -86,7 +85,7 @@ func (c *token) Delete(id string) (*apiv2.Token, error) {
User: viper.GetString("user"),
}

_, err := c.c.Client.Adminv2().Token().Revoke(ctx, connect.NewRequest(req))
_, err := c.c.Client.Adminv2().Token().Revoke(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to revoke token: %w", err)
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/api/v1/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v1
import (
"fmt"

"connectrpc.com/connect"
v1 "github.com/metal-stack/api/go/metalstack/api/v2"
"github.com/metal-stack/cli/cmd/config"
"github.com/spf13/cobra"
Expand All @@ -18,12 +17,12 @@ func newHealthCmd(c *config.Config) *cobra.Command {
ctx, cancel := c.NewRequestContext()
defer cancel()

resp, err := c.Client.Apiv2().Health().Get(ctx, connect.NewRequest(&v1.HealthServiceGetRequest{}))
resp, err := c.Client.Apiv2().Health().Get(ctx, &v1.HealthServiceGetRequest{})
if err != nil {
return fmt.Errorf("failed to get health: %w", err)
}

return c.ListPrinter.Print(resp.Msg.Health)
return c.ListPrinter.Print(resp.Health)
},
}

Expand Down
13 changes: 6 additions & 7 deletions cmd/api/v1/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"strings"

"connectrpc.com/connect"
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"
Expand Down Expand Up @@ -68,12 +67,12 @@ func (c *image) Get(id string) (*apiv2.Image, error) {

req := &apiv2.ImageServiceGetRequest{Id: id}

resp, err := c.c.Client.Apiv2().Image().Get(ctx, connect.NewRequest(req))
resp, err := c.c.Client.Apiv2().Image().Get(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to get image: %w", err)
}

return resp.Msg.Image, nil
return resp.Image, nil
}

func (c *image) List() ([]*apiv2.Image, error) {
Expand All @@ -89,12 +88,12 @@ func (c *image) List() ([]*apiv2.Image, error) {
Feature: imageFeatureFromString(viper.GetString("feature")),
}}

resp, err := c.c.Client.Apiv2().Image().List(ctx, connect.NewRequest(req))
resp, err := c.c.Client.Apiv2().Image().List(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to get images: %w", err)
}

return resp.Msg.Images, nil
return resp.Images, nil
}

func (c *image) latest() error {
Expand All @@ -103,12 +102,12 @@ func (c *image) latest() error {

req := &apiv2.ImageServiceLatestRequest{Os: viper.GetString("os")}

resp, err := c.c.Client.Apiv2().Image().Latest(ctx, connect.NewRequest(req))
resp, err := c.c.Client.Apiv2().Image().Latest(ctx, req)
if err != nil {
return fmt.Errorf("failed to get images: %w", err)
}

return c.c.ListPrinter.Print(resp.Msg.Image)
return c.c.ListPrinter.Print(resp.Image)
}

func imageFeatureFromString(feature string) *apiv2.ImageFeature {
Expand Down
31 changes: 15 additions & 16 deletions cmd/api/v1/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v1
import (
"fmt"

"connectrpc.com/connect"
apiv2 "github.com/metal-stack/api/go/metalstack/api/v2"
"github.com/metal-stack/cli/cmd/config"
"github.com/metal-stack/cli/cmd/sorters"
Expand Down Expand Up @@ -125,12 +124,12 @@ func (c *ip) Create(rq *apiv2.IPServiceCreateRequest) (*apiv2.IP, error) {
ctx, cancel := c.c.NewRequestContext()
defer cancel()

resp, err := c.c.Client.Apiv2().IP().Create(ctx, connect.NewRequest(rq))
resp, err := c.c.Client.Apiv2().IP().Create(ctx, rq)
if err != nil {
return nil, err
}

return resp.Msg.Ip, nil
return resp.Ip, nil
}

func (c *ip) Delete(id string) (*apiv2.IP, error) {
Expand All @@ -150,53 +149,53 @@ func (c *ip) Delete(id string) (*apiv2.IP, error) {
}
}

resp, err := c.c.Client.Apiv2().IP().Delete(ctx, connect.NewRequest(req))
resp, err := c.c.Client.Apiv2().IP().Delete(ctx, req)
if err != nil {
return nil, err
}

return resp.Msg.Ip, nil
return resp.Ip, nil
}

func (c *ip) Get(id string) (*apiv2.IP, error) {
ctx, cancel := c.c.NewRequestContext()
defer cancel()

resp, err := c.c.Client.Apiv2().IP().Get(ctx, connect.NewRequest(&apiv2.IPServiceGetRequest{
resp, err := c.c.Client.Apiv2().IP().Get(ctx, &apiv2.IPServiceGetRequest{
Project: c.c.GetProject(),
Ip: id,
}))
})
if err != nil {
return nil, err
}

return resp.Msg.Ip, nil
return resp.Ip, nil
}

func (c *ip) List() ([]*apiv2.IP, error) {
ctx, cancel := c.c.NewRequestContext()
defer cancel()

resp, err := c.c.Client.Apiv2().IP().List(ctx, connect.NewRequest(&apiv2.IPServiceListRequest{
resp, err := c.c.Client.Apiv2().IP().List(ctx, &apiv2.IPServiceListRequest{
Project: c.c.GetProject(),
}))
})
if err != nil {
return nil, err
}

return resp.Msg.Ips, nil
return resp.Ips, nil
}

func (c *ip) Update(rq *apiv2.IPServiceUpdateRequest) (*apiv2.IP, error) {
ctx, cancel := c.c.NewRequestContext()
defer cancel()

resp, err := c.c.Client.Apiv2().IP().Update(ctx, connect.NewRequest(rq))
resp, err := c.c.Client.Apiv2().IP().Update(ctx, rq)
if err != nil {
return nil, err
}

return resp.Msg.Ip, nil
return resp.Ip, nil
}

func (c *ip) Convert(r *apiv2.IP) (string, *apiv2.IPServiceCreateRequest, *apiv2.IPServiceUpdateRequest, error) {
Expand All @@ -219,10 +218,10 @@ func (c *ip) IpResponseToUpdate(desired *apiv2.IP) (*apiv2.IPServiceUpdateReques
ctx, cancel := c.c.NewRequestContext()
defer cancel()

current, err := c.c.Client.Apiv2().IP().Get(ctx, connect.NewRequest(&apiv2.IPServiceGetRequest{
current, err := c.c.Client.Apiv2().IP().Get(ctx, &apiv2.IPServiceGetRequest{
Ip: desired.Ip,
Project: desired.Project,
}))
})
if err != nil {
return nil, err
}
Expand All @@ -232,7 +231,7 @@ func (c *ip) IpResponseToUpdate(desired *apiv2.IP) (*apiv2.IPServiceUpdateReques
Update: &apiv2.Labels{},
}

for key, currentValue := range current.Msg.Ip.Meta.Labels.Labels {
for key, currentValue := range current.Ip.Meta.Labels.Labels {
value, ok := desired.Meta.Labels.Labels[key]

if !ok {
Expand Down
9 changes: 4 additions & 5 deletions cmd/api/v1/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"sort"

"connectrpc.com/connect"
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/printers"
Expand All @@ -24,25 +23,25 @@ func newMethodsCmd(c *config.Config) *cobra.Command {

req := &apiv2.MethodServiceTokenScopedListRequest{}

resp, err := c.Client.Apiv2().Method().TokenScopedList(ctx, connect.NewRequest(req))
resp, err := c.Client.Apiv2().Method().TokenScopedList(ctx, req)
if err != nil {
return fmt.Errorf("failed to list methods: %w", err)
}

return printers.NewProtoYAMLPrinter().WithOut(c.Out).Print(resp.Msg)
return printers.NewProtoYAMLPrinter().WithOut(c.Out).Print(resp)
}

var (
methods []string
req = &apiv2.MethodServiceListRequest{}
)

resp, err := c.Client.Apiv2().Method().List(ctx, connect.NewRequest(req))
resp, err := c.Client.Apiv2().Method().List(ctx, req)
if err != nil {
return fmt.Errorf("failed to list methods: %w", err)
}

methods = resp.Msg.GetMethods()
methods = resp.GetMethods()

sort.Strings(methods)

Expand Down
Loading