Skip to content

Commit

Permalink
Merge pull request #84 from NetApp/stable-1.0
Browse files Browse the repository at this point in the history
Stable 1.0
  • Loading branch information
carchi8py authored Nov 9, 2023
2 parents 1cbbfce + 4401b5a commit ee4b87c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
## 1.0.1 ()

BUG FIXES:
* netapp-ontap_name_services_dns_resource: Fixed and Documented Import ([#63](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/63))
* netapp-ontap_cluster_data_source, netapp-ontap_snapmirrors_data_source, netapp-ontap_networking_ip_route_resource and netapp-ontap_sotrage_volume_resource: Fix documentation ([#70](https://github.com/NetApp/terraform-provider-netapp-ontap/issues/70))

## 1.0.0 (2023-11-06)
Expand Down
13 changes: 12 additions & 1 deletion docs/resources/name_services_dns_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ resource "netapp-ontap_name_services_dns_resource" "name_services_dns" {
- `id` (String) UUID of svm

## Import
Import has not been tested, and may not work. We are working on getting this documented for the next release..
### Terrafrom import
terraform import netapp-ontap_name_services_dns_resource.`name` `svm_name`,`cx_profile_name`
* name -- name you want to give the resource in terraform
* svm_name -- name of the svm the resource belongs to
* cx_profile_name -- name of the connection profile to use

For example
```shell
terraform import netapp-ontap_name_services_dns_resource.dns_import ansibleSVM,cluster4
```

!> The terraform import CLI command can only import resources into the state. Importing via the CLI does not generate configuration. If you want to generate the accompanying configuration for imported resources, use the import block instead.


2 changes: 1 addition & 1 deletion internal/interfaces/name_services_dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func CreateNameServicesDNS(errorHandler *utils.ErrorHandler, r restclient.RestCl
}
query := r.NewQuery()
query.Add("return_records", "true")
tflog.Debug(errorHandler.Ctx, fmt.Sprintf("carchi8py body is : %#v", body))
tflog.Debug(errorHandler.Ctx, fmt.Sprintf("name-services/dns body is : %#v", body))
statusCode, response, err := r.CallCreateMethod("name-services/dns", query, body)
if err != nil {
return nil, errorHandler.MakeAndReportError("error creating DNS", fmt.Sprintf("error on POST name-services/dns: %s, statusCode %d", err, statusCode))
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ func ExpontentialBackoff(sleepTime int, maxSleepTime int) int {
time.Sleep(time.Duration(sleepTime) * time.Second)
return sleepTime
}

// StringInSlice checks if a string is in a slice of strings
func StringInSlice(str string, list []types.String) bool {
for _, v := range list {
if v.ValueString() == str {
return true
}
}
return false
}
8 changes: 6 additions & 2 deletions internal/provider/name_services_dns_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,16 @@ func (r *NameServicesDNSResource) Read(ctx context.Context, req resource.ReadReq
data.ID = types.StringValue(restInfo.SVM.UUID)
var servers []types.String
for _, v := range restInfo.Servers {
servers = append(data.NameServers, types.StringValue(v))
if !StringInSlice(v, data.NameServers) {
servers = append(servers, types.StringValue(v))
}
}
data.NameServers = servers
var domains []types.String
for _, v := range restInfo.Domains {
domains = append(data.Domains, types.StringValue(v))
if !StringInSlice(v, data.Domains) {
domains = append(domains, types.StringValue(v))
}
}
data.Domains = domains

Expand Down

0 comments on commit ee4b87c

Please sign in to comment.