Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
favoretti committed May 26, 2021
1 parent c745fec commit 245103e
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,111 +6,110 @@ import (

"github.com/Azure/azure-sdk-for-go/services/machinelearningservices/mgmt/2020-04-01/machinelearningservices"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/pluginsdk"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/validation"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/machinelearning/parse"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"

azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func resourceComputeCluster() *schema.Resource {
return &schema.Resource{
func resourceComputeCluster() *pluginsdk.Resource {
return &pluginsdk.Resource{
Create: resourceComputeClusterCreate,
Read: resourceComputeClusterRead,
Delete: resourceComputeClusterDelete,

Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error {
Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error {
_, err := parse.ComputeClusterID(id)
return err
}),

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(30 * time.Minute),
Read: schema.DefaultTimeout(5 * time.Minute),
Delete: schema.DefaultTimeout(30 * time.Minute),
Timeouts: &pluginsdk.ResourceTimeout{
Create: pluginsdk.DefaultTimeout(30 * time.Minute),
Read: pluginsdk.DefaultTimeout(5 * time.Minute),
Delete: pluginsdk.DefaultTimeout(30 * time.Minute),
},

Schema: map[string]*schema.Schema{
Schema: map[string]*pluginsdk.Schema{
"name": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},

"machine_learning_workspace_id": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},

"location": azure.SchemaLocation(),

"vm_size": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},

"vm_priority": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},

"identity": {
Type: schema.TypeList,
Type: pluginsdk.TypeList,
Required: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"type": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(machinelearningservices.SystemAssigned),
}, false),
},
"principal_id": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Computed: true,
},
"tenant_id": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Computed: true,
},
},
},
},

"scale_settings": {
Type: schema.TypeList,
Type: pluginsdk.TypeList,
Required: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"max_node_count": {
Type: schema.TypeInt,
Type: pluginsdk.TypeInt,
Required: true,
ForceNew: true,
},
"min_node_count": {
Type: schema.TypeInt,
Type: pluginsdk.TypeInt,
Required: true,
ForceNew: true,
},
"node_idle_time_before_scale_down": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},
Expand All @@ -119,13 +118,13 @@ func resourceComputeCluster() *schema.Resource {
},

"description": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
},

"subnet_resource_id": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
},
Expand All @@ -135,7 +134,7 @@ func resourceComputeCluster() *schema.Resource {
}
}

func resourceComputeClusterCreate(d *schema.ResourceData, meta interface{}) error {
func resourceComputeClusterCreate(d *pluginsdk.ResourceData, meta interface{}) error {
mlWorkspacesClient := meta.(*clients.Client).MachineLearning.WorkspacesClient
mlComputeClient := meta.(*clients.Client).MachineLearning.MachineLearningComputeClient
ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)
Expand Down Expand Up @@ -207,7 +206,7 @@ func resourceComputeClusterCreate(d *schema.ResourceData, meta interface{}) erro
return resourceComputeClusterRead(d, meta)
}

func resourceComputeClusterRead(d *schema.ResourceData, meta interface{}) error {
func resourceComputeClusterRead(d *pluginsdk.ResourceData, meta interface{}) error {
mlComputeClient := meta.(*clients.Client).MachineLearning.MachineLearningComputeClient
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down Expand Up @@ -256,7 +255,7 @@ func resourceComputeClusterRead(d *schema.ResourceData, meta interface{}) error
return tags.FlattenAndSet(d, computeResource.Tags)
}

func resourceComputeClusterDelete(d *schema.ResourceData, meta interface{}) error {
func resourceComputeClusterDelete(d *pluginsdk.ResourceData, meta interface{}) error {
mlComputeClient := meta.(*clients.Client).MachineLearning.MachineLearningComputeClient
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance/check"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/machinelearning/parse"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/pluginsdk"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand All @@ -20,10 +19,10 @@ func TestAccComputeCluster_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_machine_learning_compute_cluster", "test")
r := ComputeClusterResource{}

data.ResourceTest(t, r, []resource.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: resource.ComposeTestCheckFunc(
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("identity.#").HasValue("1"),
check.That(data.ResourceName).Key("identity.0.type").HasValue("SystemAssigned"),
Expand All @@ -43,10 +42,10 @@ func TestAccComputeCluster_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_machine_learning_compute_cluster", "test")
r := ComputeClusterResource{}

data.ResourceTest(t, r, []resource.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: resource.ComposeTestCheckFunc(
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("identity.#").HasValue("1"),
check.That(data.ResourceName).Key("identity.0.type").HasValue("SystemAssigned"),
Expand All @@ -62,7 +61,7 @@ func TestAccComputeCluster_requiresImport(t *testing.T) {
})
}

func (r ComputeClusterResource) Exists(ctx context.Context, client *clients.Client, state *terraform.InstanceState) (*bool, error) {
func (r ComputeClusterResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
computeClusterClient := client.MachineLearning.MachineLearningComputeClient
id, err := parse.ComputeClusterID(state.ID)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2021-03-01/containerservice"
"github.com/Azure/azure-sdk-for-go/services/machinelearningservices/mgmt/2020-04-01/machinelearningservices"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/pluginsdk"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/validation"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
Expand All @@ -18,39 +18,38 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/machinelearning/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"

azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/suppress"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func resourceAksInferenceCluster() *schema.Resource {
return &schema.Resource{
func resourceAksInferenceCluster() *pluginsdk.Resource {
return &pluginsdk.Resource{
Create: resourceAksInferenceClusterCreate,
Read: resourceAksInferenceClusterRead,
Delete: resourceAksInferenceClusterDelete,

Importer: azSchema.ValidateResourceIDPriorToImport(func(id string) error {
Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error {
_, err := parse.InferenceClusterID(id)
return err
}),

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(30 * time.Minute),
Read: schema.DefaultTimeout(5 * time.Minute),
Update: schema.DefaultTimeout(30 * time.Minute),
Delete: schema.DefaultTimeout(30 * time.Minute),
Timeouts: &pluginsdk.ResourceTimeout{
Create: pluginsdk.DefaultTimeout(30 * time.Minute),
Read: pluginsdk.DefaultTimeout(5 * time.Minute),
Update: pluginsdk.DefaultTimeout(30 * time.Minute),
Delete: pluginsdk.DefaultTimeout(30 * time.Minute),
},

Schema: map[string]*schema.Schema{
Schema: map[string]*pluginsdk.Schema{
"name": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},

"kubernetes_cluster_id": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.KubernetesClusterID,
Expand All @@ -61,13 +60,13 @@ func resourceAksInferenceCluster() *schema.Resource {
"location": azure.SchemaLocation(),

"machine_learning_workspace_id": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},

"cluster_purpose": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Default: string(machinelearningservices.FastProd),
Expand All @@ -79,32 +78,32 @@ func resourceAksInferenceCluster() *schema.Resource {
},

"description": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
},

"ssl": {
Type: schema.TypeList,
Type: pluginsdk.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"cert": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Default: "",
},
"key": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Default: "",
},
"cname": {
Type: schema.TypeString,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Default: "",
Expand All @@ -118,7 +117,7 @@ func resourceAksInferenceCluster() *schema.Resource {
}
}

func resourceAksInferenceClusterCreate(d *schema.ResourceData, meta interface{}) error {
func resourceAksInferenceClusterCreate(d *pluginsdk.ResourceData, meta interface{}) error {
mlComputeClient := meta.(*clients.Client).MachineLearning.MachineLearningComputeClient
aksClient := meta.(*clients.Client).Containers.KubernetesClustersClient
ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)
Expand Down Expand Up @@ -178,7 +177,7 @@ func resourceAksInferenceClusterCreate(d *schema.ResourceData, meta interface{})
return resourceAksInferenceClusterRead(d, meta)
}

func resourceAksInferenceClusterRead(d *schema.ResourceData, meta interface{}) error {
func resourceAksInferenceClusterRead(d *pluginsdk.ResourceData, meta interface{}) error {
mlComputeClient := meta.(*clients.Client).MachineLearning.MachineLearningComputeClient
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down Expand Up @@ -229,7 +228,7 @@ func resourceAksInferenceClusterRead(d *schema.ResourceData, meta interface{}) e
return tags.FlattenAndSet(d, computeResource.Tags)
}

func resourceAksInferenceClusterDelete(d *schema.ResourceData, meta interface{}) error {
func resourceAksInferenceClusterDelete(d *pluginsdk.ResourceData, meta interface{}) error {
mlComputeClient := meta.(*clients.Client).MachineLearning.MachineLearningComputeClient
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand All @@ -250,7 +249,7 @@ func resourceAksInferenceClusterDelete(d *schema.ResourceData, meta interface{})
return nil
}

func expandAksComputeProperties(aks *containerservice.ManagedCluster, d *schema.ResourceData) machinelearningservices.AKS {
func expandAksComputeProperties(aks *containerservice.ManagedCluster, d *pluginsdk.ResourceData) machinelearningservices.AKS {
return machinelearningservices.AKS{
Properties: &machinelearningservices.AKSProperties{
ClusterFqdn: utils.String(*aks.Fqdn),
Expand Down
Loading

0 comments on commit 245103e

Please sign in to comment.