Skip to content

Commit

Permalink
refactor: shared
Browse files Browse the repository at this point in the history
  • Loading branch information
avirtopeanu-ionos committed Jan 28, 2025
1 parent d5c4241 commit f0ec7dd
Show file tree
Hide file tree
Showing 25 changed files with 61 additions and 59 deletions.
2 changes: 1 addition & 1 deletion commands/container-registry/artifacts/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
cloudapiv6 "github.com/ionos-cloud/ionosctl/v6/services/cloudapi-v6"
"github.com/ionos-cloud/ionosctl/v6/services/cloudapi-v6/resources"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/registry/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/registry/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/registry/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/registry/registries.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/core"
"github.com/ionos-cloud/ionosctl/v6/pkg/functional"
"github.com/ionos-cloud/ionosctl/v6/services/container-registry/resources"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/constants"

"github.com/ionos-cloud/ionosctl/v6/internal/client"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/repository/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
cloudapiv6 "github.com/ionos-cloud/ionosctl/v6/services/cloudapi-v6"
"github.com/ionos-cloud/ionosctl/v6/services/cloudapi-v6/resources"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/constants"
"github.com/ionos-cloud/ionosctl/v6/internal/core"
"github.com/ionos-cloud/ionosctl/v6/pkg/functional"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/token/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/token/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/token/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/token/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/token/scopes/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/constants"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/jsontabwriter"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"

"github.com/ionos-cloud/ionosctl/v6/commands/container-registry/registry"
"github.com/ionos-cloud/ionosctl/v6/internal/core"
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/token/scopes/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/core"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
"github.com/ionos-cloud/ionosctl/v6/pkg/confirm"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/token/scopes/scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/services/container-registry/resources"

"github.com/ionos-cloud/ionosctl/v6/internal/core"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"github.com/ionos-cloud/ionosctl/v6/commands/container-registry/registry"
"github.com/ionos-cloud/ionosctl/v6/commands/container-registry/token/scopes"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/token/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
scope "github.com/ionos-cloud/ionosctl/v6/commands/container-registry/token/scopes"
"github.com/ionos-cloud/ionosctl/v6/internal/core"
"github.com/ionos-cloud/ionosctl/v6/services/container-registry/resources"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion commands/container-registry/vulnerabilities/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/ionos-cloud/ionosctl/v6/internal/printer/tabheaders"
cloudapiv6 "github.com/ionos-cloud/ionosctl/v6/services/cloudapi-v6"
"github.com/ionos-cloud/ionosctl/v6/services/cloudapi-v6/resources"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
5 changes: 1 addition & 4 deletions internal/client/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ func newClient(name, pwd, token, hostUrl string, usedLayer *Layer) *Client {
dpConfig := dataplatform.NewConfiguration(name, pwd, token, hostUrl)
dpConfig.UserAgent = appendUserAgent(dpConfig.UserAgent)

registryConfig := containerregistry.NewConfiguration(name, pwd, token, hostUrl)
registryConfig.UserAgent = appendUserAgent(registryConfig.UserAgent)

vmascConfig := vmasc.NewConfiguration(name, pwd, token, hostUrl)
vmascConfig.UserAgent = appendUserAgent(vmascConfig.UserAgent)
// DBAAS
Expand All @@ -127,7 +124,7 @@ func newClient(name, pwd, token, hostUrl string, usedLayer *Layer) *Client {
CDNClient: cdn.NewAPIClient(sharedConfig),
CertManagerClient: certmanager.NewAPIClient(certManagerConfig),
DataplatformClient: dataplatform.NewAPIClient(dpConfig),
RegistryClient: containerregistry.NewAPIClient(registryConfig),
RegistryClient: containerregistry.NewAPIClient(sharedConfig),
DnsClient: dns.NewAPIClient(sharedConfig),
LoggingServiceClient: logging.NewAPIClient(sharedConfig),
VMAscClient: vmasc.NewAPIClient(vmascConfig).AutoScalingGroupsApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table"
"github.com/ionos-cloud/ionosctl/v6/internal/printer/json2table/jsonpaths"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
)

func ConvertContainerRegistryVulnerabilitiesToTable(vulnerabilities containerregistry.ArtifactVulnerabilityReadList) (
Expand Down
7 changes: 4 additions & 3 deletions services/container-registry/resources/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"

client2 "github.com/ionos-cloud/ionosctl/v6/internal/client"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/shared"
)

type LocationsService interface {
Get() (containerregistry.LocationsResponse, *containerregistry.APIResponse, error)
Get() (containerregistry.LocationsResponse, *shared.APIResponse, error)
}

type locationsService struct {
Expand All @@ -25,7 +26,7 @@ func NewLocationsService(client *client2.Client, ctx context.Context) LocationsS
}
}

func (svc *locationsService) Get() (containerregistry.LocationsResponse, *containerregistry.APIResponse, error) {
func (svc *locationsService) Get() (containerregistry.LocationsResponse, *shared.APIResponse, error) {
req := svc.client.LocationsApi.LocationsGet(svc.context)
loc, res, err := svc.client.LocationsApi.LocationsGetExecute(req)
return loc, res, err
Expand Down
9 changes: 5 additions & 4 deletions services/container-registry/resources/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"

client2 "github.com/ionos-cloud/ionosctl/v6/internal/client"
"github.com/ionos-cloud/sdk-go-bundle/shared"

containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
)

// NameService is a contract for the name service.
type NameService interface {
Head(name string) (*containerregistry.APIResponse, error)
Head(name string) (*shared.APIResponse, error)
}

// NameServiceOp is an implementation of the NameService interface.
Expand All @@ -29,8 +30,8 @@ func NewNameService(client *client2.Client, ctx context.Context) NameService {
}
}

// Get returns a containerregistry.APIResponse.
func (svc *nameService) Head(name string) (*containerregistry.APIResponse, error) {
// Get returns a *shared.APIResponse.
func (svc *nameService) Head(name string) (*shared.APIResponse, error) {
req := svc.client.NamesApi.NamesCheckUsage(svc.context, name)
res, err := svc.client.NamesApi.NamesCheckUsageExecute(req)
return res, err
Expand Down
27 changes: 14 additions & 13 deletions services/container-registry/resources/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import (
"context"

client2 "github.com/ionos-cloud/ionosctl/v6/internal/client"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/shared"
)

// RegistriesService is a wrapper around ionoscloud.Registry
type RegistriesService interface {
Get(id string) (containerregistry.RegistryResponse, *containerregistry.APIResponse, error)
List(filterName string) (containerregistry.RegistriesResponse, *containerregistry.APIResponse, error)
Post(input containerregistry.PostRegistryInput) (containerregistry.PostRegistryOutput, *containerregistry.APIResponse, error)
Delete(id string) (*containerregistry.APIResponse, error)
Patch(id string, input containerregistry.PatchRegistryInput) (containerregistry.RegistryResponse, *containerregistry.APIResponse, error)
Put(id string, input containerregistry.PutRegistryInput) (containerregistry.PutRegistryOutput, *containerregistry.APIResponse, error)
Get(id string) (containerregistry.RegistryResponse, *shared.APIResponse, error)
List(filterName string) (containerregistry.RegistriesResponse, *shared.APIResponse, error)
Post(input containerregistry.PostRegistryInput) (containerregistry.PostRegistryOutput, *shared.APIResponse, error)
Delete(id string) (*shared.APIResponse, error)
Patch(id string, input containerregistry.PatchRegistryInput) (containerregistry.RegistryResponse, *shared.APIResponse, error)
Put(id string, input containerregistry.PutRegistryInput) (containerregistry.PutRegistryOutput, *shared.APIResponse, error)
}

type registriesService struct {
Expand All @@ -31,7 +32,7 @@ func NewRegistriesService(client *client2.Client, ctx context.Context) Registrie
}
}

func (svc *registriesService) List(filterName string) (containerregistry.RegistriesResponse, *containerregistry.APIResponse, error) {
func (svc *registriesService) List(filterName string) (containerregistry.RegistriesResponse, *shared.APIResponse, error) {
req := svc.client.RegistriesApi.RegistriesGet(svc.context)
if filterName != "" {
req = req.FilterName(filterName)
Expand All @@ -40,34 +41,34 @@ func (svc *registriesService) List(filterName string) (containerregistry.Registr
return registryList, res, err
}

func (svc *registriesService) Post(input containerregistry.PostRegistryInput) (containerregistry.PostRegistryOutput, *containerregistry.APIResponse, error) {
func (svc *registriesService) Post(input containerregistry.PostRegistryInput) (containerregistry.PostRegistryOutput, *shared.APIResponse, error) {
req := svc.client.RegistriesApi.RegistriesPost(svc.context).PostRegistryInput(input)
registryList, res, err := svc.client.RegistriesApi.RegistriesPostExecute(req)
return registryList, res, err
}

func (svc *registriesService) Get(id string) (containerregistry.RegistryResponse, *containerregistry.APIResponse, error) {
func (svc *registriesService) Get(id string) (containerregistry.RegistryResponse, *shared.APIResponse, error) {
req := svc.client.RegistriesApi.RegistriesFindById(svc.context, id)
reg, res, err := svc.client.RegistriesApi.RegistriesFindByIdExecute(req)
return reg, res, err
}

func (svc *registriesService) Delete(id string) (*containerregistry.APIResponse, error) {
func (svc *registriesService) Delete(id string) (*shared.APIResponse, error) {
req := svc.client.RegistriesApi.RegistriesDelete(svc.context, id)
res, err := svc.client.RegistriesApi.RegistriesDeleteExecute(req)
return res, err
}

func (svc *registriesService) Patch(id string, input containerregistry.PatchRegistryInput) (
containerregistry.RegistryResponse, *containerregistry.APIResponse, error,
containerregistry.RegistryResponse, *shared.APIResponse, error,
) {
req := svc.client.RegistriesApi.RegistriesPatch(svc.context, id).PatchRegistryInput(input)
reg, res, err := svc.client.RegistriesApi.RegistriesPatchExecute(req)
return reg, res, err
}

func (svc *registriesService) Put(id string, input containerregistry.PutRegistryInput) (
containerregistry.PutRegistryOutput, *containerregistry.APIResponse, error,
containerregistry.PutRegistryOutput, *shared.APIResponse, error,
) {
req := svc.client.RegistriesApi.RegistriesPut(svc.context, id).PutRegistryInput(input)
reg, res, err := svc.client.RegistriesApi.RegistriesPutExecute(req)
Expand Down
7 changes: 4 additions & 3 deletions services/container-registry/resources/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"

client2 "github.com/ionos-cloud/ionosctl/v6/internal/client"
containerregistry "github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/products/containerregistry/v2"
"github.com/ionos-cloud/sdk-go-bundle/shared"
)

type RepositoryService interface {
Delete(regId string, name string) (*containerregistry.APIResponse, error)
Delete(regId string, name string) (*shared.APIResponse, error)
}

type repositoryService struct {
Expand All @@ -25,7 +26,7 @@ func NewRepositoryService(client *client2.Client, ctx context.Context) Repositor
}
}

func (svc *repositoryService) Delete(regId string, name string) (*containerregistry.APIResponse, error) {
func (svc *repositoryService) Delete(regId string, name string) (*shared.APIResponse, error) {
req := svc.client.RepositoriesApi.RegistriesRepositoriesDelete(svc.context, regId, name)
res, err := svc.client.RepositoriesApi.RegistriesRepositoriesDeleteExecute(req)
return res, err
Expand Down
Loading

0 comments on commit f0ec7dd

Please sign in to comment.