Skip to content

Commit ad40030

Browse files
committed
Fix freeipa_dns_record
1 parent 0e5115c commit ad40030

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

freeipa/resource_freeipa_dns_record.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package freeipa
22

33
import (
4+
"fmt"
45
"log"
56

67
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
@@ -53,15 +54,15 @@ func resourceFreeIPADNSRecordCreate(d *schema.ResourceData, meta interface{}) er
5354
return err
5455
}
5556

57+
idnsname := d.Get("idnsname").(string)
58+
dnszoneidnsname := d.Get("dnszoneidnsname")
59+
5660
args := ipa.DnsrecordAddArgs{
57-
Idnsname: d.Get("idnsname").(string),
61+
Idnsname: idnsname,
5862
}
5963

60-
optArgs := ipa.DnsrecordAddOptionalArgs{}
61-
62-
if _dnszoneidnsname, ok := d.GetOkExists("dnszoneidnsname"); ok {
63-
dnszoneidnsname := _dnszoneidnsname.(string)
64-
optArgs.Dnszoneidnsname = &dnszoneidnsname
64+
optArgs := ipa.DnsrecordAddOptionalArgs{
65+
Dnszoneidnsname: &dnszoneidnsname,
6566
}
6667

6768
if _dnsttl, ok := d.GetOkExists("dnsttl"); ok {
@@ -84,7 +85,7 @@ func resourceFreeIPADNSRecordCreate(d *schema.ResourceData, meta interface{}) er
8485
return err
8586
}
8687

87-
d.SetId(args.Idnsname)
88+
d.SetId(fmt.Sprintf("%s.%s", idnsname, dnszoneidnsname))
8889

8990
return resourceFreeIPADNSRecordRead(d, meta)
9091
}
@@ -104,7 +105,7 @@ func resourceFreeIPADNSRecordUpdate(d *schema.ResourceData, meta interface{}) er
104105
optArgs := ipa.DnsrecordModOptionalArgs{}
105106

106107
if _dnszoneidnsname, ok := d.GetOkExists("dnszoneidnsname"); ok {
107-
dnszoneidnsname := _dnszoneidnsname.(string)
108+
dnszoneidnsname := _dnszoneidnsname
108109
optArgs.Dnszoneidnsname = &dnszoneidnsname
109110
}
110111

@@ -146,7 +147,7 @@ func resourceFreeIPADNSRecordRead(d *schema.ResourceData, meta interface{}) erro
146147
optArgs := ipa.DnsrecordShowOptionalArgs{}
147148

148149
if _dnszoneidnsname, ok := d.GetOkExists("dnszoneidnsname"); ok {
149-
dnszoneidnsname := _dnszoneidnsname.(string)
150+
dnszoneidnsname := _dnszoneidnsname
150151
optArgs.Dnszoneidnsname = &dnszoneidnsname
151152
}
152153

@@ -182,7 +183,12 @@ func resourceFreeIPADNSRecordDelete(d *schema.ResourceData, meta interface{}) er
182183
Idnsname: d.Get("idnsname").(string),
183184
}
184185

185-
optArgs := ipa.DnsrecordDelOptionalArgs{}
186+
dnszoneidnsname := d.Get("dnszoneidnsname")
187+
delAll := true
188+
optArgs := ipa.DnsrecordDelOptionalArgs{
189+
Dnszoneidnsname: &dnszoneidnsname,
190+
DelAll: &delAll,
191+
}
186192

187193
_, err = client.DnsrecordDel(&args, &optArgs)
188194
if err != nil {

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module github.com/camptocamp/terraform-provider-freeipa
22

33
go 1.12
44

5+
replace github.com/tehwalris/go-freeipa => github.com/camptocamp/go-freeipa v0.0.0-20200408154013-bc9bd4dc80cf
6+
57
require (
68
github.com/hashicorp/terraform-plugin-sdk v1.7.0
79
github.com/tehwalris/go-freeipa v0.0.0-20200322083409-e462fc554b76

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U
3030
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
3131
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
3232
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
33+
github.com/camptocamp/go-freeipa v0.0.0-20200408154013-bc9bd4dc80cf h1:tcUp4fdVVheiDFpi91kvVHPc1EwgDLGZ/wRyNgkq5YA=
34+
github.com/camptocamp/go-freeipa v0.0.0-20200408154013-bc9bd4dc80cf/go.mod h1:mZZdj7BR8u8vfMa+vTuaebKc6ko4XefzNn5bguha+0M=
3335
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
3436
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
3537
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

0 commit comments

Comments
 (0)