From f617d9a2f78ccdb05ae5cc33008cfca49e0923ce Mon Sep 17 00:00:00 2001 From: Stefan Majer Date: Wed, 11 Sep 2024 13:46:16 +0200 Subject: [PATCH] Replace func available in pointer package --- cmd/dashboard.go | 11 +++++------ cmd/output/helper.go | 7 ------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/cmd/dashboard.go b/cmd/dashboard.go index 55ccb3d..d671a32 100644 --- a/cmd/dashboard.go +++ b/cmd/dashboard.go @@ -21,7 +21,6 @@ import ( "github.com/fi-ts/cloud-go/api/client/volume" "github.com/fi-ts/cloud-go/api/models" "github.com/fi-ts/cloudctl/cmd/helper" - "github.com/fi-ts/cloudctl/cmd/output" "github.com/gardener/gardener/pkg/apis/core/v1beta1" "github.com/google/go-cmp/cmp" "github.com/metal-stack/metal-lib/pkg/cache" @@ -1266,9 +1265,9 @@ func newCache(cloud *client.CloudAPI, expiration time.Duration, partition, tenan return &apiCache{ clusters: cache.New(expiration, func(ctx context.Context, _ string) ([]*models.V1ClusterResponse, error) { resp, err := cloud.Cluster.FindClusters(cluster.NewFindClustersParams().WithBody(&models.V1ClusterFindRequest{ - PartitionID: output.StrDeref(partition), - Tenant: output.StrDeref(tenant), - Purpose: output.StrDeref(purpose), + PartitionID: pointer.PointerOrDefault(partition, ""), + Tenant: pointer.PointerOrDefault(tenant, ""), + Purpose: pointer.PointerOrDefault(purpose, ""), }).WithReturnMachines(pointer.Pointer(false)).WithContext(ctx), nil) if err != nil { return nil, err @@ -1277,8 +1276,8 @@ func newCache(cloud *client.CloudAPI, expiration time.Duration, partition, tenan }), volumes: cache.New(expiration, func(ctx context.Context, _ string) ([]*models.V1VolumeResponse, error) { resp, err := cloud.Volume.FindVolumes(volume.NewFindVolumesParams().WithBody(&models.V1VolumeFindRequest{ - PartitionID: output.StrDeref(partition), - TenantID: output.StrDeref(tenant), + PartitionID: pointer.PointerOrDefault(partition, ""), + TenantID: pointer.PointerOrDefault(tenant, ""), }).WithContext(ctx), nil) if err != nil { return nil, err diff --git a/cmd/output/helper.go b/cmd/output/helper.go index de4b189..afa6c09 100644 --- a/cmd/output/helper.go +++ b/cmd/output/helper.go @@ -74,13 +74,6 @@ func sortIPs(v1ips []*models.ModelsV1IPResponse) []*models.ModelsV1IPResponse { return result } -func StrDeref(s string) *string { - if s == "" { - return nil - } - return &s -} - func printStringSlice(s []string) { var dashed []string for _, elem := range s {