Skip to content

Commit 787ef18

Browse files
Error Handling Improvements and Dependency updates (#502)
* Go module has been updated to support 1.24.7 * Updated vendor dir for dependency packages * fixed all the data sources with proper NotFoundError handling * chore: update vendor dependencies
1 parent 2c9bca1 commit 787ef18

787 files changed

Lines changed: 78908 additions & 38246 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

go.mod

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,63 @@
11
module github.com/infobloxopen/terraform-provider-infoblox
22

3-
go 1.21
3+
go 1.24.7
44

55
require (
66
github.com/google/uuid v1.6.0
77
github.com/hashicorp/terraform-plugin-log v0.9.0
8-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
9-
github.com/infobloxopen/infoblox-go-client/v2 v2.10.0
8+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1
9+
github.com/infobloxopen/infoblox-go-client/v2 v2.10.1-0.20251014101504-7610c6d0279b
1010
github.com/sirupsen/logrus v1.9.3
1111
)
1212

1313
require (
14-
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
14+
github.com/ProtonMail/go-crypto v1.3.0 // indirect
1515
github.com/agext/levenshtein v1.2.3 // indirect
1616
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
17-
github.com/cloudflare/circl v1.3.7 // indirect
18-
github.com/fatih/color v1.17.0 // indirect
17+
github.com/cloudflare/circl v1.6.1 // indirect
18+
github.com/fatih/color v1.18.0 // indirect
1919
github.com/golang/protobuf v1.5.4 // indirect
20-
github.com/google/go-cmp v0.6.0 // indirect
20+
github.com/google/go-cmp v0.7.0 // indirect
2121
github.com/hashicorp/errwrap v1.1.0 // indirect
2222
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
2323
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
24-
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
24+
github.com/hashicorp/go-cty v1.5.0 // indirect
2525
github.com/hashicorp/go-hclog v1.6.3 // indirect
2626
github.com/hashicorp/go-multierror v1.1.1 // indirect
27-
github.com/hashicorp/go-plugin v1.6.1 // indirect
27+
github.com/hashicorp/go-plugin v1.7.0 // indirect
28+
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
2829
github.com/hashicorp/go-uuid v1.0.3 // indirect
29-
github.com/hashicorp/go-version v1.6.0 // indirect
30-
github.com/hashicorp/hc-install v0.7.0 // indirect
31-
github.com/hashicorp/hcl/v2 v2.20.1 // indirect
30+
github.com/hashicorp/go-version v1.7.0 // indirect
31+
github.com/hashicorp/hc-install v0.9.2 // indirect
32+
github.com/hashicorp/hcl/v2 v2.24.0 // indirect
3233
github.com/hashicorp/logutils v1.0.0 // indirect
33-
github.com/hashicorp/terraform-exec v0.21.0 // indirect
34-
github.com/hashicorp/terraform-json v0.22.1 // indirect
35-
github.com/hashicorp/terraform-plugin-go v0.23.0 // indirect
36-
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
34+
github.com/hashicorp/terraform-exec v0.24.0 // indirect
35+
github.com/hashicorp/terraform-json v0.27.2 // indirect
36+
github.com/hashicorp/terraform-plugin-go v0.29.0 // indirect
37+
github.com/hashicorp/terraform-registry-address v0.4.0 // indirect
3738
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
38-
github.com/hashicorp/yamux v0.1.1 // indirect
39-
github.com/mattn/go-colorable v0.1.13 // indirect
39+
github.com/hashicorp/yamux v0.1.2 // indirect
40+
github.com/mattn/go-colorable v0.1.14 // indirect
4041
github.com/mattn/go-isatty v0.0.20 // indirect
4142
github.com/mitchellh/copystructure v1.2.0 // indirect
4243
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
4344
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
4445
github.com/mitchellh/mapstructure v1.5.0 // indirect
4546
github.com/mitchellh/reflectwalk v1.0.2 // indirect
46-
github.com/oklog/run v1.1.0 // indirect
47+
github.com/oklog/run v1.2.0 // indirect
4748
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
4849
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
4950
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
50-
github.com/zclconf/go-cty v1.14.4 // indirect
51-
golang.org/x/crypto v0.26.0 // indirect
52-
golang.org/x/mod v0.20.0 // indirect
53-
golang.org/x/net v0.28.0 // indirect
54-
golang.org/x/sync v0.8.0 // indirect
55-
golang.org/x/sys v0.24.0 // indirect
56-
golang.org/x/text v0.17.0 // indirect
57-
golang.org/x/tools v0.24.0 // indirect
51+
github.com/zclconf/go-cty v1.17.0 // indirect
52+
golang.org/x/crypto v0.43.0 // indirect
53+
golang.org/x/mod v0.29.0 // indirect
54+
golang.org/x/net v0.46.0 // indirect
55+
golang.org/x/sync v0.17.0 // indirect
56+
golang.org/x/sys v0.37.0 // indirect
57+
golang.org/x/text v0.30.0 // indirect
58+
golang.org/x/tools v0.38.0 // indirect
5859
google.golang.org/appengine v1.6.8 // indirect
59-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
60-
google.golang.org/grpc v1.64.0 // indirect
61-
google.golang.org/protobuf v1.34.1 // indirect
60+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f // indirect
61+
google.golang.org/grpc v1.76.0 // indirect
62+
google.golang.org/protobuf v1.36.10 // indirect
6263
)

go.sum

Lines changed: 110 additions & 88 deletions
Large diffs are not rendered by default.

infoblox/datasource_infoblox_a_record.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ func dataSourceARecordRead(ctx context.Context, d *schema.ResourceData, m interf
8787

8888
err := connector.GetObject(n, "", qp, &res)
8989
if err != nil {
90-
return diag.FromErr(fmt.Errorf("failed getting A-record: %s", err.Error()))
91-
}
92-
93-
if res == nil {
94-
return diag.FromErr(fmt.Errorf("API returns a nil/empty ID for the A Record"))
90+
// Check if it's a "not found" error for data source - this is acceptable
91+
if _, ok := err.(*ibclient.NotFoundError); ok {
92+
// For data sources, empty results are valid - just return empty results
93+
res = []ibclient.RecordA{}
94+
} else {
95+
return diag.FromErr(fmt.Errorf("Getting A Record failed with filters %v: %s", filters, err.Error()))
96+
}
9597
}
9698

9799
// TODO: temporary scaffold, need to rework marshalling/unmarshalling of EAs

infoblox/datasource_infoblox_aaaa_record.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ func dataSourceAAAARecordRead(ctx context.Context, d *schema.ResourceData, m int
8888

8989
err := connector.GetObject(n, "", qp, &res)
9090
if err != nil {
91-
return diag.FromErr(fmt.Errorf("failed getting AAAA-record: %s", err.Error()))
92-
}
93-
if res == nil {
94-
return diag.FromErr(fmt.Errorf("API returns a nil/empty ID for the AAAA Record"))
91+
// Check if it's a "not found" error for data source - this is acceptable
92+
if _, ok := err.(*ibclient.NotFoundError); ok {
93+
// For data sources, empty results are valid - just return empty results
94+
res = []ibclient.RecordAAAA{}
95+
} else {
96+
return diag.FromErr(fmt.Errorf("Getting AAAA Record failed : %s", err.Error()))
97+
}
9598
}
9699

97100
// TODO: temporary scaffold, need to rework marshalling/unmarshalling of EAs

infoblox/datasource_infoblox_alias_record.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,7 @@ func datasourceAliasRecordRead(ctx context.Context, d *schema.ResourceData, m in
112112
objMgr := ibclient.NewObjectManager(connector, "Terraform", "")
113113

114114
qp := ibclient.NewQueryParams(false, filters)
115-
res, err := objMgr.GetAllAliasRecord(qp)
116-
if err != nil {
117-
return diag.FromErr(err)
118-
}
119-
120-
if res == nil {
121-
return diag.FromErr(fmt.Errorf("API returns a nil/empty ID for alias record"))
122-
}
115+
res, _ := objMgr.GetAllAliasRecord(qp)
123116
// TODO: temporary scaffold, need to rework marshalling/unmarshalling of EAs
124117
// (avoiding additional layer of keys ("value" key)
125118
results := make([]interface{}, 0, len(res))
@@ -131,7 +124,7 @@ func datasourceAliasRecordRead(ctx context.Context, d *schema.ResourceData, m in
131124
results = append(results, aliasRecord)
132125
}
133126

134-
err = d.Set("results", results)
127+
err := d.Set("results", results)
135128
if err != nil {
136129
return diag.FromErr(err)
137130
}

infoblox/datasource_infoblox_cname_record.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ func dataSourceCNameRecordRead(ctx context.Context, d *schema.ResourceData, m in
8888

8989
err := connector.GetObject(n, "", qp, &res)
9090
if err != nil {
91-
return diag.FromErr(fmt.Errorf("Getting CNAME Record failed : %s", err.Error()))
92-
}
93-
94-
if res == nil {
95-
return diag.FromErr(fmt.Errorf("API returns a nil/empty ID for the CNAME Record"))
91+
// Check if it's a "not found" error for data source - this is acceptable
92+
if _, ok := err.(*ibclient.NotFoundError); ok {
93+
// For data sources, empty results are valid - just return empty results
94+
res = []ibclient.RecordCNAME{}
95+
} else {
96+
return diag.FromErr(fmt.Errorf("Getting CNAME Record failed with filters %v: %s", filters, err.Error()))
97+
}
9698
}
9799

98100
// TODO: temporary scaffold, need to rework marshalling/unmarshalling of EAs

infoblox/datasource_infoblox_dns_view.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ func dataSourceDNSViewRead(ctx context.Context, d *schema.ResourceData, m interf
7171

7272
err := connector.GetObject(dv, "", qp, &res)
7373
if err != nil {
74-
return diag.FromErr(fmt.Errorf("failed getting DNS View: %s", err.Error()))
75-
}
76-
77-
if res == nil {
78-
return diag.FromErr(fmt.Errorf("API returns a nil/empty ID for the DNS View"))
74+
// Check if it's a "not found" error for data source - this is acceptable
75+
if _, ok := err.(*ibclient.NotFoundError); ok {
76+
// For data sources, empty results are valid - just return empty results
77+
res = []ibclient.View{}
78+
} else {
79+
return diag.FromErr(fmt.Errorf("Getting DNS View failed : %s", err.Error()))
80+
}
7981
}
8082

8183
// TODO: temporary scaffold, need to rework marshalling/unmarshalling of EAs

infoblox/datasource_infoblox_dtc_lbdn.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,7 @@ func dataSourceDtcLbdnRecordRead(ctx context.Context, d *schema.ResourceData, m
159159
objMgr := ibclient.NewObjectManager(connector, "Terraform", "")
160160

161161
qp := ibclient.NewQueryParams(false, filters)
162-
res, err := objMgr.GetAllDtcLbdn(qp)
163-
if err != nil {
164-
return diag.FromErr(err)
165-
}
166-
167-
if res == nil {
168-
return diag.FromErr(fmt.Errorf("API returns a nil/empty ID for DTC LBDN"))
169-
}
162+
res, _ := objMgr.GetAllDtcLbdn(qp)
170163
results := make([]interface{}, 0, len(res))
171164
for _, r := range res {
172165
dtcLbdn, err := flattenDtcLbdn(r, connector)
@@ -176,7 +169,7 @@ func dataSourceDtcLbdnRecordRead(ctx context.Context, d *schema.ResourceData, m
176169
results = append(results, dtcLbdn)
177170
}
178171

179-
err = d.Set("results", results)
172+
err := d.Set("results", results)
180173
if err != nil {
181174
return diag.FromErr(err)
182175
}

infoblox/datasource_infoblox_dtc_pool.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,6 @@ func dataSourceDtcPoolRecordRead(ctx context.Context, d *schema.ResourceData, m
202202

203203
qp := ibclient.NewQueryParams(false, filters)
204204
res, err := objMgr.GetAllDtcPool(qp)
205-
if err != nil {
206-
return diag.FromErr(err)
207-
}
208-
209-
if res == nil {
210-
return diag.FromErr(fmt.Errorf("API returns a nil/empty ID for DTC pool"))
211-
}
212205
results := make([]interface{}, 0, len(res))
213206
for _, r := range res {
214207
dtcPool, err := flattenDtcPool(r, connector)

infoblox/datasource_infoblox_dtc_server.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,6 @@ func dataSourceDtcServerRead(ctx context.Context, d *schema.ResourceData, m inte
132132
qp := ibclient.NewQueryParams(false, filters)
133133

134134
res, err := objMgr.GetAllDtcServer(qp)
135-
if err != nil {
136-
return diag.FromErr(err)
137-
}
138-
if res == nil {
139-
return diag.FromErr(fmt.Errorf("API returns a nil/empty ID for zone forward"))
140-
}
141135
// TODO: temporary scaffold, need to rework marshalling/unmarshalling of EAs
142136
// (avoiding additional layer of keys ("value" key)
143137
results := make([]interface{}, 0, len(res))

0 commit comments

Comments
 (0)