Skip to content

Commit

Permalink
Merge pull request #173 from vmware/chore/5.1.1-api
Browse files Browse the repository at this point in the history
Bump SDK to 0.3.0 and add support for VCF 5.1.1 APIs
  • Loading branch information
spacegospod authored May 23, 2024
2 parents ff434ea + eb19de4 commit de7c769
Show file tree
Hide file tree
Showing 30 changed files with 88 additions and 91 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## [v0.9.0](https://github.com/vmware/terraform-provider-vcf/releases/tag/v0.9.0)

> Release Date: May 23 2024
FEATURES:
* Official support for VCF 5.1.1 [\#173](https://github.com/vmware/terraform-provider-vcf/pull/173)

## [v0.8.5](https://github.com/vmware/terraform-provider-vcf/releases/tag/v0.8.5)

> Release Date: Apr 26 2024
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/stretchr/testify v1.9.0
github.com/vmware/vcf-sdk-go v0.2.4
github.com/vmware/vcf-sdk-go v0.3.0
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAh
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/vmware/vcf-sdk-go v0.2.4 h1:OBUhTHcgdYhH1uEEhB0KuhR0ziOmnyska6zjQ9LH3h8=
github.com/vmware/vcf-sdk-go v0.2.4/go.mod h1:EXM19ZwD2qmvMVSvgUzcnT7dSTCq3lzv84ErrFPZm1Q=
github.com/vmware/vcf-sdk-go v0.3.0 h1:uDz57vEsLMuocPsp3OHgy137YdD4z1i9x9FrepoPcRs=
github.com/vmware/vcf-sdk-go v0.3.0/go.mod h1:EXM19ZwD2qmvMVSvgUzcnT7dSTCq3lzv84ErrFPZm1Q=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
12 changes: 6 additions & 6 deletions internal/certificates/certificate_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func ValidateResourceCertificates(ctx context.Context, client *vcfclient.VcfClie
// Wait for certificate validation to fisnish
if !validationutils.HasCertificateValidationFinished(validationResponse) {
for {
getResourceCertificatesValidationResultParams := certificates.NewGetResourceCertificatesValidationResultParams().
getResourceCertificatesValidationResultParams := certificates.NewGetResourceCertificatesValidationByIDParams().
WithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout).
WithID(*validationId)
getValidationResponse, err := client.Certificates.GetResourceCertificatesValidationResult(getResourceCertificatesValidationResultParams)
getValidationResponse, err := client.Certificates.GetResourceCertificatesValidationByID(getResourceCertificatesValidationResultParams)
if err != nil {
return validationutils.ConvertVcfErrorToDiag(err)
}
Expand Down Expand Up @@ -104,11 +104,11 @@ func GetCertificateForResourceInDomain(ctx context.Context, client *vcfclient.Vc
return nil, fmt.Errorf("could not determine FQDN for resourceType %s in domain %s", resourceType, domainId)
}

viewCertificatesParams := certificates.NewViewCertificateParamsWithContext(ctx).
viewCertificatesParams := certificates.NewGetCertificatesByDomainParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout)
viewCertificatesParams.SetDomainName(domainId)
viewCertificatesParams.ID = domainId

certificatesResponse, err := client.Certificates.ViewCertificate(viewCertificatesParams)
certificatesResponse, _, err := client.Certificates.GetCertificatesByDomain(viewCertificatesParams)
if err != nil {
return nil, err
}
Expand All @@ -134,7 +134,7 @@ func GenerateCertificateForResource(ctx context.Context, client *api_client.Sddc
}
generateCertificatesParam := certificates.NewGenerateCertificatesParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout).
WithDomainName(*domainId)
WithID(*domainId)
generateCertificatesParam.SetCertificateGenerationSpec(certificateGenerationSpec)

var taskId string
Expand Down
9 changes: 5 additions & 4 deletions internal/cluster/cluster_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func SetStretchOrUnstretchSpec(updateSpec *models.ClusterUpdateSpec, data *schem

stretchSpec := &models.ClusterStretchSpec{
HostSpecs: hostSpecs,
SecondaryAzOverlayVlanID: &secondaryAzOverlayVlanId,
SecondaryAzOverlayVlanID: secondaryAzOverlayVlanId,
WitnessSpec: &witnessSpec,
IsEdgeClusterConfiguredForMultiAZ: false,
}
Expand All @@ -143,12 +143,12 @@ type EmptySpec struct{}

func ValidateClusterUpdateOperation(ctx context.Context, clusterId string,
clusterUpdateSpec *models.ClusterUpdateSpec, apiClient *client.VcfClient) diag.Diagnostics {
validateClusterSpec := clusters.NewValidateClusterOperationsParamsWithContext(ctx).
validateClusterSpec := clusters.NewValidateClusterUpdateSpecParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout)
validateClusterSpec.ClusterUpdateSpec = clusterUpdateSpec
validateClusterSpec.ID = clusterId

validateResponse, err := apiClient.Clusters.ValidateClusterOperations(validateClusterSpec)
validateResponse, err := apiClient.Clusters.ValidateClusterUpdateSpec(validateClusterSpec)
if err != nil {
return validationUtils.ConvertVcfErrorToDiag(err)
}
Expand Down Expand Up @@ -214,7 +214,8 @@ func TryConvertToClusterSpec(object map[string]interface{}) (*models.ClusterSpec
result.NetworkSpec.NsxClusterSpec.NsxTClusterSpec = &models.NsxTClusterSpec{}

if geneveVlanId, ok := object["geneve_vlan_id"]; ok && !validationUtils.IsEmpty(geneveVlanId) {
result.NetworkSpec.NsxClusterSpec.NsxTClusterSpec.GeneveVlanID = int32(geneveVlanId.(int))
vlanValue := int32(geneveVlanId.(int))
result.NetworkSpec.NsxClusterSpec.NsxTClusterSpec.GeneveVlanID = &vlanValue
}

if ipAddressPoolRaw, ok := object["ip_address_pool"]; ok && !validationUtils.IsEmpty(ipAddressPoolRaw) {
Expand Down
2 changes: 1 addition & 1 deletion internal/datastores/vsan_datastore_subresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TryConvertToVsanDatastoreSpec(object map[string]interface{}) (*models.VSAND
}
if failuresToTolerate, ok := object["failures_to_tolerate"]; ok && !validationutils.IsEmpty(failuresToTolerate) {
failuresToTolerateInt := int32(failuresToTolerate.(int))
result.FailuresToTolerate = &failuresToTolerateInt
result.FailuresToTolerate = failuresToTolerateInt
}

return result, nil
Expand Down
4 changes: 2 additions & 2 deletions internal/network/nsx_subresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ func FlattenNsxClusterRef(ctx context.Context, nsxtClusterRef *models.NsxTCluste
flattenedNsxCluster["vip"] = nsxtClusterRef.Vip
flattenedNsxCluster["vip_fqdn"] = nsxtClusterRef.VipFqdn

getNsxTClusterParams := nsxt_clusters.NewGetNSXTClusterParamsWithContext(ctx).
getNsxTClusterParams := nsxt_clusters.NewGetNsxClusterParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout).WithID(nsxtClusterRef.ID)

nsxtClusterResponse, err := apiClient.NSXTClusters.GetNSXTCluster(getNsxTClusterParams)
nsxtClusterResponse, err := apiClient.NSXTClusters.GetNsxCluster(getNsxTClusterParams)
if err != nil {
return nil, err
}
Expand Down
14 changes: 7 additions & 7 deletions internal/nsx_edge_cluster/edge_cluster_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ func GetNsxEdgeClusterCreationSpec(data *schema.ResourceData) *models.EdgeCluste
InternalTransitSubnets: internalTransitSubnets,
Mtu: &mtu,
Asn: asn,
Tier0Name: &tier0Name,
Tier0RoutingType: &routingType,
Tier0ServicesHighAvailability: &highAvailability,
Tier1Name: &tier1Name,
Tier0Name: tier0Name,
Tier0RoutingType: routingType,
Tier0ServicesHighAvailability: highAvailability,
Tier1Name: tier1Name,
Tier1Unhosted: tier1Unhosted,
TransitSubnets: transitSubnets,
}
Expand Down Expand Up @@ -152,9 +152,9 @@ func getNodeSpec(node map[string]interface{}) *models.NsxTEdgeNodeSpec {
nodeSpec := &models.NsxTEdgeNodeSpec{
ClusterID: &clusterId,
EdgeNodeName: &name,
EdgeTep1IP: &tep1IP,
EdgeTep2IP: &tep2IP,
EdgeTepGateway: &tepGateway,
EdgeTep1IP: tep1IP,
EdgeTep2IP: tep2IP,
EdgeTepGateway: tepGateway,
EdgeTepVlan: &tepVlan,
ManagementGateway: &managementGateway,
ManagementIP: &managementIP,
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/resource_ceip.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func resourceCeipUpdate(ctx context.Context, d *schema.ResourceData, meta interf
vcfClient := meta.(*api_client.SddcManagerClient)
apiClient := vcfClient.ApiClient

params := ceip.NewUpdateCEIPStatusParamsWithTimeout(2 * time.Minute)
params := ceip.NewSetCEIPStatusParamsWithTimeout(2 * time.Minute)
updateSpec := models.CEIPUpdateSpec{}

if status, ok := d.GetOk("status"); ok {
Expand All @@ -91,7 +91,7 @@ func resourceCeipUpdate(ctx context.Context, d *schema.ResourceData, meta interf
}

params.CEIPUpdateSpec = &updateSpec
_, ceipAccepted, err := apiClient.CEIP.UpdateCEIPStatus(params)
_, ceipAccepted, err := apiClient.CEIP.SetCEIPStatus(params)
if err != nil {
tflog.Error(ctx, err.Error())
return diag.FromErr(err)
Expand All @@ -111,13 +111,13 @@ func resourceCeipDelete(ctx context.Context, d *schema.ResourceData, meta interf
vcfClient := meta.(*api_client.SddcManagerClient)
apiClient := vcfClient.ApiClient

params := ceip.NewUpdateCEIPStatusParams()
params := ceip.NewSetCEIPStatusParams()
updateSpec := models.CEIPUpdateSpec{}
statusVal := DisableApiParam
updateSpec.Status = &statusVal
params.CEIPUpdateSpec = &updateSpec

_, ceipAccepted, err := apiClient.CEIP.UpdateCEIPStatus(params)
_, ceipAccepted, err := apiClient.CEIP.SetCEIPStatus(params)
if err != nil {
tflog.Error(ctx, err.Error())
return diag.FromErr(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func resourceResourceCertificateCreate(ctx context.Context, data *schema.Resourc
}
replaceCertificatesParams := certificatesSdk.NewReplaceCertificatesParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout).
WithDomainName(domainID)
WithID(domainID)
replaceCertificatesParams.SetCertificateOperationSpec(certificateOperationSpec)

var taskId string
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_certificate_authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ func resourceCertificateAuthorityDelete(ctx context.Context, data *schema.Resour
if caType == nil {
return diag.FromErr(fmt.Errorf("error deleting Certificate Authority: could not determine CA type"))
}
deleteCaConfigurationParams := certificates.NewDeleteCaConfigurationParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout).WithCaType(*caType)
deleteCaConfigurationParams := certificates.NewRemoveCertificateAuthorityParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout).WithID(*caType)

_, _, err := apiClient.Certificates.DeleteCaConfiguration(deleteCaConfigurationParams)
_, _, err := apiClient.Certificates.RemoveCertificateAuthority(deleteCaConfigurationParams)
if err != nil {
return diag.FromErr(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ func createCluster(ctx context.Context, domainId string, clusterSpec *models.Clu
DomainID: resource_utils.ToStringPointer(domainId),
}

validateClusterSpec := clusters.NewValidateClustersOperationsParamsWithContext(ctx).
validateClusterSpec := clusters.NewValidateClusterCreationSpecParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout)
validateClusterSpec.ClusterCreationSpec = &clusterCreationSpec

validateResponse, err := apiClient.Clusters.ValidateClustersOperations(validateClusterSpec)
validateResponse, err := apiClient.Clusters.ValidateClusterCreationSpec(validateClusterSpec)
if err != nil {
return "", validationUtils.ConvertVcfErrorToDiag(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func testAccVcfClusterResourceConfig(domainId, host1Fqdn, host1Pass, host2Fqdn,
network {
gateway = "192.168.12.1"
mask = "255.255.255.0"
mtu = 9000
mtu = 8940
subnet = "192.168.12.0"
type = "VSAN"
vlan_id = 100
Expand All @@ -374,7 +374,7 @@ func testAccVcfClusterResourceConfig(domainId, host1Fqdn, host1Pass, host2Fqdn,
network {
gateway = "192.168.13.1"
mask = "255.255.255.0"
mtu = 9000
mtu = 8940
subnet = "192.168.13.0"
type = "vMotion"
vlan_id = 100
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_credentials_auto_rotate_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func resourceCredentialsAutoRotatePolicyCreate(ctx context.Context, d *schema.Re
func resourceCredentialsAutoRotatePolicyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
apiClient := meta.(*api_client.SddcManagerClient).ApiClient
matchedCredentials, err := credentials.ReadCredentials(ctx, d, apiClient)
matchedCredentials = filterCredentialsByUsername(d.Get("user_name").(string), matchedCredentials)
matchedCredentials = filterCredentials(d.Get("user_name").(string), d.Get("resource_id").(string), matchedCredentials)

if err != nil {
return diag.FromErr(err)
Expand Down Expand Up @@ -129,10 +129,10 @@ func createAutorotateID(data *schema.ResourceData) (string, error) {
return credentials.HashFields(params)
}

func filterCredentialsByUsername(userName string, creds []*models.Credential) []*models.Credential {
func filterCredentials(userName, resourceId string, creds []*models.Credential) []*models.Credential {
result := make([]*models.Credential, 0)
for _, cred := range creds {
if *cred.Username == userName {
if *cred.Username == userName && cred.Resource != nil && *cred.Resource.ResourceID == resourceId {
result = append(result, cred)
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func resourceCsrCreate(ctx context.Context, data *schema.ResourceData, meta inte

generateCsrParams := certificatesSdk.NewGeneratesCSRsParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout).
WithDomainName(domainId).
WithID(domainId).
WithCSRSGenerationSpec(csrsGenerationSpec)

var taskId string
Expand All @@ -162,7 +162,7 @@ func resourceCsrCreate(ctx context.Context, data *schema.ResourceData, meta inte

getCsrsParams := certificatesSdk.NewGetCSRsParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout).
WithDomainName(domainId)
WithID(domainId)
getCsrResponse, err := apiClient.Certificates.GetCSRs(getCsrsParams)
if err != nil {
return diag.FromErr(err)
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ func resourceDomainCreate(ctx context.Context, data *schema.ResourceData, meta i
if err != nil {
return diag.FromErr(err)
}
validateDomainSpec := domains.NewValidateDomainsOperationsParamsWithContext(ctx).
validateDomainSpec := domains.NewValidateDomainCreationSpecParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout)
validateDomainSpec.DomainCreationSpec = domainCreationSpec

validateResponse, err := apiClient.Domains.ValidateDomainsOperations(validateDomainSpec)
validateResponse, err := apiClient.Domains.ValidateDomainCreationSpec(validateDomainSpec)
if err != nil {
return validationUtils.ConvertVcfErrorToDiag(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func testAccVcfDomainConfig(commissionHostConfig, nsxLicenseKey,
network {
gateway = "192.168.10.1"
mask = "255.255.255.0"
mtu = 9000
mtu = 8940
subnet = "192.168.10.0"
type = "VSAN"
vlan_id = 100
Expand All @@ -374,7 +374,7 @@ func testAccVcfDomainConfig(commissionHostConfig, nsxLicenseKey,
network {
gateway = "192.168.11.1"
mask = "255.255.255.0"
mtu = 9000
mtu = 8940
subnet = "192.168.11.0"
type = "vMotion"
vlan_id = 100
Expand Down
12 changes: 6 additions & 6 deletions internal/provider/resource_edge_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ func resourceNsxEdgeClusterCreate(ctx context.Context, data *schema.ResourceData
return validationErr
}

createClusterParams := &nsxt_edge_clusters.CreateEdgeParams{
createClusterParams := &nsxt_edge_clusters.CreateEdgeClusterParams{
EdgeCreationSpec: spec,
Context: ctx,
}

_, task, err := client.NSXTEdgeClusters.CreateEdge(createClusterParams.WithTimeout(constants.DefaultVcfApiCallTimeout))
_, task, err := client.NSXTEdgeClusters.CreateEdgeCluster(createClusterParams.WithTimeout(constants.DefaultVcfApiCallTimeout))

if err != nil {
return diag.FromErr(err)
Expand Down Expand Up @@ -276,11 +276,11 @@ func getEdgeCluster(ctx context.Context, client *vcfClient.VcfClient, id string)
}

func validateClusterCreationSpec(client *vcfClient.VcfClient, ctx context.Context, spec *models.EdgeClusterCreationSpec) diag.Diagnostics {
validateClusterParams := &nsxt_edge_clusters.ValidateEdgeClusterSpecParams{
validateClusterParams := &nsxt_edge_clusters.ValidateEdgeClusterCreationSpecParams{
EdgeCreationSpec: spec,
}

_, validateResponse, err := client.NSXTEdgeClusters.ValidateEdgeClusterSpec(validateClusterParams.WithTimeout(constants.DefaultVcfApiCallTimeout))
_, validateResponse, err := client.NSXTEdgeClusters.ValidateEdgeClusterCreationSpec(validateClusterParams.WithTimeout(constants.DefaultVcfApiCallTimeout))

if err != nil {
return validationUtils.ConvertVcfErrorToDiag(err)
Expand All @@ -292,10 +292,10 @@ func validateClusterCreationSpec(client *vcfClient.VcfClient, ctx context.Contex
}

for {
getClusterValidationParams := nsxt_edge_clusters.NewGetValidationForCreateEdgeClusterParamsWithContext(ctx).
getClusterValidationParams := nsxt_edge_clusters.NewGetEdgeClusterValidationByIDParamsWithContext(ctx).
WithTimeout(constants.DefaultVcfApiCallTimeout)
getClusterValidationParams.SetID(validateResponse.Payload.ID)
getValidationResponse, err := client.NSXTEdgeClusters.GetValidationForCreateEdgeCluster(getClusterValidationParams)
getValidationResponse, err := client.NSXTEdgeClusters.GetEdgeClusterValidationByID(getClusterValidationParams)
if err != nil {
return validationUtils.ConvertVcfErrorToDiag(err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_edge_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func getEdgeClusterConfigInitial() string {
profile_type = "DEFAULT"
routing_type = "EBGP"
high_availability = "ACTIVE_ACTIVE"
mtu = 9000
mtu = 8940
asn = 65004
%s
%s
Expand Down Expand Up @@ -109,7 +109,7 @@ func getEdgeClusterConfigExpansion() string {
"192.168.19.3/24")
edgeNode3 := getEdgeNodeConfig(
edgeNode3Name,
"10.0.0.54/24",
"10.0.0.55/24",
"192.168.52.16/24",
"192.168.52.17/24",
"192.168.18.6/24",
Expand All @@ -127,7 +127,7 @@ func getEdgeClusterConfigExpansion() string {
profile_type = "DEFAULT"
routing_type = "EBGP"
high_availability = "ACTIVE_ACTIVE"
mtu = 9000
mtu = 8940
asn = 65004
%s
%s
Expand Down
Loading

0 comments on commit de7c769

Please sign in to comment.