From f05295c45fd840f4e0d20f64c1a2bf16fa4939bd Mon Sep 17 00:00:00 2001 From: Mickael Stanislas Date: Mon, 2 Dec 2024 14:16:43 +0100 Subject: [PATCH] chore: move uuid pckage to sdk --- go.mod | 2 +- go.sum | 4 +- internal/provider/catalog/acl_resource.go | 4 +- internal/provider/catalog/acl_schema.go | 6 +- .../catalog_vapp_template_datasource.go | 4 +- internal/provider/common/acl/acl.go | 11 +- .../provider/common/adminorg/vdc_group.go | 4 +- internal/provider/common/common.go | 16 - internal/provider/common/edgegw/edgegw.go | 6 +- .../edgegw/app_port_profile_resource.go | 6 +- .../edgegw/dhcp_forwarding_resource.go | 4 +- .../provider/edgegw/edgegateway_datasource.go | 4 +- .../provider/edgegw/edgegateway_resource.go | 11 +- .../edgegw/edgegateways_datasource.go | 4 +- internal/provider/edgegw/firewall_resource.go | 6 +- internal/provider/edgegw/ip_set_resource.go | 4 +- internal/provider/edgegw/nat_rule_resource.go | 6 +- internal/provider/edgegw/nat_rule_schema.go | 4 +- .../edgegw/security_group_resource.go | 6 +- .../provider/edgegw/static_route_resource.go | 6 +- .../provider/edgegw/vpn_ipsec_resource.go | 4 +- internal/provider/network/routed_resource.go | 4 +- .../provider/publicip/publicip_resource.go | 4 +- internal/provider/s3/user_datasource.go | 6 +- .../vapp/isolated_network_resource.go | 4 +- .../provider/vapp/org_network_datasource.go | 4 +- .../provider/vapp/org_network_resource.go | 6 +- internal/provider/vcda/vcda_ip_resource.go | 10 +- .../provider/vm/vm_affinity_rule_resource.go | 9 +- internal/provider/vm/vm_disk_resource.go | 20 +- internal/provider/vm/vm_disk_schema.go | 4 +- internal/provider/vm/vm_disks_datasource.go | 4 +- internal/provider/vm/vm_disks_schema.go | 6 +- internal/provider/vm/vm_resource.go | 4 +- internal/testsacc/alb_pool_datasource_test.go | 4 +- internal/testsacc/alb_pool_resource_test.go | 6 +- .../testsacc/catalog_acl_resource_test.go | 10 +- internal/testsacc/catalog_resource_test.go | 4 +- .../catalog_vapp_template_datasource_test.go | 8 +- internal/testsacc/catalogs_datasource_test.go | 4 +- ...edgegw_app_port_profile_datasource_test.go | 8 +- .../edgegw_app_port_profile_resource_test.go | 8 +- .../edgegw_dhcp_forwarding_resource_test.go | 10 +- .../edgegw_edgegateway_resource_test.go | 6 +- .../edgegw_edgegateways_datasource_test.go | 4 +- .../testsacc/edgegw_firewall_resource_test.go | 22 +- .../testsacc/edgegw_nat_rule_resource_test.go | 12 +- .../edgegw_security_group_resource_test.go | 4 +- .../edgegw_static_route_resource_test.go | 6 +- .../edgegw_vpn_ipsec_resource_test.go | 10 +- internal/testsacc/iam_token_resource_test.go | 4 +- internal/testsacc/iam_user_datasource_test.go | 4 +- internal/testsacc/iam_user_resource_test.go | 6 +- .../testsacc/iam_user_saml_resource_test.go | 4 +- .../network_isolated_resource_test.go | 6 +- .../network_routed_datasource_test.go | 4 +- .../testsacc/network_routed_resource_test.go | 8 +- internal/testsacc/profile_datasource_test.go | 4 +- internal/testsacc/profiles_datasource_test.go | 4 +- internal/testsacc/publicip_resource_test.go | 4 +- internal/testsacc/s3_user_datasource_test.go | 4 +- .../storage_profile_datasource_test.go | 4 +- .../storage_profiles_datasource_test.go | 4 +- internal/testsacc/vapp_acl_resource_test.go | 6 +- .../vapp_org_network_datasource_test.go | 4 +- .../vapp_org_network_resource_test.go | 4 +- internal/testsacc/vapp_resource_test.go | 4 +- internal/testsacc/vcda_ip_resource_test.go | 6 +- internal/testsacc/vdc_acl_resource_test.go | 6 +- internal/testsacc/vdc_group_resource_test.go | 4 +- internal/testsacc/vdc_resource_test.go | 12 +- internal/testsacc/vm_datasource_test.go | 8 +- internal/testsacc/vm_disk_resource_test.go | 10 +- internal/testsacc/vm_resource_test.go | 6 +- .../testsacc/vm_security_tag_resource_test.go | 8 +- pkg/uuid/uuid.go | 330 ---- pkg/uuid/uuid_test.go | 1354 ----------------- 77 files changed, 226 insertions(+), 1929 deletions(-) delete mode 100644 internal/provider/common/common.go delete mode 100644 pkg/uuid/uuid.go delete mode 100644 pkg/uuid/uuid_test.go diff --git a/go.mod b/go.mod index 5b782856..9abf1746 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 github.com/iancoleman/strcase v0.3.0 - github.com/orange-cloudavenue/cloudavenue-sdk-go v0.13.0 + github.com/orange-cloudavenue/cloudavenue-sdk-go v0.14.0 github.com/orange-cloudavenue/common-go/utils v0.0.0-20240119163616-66b473d92339 github.com/rs/zerolog v1.33.0 github.com/thanhpk/randstr v1.0.6 diff --git a/go.sum b/go.sum index 3c76b576..6e75c0d7 100644 --- a/go.sum +++ b/go.sum @@ -250,8 +250,8 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= -github.com/orange-cloudavenue/cloudavenue-sdk-go v0.13.0 h1:qqmOfyTj3LVZ2f059EhfevW1mdxo4mgFh8KLt6JzuAY= -github.com/orange-cloudavenue/cloudavenue-sdk-go v0.13.0/go.mod h1:CTQO1VIVFvImvmKoR4ntL3HxBi5REm6ssLzUj3kv1sc= +github.com/orange-cloudavenue/cloudavenue-sdk-go v0.14.0 h1:IHqwdPRAEfw/xP6I0COzE9hsju7Hk+TLjd3xzJ6AOqM= +github.com/orange-cloudavenue/cloudavenue-sdk-go v0.14.0/go.mod h1:CTQO1VIVFvImvmKoR4ntL3HxBi5REm6ssLzUj3kv1sc= github.com/orange-cloudavenue/common-go/utils v0.0.0-20240119163616-66b473d92339 h1:DEKcWLGbEhu/I6kn9NAXhVCFrbPhR+Ef7oLmpLVnnPM= github.com/orange-cloudavenue/common-go/utils v0.0.0-20240119163616-66b473d92339/go.mod h1:11JAFfGWVmhoT4AAORKsIC5M6nI+uDGSEOScMzavgPA= github.com/peterhellberg/link v1.2.0 h1:UA5pg3Gp/E0F2WdX7GERiNrPQrM1K6CVJUUWfHa4t6c= diff --git a/internal/provider/catalog/acl_resource.go b/internal/provider/catalog/acl_resource.go index 80a86e5e..0c0eca13 100644 --- a/internal/provider/catalog/acl_resource.go +++ b/internal/provider/catalog/acl_resource.go @@ -12,10 +12,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/adminorg" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -289,7 +289,7 @@ func (r *aclResource) read(ctx context.Context, planOrState *ACLModel) (stateRef return stateRefreshed, true, diags } x := ACLModelSharedWithUser{} - x.UserID.Set(uuid.Normalize(uuid.User, id).String()) + x.UserID.Set(urn.Normalize(urn.User, id).String()) x.AccessLevel.Set(user.AccessLevel) sharedWithUsers = append(sharedWithUsers, x) diff --git a/internal/provider/catalog/acl_schema.go b/internal/provider/catalog/acl_schema.go index 49968ee3..983254e3 100644 --- a/internal/provider/catalog/acl_schema.go +++ b/internal/provider/catalog/acl_schema.go @@ -22,7 +22,7 @@ import ( fsetvalidator "github.com/FrangipaneTeam/terraform-plugin-framework-validators/setvalidator" fstringvalidator "github.com/FrangipaneTeam/terraform-plugin-framework-validators/stringvalidator" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) func aclSchema(_ context.Context) superschema.Schema { @@ -51,7 +51,7 @@ func aclSchema(_ context.Context) superschema.Schema { Validators: []validator.String{ stringvalidator.ExactlyOneOf(path.MatchRoot("catalog_name"), path.MatchRoot("catalog_id")), fstringvalidator.IsURN(), - fstringvalidator.PrefixContains(uuid.Catalog.String()), + fstringvalidator.PrefixContains(urn.Catalog.String()), }, }, }, @@ -111,7 +111,7 @@ func aclSchema(_ context.Context) superschema.Schema { Required: true, Validators: []validator.String{ fstringvalidator.IsURN(), - fstringvalidator.PrefixContains(uuid.User.String()), + fstringvalidator.PrefixContains(urn.User.String()), }, }, DataSource: &schemaD.StringAttribute{ diff --git a/internal/provider/catalog/catalog_vapp_template_datasource.go b/internal/provider/catalog/catalog_vapp_template_datasource.go index 7f8dfb61..60d81c8a 100644 --- a/internal/provider/catalog/catalog_vapp_template_datasource.go +++ b/internal/provider/catalog/catalog_vapp_template_datasource.go @@ -9,10 +9,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/adminorg" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var ( @@ -107,7 +107,7 @@ func (d *vAppTemplateDataSource) Read(ctx context.Context, req datasource.ReadRe // field ID in vAppTemplate attribute is always empty. ID exist in HREF attribute. // get last 36 characters of href // href ex : http://url.com/xx/xx/xx/vappTemplate-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - vappTemplateID := uuid.Normalize(uuid.VAPPTemplate, vAppTemplate.HREF[len(vAppTemplate.HREF)-36:]) + vappTemplateID := urn.Normalize(urn.VAPPTemplate, vAppTemplate.HREF[len(vAppTemplate.HREF)-36:]) stateUpdated.TemplateID.Set(vappTemplateID.String()) stateUpdated.ID.Set(vappTemplateID.String()) diff --git a/internal/provider/common/acl/acl.go b/internal/provider/common/acl/acl.go index 7e1840c9..0abafda3 100644 --- a/internal/provider/common/acl/acl.go +++ b/internal/provider/common/acl/acl.go @@ -18,8 +18,7 @@ import ( superschema "github.com/FrangipaneTeam/terraform-plugin-framework-superschema" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) type SharedWithModel struct { @@ -139,7 +138,7 @@ func SharedSetToAccessControl(_ *govcd.VCDClient, org *govcd.AdminOrg, input []S subjectName = user.User.Name oModel = &SharedWithModel{ - UserID: types.StringValue(uuid.Normalize(uuid.User, common.ExtractUUID(subjectHref)).String()), + UserID: types.StringValue(urn.Normalize(urn.User, urn.ExtractUUID(subjectHref)).String()), SubjectName: types.StringValue(subjectName), } } else if !item.GroupID.IsNull() && !item.GroupID.IsUnknown() { @@ -152,7 +151,7 @@ func SharedSetToAccessControl(_ *govcd.VCDClient, org *govcd.AdminOrg, input []S subjectType = group.Group.Type subjectName = group.Group.Name oModel = &SharedWithModel{ - GroupID: types.StringValue(uuid.Normalize(uuid.Group, common.ExtractUUID(subjectHref)).String()), + GroupID: types.StringValue(urn.Normalize(urn.Group, urn.ExtractUUID(subjectHref)).String()), SubjectName: types.StringValue(subjectName), } } @@ -183,9 +182,9 @@ func AccessControlListToSharedSet(input []*govcdtypes.AccessSetting) ([]SharedWi switch item.Subject.Type { case govcdtypes.MimeAdminUser: - o.UserID = types.StringValue(uuid.Normalize(uuid.User, common.ExtractUUID(item.Subject.HREF)).String()) + o.UserID = types.StringValue(urn.Normalize(urn.User, urn.ExtractUUID(item.Subject.HREF)).String()) case govcdtypes.MimeAdminGroup: - o.GroupID = types.StringValue(uuid.Normalize(uuid.Group, common.ExtractUUID(item.Subject.HREF)).String()) + o.GroupID = types.StringValue(urn.Normalize(urn.Group, urn.ExtractUUID(item.Subject.HREF)).String()) default: return nil, fmt.Errorf("unhandled type '%s' for item %s", item.Subject.Type, item.Subject.Name) } diff --git a/internal/provider/common/adminorg/vdc_group.go b/internal/provider/common/adminorg/vdc_group.go index 5c866ccf..4e131f13 100644 --- a/internal/provider/common/adminorg/vdc_group.go +++ b/internal/provider/common/adminorg/vdc_group.go @@ -3,12 +3,12 @@ package adminorg import ( "github.com/vmware/go-vcloud-director/v2/govcd" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) // GetVDCGroupByNameOrID returns the VDC group using the name or ID provided in the argument. func (ao *AdminOrg) GetVDCGroupByNameOrID(nameOrID string) (*govcd.VdcGroup, error) { - if uuid.IsVDCGroup(nameOrID) { + if urn.IsVDCGroup(nameOrID) { return ao.GetVdcGroupById(nameOrID) } return ao.GetVdcGroupByName(nameOrID) diff --git a/internal/provider/common/common.go b/internal/provider/common/common.go deleted file mode 100644 index e649e371..00000000 --- a/internal/provider/common/common.go +++ /dev/null @@ -1,16 +0,0 @@ -package common - -import ( - "regexp" -) - -// ExtractUUID finds an UUID in the input string -// Returns an empty string if no UUID was found. -func ExtractUUID(input string) string { - reGetID := regexp.MustCompile(`([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})`) - matchListIDs := reGetID.FindAllStringSubmatch(input, -1) - if len(matchListIDs) > 0 && len(matchListIDs[0]) > 0 { - return matchListIDs[len(matchListIDs)-1][len(matchListIDs[0])-1] - } - return "" -} diff --git a/internal/provider/common/edgegw/edgegw.go b/internal/provider/common/edgegw/edgegw.go index c99c5b6a..dd4f3d14 100644 --- a/internal/provider/common/edgegw/edgegw.go +++ b/internal/provider/common/edgegw/edgegw.go @@ -9,10 +9,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" sdkv1 "github.com/orange-cloudavenue/cloudavenue-sdk-go/v1" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/mutex" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var ErrEdgeGatewayIDOrNameIsEmpty = fmt.Errorf("edge gateway ID or name is empty") @@ -93,7 +93,7 @@ func (e EdgeGateway) GetSecurityGroupByNameOrID(nsxtFirewallGroupNameOrID string return nil, err } - if uuid.IsValid(nsxtFirewallGroupNameOrID) { + if urn.IsValid(nsxtFirewallGroupNameOrID) { return e.GetNsxtFirewallGroupById(nsxtFirewallGroupNameOrID) } @@ -124,7 +124,7 @@ func (e EdgeGateway) GetIPSetByNameOrID(nsxtFirewallGroupNameOrID string) (*govc return nil, err } - if uuid.IsValid(nsxtFirewallGroupNameOrID) { + if urn.IsValid(nsxtFirewallGroupNameOrID) { return e.GetIPSetByID(nsxtFirewallGroupNameOrID) } diff --git a/internal/provider/edgegw/app_port_profile_resource.go b/internal/provider/edgegw/app_port_profile_resource.go index 86408a6c..bc6685f8 100644 --- a/internal/provider/edgegw/app_port_profile_resource.go +++ b/internal/provider/edgegw/app_port_profile_resource.go @@ -16,11 +16,11 @@ import ( supertypes "github.com/FrangipaneTeam/terraform-plugin-framework-supertypes" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // NewAppPortProfileResource is a helper function to simplify the provider implementation. @@ -297,13 +297,13 @@ func (r *appPortProfileResource) ImportState(ctx context.Context, req resource.I EdgeGatewayName: supertypes.NewStringNull(), } - if uuid.IsEdgeGateway(edgeIDOrName) { + if urn.IsEdgeGateway(edgeIDOrName) { x.EdgeGatewayID.Set(edgeIDOrName) } else { x.EdgeGatewayName.Set(edgeIDOrName) } - if uuid.IsAppPortProfile(appPortProfileIDOrName) { + if urn.IsAppPortProfile(appPortProfileIDOrName) { x.ID.Set(appPortProfileIDOrName) } else { x.Name.Set(appPortProfileIDOrName) diff --git a/internal/provider/edgegw/dhcp_forwarding_resource.go b/internal/provider/edgegw/dhcp_forwarding_resource.go index 7366e7ce..f5fd4c3e 100644 --- a/internal/provider/edgegw/dhcp_forwarding_resource.go +++ b/internal/provider/edgegw/dhcp_forwarding_resource.go @@ -14,12 +14,12 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/mutex" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -275,7 +275,7 @@ func (r *dhcpForwardingResource) ImportState(ctx context.Context, req resource.I return } - if uuid.IsEdgeGateway(req.ID) { + if urn.IsEdgeGateway(req.ID) { edgegwID = req.ID } else { edgegwName = req.ID diff --git a/internal/provider/edgegw/edgegateway_datasource.go b/internal/provider/edgegw/edgegateway_datasource.go index 60e5b8ce..446f972b 100644 --- a/internal/provider/edgegw/edgegateway_datasource.go +++ b/internal/provider/edgegw/edgegateway_datasource.go @@ -7,9 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var ( @@ -74,7 +74,7 @@ func (d *edgeGatewayDataSource) Read(ctx context.Context, req datasource.ReadReq return } - data.ID.Set(uuid.Normalize(uuid.Gateway, edgegw.GetID()).String()) + data.ID.Set(urn.Normalize(urn.Gateway, edgegw.GetID()).String()) data.Tier0VrfID.Set(edgegw.GetTier0VrfID()) data.OwnerName.Set(edgegw.GetOwnerName()) data.OwnerType.Set(string(edgegw.GetOwnerType())) diff --git a/internal/provider/edgegw/edgegateway_resource.go b/internal/provider/edgegw/edgegateway_resource.go index 7a672145..b65acecf 100644 --- a/internal/provider/edgegw/edgegateway_resource.go +++ b/internal/provider/edgegw/edgegateway_resource.go @@ -17,12 +17,11 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" commoncloudavenue "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/common/cloudavenue" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" v1 "github.com/orange-cloudavenue/cloudavenue-sdk-go/v1" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/cloudavenue" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) const ( @@ -287,7 +286,7 @@ func (r *edgeGatewayResource) Create(ctx context.Context, req resource.CreateReq } } if !found { - plan.ID.Set(uuid.Normalize(uuid.Gateway, edgegw.GetID()).String()) + plan.ID.Set(urn.Normalize(urn.Gateway, edgegw.GetID()).String()) plan.Name.Set(edgegw.GetName()) edgegwNew = edgegw break @@ -394,7 +393,7 @@ func (r *edgeGatewayResource) Update(ctx context.Context, req resource.UpdateReq ctx, cancel = context.WithTimeout(ctx, updateTimeout) defer cancel() - edgegw, err := r.client.CAVSDK.V1.EdgeGateway.Get(common.ExtractUUID(plan.ID.Get())) + edgegw, err := r.client.CAVSDK.V1.EdgeGateway.Get(urn.ExtractUUID(plan.ID.Get())) if err != nil { resp.Diagnostics.AddError("Error retrieving edge gateway", err.Error()) return @@ -446,7 +445,7 @@ func (r *edgeGatewayResource) Delete(ctx context.Context, req resource.DeleteReq return } - edgegw, err := r.client.CAVSDK.V1.EdgeGateway.Get(common.ExtractUUID(state.ID.Get())) + edgegw, err := r.client.CAVSDK.V1.EdgeGateway.Get(urn.ExtractUUID(state.ID.Get())) if err != nil { if commoncloudavenue.IsNotFound(err) { resp.State.RemoveResource(ctx) @@ -494,7 +493,7 @@ func (r *edgeGatewayResource) read(_ context.Context, planOrState *edgeGatewayRe } if !planOrState.ID.IsKnown() { - stateRefreshed.ID.Set(uuid.Normalize(uuid.Gateway, edgegw.GetID()).String()) + stateRefreshed.ID.Set(urn.Normalize(urn.Gateway, edgegw.GetID()).String()) } stateRefreshed.Tier0VrfID.Set(edgegw.GetTier0VrfID()) diff --git a/internal/provider/edgegw/edgegateways_datasource.go b/internal/provider/edgegw/edgegateways_datasource.go index 7b0f5396..f0605e7e 100644 --- a/internal/provider/edgegw/edgegateways_datasource.go +++ b/internal/provider/edgegw/edgegateways_datasource.go @@ -7,10 +7,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var ( @@ -77,7 +77,7 @@ func (d *edgeGatewaysDataSource) Read(ctx context.Context, req datasource.ReadRe gws := make([]*edgeGatewayDataSourceModelEdgeGateway, 0) for _, edge := range *gateways { gw := new(edgeGatewayDataSourceModelEdgeGateway) - gw.ID.Set(uuid.Normalize(uuid.Gateway, edge.GetID()).String()) + gw.ID.Set(urn.Normalize(urn.Gateway, edge.GetID()).String()) gw.Name.Set(edge.GetName()) gw.Description.Set(edge.GetDescription()) gw.OwnerType.Set(string(edge.GetOwnerType())) diff --git a/internal/provider/edgegw/firewall_resource.go b/internal/provider/edgegw/firewall_resource.go index dbf00397..972ecdcd 100644 --- a/internal/provider/edgegw/firewall_resource.go +++ b/internal/provider/edgegw/firewall_resource.go @@ -15,12 +15,12 @@ import ( supertypes "github.com/FrangipaneTeam/terraform-plugin-framework-supertypes" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/mutex" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -272,8 +272,8 @@ func (r *firewallResource) ImportState(ctx context.Context, req resource.ImportS return } - if uuid.IsValid(req.ID) { - edgegwID = uuid.Normalize(uuid.Gateway, req.ID).String() + if urn.IsValid(req.ID) { + edgegwID = urn.Normalize(urn.Gateway, req.ID).String() } else { edgegwName = req.ID } diff --git a/internal/provider/edgegw/ip_set_resource.go b/internal/provider/edgegw/ip_set_resource.go index 19be6b62..5db05355 100644 --- a/internal/provider/edgegw/ip_set_resource.go +++ b/internal/provider/edgegw/ip_set_resource.go @@ -15,12 +15,12 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/mutex" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -347,7 +347,7 @@ func (r *ipSetResource) ImportState(ctx context.Context, req resource.ImportStat return } - if uuid.IsEdgeGateway(idParts[0]) { + if urn.IsEdgeGateway(idParts[0]) { edgegwID = idParts[0] } else { edgegwName = idParts[0] diff --git a/internal/provider/edgegw/nat_rule_resource.go b/internal/provider/edgegw/nat_rule_resource.go index 28c3c8a4..78626257 100644 --- a/internal/provider/edgegw/nat_rule_resource.go +++ b/internal/provider/edgegw/nat_rule_resource.go @@ -14,12 +14,12 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/mutex" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -337,7 +337,7 @@ func (r *natRuleResource) ImportState(ctx context.Context, req resource.ImportSt } // Get EdgeGW is ID or Name - if uuid.IsEdgeGateway(idParts[0]) { + if urn.IsEdgeGateway(idParts[0]) { edgegwID = idParts[0] } else { edgegwName = idParts[0] @@ -353,7 +353,7 @@ func (r *natRuleResource) ImportState(ctx context.Context, req resource.ImportSt } // Check if NATRule is ID or a Name - if uuid.IsUUIDV4(idParts[1]) { + if urn.IsUUIDV4(idParts[1]) { natRule, err = r.edgegw.GetNatRuleById(idParts[1]) if err != nil { resp.Diagnostics.AddError("Failed to Get NAT Rule.", err.Error()) diff --git a/internal/provider/edgegw/nat_rule_schema.go b/internal/provider/edgegw/nat_rule_schema.go index e71219eb..fd1b70f2 100644 --- a/internal/provider/edgegw/nat_rule_schema.go +++ b/internal/provider/edgegw/nat_rule_schema.go @@ -21,7 +21,7 @@ import ( superschema "github.com/FrangipaneTeam/terraform-plugin-framework-superschema" fstringvalidator "github.com/FrangipaneTeam/terraform-plugin-framework-validators/stringvalidator" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) func natRuleSchema(_ context.Context) superschema.Schema { @@ -185,7 +185,7 @@ func natRuleSchema(_ context.Context) superschema.Schema { Resource: &schemaR.StringAttribute{ Optional: true, Validators: []validator.String{ - fstringvalidator.PrefixContains(uuid.AppPortProfile.String()), + fstringvalidator.PrefixContains(urn.AppPortProfile.String()), fstringvalidator.NullIfAttributeIsOneOf(path.MatchRoot("rule_type"), []attr.Value{types.StringValue("SNAT"), types.StringValue("NO_SNAT"), types.StringValue("NO_DNAT"), types.StringValue("REFLEXIVE")}), }, }, diff --git a/internal/provider/edgegw/security_group_resource.go b/internal/provider/edgegw/security_group_resource.go index 44663c9f..1d6849df 100644 --- a/internal/provider/edgegw/security_group_resource.go +++ b/internal/provider/edgegw/security_group_resource.go @@ -15,13 +15,13 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/mutex" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -325,13 +325,13 @@ func (r *securityGroupResource) ImportState(ctx context.Context, req resource.Im return } - if uuid.IsEdgeGateway(idParts[0]) { + if urn.IsEdgeGateway(idParts[0]) { edgegwID = idParts[0] } else { edgegwName = idParts[0] } - if uuid.IsSecurityGroup(idParts[1]) { + if urn.IsSecurityGroup(idParts[1]) { id = idParts[1] } else { name = idParts[1] diff --git a/internal/provider/edgegw/static_route_resource.go b/internal/provider/edgegw/static_route_resource.go index c3b68f86..f1dbf104 100644 --- a/internal/provider/edgegw/static_route_resource.go +++ b/internal/provider/edgegw/static_route_resource.go @@ -14,13 +14,13 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/mutex" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -328,7 +328,7 @@ func (r *staticRouteResource) ImportState(ctx context.Context, req resource.Impo return } - if uuid.IsEdgeGateway(idParts[0]) { + if urn.IsEdgeGateway(idParts[0]) { edgegwID = idParts[0] } else { edgegwName = idParts[0] @@ -344,7 +344,7 @@ func (r *staticRouteResource) ImportState(ctx context.Context, req resource.Impo } // Static Route ID is not a URN - if uuid.IsUUIDV4(idParts[1]) { + if urn.IsUUIDV4(idParts[1]) { staticRoute, err = r.edgegw.GetStaticRouteById(idParts[1]) } else { staticRoute, err = r.edgegw.GetStaticRouteByName(idParts[1]) diff --git a/internal/provider/edgegw/vpn_ipsec_resource.go b/internal/provider/edgegw/vpn_ipsec_resource.go index 9ac55a2d..4842c268 100644 --- a/internal/provider/edgegw/vpn_ipsec_resource.go +++ b/internal/provider/edgegw/vpn_ipsec_resource.go @@ -16,12 +16,12 @@ import ( supertypes "github.com/FrangipaneTeam/terraform-plugin-framework-supertypes" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/mutex" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -380,7 +380,7 @@ func (r *vpnIPSecResource) ImportState(ctx context.Context, req resource.ImportS } // Get EdgeGW is ID or Name - if uuid.IsEdgeGateway(idParts[0]) { + if urn.IsEdgeGateway(idParts[0]) { edgegwID = idParts[0] } else { edgegwName = idParts[0] diff --git a/internal/provider/network/routed_resource.go b/internal/provider/network/routed_resource.go index 36f403b1..2c70569c 100644 --- a/internal/provider/network/routed_resource.go +++ b/internal/provider/network/routed_resource.go @@ -14,13 +14,13 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" sdkv1 "github.com/orange-cloudavenue/cloudavenue-sdk-go/v1" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/mutex" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -326,7 +326,7 @@ func (r *networkRoutedResource) ImportState(ctx context.Context, req resource.Im edgeGWName string edgeGWID string ) - if uuid.IsEdgeGateway(edgeGatewayNameOrEdgeGatewayID) { + if urn.IsEdgeGateway(edgeGatewayNameOrEdgeGatewayID) { edgeGWID = edgeGatewayNameOrEdgeGatewayID } else { edgeGWName = edgeGatewayNameOrEdgeGatewayID diff --git a/internal/provider/publicip/publicip_resource.go b/internal/provider/publicip/publicip_resource.go index ddca0aaf..61099750 100644 --- a/internal/provider/publicip/publicip_resource.go +++ b/internal/provider/publicip/publicip_resource.go @@ -13,12 +13,12 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/cloudavenue" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -321,7 +321,7 @@ func (r *publicIPResource) ImportState(ctx context.Context, req resource.ImportS } edgeGwNameOrID, publicIP := idSplit[0], fmt.Sprintf("%s.%s.%s.%s", idSplit[1], idSplit[2], idSplit[3], idSplit[4]) - if uuid.IsEdgeGateway(edgeGwNameOrID) { + if urn.IsEdgeGateway(edgeGwNameOrID) { resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("edge_gateway_id"), edgeGwNameOrID)...) } else { resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("edge_gateway_name"), edgeGwNameOrID)...) diff --git a/internal/provider/s3/user_datasource.go b/internal/provider/s3/user_datasource.go index c464ee08..2a89e79e 100644 --- a/internal/provider/s3/user_datasource.go +++ b/internal/provider/s3/user_datasource.go @@ -9,10 +9,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" v1 "github.com/orange-cloudavenue/cloudavenue-sdk-go/v1" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var ( @@ -97,8 +97,8 @@ func (d *UserDataSource) Read(ctx context.Context, req datasource.ReadRequest, r return } - config.ID.Set(uuid.Normalize( - uuid.User, + config.ID.Set(urn.Normalize( + urn.User, user.GetID()).String(), ) config.CanonicalID.Set(canonicalID) diff --git a/internal/provider/vapp/isolated_network_resource.go b/internal/provider/vapp/isolated_network_resource.go index 76410e18..2146a156 100644 --- a/internal/provider/vapp/isolated_network_resource.go +++ b/internal/provider/vapp/isolated_network_resource.go @@ -17,11 +17,11 @@ import ( supertypes "github.com/FrangipaneTeam/terraform-plugin-framework-supertypes" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vapp" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vdc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -296,7 +296,7 @@ func (r *isolatedNetworkResource) read(ctx context.Context, planOrState *isolate return } - planOrState.ID.Set(uuid.Normalize(uuid.Network, networkID).String()) + planOrState.ID.Set(urn.Normalize(urn.Network, networkID).String()) planOrState.Name.Set(net.NetworkName) planOrState.VDC.Set(r.vdc.GetName()) planOrState.VAppName.Set(r.vapp.GetName()) diff --git a/internal/provider/vapp/org_network_datasource.go b/internal/provider/vapp/org_network_datasource.go index 609ede6b..30d8ecdf 100644 --- a/internal/provider/vapp/org_network_datasource.go +++ b/internal/provider/vapp/org_network_datasource.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/network" @@ -19,7 +20,6 @@ import ( "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vapp" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vdc" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var ( @@ -123,7 +123,7 @@ func (d *orgNetworkDataSource) Read(ctx context.Context, req datasource.ReadRequ // Set data plan := &orgNetworkModel{ - ID: types.StringValue(uuid.Normalize(uuid.Network, *networkID).String()), + ID: types.StringValue(urn.Normalize(urn.Network, *networkID).String()), VAppName: utils.StringValueOrNull(d.vapp.GetName()), VAppID: utils.StringValueOrNull(d.vapp.GetID()), VDC: types.StringValue(d.vdc.GetName()), diff --git a/internal/provider/vapp/org_network_resource.go b/internal/provider/vapp/org_network_resource.go index 3128afae..d6097242 100644 --- a/internal/provider/vapp/org_network_resource.go +++ b/internal/provider/vapp/org_network_resource.go @@ -16,13 +16,13 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/network" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vapp" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vdc" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -147,7 +147,7 @@ func (r *orgNetworkResource) Create(ctx context.Context, req resource.CreateRequ } state := &orgNetworkModel{ - ID: types.StringValue(uuid.Normalize(uuid.Network, networkID).String()), + ID: types.StringValue(urn.Normalize(urn.Network, networkID).String()), VAppName: plan.VAppName, VAppID: plan.VAppID, VDC: types.StringValue(r.vdc.GetName()), @@ -202,7 +202,7 @@ func (r *orgNetworkResource) Read(ctx context.Context, req resource.ReadRequest, } plan := &orgNetworkModel{ - ID: types.StringValue(uuid.Normalize(uuid.Network, *networkID).String()), + ID: types.StringValue(urn.Normalize(urn.Network, *networkID).String()), VAppName: state.VAppName, VAppID: state.VAppID, VDC: types.StringValue(r.vdc.GetName()), diff --git a/internal/provider/vcda/vcda_ip_resource.go b/internal/provider/vcda/vcda_ip_resource.go index b2ecb2c5..8d62f6c2 100644 --- a/internal/provider/vcda/vcda_ip_resource.go +++ b/internal/provider/vcda/vcda_ip_resource.go @@ -11,12 +11,12 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" v1 "github.com/orange-cloudavenue/cloudavenue-sdk-go/v1" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/cloudavenue" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -172,8 +172,8 @@ func (r *vcdaIPResource) Delete(ctx context.Context, req resource.DeleteRequest, func (r *vcdaIPResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("ip_address"), req.ID)...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), types.StringValue(uuid.Normalize( - uuid.VCDA, + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), types.StringValue(urn.Normalize( + urn.VCDA, utils.GenerateUUID( req.ID, ).ValueString(), @@ -194,8 +194,8 @@ func (r *vcdaIPResource) read(_ context.Context, planOrState *vcdaIPResourceMode return nil, false, diags } - stateRefreshed.ID.Set(uuid.Normalize( - uuid.VCDA, + stateRefreshed.ID.Set(urn.Normalize( + urn.VCDA, utils.GenerateUUID(planOrState.IPAddress.Get()).ValueString(), ).String()) diff --git a/internal/provider/vm/vm_affinity_rule_resource.go b/internal/provider/vm/vm_affinity_rule_resource.go index 0d43a986..d62984fb 100644 --- a/internal/provider/vm/vm_affinity_rule_resource.go +++ b/internal/provider/vm/vm_affinity_rule_resource.go @@ -18,11 +18,10 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vdc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -368,9 +367,9 @@ func resourceToAffinityRule(r *vmAffinityRuleResource, m *vmAffinityRuleResource for _, vmID := range rawVms.Elements() { for _, vm := range fullVMList { - uuid := common.ExtractUUID(vmID.String()) + uuid := urn.ExtractUUID(vmID.String()) if uuid != "" { - if uuid == common.ExtractUUID(vm.HREF) { + if uuid == urn.ExtractUUID(vm.HREF) { vmReferences = append(vmReferences, &govcdtypes.Reference{HREF: vm.HREF}) foundEntries[vmID.String()] = true } @@ -434,7 +433,7 @@ func vmReferencesToListValue(refs []*govcdtypes.VMs) []attr.Value { var endpointVMs []attr.Value for _, vmr := range refs { for _, ref := range vmr.VMReference { - endpointVMs = append(endpointVMs, types.StringValue(uuid.Normalize(uuid.VM, ref.ID).String())) + endpointVMs = append(endpointVMs, types.StringValue(urn.Normalize(urn.VM, ref.ID).String())) } } return endpointVMs diff --git a/internal/provider/vm/vm_disk_resource.go b/internal/provider/vm/vm_disk_resource.go index ae5fcaae..ad00a835 100644 --- a/internal/provider/vm/vm_disk_resource.go +++ b/internal/provider/vm/vm_disk_resource.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" @@ -24,7 +25,6 @@ import ( "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vm" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vm/diskparams" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -768,21 +768,21 @@ func (r *diskResource) ImportState(ctx context.Context, req resource.ImportState switch len(idParts) { // Case 2 : vAppIDOrName.DiskID case 2: - if uuid.IsVAPP(idParts[0]) { + if urn.IsVAPP(idParts[0]) { vAppID = idParts[0] } else { vAppName = idParts[0] } diskID = idParts[1] - if uuid.IsDisk(idParts[1]) { + if urn.IsDisk(idParts[1]) { isDetachable = true } // Case 3 : vAppIDOrName.VmIDOrName.DiskID or vdcName.vAppIDOrName.DiskID case 3: diskID = idParts[2] - if uuid.IsDisk(diskID) { + if urn.IsDisk(diskID) { isDetachable = true } @@ -791,7 +791,7 @@ func (r *diskResource) ImportState(ctx context.Context, req resource.ImportState if !diags.HasError() { // FORMAT : vdcName.vAppIDOrName.DiskID vdcName = idParts[0] - if uuid.IsVAPP(idParts[1]) { + if urn.IsVAPP(idParts[1]) { vAppID = idParts[1] } else { vAppName = idParts[1] @@ -801,13 +801,13 @@ func (r *diskResource) ImportState(ctx context.Context, req resource.ImportState } // FORMAT : vAppIDOrName.VmIDOrName.DiskID - if uuid.IsVAPP(idParts[0]) { + if urn.IsVAPP(idParts[0]) { vAppID = idParts[0] } else { vAppName = idParts[0] } - if uuid.IsVM(idParts[1]) { + if urn.IsVM(idParts[1]) { vmID = idParts[1] } else { vmName = idParts[1] @@ -816,20 +816,20 @@ func (r *diskResource) ImportState(ctx context.Context, req resource.ImportState // Case 4 : vdcName.vAppIDOrName.VmIDOrName.DiskID case 4: vdcName = idParts[0] - if uuid.IsVAPP(idParts[1]) { + if urn.IsVAPP(idParts[1]) { vAppID = idParts[1] } else { vAppName = idParts[1] } - if uuid.IsVM(idParts[2]) { + if urn.IsVM(idParts[2]) { vmID = idParts[2] } else { vmName = idParts[2] } diskID = idParts[3] - if uuid.IsDisk(diskID) { + if urn.IsDisk(diskID) { isDetachable = true } default: diff --git a/internal/provider/vm/vm_disk_schema.go b/internal/provider/vm/vm_disk_schema.go index 10409123..a5b5b08c 100644 --- a/internal/provider/vm/vm_disk_schema.go +++ b/internal/provider/vm/vm_disk_schema.go @@ -23,10 +23,10 @@ import ( superschema "github.com/FrangipaneTeam/terraform-plugin-framework-superschema" fstringvalidator "github.com/FrangipaneTeam/terraform-plugin-framework-validators/stringvalidator" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vapp" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vdc" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vm/diskparams" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // DiskSuperSchema returns the super schema. @@ -72,7 +72,7 @@ func DiskSuperSchema() superschema.Schema { }, Validators: []validator.String{ fstringvalidator.IsURN(), - fstringvalidator.PrefixContains(uuid.VM.String()), + fstringvalidator.PrefixContains(urn.VM.String()), }, }, }, diff --git a/internal/provider/vm/vm_disks_datasource.go b/internal/provider/vm/vm_disks_datasource.go index 587141ba..10b7bef4 100644 --- a/internal/provider/vm/vm_disks_datasource.go +++ b/internal/provider/vm/vm_disks_datasource.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" @@ -18,7 +19,6 @@ import ( "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vdc" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vm" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var ( @@ -119,7 +119,7 @@ func (d *disksDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp.Diagnostics.AddError("Unable to get disk ID", err.Error()) return } - dDisk.ID.Set(uuid.Normalize(uuid.Disk, id).String()) + dDisk.ID.Set(urn.Normalize(urn.Disk, id).String()) dDisk.Name.Set(disk.Name) dDisk.SizeInMb.Set(disk.SizeMb) dDisk.StorageProfile.Set(disk.StorageProfileName) diff --git a/internal/provider/vm/vm_disks_schema.go b/internal/provider/vm/vm_disks_schema.go index 92603676..2ddca617 100644 --- a/internal/provider/vm/vm_disks_schema.go +++ b/internal/provider/vm/vm_disks_schema.go @@ -13,7 +13,7 @@ import ( superschema "github.com/FrangipaneTeam/terraform-plugin-framework-superschema" fstringvalidator "github.com/FrangipaneTeam/terraform-plugin-framework-validators/stringvalidator" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) func disksSchema(_ context.Context) superschema.Schema { @@ -41,7 +41,7 @@ func disksSchema(_ context.Context) superschema.Schema { Validators: []validator.String{ stringvalidator.ExactlyOneOf(path.MatchRoot("vapp_name"), path.MatchRoot("vapp_id")), fstringvalidator.IsURN(), - fstringvalidator.PrefixContains(uuid.VAPP.String()), + fstringvalidator.PrefixContains(urn.VAPP.String()), }, }, }, @@ -59,7 +59,7 @@ func disksSchema(_ context.Context) superschema.Schema { Validators: []validator.String{ stringvalidator.ExactlyOneOf(path.MatchRoot("vm_name"), path.MatchRoot("vm_id")), fstringvalidator.IsURN(), - fstringvalidator.PrefixContains(uuid.VM.String()), + fstringvalidator.PrefixContains(urn.VM.String()), }, }, }, diff --git a/internal/provider/vm/vm_resource.go b/internal/provider/vm/vm_resource.go index 65e629a3..717c71a9 100644 --- a/internal/provider/vm/vm_resource.go +++ b/internal/provider/vm/vm_resource.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/adminvdc" @@ -22,7 +23,6 @@ import ( "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vdc" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/vm" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Ensure the implementation satisfies the expected interfaces. @@ -830,7 +830,7 @@ func (r *vmResource) ImportState(ctx context.Context, req resource.ImportStateRe id = idParts[1] } - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), uuid.Normalize(uuid.VM, id).String())...) + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), urn.Normalize(urn.VM, id).String())...) } func (r *vmResource) createVMWithTemplate(ctx context.Context, rm vm.VMResourceModel) (vmCreated vm.VM, diags diag.Diagnostics) { diff --git a/internal/testsacc/alb_pool_datasource_test.go b/internal/testsacc/alb_pool_datasource_test.go index 7b4e696d..f9c3066a 100644 --- a/internal/testsacc/alb_pool_datasource_test.go +++ b/internal/testsacc/alb_pool_datasource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccAlbPoolDataSourceConfig = ` @@ -53,7 +53,7 @@ func TestAccAlbPoolDataSource(t *testing.T) { // Apply test Config: testAccAlbPoolDataSourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.LoadBalancerPool)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.LoadBalancerPool)), resource.TestCheckResourceAttrPair(dataSourceName, "name", resourceName, "name"), resource.TestCheckResourceAttrPair(dataSourceName, "persistence_profile.#", resourceName, "persistence_profile.#"), resource.TestCheckResourceAttrPair(dataSourceName, "members.#", resourceName, "members.#"), diff --git a/internal/testsacc/alb_pool_resource_test.go b/internal/testsacc/alb_pool_resource_test.go index b246317e..fd87f3f1 100644 --- a/internal/testsacc/alb_pool_resource_test.go +++ b/internal/testsacc/alb_pool_resource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccAlbPoolResourceConfig = ` @@ -54,7 +54,7 @@ func TestAccAlbPoolResource(t *testing.T) { // Apply test Config: testAccAlbPoolResourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.LoadBalancerPool)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.LoadBalancerPool)), resource.TestCheckResourceAttr(resourceName, "name", "Example"), resource.TestCheckResourceAttr(resourceName, "persistence_profile.type", "CLIENT_IP"), ), @@ -63,7 +63,7 @@ func TestAccAlbPoolResource(t *testing.T) { // Update test Config: testAccAlbPoolResourceConfigUpdate, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.LoadBalancerPool)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.LoadBalancerPool)), resource.TestCheckResourceAttr(resourceName, "name", "Example"), resource.TestCheckNoResourceAttr(resourceName, "persistence_profile"), resource.TestCheckNoResourceAttr(resourceName, "members"), diff --git a/internal/testsacc/catalog_acl_resource_test.go b/internal/testsacc/catalog_acl_resource_test.go index f131d9cd..6b5c8f1c 100644 --- a/internal/testsacc/catalog_acl_resource_test.go +++ b/internal/testsacc/catalog_acl_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &CatalogACLResource{} @@ -42,8 +42,8 @@ func (r *CatalogACLResource) Tests(ctx context.Context) map[testsacc.TestName]fu CommonChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttrSet(resourceName, "catalog_name"), - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Catalog)), - resource.TestCheckResourceAttrWith(resourceName, "catalog_id", uuid.TestIsType(uuid.Catalog)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Catalog)), + resource.TestCheckResourceAttrWith(resourceName, "catalog_id", urn.TestIsType(urn.Catalog)), }, // ! Create testing Create: testsacc.TFConfig{ @@ -98,8 +98,8 @@ func (r *CatalogACLResource) Tests(ctx context.Context) map[testsacc.TestName]fu resource.TestCheckResourceAttr(resourceName, "shared_with_everyone", "false"), resource.TestCheckResourceAttr(resourceName, "shared_with_users.#", "2"), - resource.TestCheckResourceAttrWith(resourceName, "shared_with_users.0.user_id", uuid.TestIsType(uuid.User)), - resource.TestCheckResourceAttrWith(resourceName, "shared_with_users.1.user_id", uuid.TestIsType(uuid.User)), + resource.TestCheckResourceAttrWith(resourceName, "shared_with_users.0.user_id", urn.TestIsType(urn.User)), + resource.TestCheckResourceAttrWith(resourceName, "shared_with_users.1.user_id", urn.TestIsType(urn.User)), // shared_with_users it's a SetNestedAttribute, so we can't be sure of the order of the elements in the list is not possible to test each attribute }, }, diff --git a/internal/testsacc/catalog_resource_test.go b/internal/testsacc/catalog_resource_test.go index 05a60931..ff730fdd 100644 --- a/internal/testsacc/catalog_resource_test.go +++ b/internal/testsacc/catalog_resource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &CatalogResource{} @@ -38,7 +38,7 @@ func (r *CatalogResource) Tests(ctx context.Context) map[testsacc.TestName]func( "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Catalog)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Catalog)), resource.TestCheckResourceAttr(resourceName, "delete_recursive", "true"), resource.TestCheckResourceAttr(resourceName, "delete_force", "true"), resource.TestCheckResourceAttrSet(resourceName, "owner_name"), diff --git a/internal/testsacc/catalog_vapp_template_datasource_test.go b/internal/testsacc/catalog_vapp_template_datasource_test.go index abcc99c6..67c31567 100644 --- a/internal/testsacc/catalog_vapp_template_datasource_test.go +++ b/internal/testsacc/catalog_vapp_template_datasource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &CatalogVAppTemplateDataSource{} @@ -45,13 +45,13 @@ func (r *CatalogVAppTemplateDataSource) Tests(ctx context.Context) map[testsacc. template_name = "UBUNTU_20.04" }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VAPPTemplate)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VAPPTemplate)), // Catalog resource.TestCheckResourceAttr(resourceName, "catalog_name", "Orange-Linux"), - resource.TestCheckResourceAttrWith(resourceName, "catalog_id", uuid.TestIsType(uuid.Catalog)), + resource.TestCheckResourceAttrWith(resourceName, "catalog_id", urn.TestIsType(urn.Catalog)), resource.TestCheckResourceAttr(resourceName, "template_name", "UBUNTU_20.04"), - resource.TestCheckResourceAttrWith(resourceName, "template_id", uuid.TestIsType(uuid.VAPPTemplate)), + resource.TestCheckResourceAttrWith(resourceName, "template_id", urn.TestIsType(urn.VAPPTemplate)), // Other resource.TestCheckResourceAttrSet(resourceName, "created_at"), resource.TestCheckResourceAttrSet(resourceName, "vm_names.#"), diff --git a/internal/testsacc/catalogs_datasource_test.go b/internal/testsacc/catalogs_datasource_test.go index d208fdb3..27ca0ef9 100644 --- a/internal/testsacc/catalogs_datasource_test.go +++ b/internal/testsacc/catalogs_datasource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &CatalogsDataSource{} @@ -45,7 +45,7 @@ func (r *CatalogsDataSource) Tests(ctx context.Context) map[testsacc.TestName]fu resource.TestCheckResourceAttrSet(resourceName, "catalogs_name.#"), resource.TestCheckResourceAttrSet(resourceName, "catalogs.%"), - resource.TestCheckResourceAttrWith(resourceName, "catalogs.Orange-Linux.id", uuid.TestIsType(uuid.Catalog)), + resource.TestCheckResourceAttrWith(resourceName, "catalogs.Orange-Linux.id", urn.TestIsType(urn.Catalog)), resource.TestCheckResourceAttrSet(resourceName, "catalogs.Orange-Linux.name"), resource.TestCheckResourceAttrSet(resourceName, "catalogs.Orange-Linux.created_at"), resource.TestCheckResourceAttrSet(resourceName, "catalogs.Orange-Linux.preserve_identity_information"), diff --git a/internal/testsacc/edgegw_app_port_profile_datasource_test.go b/internal/testsacc/edgegw_app_port_profile_datasource_test.go index 2046b877..c3d6da0e 100644 --- a/internal/testsacc/edgegw_app_port_profile_datasource_test.go +++ b/internal/testsacc/edgegw_app_port_profile_datasource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &EdgeGatewayAppPortProfileDatasource{} @@ -86,7 +86,7 @@ func (r *EdgeGatewayAppPortProfileDatasource) Tests(ctx context.Context) map[tes name = "BKP_TCP_bpcd" }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.AppPortProfile)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.AppPortProfile)), resource.TestCheckResourceAttr(resourceName, "name", "BKP_TCP_bpcd"), resource.TestCheckResourceAttr(resourceName, "app_ports.0.protocol", "TCP"), resource.TestCheckResourceAttr(resourceName, "app_ports.0.ports.0", "13782"), @@ -109,7 +109,7 @@ func (r *EdgeGatewayAppPortProfileDatasource) Tests(ctx context.Context) map[tes name = "HTTP" }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.AppPortProfile)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.AppPortProfile)), resource.TestCheckResourceAttr(resourceName, "name", "HTTP"), resource.TestCheckResourceAttr(resourceName, "description", "HTTP"), resource.TestCheckResourceAttr(resourceName, "app_ports.0.protocol", "TCP"), @@ -132,7 +132,7 @@ func (r *EdgeGatewayAppPortProfileDatasource) Tests(ctx context.Context) map[tes name = "Heartbeat" }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.AppPortProfile)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.AppPortProfile)), resource.TestCheckResourceAttr(resourceName, "name", "Heartbeat"), resource.TestCheckResourceAttr(resourceName, "description", "Heartbeat"), resource.TestCheckResourceAttr(resourceName, "app_ports.#", "2"), diff --git a/internal/testsacc/edgegw_app_port_profile_resource_test.go b/internal/testsacc/edgegw_app_port_profile_resource_test.go index 2b70b006..422e2b5a 100644 --- a/internal/testsacc/edgegw_app_port_profile_resource_test.go +++ b/internal/testsacc/edgegw_app_port_profile_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &EdgeGatewayAppPortProfileResource{} @@ -37,7 +37,7 @@ func (r *EdgeGatewayAppPortProfileResource) Tests(ctx context.Context) map[tests "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.AppPortProfile)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.AppPortProfile)), }, // ! Create testing Create: testsacc.TFConfig{ @@ -53,7 +53,7 @@ func (r *EdgeGatewayAppPortProfileResource) Tests(ctx context.Context) map[tests ] }`), Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.AppPortProfile)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.AppPortProfile)), resource.TestCheckResourceAttr(resourceName, "name", testsacc.GetValueFromTemplate(resourceName, "name")), resource.TestCheckResourceAttr(resourceName, "description", testsacc.GetValueFromTemplate(resourceName, "description")), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "app_ports.*", map[string]string{ @@ -90,7 +90,7 @@ func (r *EdgeGatewayAppPortProfileResource) Tests(ctx context.Context) map[tests ] }`), Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.AppPortProfile)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.AppPortProfile)), resource.TestCheckResourceAttr(resourceName, "name", testsacc.GetValueFromTemplate(resourceName, "name")), resource.TestCheckResourceAttr(resourceName, "description", testsacc.GetValueFromTemplate(resourceName, "description")), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "app_ports.*", map[string]string{ diff --git a/internal/testsacc/edgegw_dhcp_forwarding_resource_test.go b/internal/testsacc/edgegw_dhcp_forwarding_resource_test.go index 2bc765c2..137938e3 100644 --- a/internal/testsacc/edgegw_dhcp_forwarding_resource_test.go +++ b/internal/testsacc/edgegw_dhcp_forwarding_resource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &EdgeGatewayDhcpForwardingResource{} @@ -38,8 +38,8 @@ func (r *EdgeGatewayDhcpForwardingResource) Tests(ctx context.Context) map[tests return testsacc.Test{ // ! Create testing CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Gateway)), - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttrSet(resourceName, "edge_gateway_name"), }, CommonDependencies: func() (resp testsacc.DependenciesConfigResponse) { @@ -118,8 +118,8 @@ func (r *EdgeGatewayDhcpForwardingResource) Tests(ctx context.Context) map[tests // return testsacc.Test{ // // ! Create testing // CommonChecks: []resource.TestCheckFunc{ - // resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Gateway)), - // resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + // resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Gateway)), + // resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), // resource.TestCheckResourceAttrSet(resourceName, "edge_gateway_name"), // }, // CommonDependencies: func() (resp testsacc.DependenciesConfigResponse) { diff --git a/internal/testsacc/edgegw_edgegateway_resource_test.go b/internal/testsacc/edgegw_edgegateway_resource_test.go index 31e4702e..e7bb2192 100644 --- a/internal/testsacc/edgegw_edgegateway_resource_test.go +++ b/internal/testsacc/edgegw_edgegateway_resource_test.go @@ -9,9 +9,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/edgegw" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) const testAccEdgeGatewayResourceConfig = ` @@ -66,7 +66,7 @@ func (r *EdgeGatewayResource) Tests(ctx context.Context) map[testsacc.TestName]f resource.TestCheckResourceAttr(resourceName, "owner_type", "vdc"), // Read-Only attributes - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Gateway)), resource.TestMatchResourceAttr(resourceName, "tier0_vrf_name", regexp.MustCompile(regexpTier0VRFName)), resource.TestCheckResourceAttrSet(resourceName, "name"), resource.TestCheckResourceAttrSet(resourceName, "description"), @@ -151,7 +151,7 @@ func (r *EdgeGatewayResource) Tests(ctx context.Context) map[testsacc.TestName]f resource.TestCheckResourceAttr(resourceName, "owner_type", "vdc-group"), // Read-Only attributes - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Gateway)), resource.TestMatchResourceAttr(resourceName, "tier0_vrf_name", regexp.MustCompile(regexpTier0VRFName)), resource.TestCheckResourceAttrSet(resourceName, "description"), }, diff --git a/internal/testsacc/edgegw_edgegateways_datasource_test.go b/internal/testsacc/edgegw_edgegateways_datasource_test.go index 960658de..a6878571 100644 --- a/internal/testsacc/edgegw_edgegateways_datasource_test.go +++ b/internal/testsacc/edgegw_edgegateways_datasource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &EdgeGatewaysDataSource{} @@ -43,7 +43,7 @@ func (r *EdgeGatewaysDataSource) Tests(ctx context.Context) map[testsacc.TestNam data "cloudavenue_edgegateways" "example" {}`, Checks: []resource.TestCheckFunc{ resource.TestCheckResourceAttrSet(resourceName, "id"), - resource.TestCheckResourceAttrWith(resourceName, "edge_gateways.0.id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateways.0.id", urn.TestIsType(urn.Gateway)), }, }, } diff --git a/internal/testsacc/edgegw_firewall_resource_test.go b/internal/testsacc/edgegw_firewall_resource_test.go index 98177b6d..2f139eb8 100644 --- a/internal/testsacc/edgegw_firewall_resource_test.go +++ b/internal/testsacc/edgegw_firewall_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &EdgeGatewayFirewallResource{} @@ -37,7 +37,7 @@ func (r *EdgeGatewayFirewallResource) Tests(ctx context.Context) map[testsacc.Te "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Gateway)), }, // ! Create testing Create: testsacc.TFConfig{ @@ -108,7 +108,7 @@ func (r *EdgeGatewayFirewallResource) Tests(ctx context.Context) map[testsacc.Te "example_with_ids": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Gateway)), }, // ! Create testing Create: testsacc.TFConfig{ @@ -141,7 +141,7 @@ func (r *EdgeGatewayFirewallResource) Tests(ctx context.Context) map[testsacc.Te }] }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttr(resourceName, "rules.#", "3"), resource.TestCheckResourceAttr(resourceName, "rules.0.action", "ALLOW"), @@ -154,7 +154,7 @@ func (r *EdgeGatewayFirewallResource) Tests(ctx context.Context) map[testsacc.Te resource.TestCheckResourceAttr(resourceName, "rules.1.direction", "IN"), resource.TestCheckResourceAttr(resourceName, "rules.1.ip_protocol", "IPV4"), resource.TestCheckResourceAttr(resourceName, "rules.1.destination_ids.#", "1"), - resource.TestCheckResourceAttrWith(resourceName, "rules.1.destination_ids.0", uuid.TestIsType(uuid.SecurityGroup)), + resource.TestCheckResourceAttrWith(resourceName, "rules.1.destination_ids.0", urn.TestIsType(urn.SecurityGroup)), resource.TestCheckResourceAttr(resourceName, "rules.1.app_port_profile_ids.#", "1"), resource.TestCheckResourceAttr(resourceName, "rules.1.app_port_profile_ids.0", "urn:vcloud:applicationPortProfile:4d8cc407-fe83-3a9f-af20-95dfe3a1e9a2"), @@ -163,7 +163,7 @@ func (r *EdgeGatewayFirewallResource) Tests(ctx context.Context) map[testsacc.Te resource.TestCheckResourceAttr(resourceName, "rules.2.direction", "IN"), resource.TestCheckResourceAttr(resourceName, "rules.2.ip_protocol", "IPV4"), resource.TestCheckResourceAttr(resourceName, "rules.2.destination_ids.#", "1"), - resource.TestCheckResourceAttrWith(resourceName, "rules.2.destination_ids.0", uuid.TestIsType(uuid.SecurityGroup)), + resource.TestCheckResourceAttrWith(resourceName, "rules.2.destination_ids.0", urn.TestIsType(urn.SecurityGroup)), resource.TestCheckResourceAttr(resourceName, "rules.2.app_port_profile_ids.#", "1"), resource.TestCheckResourceAttr(resourceName, "rules.2.app_port_profile_ids.0", "urn:vcloud:applicationPortProfile:9c8049b5-9820-36f9-b90c-ab8f462df3c6"), }, @@ -209,7 +209,7 @@ func (r *EdgeGatewayFirewallResource) Tests(ctx context.Context) map[testsacc.Te }] }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttr(resourceName, "rules.#", "4"), resource.TestCheckResourceAttr(resourceName, "rules.0.action", "ALLOW"), @@ -222,7 +222,7 @@ func (r *EdgeGatewayFirewallResource) Tests(ctx context.Context) map[testsacc.Te resource.TestCheckResourceAttr(resourceName, "rules.1.direction", "IN"), resource.TestCheckResourceAttr(resourceName, "rules.1.ip_protocol", "IPV4"), resource.TestCheckResourceAttr(resourceName, "rules.1.destination_ids.#", "1"), - resource.TestCheckResourceAttrWith(resourceName, "rules.1.destination_ids.0", uuid.TestIsType(uuid.SecurityGroup)), + resource.TestCheckResourceAttrWith(resourceName, "rules.1.destination_ids.0", urn.TestIsType(urn.SecurityGroup)), resource.TestCheckResourceAttr(resourceName, "rules.1.app_port_profile_ids.#", "1"), resource.TestCheckResourceAttr(resourceName, "rules.1.app_port_profile_ids.0", "urn:vcloud:applicationPortProfile:4d8cc407-fe83-3a9f-af20-95dfe3a1e9a2"), @@ -231,7 +231,7 @@ func (r *EdgeGatewayFirewallResource) Tests(ctx context.Context) map[testsacc.Te resource.TestCheckResourceAttr(resourceName, "rules.2.direction", "IN"), resource.TestCheckResourceAttr(resourceName, "rules.2.ip_protocol", "IPV4"), resource.TestCheckResourceAttr(resourceName, "rules.2.destination_ids.#", "1"), - resource.TestCheckResourceAttrWith(resourceName, "rules.2.destination_ids.0", uuid.TestIsType(uuid.SecurityGroup)), + resource.TestCheckResourceAttrWith(resourceName, "rules.2.destination_ids.0", urn.TestIsType(urn.SecurityGroup)), resource.TestCheckResourceAttr(resourceName, "rules.2.app_port_profile_ids.#", "1"), resource.TestCheckResourceAttr(resourceName, "rules.2.app_port_profile_ids.0", "urn:vcloud:applicationPortProfile:9c8049b5-9820-36f9-b90c-ab8f462df3c6"), @@ -240,9 +240,9 @@ func (r *EdgeGatewayFirewallResource) Tests(ctx context.Context) map[testsacc.Te resource.TestCheckResourceAttr(resourceName, "rules.3.direction", "IN_OUT"), resource.TestCheckResourceAttr(resourceName, "rules.3.ip_protocol", "IPV4"), resource.TestCheckResourceAttr(resourceName, "rules.3.source_ids.#", "1"), - resource.TestCheckResourceAttrWith(resourceName, "rules.3.source_ids.0", uuid.TestIsType(uuid.SecurityGroup)), + resource.TestCheckResourceAttrWith(resourceName, "rules.3.source_ids.0", urn.TestIsType(urn.SecurityGroup)), resource.TestCheckResourceAttr(resourceName, "rules.3.destination_ids.#", "1"), - resource.TestCheckResourceAttrWith(resourceName, "rules.3.destination_ids.0", uuid.TestIsType(uuid.SecurityGroup)), + resource.TestCheckResourceAttrWith(resourceName, "rules.3.destination_ids.0", urn.TestIsType(urn.SecurityGroup)), }, }, }, diff --git a/internal/testsacc/edgegw_nat_rule_resource_test.go b/internal/testsacc/edgegw_nat_rule_resource_test.go index 4ffaad91..4e24bcc9 100644 --- a/internal/testsacc/edgegw_nat_rule_resource_test.go +++ b/internal/testsacc/edgegw_nat_rule_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &NATRuleResource{} @@ -36,7 +36,7 @@ func (r *NATRuleResource) Tests(ctx context.Context) map[testsacc.TestName]func( "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttrSet(resourceName, "id"), }, // ! Create testing @@ -126,7 +126,7 @@ func (r *NATRuleResource) Tests(ctx context.Context) map[testsacc.TestName]func( return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttrSet(resourceName, "id"), - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttr(resourceName, "rule_type", "NO_SNAT"), }, // ! Create testing @@ -157,7 +157,7 @@ func (r *NATRuleResource) Tests(ctx context.Context) map[testsacc.TestName]func( return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttrSet(resourceName, "id"), - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttr(resourceName, "rule_type", "DNAT"), }, // ! Create testing @@ -220,7 +220,7 @@ func (r *NATRuleResource) Tests(ctx context.Context) map[testsacc.TestName]func( return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttrSet(resourceName, "id"), - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttr(resourceName, "rule_type", "DNAT"), }, CommonDependencies: func() (resp testsacc.DependenciesConfigResponse) { @@ -315,7 +315,7 @@ func (r *NATRuleResource) Tests(ctx context.Context) map[testsacc.TestName]func( return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ resource.TestCheckResourceAttrSet(resourceName, "id"), - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttr(resourceName, "rule_type", "DNAT"), }, CommonDependencies: func() (resp testsacc.DependenciesConfigResponse) { diff --git a/internal/testsacc/edgegw_security_group_resource_test.go b/internal/testsacc/edgegw_security_group_resource_test.go index 246c047b..2fa14ce0 100644 --- a/internal/testsacc/edgegw_security_group_resource_test.go +++ b/internal/testsacc/edgegw_security_group_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &EdgeGatewaySecurityGroupResource{} @@ -37,7 +37,7 @@ func (r *EdgeGatewaySecurityGroupResource) Tests(ctx context.Context) map[testsa "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.SecurityGroup)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.SecurityGroup)), resource.TestCheckResourceAttr(resourceName, "member_org_network_ids.#", "1"), resource.TestCheckResourceAttrSet(resourceName, "edge_gateway_id"), }, diff --git a/internal/testsacc/edgegw_static_route_resource_test.go b/internal/testsacc/edgegw_static_route_resource_test.go index 0cd327bb..e4a4c564 100644 --- a/internal/testsacc/edgegw_static_route_resource_test.go +++ b/internal/testsacc/edgegw_static_route_resource_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccStaticRouteResourceConfig = ` @@ -75,7 +75,7 @@ resource "cloudavenue_edgegateway_static_route" "example" { func staticRouteTestCheck(resourceName string) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrSet(resourceName, "id"), - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttr(resourceName, "name", "example"), resource.TestCheckNoResourceAttr(resourceName, "description"), resource.TestCheckResourceAttr(resourceName, "network_cidr", "192.168.1.0/24"), @@ -88,7 +88,7 @@ func staticRouteTestCheck(resourceName string) resource.TestCheckFunc { func staticRouteTestCheckUpdated(resourceName string) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrSet(resourceName, "id"), - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttr(resourceName, "name", "example"), resource.TestCheckResourceAttr(resourceName, "description", "example description"), resource.TestCheckResourceAttr(resourceName, "network_cidr", "192.168.2.0/24"), diff --git a/internal/testsacc/edgegw_vpn_ipsec_resource_test.go b/internal/testsacc/edgegw_vpn_ipsec_resource_test.go index c66c9560..2caf735c 100644 --- a/internal/testsacc/edgegw_vpn_ipsec_resource_test.go +++ b/internal/testsacc/edgegw_vpn_ipsec_resource_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const MytestAccVDCResourceConfig = ` @@ -166,7 +166,7 @@ resource "cloudavenue_edgegateway_vpn_ipsec" "example" { func vpnIPSecTestCheckDefault(resourceName string) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttrSet(resourceName, "id"), resource.TestCheckResourceAttr(resourceName, "name", "example-default"), resource.TestCheckResourceAttr(resourceName, "description", "example VPN IPSec"), @@ -194,7 +194,7 @@ func vpnIPSecTestCheckDefault(resourceName string) resource.TestCheckFunc { func vpnIPSecTestCheckDefaultUpdate(resourceName string) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttrSet(resourceName, "id"), resource.TestCheckResourceAttr(resourceName, "name", "example-default"), resource.TestCheckResourceAttr(resourceName, "description", "example VPN IPSec Updated"), @@ -222,7 +222,7 @@ func vpnIPSecTestCheckDefaultUpdate(resourceName string) resource.TestCheckFunc func vpnIPSecTestCheckCustomize(resourceName string) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttrSet(resourceName, "id"), resource.TestCheckResourceAttr(resourceName, "name", "example-customize"), resource.TestCheckResourceAttr(resourceName, "description", "example VPN IPSec"), @@ -250,7 +250,7 @@ func vpnIPSecTestCheckCustomize(resourceName string) resource.TestCheckFunc { func vpnIPSecTestCheckCustomizeUpdate(resourceName string) resource.TestCheckFunc { return resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckResourceAttrSet(resourceName, "id"), resource.TestCheckResourceAttr(resourceName, "name", "example-customize"), resource.TestCheckResourceAttr(resourceName, "description", "example VPN IPSec Updated"), diff --git a/internal/testsacc/iam_token_resource_test.go b/internal/testsacc/iam_token_resource_test.go index e0b3a1bc..9b2f55a1 100644 --- a/internal/testsacc/iam_token_resource_test.go +++ b/internal/testsacc/iam_token_resource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccTokenResourceConfig = ` @@ -42,7 +42,7 @@ func TestAccTokenResource(t *testing.T) { // Apply test Config: testAccTokenResourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Token)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Token)), resource.TestCheckResourceAttr(resourceName, "name", "example"), resource.TestCheckResourceAttr(resourceName, "save_in_tfstate", "true"), resource.TestCheckResourceAttr(resourceName, "save_in_file", "true"), diff --git a/internal/testsacc/iam_user_datasource_test.go b/internal/testsacc/iam_user_datasource_test.go index 28eb167b..e1375e0a 100644 --- a/internal/testsacc/iam_user_datasource_test.go +++ b/internal/testsacc/iam_user_datasource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &IAMUserDataSource{} @@ -61,7 +61,7 @@ func (r *IAMUserDataSource) Tests(ctx context.Context) map[testsacc.TestName]fun name = cloudavenue_iam_user_saml.example.user_name }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.User)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.User)), resource.TestCheckResourceAttr(resourceName, "name", "mickael.stanislas.ext"), resource.TestCheckResourceAttr(resourceName, "enabled", "true"), resource.TestCheckResourceAttr(resourceName, "deployed_vm_quota", "0"), diff --git a/internal/testsacc/iam_user_resource_test.go b/internal/testsacc/iam_user_resource_test.go index 6a015f83..5e495b34 100644 --- a/internal/testsacc/iam_user_resource_test.go +++ b/internal/testsacc/iam_user_resource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &IAMUserResource{} @@ -38,7 +38,7 @@ func (r *IAMUserResource) Tests(ctx context.Context) map[testsacc.TestName]func( "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.User)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.User)), }, // ! Create testing Create: testsacc.TFConfig{ @@ -104,7 +104,7 @@ func (r *IAMUserResource) Tests(ctx context.Context) map[testsacc.TestName]func( "example_2": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.User)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.User)), }, // ! Create testing Create: testsacc.TFConfig{ diff --git a/internal/testsacc/iam_user_saml_resource_test.go b/internal/testsacc/iam_user_saml_resource_test.go index d7375d41..bb3087e5 100644 --- a/internal/testsacc/iam_user_saml_resource_test.go +++ b/internal/testsacc/iam_user_saml_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &IAMUserSAMLResource{} @@ -36,7 +36,7 @@ func (r *IAMUserSAMLResource) Tests(ctx context.Context) map[testsacc.TestName]f "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.User)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.User)), }, // ! Create testing Create: testsacc.TFConfig{ diff --git a/internal/testsacc/network_isolated_resource_test.go b/internal/testsacc/network_isolated_resource_test.go index ecbe28cc..adca4c2d 100644 --- a/internal/testsacc/network_isolated_resource_test.go +++ b/internal/testsacc/network_isolated_resource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccNetworkIsolatedResourceConfig = ` @@ -71,7 +71,7 @@ func TestAccNetworkIsolatedResource(t *testing.T) { // Apply test Config: testAccNetworkIsolatedResourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Network)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Network)), resource.TestCheckResourceAttr(resourceName, "vdc", "VDC_Test"), resource.TestCheckResourceAttr(resourceName, "name", "rsx-example-isolated-network"), resource.TestCheckResourceAttr(resourceName, "description", "My isolated Org VDC network"), @@ -88,7 +88,7 @@ func TestAccNetworkIsolatedResource(t *testing.T) { // Apply test Config: updateAccNetworkIsolatedResourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Network)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Network)), resource.TestCheckResourceAttr(resourceName, "vdc", "VDC_Test"), resource.TestCheckResourceAttr(resourceName, "description", "Example"), resource.TestCheckResourceAttr(resourceName, "dns1", "1.1.1.2"), diff --git a/internal/testsacc/network_routed_datasource_test.go b/internal/testsacc/network_routed_datasource_test.go index eb76df49..ecd8b657 100644 --- a/internal/testsacc/network_routed_datasource_test.go +++ b/internal/testsacc/network_routed_datasource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccNetworkRoutedDataSourceConfig = ` @@ -49,7 +49,7 @@ func TestAccNetworkRoutedDataSource(t *testing.T) { // Apply test Config: testAccNetworkRoutedDataSourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Network)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Network)), resource.TestCheckResourceAttrPair(dataSourceName, "name", resourceName, "name"), resource.TestCheckResourceAttrPair(dataSourceName, "static_ip_pool.#", resourceName, "static_ip_pool.#"), resource.TestCheckResourceAttrPair(dataSourceName, "gateway", resourceName, "gateway"), diff --git a/internal/testsacc/network_routed_resource_test.go b/internal/testsacc/network_routed_resource_test.go index 6f961182..9fd62824 100644 --- a/internal/testsacc/network_routed_resource_test.go +++ b/internal/testsacc/network_routed_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &NetworkRoutedResource{} @@ -40,7 +40,7 @@ func (r *NetworkRoutedResource) Tests(ctx context.Context) map[testsacc.TestName return }, CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Network)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Network)), resource.TestCheckResourceAttrSet(resourceName, "edge_gateway_id"), resource.TestCheckResourceAttrSet(resourceName, "edge_gateway_name"), }, @@ -134,7 +134,7 @@ func (r *NetworkRoutedResource) Tests(ctx context.Context) map[testsacc.TestName return }, CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Network)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Network)), resource.TestCheckResourceAttrSet(resourceName, "edge_gateway_id"), resource.TestCheckResourceAttrSet(resourceName, "edge_gateway_name"), }, @@ -187,7 +187,7 @@ func (r *NetworkRoutedResource) Tests(ctx context.Context) map[testsacc.TestName return }, CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Network)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Network)), resource.TestCheckResourceAttrSet(resourceName, "edge_gateway_id"), resource.TestCheckResourceAttrSet(resourceName, "edge_gateway_name"), }, diff --git a/internal/testsacc/profile_datasource_test.go b/internal/testsacc/profile_datasource_test.go index 068f0b1d..57f3b8b9 100644 --- a/internal/testsacc/profile_datasource_test.go +++ b/internal/testsacc/profile_datasource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccProfileDataSourceConfig = ` @@ -26,7 +26,7 @@ func TestAccProfileDataSource(t *testing.T) { // Apply test Config: testAccProfileDataSourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(dataSourceName, "id", uuid.TestIsType(uuid.VDCStorageProfile)), + resource.TestCheckResourceAttrWith(dataSourceName, "id", urn.TestIsType(urn.VDCStorageProfile)), resource.TestCheckResourceAttrSet(dataSourceName, "vdc"), resource.TestCheckResourceAttr(dataSourceName, "name", "gold"), resource.TestCheckResourceAttrSet(dataSourceName, "limit"), diff --git a/internal/testsacc/profiles_datasource_test.go b/internal/testsacc/profiles_datasource_test.go index d52d235c..fc315b56 100644 --- a/internal/testsacc/profiles_datasource_test.go +++ b/internal/testsacc/profiles_datasource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccProfilesDataSourceConfig = ` @@ -25,7 +25,7 @@ func TestAccProfilesDataSource(t *testing.T) { // Apply test Config: testAccProfilesDataSourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(dataSourceName, "id", uuid.TestIsType(uuid.VDCStorageProfile)), + resource.TestCheckResourceAttrWith(dataSourceName, "id", urn.TestIsType(urn.VDCStorageProfile)), resource.TestCheckResourceAttrSet(dataSourceName, "vdc"), resource.TestCheckResourceAttrSet(dataSourceName, "storage_profiles.0.id"), resource.TestCheckResourceAttrSet(dataSourceName, "storage_profiles.0.vdc"), diff --git a/internal/testsacc/publicip_resource_test.go b/internal/testsacc/publicip_resource_test.go index 7db007f9..855e7f77 100644 --- a/internal/testsacc/publicip_resource_test.go +++ b/internal/testsacc/publicip_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &PublicIPResource{} @@ -46,7 +46,7 @@ func (r *PublicIPResource) Tests(ctx context.Context) map[testsacc.TestName]func Checks: []resource.TestCheckFunc{ resource.TestCheckResourceAttrSet(resourceName, "id"), resource.TestCheckResourceAttrSet(resourceName, "public_ip"), - resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", uuid.TestIsType(uuid.Gateway)), + resource.TestCheckResourceAttrWith(resourceName, "edge_gateway_id", urn.TestIsType(urn.Gateway)), resource.TestCheckNoResourceAttr(resourceName, "edge_gateway_name"), }, }, diff --git a/internal/testsacc/s3_user_datasource_test.go b/internal/testsacc/s3_user_datasource_test.go index d44d263e..16cbc812 100644 --- a/internal/testsacc/s3_user_datasource_test.go +++ b/internal/testsacc/s3_user_datasource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &S3UserDataSource{} @@ -44,7 +44,7 @@ func (r *S3UserDataSource) Tests(ctx context.Context) map[testsacc.TestName]func user_name = cloudavenue_iam_user.example.name }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.User)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.User)), resource.TestCheckResourceAttrSet(resourceName, "user_id"), resource.TestCheckResourceAttrSet(resourceName, "user_name"), resource.TestCheckResourceAttrSet(resourceName, "full_name"), diff --git a/internal/testsacc/storage_profile_datasource_test.go b/internal/testsacc/storage_profile_datasource_test.go index 38a1db8d..52e9f37a 100644 --- a/internal/testsacc/storage_profile_datasource_test.go +++ b/internal/testsacc/storage_profile_datasource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &StorageProfileDataSource{} @@ -45,7 +45,7 @@ func (r *StorageProfileDataSource) Tests(ctx context.Context) map[testsacc.TestN vdc = cloudavenue_vdc.example.name }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDCStorageProfile)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDCStorageProfile)), resource.TestCheckResourceAttrSet(resourceName, "vdc"), resource.TestCheckResourceAttr(resourceName, "name", "gold"), resource.TestCheckResourceAttrSet(resourceName, "limit"), diff --git a/internal/testsacc/storage_profiles_datasource_test.go b/internal/testsacc/storage_profiles_datasource_test.go index 1e1afa5b..5654b296 100644 --- a/internal/testsacc/storage_profiles_datasource_test.go +++ b/internal/testsacc/storage_profiles_datasource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &StorageProfilesDataSource{} @@ -44,7 +44,7 @@ func (r *StorageProfilesDataSource) Tests(ctx context.Context) map[testsacc.Test vdc = cloudavenue_vdc.example.name }`, Checks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDCStorageProfile)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDCStorageProfile)), resource.TestCheckResourceAttrSet(resourceName, "vdc"), resource.TestCheckResourceAttrSet(resourceName, "storage_profiles.0.id"), resource.TestCheckResourceAttrSet(resourceName, "storage_profiles.0.vdc"), diff --git a/internal/testsacc/vapp_acl_resource_test.go b/internal/testsacc/vapp_acl_resource_test.go index 50762550..923dc29a 100644 --- a/internal/testsacc/vapp_acl_resource_test.go +++ b/internal/testsacc/vapp_acl_resource_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccVAPPACLResourceConfig = ` @@ -61,7 +61,7 @@ func TestAccVAPPACLResource(t *testing.T) { // Apply test Config: testAccVAPPACLResourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VAPP)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VAPP)), resource.TestCheckResourceAttr(resourceName, "vdc", os.Getenv("CLOUDAVENUE_VDC")), resource.TestCheckResourceAttr(resourceName, "vapp_name", "MyVapp"), resource.TestCheckResourceAttrSet(resourceName, "shared_with.0.subject_name"), @@ -72,7 +72,7 @@ func TestAccVAPPACLResource(t *testing.T) { // Update test Config: testAccVAPPACLResourceConfigUpdate, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VAPP)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VAPP)), resource.TestCheckResourceAttr(resourceName, "vdc", os.Getenv("CLOUDAVENUE_VDC")), resource.TestCheckResourceAttr(resourceName, "vapp_name", "MyVapp"), resource.TestCheckResourceAttr(resourceName, "everyone_access_level", "Change"), diff --git a/internal/testsacc/vapp_org_network_datasource_test.go b/internal/testsacc/vapp_org_network_datasource_test.go index 205806ed..7924e134 100644 --- a/internal/testsacc/vapp_org_network_datasource_test.go +++ b/internal/testsacc/vapp_org_network_datasource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccOrgNetworkDataSourceConfig = ` @@ -70,7 +70,7 @@ func TestAccOrgNetworkDataSource(t *testing.T) { // Apply test Config: testAccOrgNetworkDataSourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Network)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Network)), resource.TestCheckResourceAttrPair(dataSourceName, "network_name", resourceName, "network_name"), ), }, diff --git a/internal/testsacc/vapp_org_network_resource_test.go b/internal/testsacc/vapp_org_network_resource_test.go index 510bb59f..2522940a 100644 --- a/internal/testsacc/vapp_org_network_resource_test.go +++ b/internal/testsacc/vapp_org_network_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &VAppOrgNetworkResource{} @@ -39,7 +39,7 @@ func (r *VAppOrgNetworkResource) Tests(ctx context.Context) map[testsacc.TestNam "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.Network)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.Network)), resource.TestCheckResourceAttrSet(resourceName, "vdc"), resource.TestCheckResourceAttrSet(resourceName, "network_name"), resource.TestCheckResourceAttrSet(resourceName, "vapp_name"), diff --git a/internal/testsacc/vapp_resource_test.go b/internal/testsacc/vapp_resource_test.go index 43c64c3f..caab6a9d 100644 --- a/internal/testsacc/vapp_resource_test.go +++ b/internal/testsacc/vapp_resource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &VAppResource{} @@ -39,7 +39,7 @@ func (r *VAppResource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VAPP)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VAPP)), resource.TestCheckResourceAttrSet(resourceName, "vdc"), }, // ! Create testing diff --git a/internal/testsacc/vcda_ip_resource_test.go b/internal/testsacc/vcda_ip_resource_test.go index efa2f4b9..44f7b8d2 100644 --- a/internal/testsacc/vcda_ip_resource_test.go +++ b/internal/testsacc/vcda_ip_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &VCDAIPResource{} @@ -37,7 +37,7 @@ func (r *VCDAIPResource) Tests(ctx context.Context) map[testsacc.TestName]func(c "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VCDA)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VCDA)), }, // ! Create testing Create: testsacc.TFConfig{ @@ -67,7 +67,7 @@ func (r *VCDAIPResource) Tests(ctx context.Context) map[testsacc.TestName]func(c "example_multiple": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VCDA)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VCDA)), }, // ! Create testing Create: testsacc.TFConfig{ diff --git a/internal/testsacc/vdc_acl_resource_test.go b/internal/testsacc/vdc_acl_resource_test.go index 78d563b5..ca9dc5dd 100644 --- a/internal/testsacc/vdc_acl_resource_test.go +++ b/internal/testsacc/vdc_acl_resource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccVDCACLResourceConfig = ` @@ -38,7 +38,7 @@ func TestAccVDCACLResource(t *testing.T) { // Apply test Config: testAccVDCACLResourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDC)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDC)), resource.TestCheckResourceAttr(resourceName, "vdc", "VDC_Test"), resource.TestCheckResourceAttr(resourceName, "everyone_access_level", "ReadOnly"), ), @@ -47,7 +47,7 @@ func TestAccVDCACLResource(t *testing.T) { // Apply test Config: testAccVDCACLResourceSharedWithConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDC)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDC)), resource.TestCheckResourceAttr(resourceName, "vdc", "VDC_Test"), resource.TestCheckResourceAttrSet(resourceName, "shared_with.0.subject_name"), ), diff --git a/internal/testsacc/vdc_group_resource_test.go b/internal/testsacc/vdc_group_resource_test.go index 3ccd172d..498e79b2 100644 --- a/internal/testsacc/vdc_group_resource_test.go +++ b/internal/testsacc/vdc_group_resource_test.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &VDCGroupResource{} @@ -40,7 +40,7 @@ func (r *VDCGroupResource) Tests(ctx context.Context) map[testsacc.TestName]func "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDCGroup)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDCGroup)), resource.TestCheckResourceAttrSet(resourceName, "status"), resource.TestCheckResourceAttrSet(resourceName, "type"), }, diff --git a/internal/testsacc/vdc_resource_test.go b/internal/testsacc/vdc_resource_test.go index f44bf52a..4c9d88bc 100644 --- a/internal/testsacc/vdc_resource_test.go +++ b/internal/testsacc/vdc_resource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) var _ testsacc.TestACC = &VDCResource{} @@ -38,7 +38,7 @@ func (r *VDCResource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDC)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDC)), resource.TestCheckResourceAttr(resourceName, "billing_model", "PAYG"), resource.TestCheckResourceAttr(resourceName, "disponibility_class", "ONE-ROOM"), resource.TestCheckResourceAttr(resourceName, "service_class", "STD"), @@ -205,7 +205,7 @@ func (r *VDCResource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx "example_reserved": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDC)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDC)), resource.TestCheckResourceAttr(resourceName, "billing_model", "RESERVED"), resource.TestCheckResourceAttr(resourceName, "disponibility_class", "ONE-ROOM"), resource.TestCheckResourceAttr(resourceName, "service_class", "STD"), @@ -281,7 +281,7 @@ func (r *VDCResource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx "example_vdc_group_1": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDC)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDC)), resource.TestCheckResourceAttr(resourceName, "billing_model", "PAYG"), resource.TestCheckResourceAttr(resourceName, "disponibility_class", "ONE-ROOM"), resource.TestCheckResourceAttr(resourceName, "service_class", "STD"), @@ -324,7 +324,7 @@ func (r *VDCResource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx "example_vdc_group_2": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDC)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDC)), resource.TestCheckResourceAttr(resourceName, "billing_model", "PAYG"), resource.TestCheckResourceAttr(resourceName, "disponibility_class", "ONE-ROOM"), resource.TestCheckResourceAttr(resourceName, "service_class", "STD"), @@ -368,7 +368,7 @@ func (r *VDCResource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx "example_storage_profiles": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VDC)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDC)), resource.TestCheckResourceAttr(resourceName, "billing_model", "PAYG"), resource.TestCheckResourceAttr(resourceName, "disponibility_class", "ONE-ROOM"), resource.TestCheckResourceAttr(resourceName, "service_class", "STD"), diff --git a/internal/testsacc/vm_datasource_test.go b/internal/testsacc/vm_datasource_test.go index ce65f738..cfcc2c89 100644 --- a/internal/testsacc/vm_datasource_test.go +++ b/internal/testsacc/vm_datasource_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccVMDataSourceConfig = ` @@ -57,10 +57,10 @@ func TestAccVMDataSource(t *testing.T) { Config: testAccVMDataSourceConfig, Check: resource.ComposeAggregateTestCheckFunc( // ! basic - resource.TestCheckResourceAttrWith(dataSourceName, "id", uuid.TestIsType(uuid.VM)), + resource.TestCheckResourceAttrWith(dataSourceName, "id", urn.TestIsType(urn.VM)), resource.TestCheckResourceAttr(dataSourceName, "name", "example-vm"), resource.TestCheckResourceAttr(dataSourceName, "vapp_name", "example-vapp"), - resource.TestCheckResourceAttrWith(dataSourceName, "vapp_id", uuid.TestIsType(uuid.VAPP)), + resource.TestCheckResourceAttrWith(dataSourceName, "vapp_id", urn.TestIsType(urn.VAPP)), resource.TestCheckResourceAttr(dataSourceName, "vdc", os.Getenv("CLOUDAVENUE_VDC")), // ! resource resource.TestCheckResourceAttr(dataSourceName, "resource.cpus", "1"), @@ -70,7 +70,7 @@ func TestAccVMDataSource(t *testing.T) { resource.TestCheckResourceAttr(dataSourceName, "resource.memory_hot_add_enabled", "true"), resource.TestCheckResourceAttr(dataSourceName, "resource.networks.#", "0"), // ! settings - resource.TestCheckResourceAttrWith(dataSourceName, "settings.affinity_rule_id", uuid.TestIsType(uuid.VDCComputePolicy)), + resource.TestCheckResourceAttrWith(dataSourceName, "settings.affinity_rule_id", urn.TestIsType(urn.VDCComputePolicy)), resource.TestCheckResourceAttrSet(dataSourceName, "settings.customization.allow_local_admin_password"), resource.TestCheckResourceAttrSet(dataSourceName, "settings.customization.auto_generate_password"), resource.TestCheckResourceAttrSet(dataSourceName, "settings.customization.change_sid"), diff --git a/internal/testsacc/vm_disk_resource_test.go b/internal/testsacc/vm_disk_resource_test.go index e96bd4eb..1b1de134 100644 --- a/internal/testsacc/vm_disk_resource_test.go +++ b/internal/testsacc/vm_disk_resource_test.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccVMDiskResourceConfig = ` @@ -110,7 +110,7 @@ func TestAccVMDiskResource(t *testing.T) { { Config: testAccVMDiskResourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceNameDetachable, "id", uuid.TestIsType(uuid.Disk)), + resource.TestCheckResourceAttrWith(resourceNameDetachable, "id", urn.TestIsType(urn.Disk)), resource.TestCheckResourceAttr(resourceNameDetachable, "name", "disk-example-detachable"), resource.TestCheckResourceAttr(resourceNameDetachable, "bus_type", "SATA"), resource.TestCheckResourceAttr(resourceNameDetachable, "storage_profile", "gold"), @@ -125,7 +125,7 @@ func TestAccVMDiskResource(t *testing.T) { { Config: strings.Replace(testAccVMDiskResourceConfig, "2048", "4096", 1), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceNameDetachable, "id", uuid.TestIsType(uuid.Disk)), + resource.TestCheckResourceAttrWith(resourceNameDetachable, "id", urn.TestIsType(urn.Disk)), resource.TestCheckResourceAttr(resourceNameDetachable, "name", "disk-example-detachable"), resource.TestCheckResourceAttr(resourceNameDetachable, "bus_type", "SATA"), resource.TestCheckResourceAttr(resourceNameDetachable, "storage_profile", "gold"), @@ -164,7 +164,7 @@ func TestAccVMDiskResource(t *testing.T) { { Config: testAccVMDiskWithVMResourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceNameDetachableWithVM, "id", uuid.TestIsType(uuid.Disk)), + resource.TestCheckResourceAttrWith(resourceNameDetachableWithVM, "id", urn.TestIsType(urn.Disk)), resource.TestCheckResourceAttr(resourceNameDetachableWithVM, "name", "disk-example-detachable-with-vm"), resource.TestCheckResourceAttr(resourceNameDetachableWithVM, "bus_type", "SATA"), resource.TestCheckResourceAttr(resourceNameDetachableWithVM, "storage_profile", "gold"), @@ -179,7 +179,7 @@ func TestAccVMDiskResource(t *testing.T) { { Config: strings.Replace(testAccVMDiskWithVMResourceConfig, "2048", "4096", 1), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceNameDetachableWithVM, "id", uuid.TestIsType(uuid.Disk)), + resource.TestCheckResourceAttrWith(resourceNameDetachableWithVM, "id", urn.TestIsType(urn.Disk)), resource.TestCheckResourceAttr(resourceNameDetachableWithVM, "name", "disk-example-detachable-with-vm"), resource.TestCheckResourceAttr(resourceNameDetachableWithVM, "bus_type", "SATA"), resource.TestCheckResourceAttr(resourceNameDetachableWithVM, "storage_profile", "gold"), diff --git a/internal/testsacc/vm_resource_test.go b/internal/testsacc/vm_resource_test.go index 41c45a41..327eb134 100644 --- a/internal/testsacc/vm_resource_test.go +++ b/internal/testsacc/vm_resource_test.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/helpers/testsacc" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" ) // Used into old tests. @@ -76,7 +76,7 @@ func (r *VMResource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx c "example": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VM)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VM)), resource.TestCheckResourceAttrSet(resourceName, "vdc"), resource.TestCheckResourceAttrSet(resourceName, "vapp_name"), resource.TestCheckResourceAttrSet(resourceName, "vapp_id"), @@ -274,7 +274,7 @@ func (r *VMResource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx c "example_with_password": func(_ context.Context, resourceName string) testsacc.Test { return testsacc.Test{ CommonChecks: []resource.TestCheckFunc{ - resource.TestCheckResourceAttrWith(resourceName, "id", uuid.TestIsType(uuid.VM)), + resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VM)), resource.TestCheckResourceAttrSet(resourceName, "vdc"), resource.TestCheckResourceAttrSet(resourceName, "vapp_name"), resource.TestCheckResourceAttrSet(resourceName, "vapp_id"), diff --git a/internal/testsacc/vm_security_tag_resource_test.go b/internal/testsacc/vm_security_tag_resource_test.go index ce32993f..e6126e10 100644 --- a/internal/testsacc/vm_security_tag_resource_test.go +++ b/internal/testsacc/vm_security_tag_resource_test.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/uuid" + "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" ) const testAccSecurityTagResourceConfig = ` @@ -113,7 +113,7 @@ func TestAccSecurityTagResource(t *testing.T) { Config: testAccSecurityTagResourceConfig, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "id", "tag-example"), - resource.TestCheckResourceAttrWith(resourceName, "vm_ids.0", uuid.TestIsType(uuid.VM)), + resource.TestCheckResourceAttrWith(resourceName, "vm_ids.0", urn.TestIsType(urn.VM)), ), }, { @@ -121,8 +121,8 @@ func TestAccSecurityTagResource(t *testing.T) { Config: testAccSecurityTagResourceConfigUpdate, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "id", "tag-example"), - resource.TestCheckResourceAttrWith(resourceName, "vm_ids.0", uuid.TestIsType(uuid.VM)), - resource.TestCheckResourceAttrWith(resourceName, "vm_ids.1", uuid.TestIsType(uuid.VM)), + resource.TestCheckResourceAttrWith(resourceName, "vm_ids.0", urn.TestIsType(urn.VM)), + resource.TestCheckResourceAttrWith(resourceName, "vm_ids.1", urn.TestIsType(urn.VM)), ), }, // Import testing diff --git a/pkg/uuid/uuid.go b/pkg/uuid/uuid.go deleted file mode 100644 index a5b9c5fa..00000000 --- a/pkg/uuid/uuid.go +++ /dev/null @@ -1,330 +0,0 @@ -package uuid - -import ( - "fmt" - "regexp" - "strings" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -const ( - - // VcloudUUIDPrefix is the prefix for all vCloud UUIDs. - VcloudUUIDPrefix = "urn:vcloud:" - CloudAvenueUUIDPrefix = "urn:cloudavenue:" - - // * VCD. - VM = VcloudUUID(VcloudUUIDPrefix + "vm:") - User = VcloudUUID(VcloudUUIDPrefix + "user:") - Group = VcloudUUID(VcloudUUIDPrefix + "group:") - Gateway = VcloudUUID(VcloudUUIDPrefix + "gateway:") - VDC = VcloudUUID(VcloudUUIDPrefix + "vdc:") - VDCGroup = VcloudUUID(VcloudUUIDPrefix + "vdcGroup:") - VDCComputePolicy = VcloudUUID(VcloudUUIDPrefix + "vdcComputePolicy:") - Network = VcloudUUID(VcloudUUIDPrefix + "network:") - LoadBalancerPool = VcloudUUID(VcloudUUIDPrefix + "loadBalancerPool:") - VDCStorageProfile = VcloudUUID(VcloudUUIDPrefix + "vdcstorageProfile:") - VAPP = VcloudUUID(VcloudUUIDPrefix + "vapp:") - VAPPTemplate = VcloudUUID(VcloudUUIDPrefix + "vappTemplate:") - Disk = VcloudUUID(VcloudUUIDPrefix + "disk:") - SecurityGroup = VcloudUUID(VcloudUUIDPrefix + "firewallGroup:") - Catalog = VcloudUUID(VcloudUUIDPrefix + "catalog:") - Token = VcloudUUID(VcloudUUIDPrefix + "token:") - AppPortProfile = VcloudUUID(VcloudUUIDPrefix + "applicationPortProfile:") - - // * CLOUDAVENUE. - VCDA = VcloudUUID(CloudAvenueUUIDPrefix + "vcda:") -) - -var vcloudUUIDs = []VcloudUUID{ - VM, - User, - Group, - Gateway, - VDC, - VDCGroup, - VDCComputePolicy, - Network, - LoadBalancerPool, - VDCStorageProfile, - VAPP, - VAPPTemplate, - Disk, - SecurityGroup, - Catalog, - Token, - AppPortProfile, -} - -type ( - VcloudUUID string -) - -// String returns the string representation of the UUID. -func (uuid VcloudUUID) String() string { - return string(uuid) -} - -// IsType returns true if the UUID is of the specified type. -func (uuid VcloudUUID) IsType(prefix VcloudUUID) bool { - if uuid.isEmpty() || prefix.isEmpty() { - return false - } - - return strings.HasPrefix(string(uuid), prefix.String()) && isUUIDV4(uuid.extractUUIDv4(prefix)) -} - -// isNotEmpty returns true if the UUID is not empty. -func (uuid VcloudUUID) isEmpty() bool { - return len(uuid) == 0 -} - -func isUUIDV4(uuid string) bool { - return regexp.MustCompile(`(?m)^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$`).MatchString(uuid) -} - -func IsUUIDV4(uuid string) bool { - return isUUIDV4(uuid) -} - -// ContainsPrefix returns true if the UUID contains any prefix. -func (uuid VcloudUUID) ContainsPrefix() bool { - return strings.Contains(string(uuid), string(VcloudUUIDPrefix)) -} - -// extractUUIDv4 returns the UUIDv4 from the UUID. -func (uuid VcloudUUID) extractUUIDv4(prefix VcloudUUID) string { - return extractUUIDv4(uuid.String(), prefix) -} - -func extractUUIDv4(uuid string, prefix VcloudUUID) string { - if len(uuid) == 0 || prefix.isEmpty() { - return "" - } - - return uuid[len(prefix):] -} - -func IsValid(uuid string) bool { - if len(uuid) == 0 { - return false - } - - u := VcloudUUID(uuid) - - for _, prefix := range vcloudUUIDs { - if u.IsType(prefix) { - return isUUIDV4(extractUUIDv4(uuid, prefix)) - } - } - return false -} - -// Normalize returns the UUID with the prefix if prefix is missing. -func Normalize(prefix VcloudUUID, uuid string) VcloudUUID { - if len(uuid) == 0 || prefix.isEmpty() { - return "" - } - - u := VcloudUUID(uuid) - if u.ContainsPrefix() { - return u - } - - return prefix + u -} - -// IsAppPortProfile returns true if the UUID is a AppPortProfile UUID. -func (uuid VcloudUUID) IsAppPortProfile() bool { - return uuid.IsType(AppPortProfile) -} - -// IsVM returns true if the UUID is a VM UUID. -func (uuid VcloudUUID) IsVM() bool { - return uuid.IsType(VM) -} - -// IsUser returns true if the UUID is a User UUID. -func (uuid VcloudUUID) IsUser() bool { - return uuid.IsType(User) -} - -// IsGroup returns true if the UUID is a Group UUID. -func (uuid VcloudUUID) IsGroup() bool { - return uuid.IsType(Group) -} - -// IsGateway returns true if the UUID is a Gateway UUID. -func (uuid VcloudUUID) IsGateway() bool { - return uuid.IsType(Gateway) -} - -// IsVDC returns true if the UUID is a VDC UUID. -func (uuid VcloudUUID) IsVDC() bool { - return uuid.IsType(VDC) -} - -// IsVDCGroup returns true if the UUID is a VDCGroup UUID. -func (uuid VcloudUUID) IsVDCGroup() bool { - return uuid.IsType(VDCGroup) -} - -// IsNetwork returns true if the UUID is a Network UUID. -func (uuid VcloudUUID) IsNetwork() bool { - return uuid.IsType(Network) -} - -// IsLoadBalancerPool returns true if the UUID is a LoadBalancerPool UUID. -func (uuid VcloudUUID) IsLoadBalancerPool() bool { - return uuid.IsType(LoadBalancerPool) -} - -// IsVDCStorageProfile returns true if the UUID is a VDCStorageProfile UUID. -func (uuid VcloudUUID) IsVDCStorageProfile() bool { - return uuid.IsType(VDCStorageProfile) -} - -// IsVAPP returns true if the UUID is a VAPP UUID. -func (uuid VcloudUUID) IsVAPP() bool { - return uuid.IsType(VAPP) -} - -// IsVAPPTemplate returns true if the UUID is a VAPPTemplate UUID. -func (uuid VcloudUUID) IsVAPPTemplate() bool { - return uuid.IsType(VAPPTemplate) -} - -// IsDisk returns true if the UUID is a Disk UUID. -func (uuid VcloudUUID) IsDisk() bool { - return uuid.IsType(Disk) -} - -// IsSecurityGroup returns true if the UUID is a SecurityGroup UUID. -func (uuid VcloudUUID) IsSecurityGroup() bool { - return uuid.IsType(SecurityGroup) -} - -// IsCatalog returns true if the UUID is a Catalog UUID. -func (uuid VcloudUUID) IsCatalog() bool { - return uuid.IsType(Catalog) -} - -// IsToken returns true if the UUID is a Token UUID. -func (uuid VcloudUUID) IsToken() bool { - return uuid.IsType(Token) -} - -// IsVDCComputePolicy returns true if the UUID is a VDCComputePolicy UUID. -func (uuid VcloudUUID) IsVDCComputePolicy() bool { - return uuid.IsType(VDCComputePolicy) -} - -// * End Methods - -// IsAppPortProfile returns true if the UUID is a AppPortProfile UUID. -func IsAppPortProfile(uuid string) bool { - return VcloudUUID(uuid).IsType(AppPortProfile) -} - -// IsEdgeGateway returns true if the UUID is a EdgeGateway UUID. -func IsEdgeGateway(uuid string) bool { - return VcloudUUID(uuid).IsType(Gateway) -} - -// IsVDC returns true if the UUID is a VDC UUID. -func IsVDC(uuid string) bool { - return VcloudUUID(uuid).IsType(VDC) -} - -// IsVDCGroup returns true if the UUID is a VDCGroup UUID. -func IsVDCGroup(uuid string) bool { - return VcloudUUID(uuid).IsType(VDCGroup) -} - -// IsNetwork returns true if the UUID is a Network UUID. -func IsNetwork(uuid string) bool { - return VcloudUUID(uuid).IsType(Network) -} - -// IsLoadBalancerPool returns true if the UUID is a LoadBalancerPool UUID. -func IsLoadBalancerPool(uuid string) bool { - return VcloudUUID(uuid).IsType(LoadBalancerPool) -} - -// IsVDCStorageProfile returns true if the UUID is a VDCStorageProfile UUID. -func IsVDCStorageProfile(uuid string) bool { - return VcloudUUID(uuid).IsType(VDCStorageProfile) -} - -// IsVAPP returns true if the UUID is a VAPP UUID. -func IsVAPP(uuid string) bool { - return VcloudUUID(uuid).IsType(VAPP) -} - -// IsVAPPTemplate returns true if the UUID is a VAPPTemplate UUID. -func IsVAPPTemplate(uuid string) bool { - return VcloudUUID(uuid).IsType(VAPPTemplate) -} - -// IsDisk returns true if the UUID is a Disk UUID. -func IsDisk(uuid string) bool { - return VcloudUUID(uuid).IsType(Disk) -} - -// IsSecurityGroup returns true if the UUID is a SecurityGroup UUID. -func IsSecurityGroup(uuid string) bool { - return VcloudUUID(uuid).IsType(SecurityGroup) -} - -// IsVCDA returns true if the UUID is a VCDA UUID. -func IsVCDA(uuid string) bool { - return VcloudUUID(uuid).IsType(VCDA) -} - -// IsVM returns true if the UUID is a VM UUID. -func IsVM(uuid string) bool { - return VcloudUUID(uuid).IsType(VM) -} - -// IsUser returns true if the UUID is a User UUID. -func IsUser(uuid string) bool { - return VcloudUUID(uuid).IsType(User) -} - -// IsGroup returns true if the UUID is a Group UUID. -func IsGroup(uuid string) bool { - return VcloudUUID(uuid).IsType(Group) -} - -// IsCatalog returns true if the UUID is a Catalog UUID. -func IsCatalog(uuid string) bool { - return VcloudUUID(uuid).IsType(Catalog) -} - -// IsToken returns true if the UUID is a Token UUID. -func IsToken(uuid string) bool { - return VcloudUUID(uuid).IsType(Token) -} - -// IsVDCComputePolicy returns true if the UUID is a VDCComputePolicy UUID. -func IsVDCComputePolicy(uuid string) bool { - return VcloudUUID(uuid).IsType(VDCComputePolicy) -} - -// * End Functions - -// TestIsType returns true if the UUID is of the specified type. -func TestIsType(uuidType VcloudUUID) resource.CheckResourceAttrWithFunc { - return func(value string) error { - if value == "" { - return nil - } - - ok := VcloudUUID(value).IsType(uuidType) - if !ok { - return fmt.Errorf("uuid %s is not of type %s", value, uuidType) - } - return nil - } -} diff --git a/pkg/uuid/uuid_test.go b/pkg/uuid/uuid_test.go deleted file mode 100644 index 63f379a8..00000000 --- a/pkg/uuid/uuid_test.go +++ /dev/null @@ -1,1354 +0,0 @@ -package uuid - -import ( - "testing" -) - -const ( - validUUIDv4 = "12345678-1234-1234-1234-123456789012" -) - -func TestVcloudUUID_ContainsPrefix(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "ContainsPrefix", - uuid: VcloudUUID(VM.String() + validUUIDv4), - want: true, - }, - { - name: "DoesNotContainPrefix", - uuid: VcloudUUID("urn:vm:" + validUUIDv4), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.ContainsPrefix(); got != tt.want { - t.Errorf("VcloudUUID.ContainsPrefix() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_isUUIDV4(t *testing.T) { - type args struct { - uuid string - } - tests := []struct { - name string - args args - want bool - }{ - { - name: "ValidUUID", - args: args{ - uuid: validUUIDv4, - }, - want: true, - }, - { - name: "InvalidUUID", - args: args{ - uuid: "f47ac10b-58cddc-43-a567-0e02b2c3d4791", - }, - want: false, - }, - { // Empty string - name: "EmptyString", - args: args{ - uuid: "", - }, - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := isUUIDV4(tt.args.uuid); got != tt.want { - t.Errorf("isUUIDV4() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestVcloudUUID_IsType(t *testing.T) { - type args struct { - prefix VcloudUUID - } - tests := []struct { - name string - uuid VcloudUUID - args args - want bool - }{ - { - name: "IsType", - uuid: VcloudUUID(VM.String() + validUUIDv4), - args: args{ - prefix: VM, - }, - want: true, - }, - { - name: "IsNotType", - uuid: VcloudUUID(VM.String() + validUUIDv4), - args: args{ - prefix: User, - }, - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - args: args{ - prefix: VM, - }, - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsType(tt.args.prefix); got != tt.want { - t.Errorf("VcloudUUID.IsType() = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_extractUUIDv4(t *testing.T) { - type args struct { - uuid string - prefix VcloudUUID - } - tests := []struct { - name string - args args - want string - }{ - { - name: "ExtractUUID", - args: args{ - uuid: VM.String() + validUUIDv4, - prefix: VM, - }, - want: validUUIDv4, - }, - { - name: "EmptyString", - args: args{ - uuid: "", - prefix: VM, - }, - want: "", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := extractUUIDv4(tt.args.uuid, tt.args.prefix); got != tt.want { - t.Errorf("extractUUIDv4() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestIsValid(t *testing.T) { - type args struct { - uuid string - } - tests := []struct { - name string - args args - want bool - }{ - { - name: "ValidUUID", - args: args{ - uuid: VM.String() + validUUIDv4, - }, - want: true, - }, - { - name: "InvalidUUID", - args: args{ - uuid: "f47ac10b-58cddc-43-a567-0e02b2c3d4791", - }, - want: false, - }, - { - name: "InvalidPrefix", - args: args{ - uuid: "urn:vm:f47ac10b-58cddc-43-a567-0e02b2c3d4791", - }, - want: false, - }, - { // Empty string - name: "EmptyString", - args: args{ - uuid: "", - }, - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsValid(tt.args.uuid); got != tt.want { - t.Errorf("IsValid() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestNormalize(t *testing.T) { - type args struct { - prefix VcloudUUID - uuid string - } - tests := []struct { - name string - args args - want VcloudUUID - }{ - { - name: "Normalize", - args: args{ - prefix: VM, - uuid: validUUIDv4, - }, - want: VcloudUUID(VM.String() + validUUIDv4), - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := Normalize(tt.args.prefix, tt.args.uuid); got != tt.want { - t.Errorf("Normalize() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestVcloudUUID_IsVM(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsVM", - uuid: VcloudUUID(VM.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotVM", - uuid: VcloudUUID("urn:vcloud:user:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsVM(); got != tt.want { - t.Errorf("VcloudUUID.IsVM() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestVcloudUUID_IsUser(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsUser", - uuid: VcloudUUID(User.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotUser", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsUser(); got != tt.want { - t.Errorf("VcloudUUID.IsUser() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsGroup. -func TestVcloudUUID_IsGroup(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsGroup", - uuid: VcloudUUID(Group.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotGroup", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsGroup(); got != tt.want { - t.Errorf("VcloudUUID.IsGroup() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsGateway. -func TestVcloudUUID_IsGateway(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsGateway", - uuid: VcloudUUID(Gateway.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotGateway", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsGateway(); got != tt.want { - t.Errorf("VcloudUUID.IsGateway() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsVDC. -func TestVcloudUUID_IsVDC(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsVDC", - uuid: VcloudUUID(VDC.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotVDC", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsVDC(); got != tt.want { - t.Errorf("VcloudUUID.IsVDC() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsVDCGroup. -func TestVcloudUUID_IsVDCGroup(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { // IsVDCGroup - name: "IsVDCGroup", - uuid: VcloudUUID(VDCGroup.String() + validUUIDv4), - want: true, - }, - { // IsNotVDCGroup - name: "IsNotVDCGroup", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsVDCGroup(); got != tt.want { - t.Errorf("VcloudUUID.IsVDCGroup() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsNetwork. -func TestVcloudUUID_IsNetwork(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsNetwork", - uuid: VcloudUUID(Network.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotNetwork", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsNetwork(); got != tt.want { - t.Errorf("VcloudUUID.IsNetwork() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsLoadBalancerPool. -func TestVcloudUUID_IsLoadBalancerPool(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsLoadBalancerPool", - uuid: VcloudUUID(LoadBalancerPool.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotLoadBalancerPool", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsLoadBalancerPool(); got != tt.want { - t.Errorf("VcloudUUID.IsLoadBalancerPool() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsVDCStorageProfile. -func TestVcloudUUID_IsVDCStorageProfile(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsVDCStorageProfile", - uuid: VcloudUUID(VDCStorageProfile.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotVDCStorageProfile", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsVDCStorageProfile(); got != tt.want { - t.Errorf("VcloudUUID.IsVDCStorageProfile() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsVAPP. -func TestVcloudUUID_IsVAPP(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsVAPP", - uuid: VcloudUUID(VAPP.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotVAPP", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsVAPP(); got != tt.want { - t.Errorf("VcloudUUID.IsVAPP() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsDisk. -func TestVcloudUUID_IsDisk(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsDisk", - uuid: VcloudUUID(Disk.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotDisk", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsDisk(); got != tt.want { - t.Errorf("VcloudUUID.IsDisk() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsSecurityGroup. -func TestVcloudUUID_IsSecurityGroup(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { - name: "IsSecurityGroup", - uuid: VcloudUUID(SecurityGroup.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotSecurityGroup", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsSecurityGroup(); got != tt.want { - t.Errorf("VcloudUUID.IsSecurityGroup() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsVAPPTemplate. -func TestVcloudUUID_IsVAPPTemplate(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { // IsVAPPTemplate - name: "IsVAPPTemplate", - uuid: VcloudUUID(VAPPTemplate.String() + validUUIDv4), - want: true, - }, - { // IsNotVAPPTemplate - name: "IsNotVAPPTemplate", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsVAPPTemplate(); got != tt.want { - t.Errorf("VcloudUUID.IsVAPPTemplate() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsCatalog. -func TestVcloudUUID_IsCatalog(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { // IsCatalog - name: "IsCatalog", - uuid: VcloudUUID(Catalog.String() + validUUIDv4), - want: true, - }, - { // IsNotCatalog - name: "IsNotCatalog", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsCatalog(); got != tt.want { - t.Errorf("VcloudUUID.IsCatalog() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsToken. -func TestVcloudUUID_IsToken(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { // IsToken - name: "IsToken", - uuid: VcloudUUID(Token.String() + validUUIDv4), - want: true, - }, - { // IsNotToken - name: "IsNotToken", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsToken(); got != tt.want { - t.Errorf("VcloudUUID.IsToken() = %v, want %v", got, tt.want) - } - }) - } -} - -// TestVcloudUUID_IsAppProfile tests the IsAppProfile function. -func TestVcloudUUID_IsAppPortProfile(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { // IsAppProfile - name: "IsAppProfile", - uuid: VcloudUUID(AppPortProfile.String() + validUUIDv4), - want: true, - }, - { // IsNotAppProfile - name: "IsNotAppProfile", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsAppPortProfile(); got != tt.want { - t.Errorf("VcloudUUID.IsAppPortProfile() = %v, want %v", got, tt.want) - } - }) - } -} - -// TestVcloudUUID_IsVDCComputePolicy tests the IsVDCComputePolicy function. -func TestVcloudUUID_IsVDCComputePolicy(t *testing.T) { - tests := []struct { - name string - uuid VcloudUUID - want bool - }{ - { // IsVDCComputePolicy - name: "IsVDCComputePolicy", - uuid: VcloudUUID(VDCComputePolicy.String() + validUUIDv4), - want: true, - }, - { // IsNotVDCComputePolicy - name: "IsNotVDCComputePolicy", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { // Empty string - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.uuid.IsVDCComputePolicy(); got != tt.want { - t.Errorf("VcloudUUID.IsVDCComputePolicy() = %v, want %v", got, tt.want) - } - }) - } -} - -// TestIsType tests the TestIsType function. -func TestTestIsType(t *testing.T) { - testCases := []struct { - name string - uuidType VcloudUUID - uuid VcloudUUID - want bool - }{ - { - name: "valid uuid", - uuidType: VM, - uuid: VcloudUUID(VM.String() + validUUIDv4), - want: true, - }, - { - name: "invalid uuid", - uuidType: VM, - uuid: "invalid-uuid", - want: false, - }, - { - name: "empty value", - uuidType: VM, - uuid: "", - want: false, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - err := TestIsType(tc.uuidType)(tc.uuid.String()) - if tc.want && err != nil { - t.Errorf("TestIsType() = %v, want %v", err, tc.want) - } - }) - } -} - -func TestIsGroup(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid VcloudUUID - want bool - }{ - { - name: "IsGroup", - uuid: VcloudUUID(Group.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotGroup", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479"), - want: false, - }, - { - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsGroup(tt.uuid.String()); got != tt.want { - t.Errorf("IsGroup() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsGateway. -func TestIsEdgeGateway(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid VcloudUUID - want bool - }{ - { - name: "IsGateway", - uuid: VcloudUUID(Gateway.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotGateway", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsEdgeGateway(tt.uuid.String()); got != tt.want { - t.Errorf("IsEdgeGateway() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsVDC. -func TestIsVDC(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid VcloudUUID - want bool - }{ - { - name: "IsVDC", - uuid: VcloudUUID(VDC.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotVDC", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsVDC(tt.uuid.String()); got != tt.want { - t.Errorf("IsVDC() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsVDCGroup. -func TestIsVDCGroup(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid VcloudUUID - want bool - }{ - { - name: "IsVDCGroup", - uuid: VcloudUUID(VDCGroup.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotVDCGroup", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsVDCGroup(tt.uuid.String()); got != tt.want { - t.Errorf("IsVDCGroup() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsNetwork. -func TestIsNetwork(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid VcloudUUID - want bool - }{ - { - name: "IsNetwork", - uuid: VcloudUUID(Network.String() + validUUIDv4), - want: true, - }, - { - name: "IsNotNetwork", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsNetwork(tt.uuid.String()); got != tt.want { - t.Errorf("IsNetwork() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsLoadBalancerPool. -func TestIsLoadBalancerPool(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid VcloudUUID - want bool - }{ - { // IsLoadBalancerPool - name: "IsLoadBalancerPool", - uuid: VcloudUUID(LoadBalancerPool.String() + validUUIDv4), - want: true, - }, - { // IsNotLoadBalancerPool - name: "IsNotLoadBalancerPool", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsLoadBalancerPool(tt.uuid.String()); got != tt.want { - t.Errorf("IsLoadBalancerPool() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsVDCStorageProfile. -func TestIsVDCStorageProfile(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid VcloudUUID - want bool - }{ - { // IsVDCStorageProfile - name: "IsVDCStorageProfile", - uuid: VcloudUUID(VDCStorageProfile.String() + validUUIDv4), - want: true, - }, - { // IsNotVDCStorageProfile - name: "IsNotVDCStorageProfile", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791"), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID(""), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsVDCStorageProfile(tt.uuid.String()); got != tt.want { - t.Errorf("IsVDCStorageProfile() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsVAPP. -func TestIsVAPP(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid string - want bool - }{ - { // IsVAPP - name: "IsVAPP", - uuid: VcloudUUID(VAPP.String() + validUUIDv4).String(), - want: true, - }, - { // IsNotVAPP - name: "IsNotVAPP", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791").String(), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID("").String(), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsVAPP(tt.uuid); got != tt.want { - t.Errorf("IsVAPP() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsDisk. -func TestIsDisk(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid string - want bool - }{ - { // IsDisk - name: "IsDisk", - uuid: VcloudUUID(Disk.String() + validUUIDv4).String(), - want: true, - }, - { // IsNotDisk - name: "IsNotDisk", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791").String(), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID("").String(), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsDisk(tt.uuid); got != tt.want { - t.Errorf("IsDisk() = %v, want %v", got, tt.want) - } - }) - } -} - -// IsSecurityGroup. -func TestIsSecurityGroup(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid string - want bool - }{ - { // IsSecurityGroup - name: "IsSecurityGroup", - uuid: VcloudUUID(SecurityGroup.String() + validUUIDv4).String(), - want: true, - }, - { // IsNotSecurityGroup - name: "IsNotSecurityGroup", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791").String(), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID("").String(), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsSecurityGroup(tt.uuid); got != tt.want { - t.Errorf("IsSecurityGroup() = %v, want %v", got, tt.want) - } - }) - } -} - -// TestIsVCDA. -func TestIsVCDA(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid string - want bool - }{ - { // IsVCDA - name: "IsVCDA", - uuid: VcloudUUID(VCDA.String() + validUUIDv4).String(), - want: true, - }, - { // IsNotVCDA - name: "IsNotVCDA", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791").String(), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID("").String(), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsVCDA(tt.uuid); got != tt.want { - t.Errorf("IsVCDA() = %v, want %v", got, tt.want) - } - }) - } -} - -// TestIsVM. -func TestIsVM(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid string - want bool - }{ - { // IsVM - name: "IsVM", - uuid: VcloudUUID(VM.String() + validUUIDv4).String(), - want: true, - }, - { // IsNotVM - name: "IsNotVM", - uuid: VcloudUUID("urn:vcloud:user:f47ac10b-58cc-4372-a567-0e02b2c3d4791").String(), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID("").String(), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsVM(tt.uuid); got != tt.want { - t.Errorf("IsVM() = %v, want %v", got, tt.want) - } - }) - } -} - -// TestIsUser. -func TestIsUser(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid string - want bool - }{ - { // IsUser - name: "IsUser", - uuid: VcloudUUID(User.String() + validUUIDv4).String(), - want: true, - }, - { // IsNotUser - name: "IsNotUser", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791").String(), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID("").String(), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsUser(tt.uuid); got != tt.want { - t.Errorf("IsUser() = %v, want %v", got, tt.want) - } - }) - } -} - -// TestIsToken. -func TestIsToken(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid string - want bool - }{ - { // IsToken - name: "IsToken", - uuid: VcloudUUID(Token.String() + validUUIDv4).String(), - want: true, - }, - { // IsNotToken - name: "IsNotToken", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d4791").String(), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID("").String(), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsToken(tt.uuid); got != tt.want { - t.Errorf("IsToken() = %v, want %v", got, tt.want) - } - }) - } -} - -// TestIsAppPortProfile. -func TestIsAppPortProfile(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid string - want bool - }{ - { // IsAppPortProfile - name: "IsAppPortProfile", - uuid: VcloudUUID(AppPortProfile.String() + validUUIDv4).String(), - want: true, - }, - { // IsNotAppPortProfile - name: "IsNotAppPortProfile", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479").String(), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID("").String(), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsAppPortProfile(tt.uuid); got != tt.want { - t.Errorf("IsAppPortProfile() = %v, want %v", got, tt.want) - } - }) - } -} - -// TestIsVDCComputePolicy. -func TestIsVDCComputePolicy(t *testing.T) { - tests := []struct { - name string - uuidType VcloudUUID - uuid string - want bool - }{ - { // IsVDCComputePolicy - name: "IsVDCComputePolicy", - uuid: VcloudUUID(VDCComputePolicy.String() + validUUIDv4).String(), - want: true, - }, - { // IsNotVDCComputePolicy - name: "IsNotVDCComputePolicy", - uuid: VcloudUUID("urn:vcloud:vm:f47ac10b-58cc-4372-a567-0e02b2c3d479").String(), - want: false, - }, - { // EmptyString - name: "EmptyString", - uuid: VcloudUUID("").String(), - want: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsVDCComputePolicy(tt.uuid); got != tt.want { - t.Errorf("IsAppPortProfile() = %v, want %v", got, tt.want) - } - }) - } -}