Skip to content

Commit 74ff422

Browse files
committed
fixed linting issues for odb network.
1 parent e1e1093 commit 74ff422

File tree

7 files changed

+100
-103
lines changed

7 files changed

+100
-103
lines changed

examples/odb/odb_network.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright © 2025, Oracle and/or its affiliates. All rights reserved.
22

33
# odb network without managed service
4-
resource "aws_odb_network" "test" {
4+
resource "aws_odb_network" "test_1" {
55
display_name = "odb-my-net"
66
availability_zone_id = "use1-az6"
77
client_subnet_cidr = "10.2.0.0/24"
@@ -14,7 +14,7 @@ resource "aws_odb_network" "test" {
1414
}
1515

1616
# odb network with managed service
17-
resource "aws_odb_network" "test" {
17+
resource "aws_odb_network" "test_2" {
1818
display_name = "odb-my-net"
1919
availability_zone_id = "use1-az6"
2020
client_subnet_cidr = "10.2.0.0/24"

internal/service/odb/network.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package odb
55
import (
66
"context"
77
"errors"
8-
"github.com/hashicorp/terraform-plugin-framework/path"
98
"time"
109

1110
"github.com/aws/aws-sdk-go-v2/aws"
@@ -15,6 +14,7 @@ import (
1514
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
1615
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
1716
"github.com/hashicorp/terraform-plugin-framework/attr"
17+
"github.com/hashicorp/terraform-plugin-framework/path"
1818
"github.com/hashicorp/terraform-plugin-framework/resource"
1919
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
2020
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
@@ -56,7 +56,7 @@ type resourceNetwork struct {
5656
framework.WithImportByID
5757
}
5858

59-
var OdbNetwork = newResourceNetwork
59+
var OracleDBNetwork = newResourceNetwork
6060
var managedServiceTimeout = 15 * time.Minute
6161

6262
func (r *resourceNetwork) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
@@ -68,7 +68,7 @@ func (r *resourceNetwork) Schema(ctx context.Context, req resource.SchemaRequest
6868
Attributes: map[string]schema.Attribute{
6969
names.AttrARN: framework.ARNAttributeComputedOnly(),
7070
names.AttrID: framework.IDAttribute(),
71-
"display_name": schema.StringAttribute{
71+
names.AttrDisplayName: schema.StringAttribute{
7272
Required: true,
7373
Description: "The user-friendly name for the odb network. Changing this will force terraform to create a new resource.",
7474
PlanModifiers: []planmodifier.String{
@@ -155,7 +155,7 @@ func (r *resourceNetwork) Schema(ctx context.Context, req resource.SchemaRequest
155155
Description: "The DNS resolver endpoint in OCI for forwarding DNS queries for the ociPrivateZone domain.",
156156
ElementType: types.ObjectType{
157157
AttrTypes: map[string]attr.Type{
158-
"domain_name": types.StringType,
158+
names.AttrDomainName: types.StringType,
159159
"oci_dns_listener_ip": types.StringType,
160160
},
161161
},
@@ -199,7 +199,7 @@ func (r *resourceNetwork) Schema(ctx context.Context, req resource.SchemaRequest
199199
Computed: true,
200200
Description: "Additional information about the current status of the ODB network.",
201201
},
202-
"created_at": schema.StringAttribute{
202+
names.AttrCreatedAt: schema.StringAttribute{
203203
Computed: true,
204204
CustomType: timetypes.RFC3339Type{},
205205
Description: "The date and time when the ODB network was created.",
@@ -323,7 +323,7 @@ func (r *resourceNetwork) Read(ctx context.Context, req resource.ReadRequest, re
323323
return
324324
}
325325

326-
out, err := FindOdbNetworkResourceByID(ctx, conn, state.OdbNetworkId.ValueString())
326+
out, err := FindOracleDBNetworkResourceByID(ctx, conn, state.OdbNetworkId.ValueString())
327327
if tfresource.NotFound(err) {
328328
resp.Diagnostics.Append(fwdiag.NewResourceNotFoundWarningDiagnostic(err))
329329
resp.State.RemoveResource(ctx)
@@ -520,7 +520,10 @@ func waitNetworkCreated(ctx context.Context, conn *odb.Client, id string, timeou
520520
}
521521

522522
func waitForManagedService(ctx context.Context, targetStatus odbtypes.Access, conn *odb.Client, id string, timeout time.Duration, managedResourceStatus func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus) (*odbtypes.OdbNetwork, error) {
523-
if targetStatus == odbtypes.AccessEnabled {
523+
524+
switch targetStatus {
525+
526+
case odbtypes.AccessEnabled:
524527
stateConf := &retry.StateChangeConf{
525528
Pending: enum.Slice(odbtypes.ManagedResourceStatusEnabling),
526529
Target: enum.Slice(odbtypes.ManagedResourceStatusEnabled),
@@ -533,7 +536,7 @@ func waitForManagedService(ctx context.Context, targetStatus odbtypes.Access, co
533536
return out, err
534537
}
535538
return nil, err
536-
} else if targetStatus == odbtypes.AccessDisabled {
539+
case odbtypes.AccessDisabled:
537540
stateConf := &retry.StateChangeConf{
538541
Pending: enum.Slice(odbtypes.ManagedResourceStatusDisabling),
539542
Target: enum.Slice(odbtypes.ManagedResourceStatusDisabled),
@@ -545,16 +548,16 @@ func waitForManagedService(ctx context.Context, targetStatus odbtypes.Access, co
545548
if out, ok := outputRaw.(*odbtypes.OdbNetwork); ok {
546549
return out, err
547550
}
548-
549551
return nil, err
550-
}
551552

552-
return nil, errors.New("odb network invalid manged service status")
553+
default:
554+
return nil, errors.New("odb network invalid manged service status")
555+
}
553556
}
554557

555558
func statusManagedService(ctx context.Context, conn *odb.Client, id string, managedResourceStatus func(managedService *odbtypes.ManagedServices) odbtypes.ManagedResourceStatus) retry.StateRefreshFunc {
556559
return func() (any, string, error) {
557-
out, err := FindOdbNetworkResourceByID(ctx, conn, id)
560+
out, err := FindOracleDBNetworkResourceByID(ctx, conn, id)
558561

559562
if err != nil {
560563
return nil, "", err
@@ -602,7 +605,7 @@ func waitNetworkDeleted(ctx context.Context, conn *odb.Client, id string, timeou
602605

603606
func statusNetwork(ctx context.Context, conn *odb.Client, id string) retry.StateRefreshFunc {
604607
return func() (any, string, error) {
605-
out, err := FindOdbNetworkResourceByID(ctx, conn, id)
608+
out, err := FindOracleDBNetworkResourceByID(ctx, conn, id)
606609
if tfresource.NotFound(err) {
607610
return nil, "", nil
608611
}
@@ -625,7 +628,7 @@ func mapManagedServiceStatusToAccessStatus(mangedStatus odbtypes.ManagedResource
625628
return "", errors.New("can not convert managed status to access status")
626629
}
627630

628-
func FindOdbNetworkResourceByID(ctx context.Context, conn *odb.Client, id string) (*odbtypes.OdbNetwork, error) {
631+
func FindOracleDBNetworkResourceByID(ctx context.Context, conn *odb.Client, id string) (*odbtypes.OdbNetwork, error) {
629632
input := odb.GetOdbNetworkInput{
630633
OdbNetworkId: aws.String(id),
631634
}

internal/service/odb/network_data_source.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package odb
44

55
import (
66
"context"
7+
78
"github.com/aws/aws-sdk-go-v2/service/odb"
89
odbtypes "github.com/aws/aws-sdk-go-v2/service/odb/types"
910
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
@@ -41,15 +42,15 @@ func (d *dataSourceNetwork) Schema(ctx context.Context, req datasource.SchemaReq
4142
names.AttrID: schema.StringAttribute{
4243
Required: true,
4344
},
44-
"display_name": schema.StringAttribute{
45+
names.AttrDisplayName: schema.StringAttribute{
4546
Computed: true,
4647
Description: "Display name for the network resource.",
4748
},
4849
"availability_zone_id": schema.StringAttribute{
4950
Computed: true,
5051
Description: "The AZ ID of the AZ where the ODB network is located.",
5152
},
52-
"availability_zone": schema.StringAttribute{
53+
names.AttrAvailabilityZone: schema.StringAttribute{
5354
Computed: true,
5455
Description: "The availability zone where the ODB network is located.",
5556
},
@@ -99,16 +100,16 @@ func (d *dataSourceNetwork) Schema(ctx context.Context, req datasource.SchemaReq
99100
Computed: true,
100101
Description: "The list of CIDR ranges from the peered VPC that are allowed access to the ODB network. Please refer odb network peering documentation.",
101102
},
102-
"status": schema.StringAttribute{
103+
names.AttrStatus: schema.StringAttribute{
103104
CustomType: statusType,
104105
Computed: true,
105106
Description: "The status of the network resource.",
106107
},
107-
"status_reason": schema.StringAttribute{
108+
names.AttrStatusReason: schema.StringAttribute{
108109
Computed: true,
109110
Description: "Additional information about the current status of the ODB network.",
110111
},
111-
"created_at": schema.StringAttribute{
112+
names.AttrCreatedAt: schema.StringAttribute{
112113
Computed: true,
113114
CustomType: timetypes.RFC3339Type{},
114115
Description: "The date and time when the ODB network was created.",

internal/service/odb/network_data_source_test.go

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import (
2424
"github.com/hashicorp/terraform-provider-aws/names"
2525
)
2626

27-
type odbNetworkDataSourceTest struct {
27+
type oracleDBNetworkDataSourceTest struct {
2828
}
2929

30-
var odbNetworkDataSourceTestEntity = odbNetworkDataSourceTest{}
30+
var oracleDBNetworkDataSourceTestEntity = oracleDBNetworkDataSourceTest{}
3131

3232
func TestAccODBNetworkDataSource_basic(t *testing.T) {
3333
ctx := acctest.Context(t)
@@ -36,36 +36,36 @@ func TestAccODBNetworkDataSource_basic(t *testing.T) {
3636
}
3737
networkResource := "aws_odb_network.test_resource"
3838
networkDataSource := "data.aws_odb_network.test"
39-
rName := sdkacctest.RandomWithPrefix("tf-odb-net")
39+
rName := sdkacctest.RandomWithPrefix("tf-ora-net")
4040

41-
resource.Test(t, resource.TestCase{
41+
resource.ParallelTest(t, resource.TestCase{
4242
PreCheck: func() {
4343
acctest.PreCheck(ctx, t)
44-
odbNetworkDataSourceTestEntity.testAccOdbNetworkDataSourcePreCheck(ctx, t)
44+
oracleDBNetworkDataSourceTestEntity.testAccNetworkDataSourcePreCheck(ctx, t)
4545
},
4646
ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID),
4747
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
48-
CheckDestroy: odbNetworkDataSourceTestEntity.testAccCheckOdbNetworkDataSourceDestroyed(ctx),
48+
CheckDestroy: oracleDBNetworkDataSourceTestEntity.testAccCheckNetworkDataSourceDestroyed(ctx),
4949
Steps: []resource.TestStep{
5050
{
51-
Config: odbNetworkDataSourceTestEntity.basicOdbNetworkDataSource(rName),
51+
Config: oracleDBNetworkDataSourceTestEntity.basicNetworkDataSource(rName),
5252
Check: resource.ComposeAggregateTestCheckFunc(
53-
resource.TestCheckResourceAttrPair(networkResource, "id", networkDataSource, "id"),
53+
resource.TestCheckResourceAttrPair(networkResource, names.AttrID, networkDataSource, names.AttrID),
5454
),
5555
},
5656
},
5757
})
5858
}
5959

60-
func (odbNetworkDataSourceTest) testAccCheckOdbNetworkDataSourceDestroyed(ctx context.Context) resource.TestCheckFunc {
60+
func (oracleDBNetworkDataSourceTest) testAccCheckNetworkDataSourceDestroyed(ctx context.Context) resource.TestCheckFunc {
6161
return func(s *terraform.State) error {
6262
conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx)
6363

6464
for _, rs := range s.RootModule().Resources {
6565
if rs.Type != "aws_odb_network" {
6666
continue
6767
}
68-
_, err := odbNetworkDataSourceTestEntity.findOdbNetwork(ctx, conn, rs.Primary.ID)
68+
_, err := oracleDBNetworkDataSourceTestEntity.findNetwork(ctx, conn, rs.Primary.ID)
6969
if tfresource.NotFound(err) {
7070
return nil
7171
}
@@ -80,7 +80,7 @@ func (odbNetworkDataSourceTest) testAccCheckOdbNetworkDataSourceDestroyed(ctx co
8080
}
8181
}
8282

83-
func (odbNetworkDataSourceTest) findOdbNetwork(ctx context.Context, conn *odb.Client, id string) (*odbtypes.OdbNetwork, error) {
83+
func (oracleDBNetworkDataSourceTest) findNetwork(ctx context.Context, conn *odb.Client, id string) (*odbtypes.OdbNetwork, error) {
8484
input := odb.GetOdbNetworkInput{
8585
OdbNetworkId: aws.String(id),
8686
}
@@ -104,7 +104,7 @@ func (odbNetworkDataSourceTest) findOdbNetwork(ctx context.Context, conn *odb.Cl
104104
return out.OdbNetwork, nil
105105
}
106106

107-
func (odbNetworkDataSourceTest) basicOdbNetworkDataSource(rName string) string {
107+
func (oracleDBNetworkDataSourceTest) basicNetworkDataSource(rName string) string {
108108
networkRes := fmt.Sprintf(`
109109
110110
@@ -131,13 +131,10 @@ data "aws_odb_network" "test" {
131131
`, rName)
132132
return networkRes
133133
}
134-
func (odbNetworkDataSourceTest) testAccOdbNetworkDataSourcePreCheck(ctx context.Context, t *testing.T) {
134+
func (oracleDBNetworkDataSourceTest) testAccNetworkDataSourcePreCheck(ctx context.Context, t *testing.T) {
135135
conn := acctest.Provider.Meta().(*conns.AWSClient).ODBClient(ctx)
136-
137-
input := &odb.ListOdbNetworksInput{}
138-
139-
_, err := conn.ListOdbNetworks(ctx, input)
140-
136+
input := odb.ListOdbNetworksInput{}
137+
_, err := conn.ListOdbNetworks(ctx, &input)
141138
if acctest.PreCheckSkipError(err) {
142139
t.Skipf("skipping acceptance testing: %s", err)
143140
}

0 commit comments

Comments
 (0)