Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new resource azurerm_stack_hci_deployment_setting #25646

Merged
merged 19 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/labeler-issue-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ service/automation:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_automation_((.|\n)*)###'

service/azure-stack-hci:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_stack_hci_cluster((.|\n)*)###'
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_stack_hci_((.|\n)*)###'

service/batch:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_batch_((.|\n)*)###'
Expand Down
5 changes: 5 additions & 0 deletions internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import (
elasticsan "github.com/hashicorp/terraform-provider-azurerm/internal/services/elasticsan/client"
eventgrid "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventgrid/client"
eventhub "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventhub/client"
extendedlocation "github.com/hashicorp/terraform-provider-azurerm/internal/services/extendedlocation/client"
fluidrelay "github.com/hashicorp/terraform-provider-azurerm/internal/services/fluidrelay/client"
frontdoor "github.com/hashicorp/terraform-provider-azurerm/internal/services/frontdoor/client"
graph "github.com/hashicorp/terraform-provider-azurerm/internal/services/graphservices/client"
Expand Down Expand Up @@ -210,6 +211,7 @@ type Client struct {
ElasticSan *elasticsan.Client
EventGrid *eventgrid_v2022_06_15.Client
Eventhub *eventhub.Client
ExtendedLocation *extendedlocation.Client
FluidRelay *fluidrelay_2022_05_26.Client
Frontdoor *frontdoor.Client
Graph *graph.Client
Expand Down Expand Up @@ -447,6 +449,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
if client.Eventhub, err = eventhub.NewClient(o); err != nil {
return fmt.Errorf("building clients for Eventhub: %+v", err)
}
if client.ExtendedLocation, err = extendedlocation.NewClient(o); err != nil {
return fmt.Errorf("building clients for ExtendedLocation: %+v", err)
}
if client.FluidRelay, err = fluidrelay.NewClient(o); err != nil {
return fmt.Errorf("building clients for FluidRelay: %+v", err)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/features/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func Default() UserFeatures {
ApplicationInsights: ApplicationInsightFeatures{
DisableGeneratedRule: false,
},
AzureStackHci: AzureStackHciFeatures{
DeleteArcBridgeOnDestroy: false,
DeleteCustomLocationOnDestroy: false,
},
CognitiveAccount: CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: true,
},
Expand Down
6 changes: 6 additions & 0 deletions internal/features/user_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type UserFeatures struct {
ApiManagement ApiManagementFeatures
AppConfiguration AppConfigurationFeatures
ApplicationInsights ApplicationInsightFeatures
AzureStackHci AzureStackHciFeatures
CognitiveAccount CognitiveAccountFeatures
VirtualMachine VirtualMachineFeatures
VirtualMachineScaleSet VirtualMachineScaleSetFeatures
Expand Down Expand Up @@ -71,6 +72,11 @@ type ApplicationInsightFeatures struct {
DisableGeneratedRule bool
}

type AzureStackHciFeatures struct {
DeleteArcBridgeOnDestroy bool
DeleteCustomLocationOnDestroy bool
}

type ManagedDiskFeatures struct {
ExpandWithoutDowntime bool
}
Expand Down
37 changes: 35 additions & 2 deletions internal/provider/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func schemaFeatures(supportLegacyTestSuite bool) *pluginsdk.Schema {
// NOTE: if there's only one nested field these want to be Required (since there's no point
// specifying the block otherwise) - however for 2+ they should be optional
featuresMap := map[string]*pluginsdk.Schema{
//lintignore:XS003
// lintignore:XS003
"api_management": {
Type: pluginsdk.TypeList,
Optional: true,
Expand Down Expand Up @@ -73,6 +73,26 @@ func schemaFeatures(supportLegacyTestSuite bool) *pluginsdk.Schema {
},
},

"azure_stack_hci": {
Type: pluginsdk.TypeList,
Optional: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"delete_arc_bridge_on_destroy": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},
"delete_custom_location_on_destroy": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},
},
},
},

"cognitive_account": {
Type: pluginsdk.TypeList,
Optional: true,
Expand Down Expand Up @@ -189,7 +209,7 @@ func schemaFeatures(supportLegacyTestSuite bool) *pluginsdk.Schema {
},
},

//lintignore:XS003
// lintignore:XS003
"virtual_machine": {
Type: pluginsdk.TypeList,
Optional: true,
Expand Down Expand Up @@ -409,6 +429,19 @@ func expandFeatures(input []interface{}) features.UserFeatures {
}
}

if raw, ok := val["azure_stack_hci"]; ok {
items := raw.([]interface{})
if len(items) > 0 && items[0] != nil {
azureStackHciRaw := items[0].(map[string]interface{})
if v, ok := azureStackHciRaw["delete_arc_bridge_on_destroy"]; ok {
featuresMap.AzureStackHci.DeleteArcBridgeOnDestroy = v.(bool)
}
if v, ok := azureStackHciRaw["delete_custom_location_on_destroy"]; ok {
featuresMap.AzureStackHci.DeleteCustomLocationOnDestroy = v.(bool)
}
}
}

if raw, ok := val["cognitive_account"]; ok {
items := raw.([]interface{})
if len(items) > 0 && items[0] != nil {
Expand Down
24 changes: 24 additions & 0 deletions internal/provider/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func TestExpandFeatures(t *testing.T) {
ApplicationInsights: features.ApplicationInsightFeatures{
DisableGeneratedRule: false,
},
AzureStackHci: features.AzureStackHciFeatures{
DeleteArcBridgeOnDestroy: false,
DeleteCustomLocationOnDestroy: false,
},
CognitiveAccount: features.CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: true,
},
Expand Down Expand Up @@ -105,6 +109,12 @@ func TestExpandFeatures(t *testing.T) {
"disable_generated_rule": true,
},
},
"azure_stack_hci": []interface{}{
map[string]interface{}{
"delete_arc_bridge_on_destroy": true,
"delete_custom_location_on_destroy": true,
},
},
"cognitive_account": []interface{}{
map[string]interface{}{
"purge_soft_delete_on_destroy": true,
Expand Down Expand Up @@ -193,6 +203,10 @@ func TestExpandFeatures(t *testing.T) {
ApplicationInsights: features.ApplicationInsightFeatures{
DisableGeneratedRule: true,
},
AzureStackHci: features.AzureStackHciFeatures{
DeleteArcBridgeOnDestroy: true,
DeleteCustomLocationOnDestroy: true,
},
CognitiveAccount: features.CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: true,
},
Expand Down Expand Up @@ -266,6 +280,12 @@ func TestExpandFeatures(t *testing.T) {
"disable_generated_rule": false,
},
},
"azure_stack_hci": []interface{}{
map[string]interface{}{
"delete_arc_bridge_on_destroy": false,
"delete_custom_location_on_destroy": false,
},
},
"cognitive_account": []interface{}{
map[string]interface{}{
"purge_soft_delete_on_destroy": false,
Expand Down Expand Up @@ -354,6 +374,10 @@ func TestExpandFeatures(t *testing.T) {
ApplicationInsights: features.ApplicationInsightFeatures{
DisableGeneratedRule: false,
},
AzureStackHci: features.AzureStackHciFeatures{
DeleteArcBridgeOnDestroy: false,
DeleteCustomLocationOnDestroy: false,
},
CognitiveAccount: features.CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: false,
},
Expand Down
4 changes: 3 additions & 1 deletion internal/services/azurestackhci/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ func (r Registration) DataSources() []sdk.DataSource {
}

func (r Registration) Resources() []sdk.Resource {
return []sdk.Resource{}
return []sdk.Resource{
StackHCIDeploymentSettingResource{},
}
}
Loading
Loading