Skip to content

Commit

Permalink
feat(cloud-provisioning): Machine Identity struct changes
Browse files Browse the repository at this point in the history
Changes type of Machine Identity IDs from UUID to string for ease of use
  • Loading branch information
rvelaVenafi committed May 31, 2024
1 parent f8441ed commit 5f41ec7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
10 changes: 4 additions & 6 deletions pkg/domain/cloudproviders.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package domain

import (
"strings"

"github.com/google/uuid"
)

type CloudProviderStatus int
Expand Down Expand Up @@ -221,12 +219,12 @@ func (ccm *CertificateCloudMetadata) GetValue(key string) interface{} {
}

type CloudMachineIdentity struct {
ID uuid.UUID
CloudKeystoreID uuid.UUID
ID string
CloudKeystoreID string
CloudKeystoreName string
CloudProviderID uuid.UUID
CloudProviderID string
CloudProviderName string
CertificateID uuid.UUID
CertificateID string
Metadata *CertificateCloudMetadata
Status MachineIdentityStatus
StatusDetails string
Expand Down
29 changes: 5 additions & 24 deletions pkg/webclient/cloudproviders/cloudproviders.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"net/http"

"github.com/Khan/genqlient/graphql"
"github.com/google/uuid"

"github.com/Venafi/vcert/v5/pkg/domain"
"github.com/Venafi/vcert/v5/pkg/util"
)
Expand Down Expand Up @@ -172,27 +170,10 @@ func (c *CloudProvidersClient) ProvisionCertificateToMachineIdentity(ctx context
}

func (v *GetMachineIdentitiesCloudMachineIdentitiesMachineIdentityConnectionNodesMachineIdentity) toDomain() (*domain.CloudMachineIdentity, error) {
id, err := uuid.Parse(v.Id)
if err != nil {
return nil, fmt.Errorf("failed to parse cloud machine identity id %s: %w", v.Id, err)
}
keystoreID, err := uuid.Parse(v.CloudKeystoreId)
if err != nil {
return nil, fmt.Errorf("failed to parse cloud key store id %s: %w", v.CloudKeystoreId, err)
}
certificateID, err := uuid.Parse(v.CertificateId)
if err != nil {
return nil, fmt.Errorf("failed to parse cloud certificate id %s: %w", v.CertificateId, err)
}
providerIDStr := ""
providerID := ""
if v.CloudProviderId != nil {
providerIDStr = *v.CloudProviderId
providerID = *v.CloudProviderId
}
providerID, err := uuid.Parse(providerIDStr)
if err != nil {
return nil, fmt.Errorf("failed to parse cloud provider id %s: %w", providerIDStr, err)
}

keystoreName := ""
if v.CloudKeystoreName != nil {
keystoreName = *v.CloudKeystoreName
Expand All @@ -211,12 +192,12 @@ func (v *GetMachineIdentitiesCloudMachineIdentitiesMachineIdentityConnectionNode
}

return &domain.CloudMachineIdentity{
ID: id,
CloudKeystoreID: keystoreID,
ID: v.Id,
CloudKeystoreID: v.CloudKeystoreId,
CloudKeystoreName: keystoreName,
CloudProviderID: providerID,
CloudProviderName: providerName,
CertificateID: certificateID,
CertificateID: v.CertificateId,
Metadata: metadata,
Status: v.Status.toDomain(),
StatusDetails: statusDetails,
Expand Down

0 comments on commit 5f41ec7

Please sign in to comment.