Skip to content

Commit 89ad114

Browse files
committed
fixed linting issues and refactoring AVMC as per exa-infra PR feedback
1 parent 6402ede commit 89ad114

File tree

4 files changed

+68
-61
lines changed

4 files changed

+68
-61
lines changed

internal/service/odb/cloud_autonomous_vm_cluster.go

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Copyright (c) HashiCorp, Inc.
2-
// SPDX-License-Identifier: MPL-2.0
1+
// Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
32

43
package odb
54

@@ -60,6 +59,7 @@ var ResourceCloudAutonomousVMCluster = newResourceCloudAutonomousVmCluster
6059
type resourceCloudAutonomousVmCluster struct {
6160
framework.ResourceWithModel[cloudAutonomousVmClusterResourceModel]
6261
framework.WithTimeouts
62+
framework.WithImportByID
6363
}
6464

6565
func (r *resourceCloudAutonomousVmCluster) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
@@ -339,30 +339,55 @@ func (r *resourceCloudAutonomousVmCluster) Schema(ctx context.Context, req resou
339339

340340
NestedObject: schema.NestedBlockObject{
341341
Attributes: map[string]schema.Attribute{
342-
"days_of_week": schema.SetAttribute{
343-
ElementType: fwtypes.NewObjectTypeOf[dayWeekNameAutonomousVmClusterMaintenanceWindowResourceModel](ctx),
342+
"custom_action_timeout_in_mins": schema.Int32Attribute{
344343
Optional: true,
345344
Computed: true,
346-
Description: "The day of week of the Autonomous VM cluster.",
345+
Description: "The custom action timeout in minutes for the maintenance window.",
347346
},
348-
"months": schema.SetAttribute{
349-
ElementType: fwtypes.NewObjectTypeOf[monthNameAutonomousVmClusterMaintenanceWindowResourceModel](ctx),
347+
"days_of_week": schema.SetAttribute{
348+
ElementType: fwtypes.NewObjectTypeOf[dayWeekNameAutonomousVmClusterMaintenanceWindowResourceModel](ctx),
350349
Optional: true,
351350
Computed: true,
352-
Description: "The month of the Autonomous VM cluster.",
351+
Description: "The days of the week when maintenance can be performed.",
353352
},
354353
"hours_of_day": schema.SetAttribute{
355354
ElementType: types.Int32Type,
356355
Optional: true,
357356
Computed: true,
357+
Description: "The hours of the day when maintenance can be performed.",
358+
},
359+
"is_custom_action_timeout_enabled": schema.BoolAttribute{
360+
Optional: true,
361+
Computed: true,
362+
Description: "Indicates whether custom action timeout is enabled for the maintenance window.",
358363
},
359364
"lead_time_in_weeks": schema.Int32Attribute{
360-
Optional: true,
361-
Computed: true,
365+
Optional: true,
366+
Computed: true,
367+
Description: "The lead time in weeks before the maintenance window.",
368+
},
369+
"months": schema.SetAttribute{
370+
ElementType: fwtypes.NewObjectTypeOf[monthNameAutonomousVmClusterMaintenanceWindowResourceModel](ctx),
371+
Optional: true,
372+
Computed: true,
373+
Description: "The months when maintenance can be performed.",
374+
},
375+
"patching_mode": schema.StringAttribute{
376+
Optional: true,
377+
Computed: true,
378+
CustomType: fwtypes.StringEnumType[odbtypes.PatchingModeType](),
379+
Description: "The patching mode for the maintenance window.",
362380
},
363381
"preference": schema.StringAttribute{
364-
Required: true,
365-
CustomType: fwtypes.StringEnumType[odbtypes.PreferenceType](),
382+
Required: true,
383+
CustomType: fwtypes.StringEnumType[odbtypes.PreferenceType](),
384+
Description: "The preference for the maintenance window scheduling.",
385+
},
386+
"weeks_of_month": schema.SetAttribute{
387+
ElementType: types.Int32Type,
388+
Optional: true,
389+
Computed: true,
390+
Description: "Indicates whether to skip release updates during maintenance.",
366391
},
367392
},
368393
},
@@ -651,12 +676,15 @@ type cloudAutonomousVmClusterResourceModel struct {
651676
}
652677

653678
type cloudAutonomousVmClusterMaintenanceWindowResourceModel struct {
654-
DaysOfWeek fwtypes.SetNestedObjectValueOf[dayWeekNameAutonomousVmClusterMaintenanceWindowResourceModel] `tfsdk:"days_of_week"`
655-
HoursOfDay fwtypes.SetValueOf[types.Int32] `tfsdk:"hours_of_day"`
656-
LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"`
657-
Months fwtypes.SetNestedObjectValueOf[monthNameAutonomousVmClusterMaintenanceWindowResourceModel] `tfsdk:"months"`
658-
Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"`
659-
WeeksOfMonth fwtypes.SetValueOf[types.Int32] `tfsdk:"weeks_of_month"`
679+
CustomActionTimeoutInMins types.Int32 `tfsdk:"custom_action_timeout_in_mins"`
680+
DaysOfWeek fwtypes.SetNestedObjectValueOf[dayWeekNameAutonomousVmClusterMaintenanceWindowResourceModel] `tfsdk:"days_of_week"`
681+
HoursOfDay fwtypes.SetValueOf[types.Int32] `tfsdk:"hours_of_day"`
682+
IsCustomActionTimeoutEnabled types.Bool `tfsdk:"is_custom_action_timeout_enabled"`
683+
LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"`
684+
Months fwtypes.SetNestedObjectValueOf[monthNameAutonomousVmClusterMaintenanceWindowResourceModel] `tfsdk:"months"`
685+
PatchingMode fwtypes.StringEnum[odbtypes.PatchingModeType] `tfsdk:"patching_mode"`
686+
Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"`
687+
WeeksOfMonth fwtypes.SetValueOf[types.Int32] `tfsdk:"weeks_of_month"`
660688
}
661689

662690
type dayWeekNameAutonomousVmClusterMaintenanceWindowResourceModel struct {

internal/service/odb/cloud_autonomous_vm_cluster_data_source.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Copyright (c) HashiCorp, Inc.
2-
// SPDX-License-Identifier: MPL-2.0
1+
// Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
32

43
package odb
54

@@ -330,12 +329,15 @@ type cloudAutonomousVmClusterDataSourceModel struct {
330329
Tags tftags.Map `tfsdk:"tags"`
331330
}
332331
type cloudAutonomousVmClusterMaintenanceWindowDataSourceModel struct {
333-
DaysOfWeek fwtypes.SetNestedObjectValueOf[dayWeekNameAutonomousVmClusterMaintenanceWindowDataSourceModel] `tfsdk:"days_of_week"`
334-
HoursOfDay fwtypes.SetValueOf[types.Int32] `tfsdk:"hours_of_day"`
335-
LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"`
336-
Months fwtypes.SetNestedObjectValueOf[monthNameAutonomousVmClusterMaintenanceWindowDataSourceModel] `tfsdk:"months"`
337-
Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"`
338-
WeeksOfMonth fwtypes.SetValueOf[types.Int32] `tfsdk:"weeks_of_month"`
332+
CustomActionTimeoutInMins types.Int32 `tfsdk:"custom_action_timeout_in_mins"`
333+
DaysOfWeek fwtypes.SetNestedObjectValueOf[dayWeekNameAutonomousVmClusterMaintenanceWindowDataSourceModel] `tfsdk:"days_of_week"`
334+
HoursOfDay fwtypes.SetValueOf[types.Int32] `tfsdk:"hours_of_day"`
335+
IsCustomActionTimeoutEnabled types.Bool `tfsdk:"is_custom_action_timeout_enabled"`
336+
LeadTimeInWeeks types.Int32 `tfsdk:"lead_time_in_weeks"`
337+
Months fwtypes.SetNestedObjectValueOf[monthNameAutonomousVmClusterMaintenanceWindowDataSourceModel] `tfsdk:"months"`
338+
PatchingMode fwtypes.StringEnum[odbtypes.PatchingModeType] `tfsdk:"patching_mode"`
339+
Preference fwtypes.StringEnum[odbtypes.PreferenceType] `tfsdk:"preference"`
340+
WeeksOfMonth fwtypes.SetValueOf[types.Int32] `tfsdk:"weeks_of_month"`
339341
}
340342
type dayWeekNameAutonomousVmClusterMaintenanceWindowDataSourceModel struct {
341343
Name fwtypes.StringEnum[odbtypes.DayOfWeekName] `tfsdk:"name"`

internal/service/odb/cloud_autonomous_vm_cluster_data_source_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Copyright (c) HashiCorp, Inc.
2-
// SPDX-License-Identifier: MPL-2.0
1+
// Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
32

43
package odb_test
54

internal/service/odb/cloud_autonomous_vm_cluster_test.go

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Copyright (c) HashiCorp, Inc.
2-
// SPDX-License-Identifier: MPL-2.0
1+
// Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
32

43
package odb_test
54

@@ -34,7 +33,7 @@ type autonomousVMClusterResourceTest struct {
3433

3534
var autonomousVMClusterResourceTestEntity = autonomousVMClusterResourceTest{
3635
exaInfraDisplayNamePrefix: "Ofake-exa",
37-
odbNetDisplayNamePrefix: "odb-net",
36+
odbNetDisplayNamePrefix: "oracleDB-net",
3837
autonomousVmClusterDisplayNamePrefix: "Ofake-avmc",
3938
}
4039

@@ -295,13 +294,8 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
295294
db_servers = [for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id]
296295
scan_listener_port_tls = 8561
297296
scan_listener_port_non_tls = 1024
298-
maintenance_window = {
297+
maintenance_window {
299298
preference = "NO_PREFERENCE"
300-
days_of_week = []
301-
hours_of_day = []
302-
months = []
303-
weeks_of_month = []
304-
lead_time_in_weeks = 0
305299
}
306300
307301
}
@@ -341,13 +335,8 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
341335
db_servers = [for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id]
342336
scan_listener_port_tls = 8561
343337
scan_listener_port_non_tls = 1024
344-
maintenance_window = {
338+
maintenance_window {
345339
preference = "NO_PREFERENCE"
346-
days_of_week = []
347-
hours_of_day = []
348-
months = []
349-
weeks_of_month = []
350-
lead_time_in_weeks = 0
351340
}
352341
353342
}
@@ -375,13 +364,8 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
375364
db_servers = [for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id]
376365
scan_listener_port_tls = 8561
377366
scan_listener_port_non_tls = 1024
378-
maintenance_window = {
367+
maintenance_window {
379368
preference = "NO_PREFERENCE"
380-
days_of_week = []
381-
hours_of_day = []
382-
months = []
383-
weeks_of_month = []
384-
lead_time_in_weeks = 0
385369
}
386370
tags = {
387371
"env" = "dev"
@@ -426,11 +410,11 @@ resource "aws_odb_cloud_autonomous_vm_cluster" "test" {
426410
db_servers = [for db_server in data.aws_odb_db_servers_list.test.db_servers : db_server.id]
427411
scan_listener_port_tls = 8561
428412
scan_listener_port_non_tls = 1024
429-
maintenance_window = {
413+
maintenance_window {
430414
preference = "CUSTOM_PREFERENCE"
431-
days_of_week = ["MONDAY", "TUESDAY"]
415+
days_of_week = [{ name = "MONDAY" }, { name = "TUESDAY" }]
432416
hours_of_day = [4, 16]
433-
months = ["FEBRUARY", "MAY", "AUGUST", "NOVEMBER"]
417+
months = [{ name = "FEBRUARY" }, { name = "MAY" }, { name = "AUGUST" }, { name = "NOVEMBER" }]
434418
weeks_of_month = [2, 4]
435419
lead_time_in_weeks = 3
436420
}
@@ -469,23 +453,17 @@ resource "aws_odb_network" "test" {
469453
func (autonomousVMClusterResourceTest) exaInfra(exaDisplayName, emailAddress string) string {
470454
resource := fmt.Sprintf(`
471455
resource "aws_odb_cloud_exadata_infrastructure" "test" {
472-
display_name = "%[1]s"
456+
display_name = %[1]q
473457
shape = "Exadata.X9M"
474458
storage_count = 3
475459
compute_count = 2
476460
availability_zone_id = "use1-az6"
477-
customer_contacts_to_send_to_oci = ["%[2]s"]
478-
479-
maintenance_window = {
461+
customer_contacts_to_send_to_oci = [{ email = "%[2]s" }]
462+
maintenance_window {
480463
custom_action_timeout_in_mins = 16
481-
days_of_week = []
482-
hours_of_day = []
483464
is_custom_action_timeout_enabled = true
484-
lead_time_in_weeks = 0
485-
months = []
486465
patching_mode = "ROLLING"
487466
preference = "NO_PREFERENCE"
488-
weeks_of_month = []
489467
}
490468
}
491469
`, exaDisplayName, emailAddress)

0 commit comments

Comments
 (0)