From 9211a8943d8a2f8d5d58308568dd753291f143b2 Mon Sep 17 00:00:00 2001 From: hemanthKa677 Date: Tue, 24 Oct 2023 13:43:58 +0530 Subject: [PATCH 1/3] Updates filters description in datasource docs --- docs/data-sources/infoblox_a_record.md | 5 ++--- docs/data-sources/infoblox_aaaa_record.md | 5 ++--- docs/data-sources/infoblox_cname_record.md | 5 ++--- docs/data-sources/infoblox_dns_view.md | 5 ++--- docs/data-sources/infoblox_ipv4_network.md | 5 ++--- docs/data-sources/infoblox_ipv4_network_container.md | 5 ++--- docs/data-sources/infoblox_mx_record.md | 5 ++--- docs/data-sources/infoblox_network_view.md | 5 ++--- docs/data-sources/infoblox_ptr_record.md | 5 ++--- docs/data-sources/infoblox_srv_record.md | 5 ++--- docs/data-sources/infoblox_txt_record.md | 5 ++--- docs/data-sources/infoblox_zone_auth.md | 5 ++--- docs/resources/infoblox_zone_auth.md | 2 +- 13 files changed, 25 insertions(+), 37 deletions(-) diff --git a/docs/data-sources/infoblox_a_record.md b/docs/data-sources/infoblox_a_record.md index baadb7027..43abe30e1 100644 --- a/docs/data-sources/infoblox_a_record.md +++ b/docs/data-sources/infoblox_a_record.md @@ -12,9 +12,8 @@ Use the `infoblox_a_record` data source to retrieve the following information fo As there is new feature filters , the previous usage of combination of DNS view, IPv4 address and FQDN, has been removed. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_aaaa_record.md b/docs/data-sources/infoblox_aaaa_record.md index 054447e57..e76c7358b 100644 --- a/docs/data-sources/infoblox_aaaa_record.md +++ b/docs/data-sources/infoblox_aaaa_record.md @@ -12,9 +12,8 @@ Use the `infoblox_aaaa_record` data source to retrieve the following information As there is new feature filters , the previous usage of combination of DNS view, IPv6 address and FQDN, has been removed. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_cname_record.md b/docs/data-sources/infoblox_cname_record.md index b59358535..aa2e5acac 100644 --- a/docs/data-sources/infoblox_cname_record.md +++ b/docs/data-sources/infoblox_cname_record.md @@ -12,9 +12,8 @@ Use the `infoblox_cname_record` data resource for the CNAME object to retrieve t As there is new feature filters , the previous usage of combination of DNS view, alias and canonical name, has been removed. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_dns_view.md b/docs/data-sources/infoblox_dns_view.md index 2fa41e716..c70e53bad 100644 --- a/docs/data-sources/infoblox_dns_view.md +++ b/docs/data-sources/infoblox_dns_view.md @@ -7,9 +7,8 @@ Use the `infoblox_dns_view` data source to retrieve the following information fo * `comment`: The description of the DNS View. This is a regular comment. Example `this is some text`. * `ext_attrs`: the set of extensible attributes of the record, if any. The content is formatted as string of JSON map. Example: `"{\"Owner\":\"State Library\", \"Expires\":\"never\"}"`. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_ipv4_network.md b/docs/data-sources/infoblox_ipv4_network.md index e202fcae4..637af6ab7 100644 --- a/docs/data-sources/infoblox_ipv4_network.md +++ b/docs/data-sources/infoblox_ipv4_network.md @@ -8,9 +8,8 @@ The data source for the network object allows you to get the following parameter * `ext_attrs`: The set of extensible attributes, if any. The content is formatted as string of JSON map. Example: `"{\"Owner\":\"State Library\",\"Administrator\":\"unknown\"}"`. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_ipv4_network_container.md b/docs/data-sources/infoblox_ipv4_network_container.md index 13c9c96ab..78f3f8b80 100644 --- a/docs/data-sources/infoblox_ipv4_network_container.md +++ b/docs/data-sources/infoblox_ipv4_network_container.md @@ -9,9 +9,8 @@ object in NIOS: As there is new feature filters , the previous usage of combination of Network view and address of the network block in CIDR format has been removed. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_mx_record.md b/docs/data-sources/infoblox_mx_record.md index f9100f14d..47c627534 100644 --- a/docs/data-sources/infoblox_mx_record.md +++ b/docs/data-sources/infoblox_mx_record.md @@ -11,9 +11,8 @@ Use the data source to retrieve the following information for MX-record from the * `comment`: the description of the record. This is a regular comment. Example: `spare node for the service`. * `ext_attrs`: the set of extensible attributes of the record, if any. The content is formatted as stirng of JSON map. Example: `"{\"Owner\":\"State Library\", \"Expires\":\"never\"}"`. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_network_view.md b/docs/data-sources/infoblox_network_view.md index 11b237624..40e0703af 100644 --- a/docs/data-sources/infoblox_network_view.md +++ b/docs/data-sources/infoblox_network_view.md @@ -6,9 +6,8 @@ Use the data source to retrieve the following information for a network view res * `comment`: a description of the network view. This is a regular comment. Example: `From the outside`. * `ext_attrs`: the set of extensible attributes of the network view, if any. The content is formatted string of JSON map. Example: `"{\"Administrator\":\"jsw@telecom.ca\"}"`. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_ptr_record.md b/docs/data-sources/infoblox_ptr_record.md index 28df971ce..02e6fe0ad 100644 --- a/docs/data-sources/infoblox_ptr_record.md +++ b/docs/data-sources/infoblox_ptr_record.md @@ -14,9 +14,8 @@ Use the data source to retrieve the following information for PTR-record from th As new feature filters are introduced, specifying combination DNS view , IPv4 address or IPv6 address or record name used instead of IP address and ptrdname is removed. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_srv_record.md b/docs/data-sources/infoblox_srv_record.md index 6a1bc30ea..c03b0acd4 100644 --- a/docs/data-sources/infoblox_srv_record.md +++ b/docs/data-sources/infoblox_srv_record.md @@ -13,9 +13,8 @@ Use the data source to retrieve the following information for SRV-record from th * `comment`: the description of the record. This is a regular comment. Example: `spare node for the service`. * `ext_attrs`: the set of extensible attributes of the record, if any. The content is formatted as string of JSON map. Example: `"{\"Owner\":\"State Library\", \"Expires\":\"never\"}"`. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_txt_record.md b/docs/data-sources/infoblox_txt_record.md index 57ea91d40..bc5f2abc7 100644 --- a/docs/data-sources/infoblox_txt_record.md +++ b/docs/data-sources/infoblox_txt_record.md @@ -10,9 +10,8 @@ Use the data source to retrieve the following information for TXT-record from th * `comment`: the description of the record. This is a regular comment. Example: `spare node for the service`. * `ext_attrs`: the set of extensible attributes of the record, if any. The content is formatted as string of JSON map. Example: `"{\"Owner\":\"State Library\", \"Expires\":\"never\"}"`. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/data-sources/infoblox_zone_auth.md b/docs/data-sources/infoblox_zone_auth.md index d1c0a8074..19610b168 100644 --- a/docs/data-sources/infoblox_zone_auth.md +++ b/docs/data-sources/infoblox_zone_auth.md @@ -9,9 +9,8 @@ Use the `infoblox_zone_auth` data source to retrieve the following information f * `comment`: The Description of Authoritative Zone Object. Example: `random authoritative zone`. * `ext_attrs`: the set of extensible attributes of the record, if any. The content is formatted as string of JSON map. Example: `"{\"Location\":\"unknown\",\"TestEA\":\"ZoneTesting\"}"`. -For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. Only searchable fields -from below list of supported arguments for filters, are allowed to use in filters, for retrieving one or more records or objects matching -filters. +For usage of filters, add the fields as keys and appropriate values to be passed to the keys like `name`, `view` corresponding to object. +From the below list of supported arguments for filters, use only the searchable fields for retriving the matching records. ### Supported Arguments for filters diff --git a/docs/resources/infoblox_zone_auth.md b/docs/resources/infoblox_zone_auth.md index c1991ffda..99f6fab98 100644 --- a/docs/resources/infoblox_zone_auth.md +++ b/docs/resources/infoblox_zone_auth.md @@ -1,6 +1,6 @@ # Zone Auth Resource -The `infoblox_zone_auth` resource associates authoritative zone with in a DNS View.The resource represents the ‘zone_auth’ WAPI object in NIOS. +The `infoblox_zone_auth` resource associates authoritative zone with a DNS View.The resource represents the ‘zone_auth’ WAPI object in NIOS. The following list describes the parameters you can define in the resource block of the zone auth object: From 789a9de0fd64957c825eb5da7391ffbfc549df2f Mon Sep 17 00:00:00 2001 From: hemanthKa677 Date: Wed, 25 Oct 2023 17:40:14 +0530 Subject: [PATCH 2/3] Fixes terraform crashes with ttl nil pointer dereference --- examples/resources/infoblox_zone_auth.tf | 2 +- infoblox/resource_infoblox_a_record.go | 10 ++++++++-- infoblox/resource_infoblox_aaaa_record.go | 11 +++++++++-- infoblox/resource_infoblox_cname_record.go | 14 ++++++++++++-- infoblox/resource_infoblox_ip_allocation.go | 10 ++++++++-- infoblox/resource_infoblox_mx_record.go | 12 ++++++++++-- infoblox/resource_infoblox_ptr_record.go | 12 ++++++++++-- infoblox/resource_infoblox_srv_record.go | 12 ++++++++++-- infoblox/resource_infoblox_txt_record.go | 12 ++++++++++-- 9 files changed, 78 insertions(+), 17 deletions(-) diff --git a/examples/resources/infoblox_zone_auth.tf b/examples/resources/infoblox_zone_auth.tf index ffd20129c..f7cdea2fc 100644 --- a/examples/resources/infoblox_zone_auth.tf +++ b/examples/resources/infoblox_zone_auth.tf @@ -35,7 +35,7 @@ resource "infoblox_zone_auth" "zone2" { } //IPV6 reverse mapping zone, with minimal set of parameters -resource "infoblox_zone_auth" "zone2" { +resource "infoblox_zone_auth" "zone3" { fqdn = "2002:1100::/64" view = "non_defaultview" zone_format = "IPV6" diff --git a/infoblox/resource_infoblox_a_record.go b/infoblox/resource_infoblox_a_record.go index 0d30b8b5f..1fd4aaa91 100644 --- a/infoblox/resource_infoblox_a_record.go +++ b/infoblox/resource_infoblox_a_record.go @@ -147,6 +147,7 @@ func resourceARecordCreate(d *schema.ResourceData, m interface{}) error { } func resourceARecordGet(d *schema.ResourceData, m interface{}) error { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -171,7 +172,9 @@ func resourceARecordGet(d *schema.ResourceData, m interface{}) error { return err } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } if !*obj.UseTtl { ttl = ttlUndef } @@ -377,6 +380,7 @@ func resourceARecordDelete(d *schema.ResourceData, m interface{}) error { } func resourceARecordImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -401,7 +405,9 @@ func resourceARecordImport(d *schema.ResourceData, m interface{}) ([]*schema.Res return nil, err } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } if !*obj.UseTtl { ttl = ttlUndef } diff --git a/infoblox/resource_infoblox_aaaa_record.go b/infoblox/resource_infoblox_aaaa_record.go index 35b9a607f..53c35a192 100644 --- a/infoblox/resource_infoblox_aaaa_record.go +++ b/infoblox/resource_infoblox_aaaa_record.go @@ -147,6 +147,7 @@ func resourceAAAARecordCreate(d *schema.ResourceData, m interface{}) error { } func resourceAAAARecordGet(d *schema.ResourceData, m interface{}) error { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -169,7 +170,9 @@ func resourceAAAARecordGet(d *schema.ResourceData, m interface{}) error { return err } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } if !*obj.UseTtl { ttl = ttlUndef } @@ -377,6 +380,7 @@ func resourceAAAARecordDelete(d *schema.ResourceData, m interface{}) error { } func resourceAAAARecordImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -399,7 +403,10 @@ func resourceAAAARecordImport(d *schema.ResourceData, m interface{}) ([]*schema. return nil, err } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } diff --git a/infoblox/resource_infoblox_cname_record.go b/infoblox/resource_infoblox_cname_record.go index c7e2b2ee0..2e72a101d 100644 --- a/infoblox/resource_infoblox_cname_record.go +++ b/infoblox/resource_infoblox_cname_record.go @@ -100,6 +100,7 @@ func resourceCNAMERecordCreate(d *schema.ResourceData, m interface{}) error { } func resourceCNAMERecordGet(d *schema.ResourceData, m interface{}) error { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -127,7 +128,11 @@ func resourceCNAMERecordGet(d *schema.ResourceData, m interface{}) error { if err = d.Set("comment", obj.Comment); err != nil { return err } - ttl := int(*obj.Ttl) + + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } @@ -264,6 +269,7 @@ func resourceCNAMERecordDelete(d *schema.ResourceData, m interface{}) error { } func resourceCNAMERecordImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -291,7 +297,11 @@ func resourceCNAMERecordImport(d *schema.ResourceData, m interface{}) ([]*schema if err = d.Set("comment", obj.Comment); err != nil { return nil, err } - ttl := int(*obj.Ttl) + + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } diff --git a/infoblox/resource_infoblox_ip_allocation.go b/infoblox/resource_infoblox_ip_allocation.go index b06d63db0..4221afa90 100644 --- a/infoblox/resource_infoblox_ip_allocation.go +++ b/infoblox/resource_infoblox_ip_allocation.go @@ -261,6 +261,7 @@ func resourceAllocationRequest(d *schema.ResourceData, m interface{}) error { } func resourceAllocationGet(d *schema.ResourceData, m interface{}) error { + var ttl int obj, err := getOrFindHostRec(d, m) if err != nil { if _, ok := err.(*ibclient.NotFoundError); ok { @@ -344,7 +345,9 @@ func resourceAllocationGet(d *schema.ResourceData, m interface{}) error { return err } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } if !*obj.UseTtl { ttl = ttlUndef } @@ -632,6 +635,7 @@ func resourceAllocationRelease(d *schema.ResourceData, m interface{}) error { } func ipAllocationImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + var ttl int obj, err := getOrFindHostRec(d, m) if err != nil { if _, ok := err.(*ibclient.NotFoundError); ok { @@ -713,7 +717,9 @@ func ipAllocationImporter(d *schema.ResourceData, m interface{}) ([]*schema.Reso return nil, err } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } if !*obj.UseTtl { ttl = ttlUndef } diff --git a/infoblox/resource_infoblox_mx_record.go b/infoblox/resource_infoblox_mx_record.go index 93c578041..252b21810 100644 --- a/infoblox/resource_infoblox_mx_record.go +++ b/infoblox/resource_infoblox_mx_record.go @@ -117,6 +117,7 @@ func resourceMXRecordCreate(d *schema.ResourceData, m interface{}) error { } func resourceMXRecordGet(d *schema.ResourceData, m interface{}) error { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -137,7 +138,10 @@ func resourceMXRecordGet(d *schema.ResourceData, m interface{}) error { return fmt.Errorf("failed getting MX-Record: %s", err) } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } @@ -295,6 +299,7 @@ func resourceMXRecordDelete(d *schema.ResourceData, m interface{}) error { } func resourceMXRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -315,7 +320,10 @@ func resourceMXRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.Re return nil, fmt.Errorf("failed getting MX-Record: %s", err) } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } diff --git a/infoblox/resource_infoblox_ptr_record.go b/infoblox/resource_infoblox_ptr_record.go index 240aee2cb..c43130bf9 100644 --- a/infoblox/resource_infoblox_ptr_record.go +++ b/infoblox/resource_infoblox_ptr_record.go @@ -208,6 +208,7 @@ func resourcePTRRecordCreate(d *schema.ResourceData, m interface{}) error { } func resourcePTRRecordGet(d *schema.ResourceData, m interface{}) error { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -227,7 +228,10 @@ func resourcePTRRecordGet(d *schema.ResourceData, m interface{}) error { return fmt.Errorf("getting PTR-record with ID '%s' failed: %s", d.Id(), err) } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } @@ -497,6 +501,7 @@ func resourcePTRRecordDelete(d *schema.ResourceData, m interface{}) error { } func resourcePTRRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -516,7 +521,10 @@ func resourcePTRRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.R return nil, fmt.Errorf("getting PTR-record with ID '%s' failed: %s", d.Id(), err) } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } diff --git a/infoblox/resource_infoblox_srv_record.go b/infoblox/resource_infoblox_srv_record.go index 9a97d51c4..af7fb82e7 100644 --- a/infoblox/resource_infoblox_srv_record.go +++ b/infoblox/resource_infoblox_srv_record.go @@ -121,6 +121,7 @@ func resourceSRVRecordCreate(d *schema.ResourceData, m interface{}) error { } func resourceSRVRecordGet(d *schema.ResourceData, m interface{}) error { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -140,7 +141,10 @@ func resourceSRVRecordGet(d *schema.ResourceData, m interface{}) error { return fmt.Errorf("failed getting SRV-Record: %s", err.Error()) } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } @@ -308,6 +312,7 @@ func resourceSRVRecordDelete(d *schema.ResourceData, m interface{}) error { } func resourceSRVRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -327,7 +332,10 @@ func resourceSRVRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.R return nil, fmt.Errorf("failed getting SRV-Record: %s", err.Error()) } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } diff --git a/infoblox/resource_infoblox_txt_record.go b/infoblox/resource_infoblox_txt_record.go index 3be211b40..ee9875682 100644 --- a/infoblox/resource_infoblox_txt_record.go +++ b/infoblox/resource_infoblox_txt_record.go @@ -103,6 +103,7 @@ func resourceTXTRecordCreate(d *schema.ResourceData, m interface{}) error { } func resourceTXTRecordGet(d *schema.ResourceData, m interface{}) error { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -127,7 +128,10 @@ func resourceTXTRecordGet(d *schema.ResourceData, m interface{}) error { return err } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } @@ -276,6 +280,7 @@ func resourceTXTRecordDelete(d *schema.ResourceData, m interface{}) error { } func resourceTXTRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + var ttl int extAttrJSON := d.Get("ext_attrs").(string) extAttrs, err := terraformDeserializeEAs(extAttrJSON) if err != nil { @@ -300,7 +305,10 @@ func resourceTXTRecordImport(d *schema.ResourceData, m interface{}) ([]*schema.R return nil, err } - ttl := int(*obj.Ttl) + if obj.Ttl != nil { + ttl = int(*obj.Ttl) + } + if !*obj.UseTtl { ttl = ttlUndef } From 1cc367f564aa7ba024b3dd773f21fa5121fa73b1 Mon Sep 17 00:00:00 2001 From: hemanthKa677 Date: Thu, 26 Oct 2023 11:19:55 +0530 Subject: [PATCH 3/3] Fixes Import issue for IP Allocation resource --- infoblox/resource_infoblox_ip_allocation.go | 30 +++++++-------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/infoblox/resource_infoblox_ip_allocation.go b/infoblox/resource_infoblox_ip_allocation.go index 4221afa90..250b346df 100644 --- a/infoblox/resource_infoblox_ip_allocation.go +++ b/infoblox/resource_infoblox_ip_allocation.go @@ -636,16 +636,17 @@ func resourceAllocationRelease(d *schema.ResourceData, m interface{}) error { func ipAllocationImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { var ttl int + internalId := newInternalResourceIdFromString(d.Id()) + if internalId == nil { + return nil, fmt.Errorf("ID value provided is not in a proper format") + } + + d.SetId(internalId.String()) + if err := d.Set("internal_id", internalId.String()); err != nil { + return nil, err + } obj, err := getOrFindHostRec(d, m) if err != nil { - if _, ok := err.(*ibclient.NotFoundError); ok { - d.SetId("") - return nil, ibclient.NewNotFoundError(fmt.Sprintf( - "cannot find apropriate object on NIOS side for resource with ID '%s': %s;"+ - " removing the resource from Terraform state", - d.Id(), err)) - } - return nil, err } @@ -731,18 +732,5 @@ func ipAllocationImporter(d *schema.ResourceData, m interface{}) ([]*schema.Reso return nil, err } - internalId := newInternalResourceIdFromString(d.Id()) - if internalId == nil { - return nil, fmt.Errorf("ID value provided is not in a proper format") - } - - d.SetId(internalId.String()) - if err := d.Set("internal_id", internalId.String()); err != nil { - return nil, err - } - if _, err := getOrFindHostRec(d, m); err != nil { - return nil, err - } - return []*schema.ResourceData{d}, nil }