Skip to content

Commit b77a679

Browse files
authored
Merge pull request #10 from umich-vci/ip4_network
Ip4 network
2 parents 5a8ef02 + 7a9e1a9 commit b77a679

17 files changed

+335
-26
lines changed

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
## 0.3.0 (Unreleased)
1+
## 0.3.0 (October 10, 2021)
2+
3+
FEATURES:
4+
5+
* **New Datasource:** `bluecat_ip4_network`
6+
7+
BUG FIXES:
8+
9+
* Error if no entity is found with the bluecat_entity datasource.
210

311
IMPROVEMENTS:
412

5-
* Updated [Terraform SDK](https://github.com/hashicorp/terraform-plugin-sdk/) to 2.7.0
13+
* Updated [Terraform SDK](https://github.com/hashicorp/terraform-plugin-sdk/) to 2.8.0
14+
15+
* Updated [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs) to 0.5.0
616

717
* Reworked code to follow [Terraform Provider Scaffolding](https://github.com/hashicorp/terraform-provider-scaffolding)
818

docs/data-sources/ip4_network-block-range.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "bluecat_ip4_network-block-range Data Source - terraform-provider-bluecat"
44
subcategory: ""
55
description: |-
6-
Data source to access the attributes of an IPv4 network, IPv4 Block, or DHCPv4 Range.
6+
Data source to access the attributes of an IPv4 network, IPv4 Block, or DHCPv4 Range from an IPv4 address.
77
---
88

99
# bluecat_ip4_network-block-range (Data Source)
1010

11-
Data source to access the attributes of an IPv4 network, IPv4 Block, or DHCPv4 Range.
11+
Data source to access the attributes of an IPv4 network, IPv4 Block, or DHCPv4 Range from an IPv4 address.
1212

1313
## Example Usage
1414

docs/data-sources/ip4_network.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "bluecat_ip4_network Data Source - terraform-provider-bluecat"
4+
subcategory: ""
5+
description: |-
6+
Data source to access the attributes of an IPv4 network from a hint based search.
7+
---
8+
9+
# bluecat_ip4_network (Data Source)
10+
11+
Data source to access the attributes of an IPv4 network from a hint based search.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- **container_id** (String) The object ID of a container that contains the specified IPv4 network.
21+
- **hint** (String) Hint to find the IP4Network
22+
23+
### Optional
24+
25+
- **id** (String) The ID of this resource.
26+
27+
### Read-Only
28+
29+
- **addresses_free** (Number) The number of addresses unallocated/free on the network.
30+
- **addresses_in_use** (Number) The number of addresses allocated/in use on the network.
31+
- **allow_duplicate_host** (String) Duplicate host names check.
32+
- **cidr** (String) The CIDR address of the IPv4 network.
33+
- **custom_properties** (Map of String) A map of all custom properties associated with the IPv4 network.
34+
- **default_domains** (Set of String) TODO
35+
- **default_view** (String) The object id of the default DNS View for the network.
36+
- **dns_restrictions** (Set of String) TODO
37+
- **gateway** (String) The gateway of the IPv4 network.
38+
- **inherit_allow_duplicate_host** (Boolean) Duplicate host names check is inherited.
39+
- **inherit_default_domains** (Boolean) Default domains are inherited.
40+
- **inherit_default_view** (Boolean) The default DNS View is inherited.
41+
- **inherit_dns_restrictions** (Boolean) DNS restrictions are inherited.
42+
- **inherit_ping_before_assign** (Boolean) The network pings an address before assignment is inherited.
43+
- **location_code** (String) TODO
44+
- **location_inherited** (Boolean) TODO
45+
- **name** (String) The name assigned the resource.
46+
- **ping_before_assign** (String) The network pings an address before assignment.
47+
- **properties** (String) The properties of the resource as returned by the API (pipe delimited).
48+
- **template** (String) TODO
49+
- **type** (String) The type of the IP4Network
50+
51+

docs/resources/host_record.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Resource create a host record.
1414

1515
```terraform
1616
resource "bluecat_host_record" "hostname" {
17-
view = data.bluecat_entity.view.id
17+
view_id = data.bluecat_entity.view.id
1818
name = "hostname"
1919
dns_zone = "example.com"
2020
addresses = ["192.168.1.100"]

examples/resources/bluecat_host_record/resource.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "bluecat_host_record" "hostname" {
2-
view = data.bluecat_entity.view.id
2+
view_id = data.bluecat_entity.view.id
33
name = "hostname"
44
dns_zone = "example.com"
55
addresses = ["192.168.1.100"]

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ go 1.16
55
require (
66
github.com/hashicorp/terraform-plugin-docs v0.5.0
77
github.com/hashicorp/terraform-plugin-sdk/v2 v2.8.0
8-
github.com/umich-vci/gobam v0.0.0-20201026200032-5742f663694f
8+
github.com/umich-vci/gobam v0.0.0-20211001185159-1f491fdadbd8
99
)

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ github.com/hashicorp/terraform-json v0.12.0 h1:8czPgEEWWPROStjkWPUnTQDXmpmZPlkQA
200200
github.com/hashicorp/terraform-json v0.12.0/go.mod h1:pmbq9o4EuL43db5+0ogX10Yofv1nozM+wskr/bGFJpI=
201201
github.com/hashicorp/terraform-plugin-docs v0.5.0 h1:Rso/yNznoGl7KVb/Z5RefiHsLJaGTbok9sEnad+V1t4=
202202
github.com/hashicorp/terraform-plugin-docs v0.5.0/go.mod h1:Z4q6unfv05W7fjpEy8ZC+nFijZmcm64Iag6I2HKRMSA=
203-
github.com/hashicorp/terraform-plugin-go v0.3.0 h1:AJqYzP52JFYl9NABRI7smXI1pNjgR5Q/y2WyVJ/BOZA=
204-
github.com/hashicorp/terraform-plugin-go v0.3.0/go.mod h1:dFHsQMaTLpON2gWhVWT96fvtlc/MF1vSy3OdMhWBzdM=
205-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0 h1:SuI59MqNjYDrL7EfqHX9V6P/24isgqYx/FdglwVs9bg=
206-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0/go.mod h1:grseeRo9g3yNkYW09iFlV8LG78jTa1ssBgouogQg/RU=
203+
github.com/hashicorp/terraform-plugin-go v0.4.0 h1:LFbXNeLDo0J/wR0kUzSPq0RpdmFh2gNedzU0n/gzPAo=
204+
github.com/hashicorp/terraform-plugin-go v0.4.0/go.mod h1:7u/6nt6vaiwcWE2GuJKbJwNlDFnf5n95xKw4hqIVr58=
205+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.8.0 h1:GSumgrL6GGcRYU37YuF1CC59hRPR7Yzy6tpoFlo8wr4=
206+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.8.0/go.mod h1:6KbP09YzlB++S6XSUKYl83WyoHVN4MgeoCbPRsdfCtA=
207207
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
208208
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
209209
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
@@ -304,8 +304,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
304304
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
305305
github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ=
306306
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
307-
github.com/umich-vci/gobam v0.0.0-20201026200032-5742f663694f h1:KWw7Cv8RftECmBCYaaT8VTU2V+183TO9zpJOd6De3Gc=
308-
github.com/umich-vci/gobam v0.0.0-20201026200032-5742f663694f/go.mod h1:XgS74BOgjV2krJLMpvpOsF+vYyc7MQdYztgE1Q/3dtY=
307+
github.com/umich-vci/gobam v0.0.0-20211001185159-1f491fdadbd8 h1:v7RX6m4HuMi1M7OAyZ98H5SY8q6CwWG8MgM+VufRb3M=
308+
github.com/umich-vci/gobam v0.0.0-20211001185159-1f491fdadbd8/go.mod h1:XgS74BOgjV2krJLMpvpOsF+vYyc7MQdYztgE1Q/3dtY=
309309
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
310310
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
311311
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=

internal/provider/data_source_entity.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func dataSourceEntity() *schema.Resource {
4747
func dataSourceEntityRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
4848
mutex.Lock()
4949
client := meta.(*apiClient).Client
50+
client.Login(meta.(*apiClient).Username, meta.(*apiClient).Password)
5051

5152
parentID, err := strconv.ParseInt(d.Get("parent_id").(string), 10, 64)
5253
if err = gobam.LogoutClientIfError(client, err, "Unable to convert parent_id from string to int64"); err != nil {
@@ -61,6 +62,17 @@ func dataSourceEntityRead(ctx context.Context, d *schema.ResourceData, meta inte
6162
return diag.FromErr(err)
6263
}
6364

65+
if *resp.Id == 0 {
66+
var diags diag.Diagnostics
67+
err := gobam.LogoutClientWithError(client, "Entity not found")
68+
mutex.Unlock()
69+
70+
diags = append(diags, diag.FromErr(err)...)
71+
diags = append(diags, diag.Errorf("Entity ID returned was 0")...)
72+
73+
return diags
74+
}
75+
6476
d.SetId(strconv.FormatInt(*resp.Id, 10))
6577
d.Set("properties", resp.Properties)
6678

internal/provider/data_source_host_record.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func dataSourceHostRecord() *schema.Resource {
9898
func dataSourceHostRecordRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
9999
mutex.Lock()
100100
client := meta.(*apiClient).Client
101+
client.Login(meta.(*apiClient).Username, meta.(*apiClient).Password)
101102

102103
start := d.Get("start").(int)
103104
count := d.Get("result_count").(int)

internal/provider/data_source_ip4_address.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func dataSourceIP4Address() *schema.Resource {
6868
func dataSourceIP4AddressRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
6969
mutex.Lock()
7070
client := meta.(*apiClient).Client
71+
client.Login(meta.(*apiClient).Username, meta.(*apiClient).Password)
7172

7273
containerID, err := strconv.ParseInt(d.Get("container_id").(string), 10, 64)
7374
if err = gobam.LogoutClientIfError(client, err, "Unable to convert container_id from string to int64"); err != nil {

0 commit comments

Comments
 (0)