From aac1feb1f8ea09b3b4b6fae919b72cce53e54c47 Mon Sep 17 00:00:00 2001 From: Xu Wu Date: Fri, 28 Jul 2023 15:31:46 +0800 Subject: [PATCH] remove resourceid.go, use validate and parse from sdk --- ...chine_learning_compute_cluster_resource.go | 3 +- ...hine_learning_compute_instance_resource.go | 6 +- ...learning_datastore_blobstorage_resource.go | 2 +- ...arning_datastore_datalake_gen2_resource.go | 2 +- ...e_learning_datastore_fileshare_resource.go | 2 +- ...ine_learning_inference_cluster_resource.go | 6 +- ...machine_learning_synapse_spark_resource.go | 8 +- .../machine_learning_workspace_resource.go | 3 +- .../services/machinelearning/parse/compute.go | 78 ----------- .../machinelearning/parse/compute_cluster.go | 78 ----------- .../parse/compute_cluster_test.go | 131 ------------------ .../machinelearning/parse/compute_test.go | 131 ------------------ .../parse/inference_cluster.go | 78 ----------- .../parse/inference_cluster_test.go | 131 ------------------ .../parse/kubernetes_cluster.go | 72 ---------- .../parse/kubernetes_cluster_test.go | 115 --------------- .../machinelearning/parse/workspace.go | 72 ---------- .../machinelearning/parse/workspace_test.go | 115 --------------- .../services/machinelearning/resourceids.go | 10 -- .../validate/compute_cluster_id.go | 26 ---- .../validate/compute_cluster_id_test.go | 91 ------------ .../machinelearning/validate/compute_id.go | 26 ---- .../validate/compute_id_test.go | 91 ------------ .../validate/inference_cluster_id.go | 26 ---- .../validate/inference_cluster_id_test.go | 91 ------------ .../validate/kubernetes_cluster_id.go | 26 ---- .../validate/kubernetes_cluster_id_test.go | 79 ----------- .../machinelearning/validate/workspace_id.go | 26 ---- .../validate/workspace_id_test.go | 79 ----------- 29 files changed, 12 insertions(+), 1592 deletions(-) delete mode 100644 internal/services/machinelearning/parse/compute.go delete mode 100644 internal/services/machinelearning/parse/compute_cluster.go delete mode 100644 internal/services/machinelearning/parse/compute_cluster_test.go delete mode 100644 internal/services/machinelearning/parse/compute_test.go delete mode 100644 internal/services/machinelearning/parse/inference_cluster.go delete mode 100644 internal/services/machinelearning/parse/inference_cluster_test.go delete mode 100644 internal/services/machinelearning/parse/kubernetes_cluster.go delete mode 100644 internal/services/machinelearning/parse/kubernetes_cluster_test.go delete mode 100644 internal/services/machinelearning/parse/workspace.go delete mode 100644 internal/services/machinelearning/parse/workspace_test.go delete mode 100644 internal/services/machinelearning/resourceids.go delete mode 100644 internal/services/machinelearning/validate/compute_cluster_id.go delete mode 100644 internal/services/machinelearning/validate/compute_cluster_id_test.go delete mode 100644 internal/services/machinelearning/validate/compute_id.go delete mode 100644 internal/services/machinelearning/validate/compute_id_test.go delete mode 100644 internal/services/machinelearning/validate/inference_cluster_id.go delete mode 100644 internal/services/machinelearning/validate/inference_cluster_id_test.go delete mode 100644 internal/services/machinelearning/validate/kubernetes_cluster_id.go delete mode 100644 internal/services/machinelearning/validate/kubernetes_cluster_id_test.go delete mode 100644 internal/services/machinelearning/validate/workspace_id.go delete mode 100644 internal/services/machinelearning/validate/workspace_id_test.go diff --git a/internal/services/machinelearning/machine_learning_compute_cluster_resource.go b/internal/services/machinelearning/machine_learning_compute_cluster_resource.go index 8166ac81baf7..d481bf9c526d 100644 --- a/internal/services/machinelearning/machine_learning_compute_cluster_resource.go +++ b/internal/services/machinelearning/machine_learning_compute_cluster_resource.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -30,7 +29,7 @@ func resourceComputeCluster() *pluginsdk.Resource { Delete: resourceComputeClusterDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.ComputeClusterID(id) + _, err := machinelearningcomputes.ParseComputeID(id) return err }), diff --git a/internal/services/machinelearning/machine_learning_compute_instance_resource.go b/internal/services/machinelearning/machine_learning_compute_instance_resource.go index d3217409ef78..c14436394e14 100644 --- a/internal/services/machinelearning/machine_learning_compute_instance_resource.go +++ b/internal/services/machinelearning/machine_learning_compute_instance_resource.go @@ -22,8 +22,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -37,7 +35,7 @@ func resourceComputeInstance() *pluginsdk.Resource { Delete: resourceComputeInstanceDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.ComputeID(id) + _, err := machinelearningcomputes.ParseComputeID(id) return err }), @@ -61,7 +59,7 @@ func resourceComputeInstance() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.WorkspaceID, + ValidateFunc: workspaces.ValidateWorkspaceID, }, "location": commonschema.Location(), diff --git a/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go b/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go index a63f4e39e2a4..997211b76d73 100644 --- a/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go +++ b/internal/services/machinelearning/machine_learning_datastore_blobstorage_resource.go @@ -67,7 +67,7 @@ func (r MachineLearningDataStoreBlobStorage) Arguments() map[string]*pluginsdk.S Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.WorkspaceID, + ValidateFunc: workspaces.ValidateWorkspaceID, }, "storage_container_id": { diff --git a/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go b/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go index eeeb9b298750..0f7877209a87 100644 --- a/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go +++ b/internal/services/machinelearning/machine_learning_datastore_datalake_gen2_resource.go @@ -75,7 +75,7 @@ func (r MachineLearningDataStoreDataLakeGen2) Arguments() map[string]*pluginsdk. Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.WorkspaceID, + ValidateFunc: workspaces.ValidateWorkspaceID, }, "storage_container_id": { diff --git a/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go b/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go index bffba636de28..0dd3edd78058 100644 --- a/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go +++ b/internal/services/machinelearning/machine_learning_datastore_fileshare_resource.go @@ -63,7 +63,7 @@ func (r MachineLearningDataStoreFileShare) Arguments() map[string]*pluginsdk.Sch Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.WorkspaceID, + ValidateFunc: workspaces.ValidateWorkspaceID, }, "storage_fileshare_id": { diff --git a/internal/services/machinelearning/machine_learning_inference_cluster_resource.go b/internal/services/machinelearning/machine_learning_inference_cluster_resource.go index a5dec56fd268..7b894bdc1785 100644 --- a/internal/services/machinelearning/machine_learning_inference_cluster_resource.go +++ b/internal/services/machinelearning/machine_learning_inference_cluster_resource.go @@ -18,8 +18,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -34,7 +32,7 @@ func resourceAksInferenceCluster() *pluginsdk.Resource { Delete: resourceAksInferenceClusterDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.InferenceClusterID(id) + _, err := machinelearningcomputes.ParseComputeID(id) return err }), @@ -56,7 +54,7 @@ func resourceAksInferenceCluster() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.KubernetesClusterID, + ValidateFunc: managedclusters.ValidateLocationID, // remove in 3.0 of the provider DiffSuppressFunc: suppress.CaseDifference, }, diff --git a/internal/services/machinelearning/machine_learning_synapse_spark_resource.go b/internal/services/machinelearning/machine_learning_synapse_spark_resource.go index 70be77cbb0e1..a7a87a4517a9 100644 --- a/internal/services/machinelearning/machine_learning_synapse_spark_resource.go +++ b/internal/services/machinelearning/machine_learning_synapse_spark_resource.go @@ -18,8 +18,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/validate" synapseValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/synapse/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -34,7 +32,7 @@ func resourceSynapseSpark() *pluginsdk.Resource { Delete: resourceSynapseSparkDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.ComputeID(id) + _, err := machinelearningcomputes.ParseComputeID(id) return err }), @@ -58,7 +56,7 @@ func resourceSynapseSpark() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.WorkspaceID, + ValidateFunc: workspaces.ValidateWorkspaceID, }, "location": commonschema.Location(), @@ -164,7 +162,7 @@ func resourceSynapseSparkRead(d *pluginsdk.ResourceData, meta interface{}) error } d.Set("name", id.ComputeName) - workspaceId := parse.NewWorkspaceID(subscriptionId, id.ResourceGroupName, id.WorkspaceName) + workspaceId := workspaces.NewWorkspaceID(subscriptionId, id.ResourceGroupName, id.WorkspaceName) d.Set("machine_learning_workspace_id", workspaceId.ID()) if location := resp.Model.Location; location != nil { diff --git a/internal/services/machinelearning/machine_learning_workspace_resource.go b/internal/services/machinelearning/machine_learning_workspace_resource.go index a1d93a4359a5..37b0aafa5468 100644 --- a/internal/services/machinelearning/machine_learning_workspace_resource.go +++ b/internal/services/machinelearning/machine_learning_workspace_resource.go @@ -19,7 +19,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/features" appInsightsValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/applicationinsights/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/validate" storageValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -43,7 +42,7 @@ func resourceMachineLearningWorkspace() *pluginsdk.Resource { Delete: resourceMachineLearningWorkspaceDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.WorkspaceID(id) + _, err := workspaces.ParseWorkspaceID(id) return err }), diff --git a/internal/services/machinelearning/parse/compute.go b/internal/services/machinelearning/parse/compute.go deleted file mode 100644 index 38cbaa286d64..000000000000 --- a/internal/services/machinelearning/parse/compute.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ComputeId struct { - SubscriptionId string - ResourceGroup string - WorkspaceName string - Name string -} - -func NewComputeID(subscriptionId, resourceGroup, workspaceName, name string) ComputeId { - return ComputeId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - WorkspaceName: workspaceName, - Name: name, - } -} - -func (id ComputeId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Workspace Name %q", id.WorkspaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Compute", segmentsStr) -} - -func (id ComputeId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/computes/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.Name) -} - -// ComputeID parses a Compute ID into an ComputeId struct -func ComputeID(input string) (*ComputeId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an Compute ID: %+v", input, err) - } - - resourceId := ComputeId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("computes"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/machinelearning/parse/compute_cluster.go b/internal/services/machinelearning/parse/compute_cluster.go deleted file mode 100644 index 15712e763d68..000000000000 --- a/internal/services/machinelearning/parse/compute_cluster.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ComputeClusterId struct { - SubscriptionId string - ResourceGroup string - WorkspaceName string - ComputeName string -} - -func NewComputeClusterID(subscriptionId, resourceGroup, workspaceName, computeName string) ComputeClusterId { - return ComputeClusterId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - WorkspaceName: workspaceName, - ComputeName: computeName, - } -} - -func (id ComputeClusterId) String() string { - segments := []string{ - fmt.Sprintf("Compute Name %q", id.ComputeName), - fmt.Sprintf("Workspace Name %q", id.WorkspaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Compute Cluster", segmentsStr) -} - -func (id ComputeClusterId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/computes/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.ComputeName) -} - -// ComputeClusterID parses a ComputeCluster ID into an ComputeClusterId struct -func ComputeClusterID(input string) (*ComputeClusterId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ComputeCluster ID: %+v", input, err) - } - - resourceId := ComputeClusterId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { - return nil, err - } - if resourceId.ComputeName, err = id.PopSegment("computes"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/machinelearning/parse/compute_cluster_test.go b/internal/services/machinelearning/parse/compute_cluster_test.go deleted file mode 100644 index 05b9a9ffb744..000000000000 --- a/internal/services/machinelearning/parse/compute_cluster_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ComputeClusterId{} - -func TestComputeClusterIDFormatter(t *testing.T) { - actual := NewComputeClusterID("00000000-0000-0000-0000-000000000000", "resGroup1", "workspace1", "cluster1").ID() - expected := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/cluster1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestComputeClusterID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ComputeClusterId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Error: true, - }, - - { - // missing WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/", - Error: true, - }, - - { - // missing value for WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/", - Error: true, - }, - - { - // missing ComputeName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/", - Error: true, - }, - - { - // missing value for ComputeName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/cluster1", - Expected: &ComputeClusterId{ - SubscriptionId: "00000000-0000-0000-0000-000000000000", - ResourceGroup: "resGroup1", - WorkspaceName: "workspace1", - ComputeName: "cluster1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.MACHINELEARNINGSERVICES/WORKSPACES/WORKSPACE1/COMPUTES/CLUSTER1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ComputeClusterID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - if actual.ComputeName != v.Expected.ComputeName { - t.Fatalf("Expected %q but got %q for ComputeName", v.Expected.ComputeName, actual.ComputeName) - } - } -} diff --git a/internal/services/machinelearning/parse/compute_test.go b/internal/services/machinelearning/parse/compute_test.go deleted file mode 100644 index 1ace9a6af3c5..000000000000 --- a/internal/services/machinelearning/parse/compute_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ComputeId{} - -func TestComputeIDFormatter(t *testing.T) { - actual := NewComputeID("00000000-0000-0000-0000-000000000000", "resGroup1", "workspace1", "compute1").ID() - expected := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/compute1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestComputeID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ComputeId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Error: true, - }, - - { - // missing WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/", - Error: true, - }, - - { - // missing value for WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/compute1", - Expected: &ComputeId{ - SubscriptionId: "00000000-0000-0000-0000-000000000000", - ResourceGroup: "resGroup1", - WorkspaceName: "workspace1", - Name: "compute1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.MACHINELEARNINGSERVICES/WORKSPACES/WORKSPACE1/COMPUTES/COMPUTE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ComputeID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/machinelearning/parse/inference_cluster.go b/internal/services/machinelearning/parse/inference_cluster.go deleted file mode 100644 index 8b29ebf9df63..000000000000 --- a/internal/services/machinelearning/parse/inference_cluster.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type InferenceClusterId struct { - SubscriptionId string - ResourceGroup string - WorkspaceName string - ComputeName string -} - -func NewInferenceClusterID(subscriptionId, resourceGroup, workspaceName, computeName string) InferenceClusterId { - return InferenceClusterId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - WorkspaceName: workspaceName, - ComputeName: computeName, - } -} - -func (id InferenceClusterId) String() string { - segments := []string{ - fmt.Sprintf("Compute Name %q", id.ComputeName), - fmt.Sprintf("Workspace Name %q", id.WorkspaceName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Inference Cluster", segmentsStr) -} - -func (id InferenceClusterId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/computes/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.ComputeName) -} - -// InferenceClusterID parses a InferenceCluster ID into an InferenceClusterId struct -func InferenceClusterID(input string) (*InferenceClusterId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an InferenceCluster ID: %+v", input, err) - } - - resourceId := InferenceClusterId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { - return nil, err - } - if resourceId.ComputeName, err = id.PopSegment("computes"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/machinelearning/parse/inference_cluster_test.go b/internal/services/machinelearning/parse/inference_cluster_test.go deleted file mode 100644 index 57b1d4ea6513..000000000000 --- a/internal/services/machinelearning/parse/inference_cluster_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = InferenceClusterId{} - -func TestInferenceClusterIDFormatter(t *testing.T) { - actual := NewInferenceClusterID("00000000-0000-0000-0000-000000000000", "resGroup1", "workspace1", "cluster1").ID() - expected := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/cluster1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestInferenceClusterID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *InferenceClusterId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Error: true, - }, - - { - // missing WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/", - Error: true, - }, - - { - // missing value for WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/", - Error: true, - }, - - { - // missing ComputeName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/", - Error: true, - }, - - { - // missing value for ComputeName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/cluster1", - Expected: &InferenceClusterId{ - SubscriptionId: "00000000-0000-0000-0000-000000000000", - ResourceGroup: "resGroup1", - WorkspaceName: "workspace1", - ComputeName: "cluster1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.MACHINELEARNINGSERVICES/WORKSPACES/WORKSPACE1/COMPUTES/CLUSTER1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := InferenceClusterID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - if actual.ComputeName != v.Expected.ComputeName { - t.Fatalf("Expected %q but got %q for ComputeName", v.Expected.ComputeName, actual.ComputeName) - } - } -} diff --git a/internal/services/machinelearning/parse/kubernetes_cluster.go b/internal/services/machinelearning/parse/kubernetes_cluster.go deleted file mode 100644 index bcdac130f0a4..000000000000 --- a/internal/services/machinelearning/parse/kubernetes_cluster.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type KubernetesClusterId struct { - SubscriptionId string - ResourceGroup string - ManagedClusterName string -} - -func NewKubernetesClusterID(subscriptionId, resourceGroup, managedClusterName string) KubernetesClusterId { - return KubernetesClusterId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - ManagedClusterName: managedClusterName, - } -} - -func (id KubernetesClusterId) String() string { - segments := []string{ - fmt.Sprintf("Managed Cluster Name %q", id.ManagedClusterName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Kubernetes Cluster", segmentsStr) -} - -func (id KubernetesClusterId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ManagedClusterName) -} - -// KubernetesClusterID parses a KubernetesCluster ID into an KubernetesClusterId struct -func KubernetesClusterID(input string) (*KubernetesClusterId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an KubernetesCluster ID: %+v", input, err) - } - - resourceId := KubernetesClusterId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.ManagedClusterName, err = id.PopSegment("managedClusters"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/machinelearning/parse/kubernetes_cluster_test.go b/internal/services/machinelearning/parse/kubernetes_cluster_test.go deleted file mode 100644 index fb2a75cc1aec..000000000000 --- a/internal/services/machinelearning/parse/kubernetes_cluster_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = KubernetesClusterId{} - -func TestKubernetesClusterIDFormatter(t *testing.T) { - actual := NewKubernetesClusterID("00000000-0000-0000-0000-000000000000", "resGroup1", "cluster1").ID() - expected := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestKubernetesClusterID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *KubernetesClusterId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Error: true, - }, - - { - // missing ManagedClusterName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ContainerService/", - Error: true, - }, - - { - // missing value for ManagedClusterName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ContainerService/managedClusters/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1", - Expected: &KubernetesClusterId{ - SubscriptionId: "00000000-0000-0000-0000-000000000000", - ResourceGroup: "resGroup1", - ManagedClusterName: "cluster1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/CLUSTER1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := KubernetesClusterID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ManagedClusterName != v.Expected.ManagedClusterName { - t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) - } - } -} diff --git a/internal/services/machinelearning/parse/workspace.go b/internal/services/machinelearning/parse/workspace.go deleted file mode 100644 index 25da20d432fc..000000000000 --- a/internal/services/machinelearning/parse/workspace.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type WorkspaceId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewWorkspaceID(subscriptionId, resourceGroup, name string) WorkspaceId { - return WorkspaceId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id WorkspaceId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Workspace", segmentsStr) -} - -func (id WorkspaceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// WorkspaceID parses a Workspace ID into an WorkspaceId struct -func WorkspaceID(input string) (*WorkspaceId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an Workspace ID: %+v", input, err) - } - - resourceId := WorkspaceId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("workspaces"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/machinelearning/parse/workspace_test.go b/internal/services/machinelearning/parse/workspace_test.go deleted file mode 100644 index b0d162a0e67f..000000000000 --- a/internal/services/machinelearning/parse/workspace_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = WorkspaceId{} - -func TestWorkspaceIDFormatter(t *testing.T) { - actual := NewWorkspaceID("00000000-0000-0000-0000-000000000000", "resGroup1", "workspace1").ID() - expected := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestWorkspaceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *WorkspaceId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1", - Expected: &WorkspaceId{ - SubscriptionId: "00000000-0000-0000-0000-000000000000", - ResourceGroup: "resGroup1", - Name: "workspace1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.MACHINELEARNINGSERVICES/WORKSPACES/WORKSPACE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := WorkspaceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/machinelearning/resourceids.go b/internal/services/machinelearning/resourceids.go deleted file mode 100644 index 7019bb4200fc..000000000000 --- a/internal/services/machinelearning/resourceids.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package machinelearning - -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ComputeCluster -id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/cluster1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=InferenceCluster -id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/cluster1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=KubernetesCluster -id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Workspace -id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Compute -id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/compute1 diff --git a/internal/services/machinelearning/validate/compute_cluster_id.go b/internal/services/machinelearning/validate/compute_cluster_id.go deleted file mode 100644 index ce1625944834..000000000000 --- a/internal/services/machinelearning/validate/compute_cluster_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" -) - -func ComputeClusterID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ComputeClusterID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/machinelearning/validate/compute_cluster_id_test.go b/internal/services/machinelearning/validate/compute_cluster_id_test.go deleted file mode 100644 index 6ef4565673fa..000000000000 --- a/internal/services/machinelearning/validate/compute_cluster_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestComputeClusterID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Valid: false, - }, - - { - // missing WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/", - Valid: false, - }, - - { - // missing value for WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/", - Valid: false, - }, - - { - // missing ComputeName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/", - Valid: false, - }, - - { - // missing value for ComputeName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/cluster1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.MACHINELEARNINGSERVICES/WORKSPACES/WORKSPACE1/COMPUTES/CLUSTER1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ComputeClusterID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/machinelearning/validate/compute_id.go b/internal/services/machinelearning/validate/compute_id.go deleted file mode 100644 index 3003dd4b85f5..000000000000 --- a/internal/services/machinelearning/validate/compute_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" -) - -func ComputeID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ComputeID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/machinelearning/validate/compute_id_test.go b/internal/services/machinelearning/validate/compute_id_test.go deleted file mode 100644 index 037b3ecf03d8..000000000000 --- a/internal/services/machinelearning/validate/compute_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestComputeID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Valid: false, - }, - - { - // missing WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/", - Valid: false, - }, - - { - // missing value for WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/compute1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.MACHINELEARNINGSERVICES/WORKSPACES/WORKSPACE1/COMPUTES/COMPUTE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ComputeID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/machinelearning/validate/inference_cluster_id.go b/internal/services/machinelearning/validate/inference_cluster_id.go deleted file mode 100644 index c65cdefbfe7d..000000000000 --- a/internal/services/machinelearning/validate/inference_cluster_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" -) - -func InferenceClusterID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.InferenceClusterID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/machinelearning/validate/inference_cluster_id_test.go b/internal/services/machinelearning/validate/inference_cluster_id_test.go deleted file mode 100644 index 5c464e901cbb..000000000000 --- a/internal/services/machinelearning/validate/inference_cluster_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestInferenceClusterID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Valid: false, - }, - - { - // missing WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/", - Valid: false, - }, - - { - // missing value for WorkspaceName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/", - Valid: false, - }, - - { - // missing ComputeName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/", - Valid: false, - }, - - { - // missing value for ComputeName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/computes/cluster1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.MACHINELEARNINGSERVICES/WORKSPACES/WORKSPACE1/COMPUTES/CLUSTER1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := InferenceClusterID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/machinelearning/validate/kubernetes_cluster_id.go b/internal/services/machinelearning/validate/kubernetes_cluster_id.go deleted file mode 100644 index 9970c010eb15..000000000000 --- a/internal/services/machinelearning/validate/kubernetes_cluster_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" -) - -func KubernetesClusterID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.KubernetesClusterID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/machinelearning/validate/kubernetes_cluster_id_test.go b/internal/services/machinelearning/validate/kubernetes_cluster_id_test.go deleted file mode 100644 index c38915715879..000000000000 --- a/internal/services/machinelearning/validate/kubernetes_cluster_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestKubernetesClusterID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Valid: false, - }, - - { - // missing ManagedClusterName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ContainerService/", - Valid: false, - }, - - { - // missing value for ManagedClusterName - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ContainerService/managedClusters/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.ContainerService/managedClusters/cluster1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/CLUSTER1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := KubernetesClusterID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/machinelearning/validate/workspace_id.go b/internal/services/machinelearning/validate/workspace_id.go deleted file mode 100644 index bbe20a66d530..000000000000 --- a/internal/services/machinelearning/validate/workspace_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/machinelearning/parse" -) - -func WorkspaceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.WorkspaceID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/machinelearning/validate/workspace_id_test.go b/internal/services/machinelearning/validate/workspace_id_test.go deleted file mode 100644 index 28b36977de05..000000000000 --- a/internal/services/machinelearning/validate/workspace_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestWorkspaceID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.MachineLearningServices/workspaces/workspace1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/00000000-0000-0000-0000-000000000000/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.MACHINELEARNINGSERVICES/WORKSPACES/WORKSPACE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := WorkspaceID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -}