Skip to content

Commit ff8cb72

Browse files
committed
provider/powerdns: Clean up gofmt errors
1 parent 3cfe337 commit ff8cb72

5 files changed

Lines changed: 62 additions & 63 deletions

File tree

builtin/providers/powerdns/client.go

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
package powerdns
22

33
import (
4-
"net/http"
5-
"net/url"
6-
"github.com/hashicorp/go-cleanhttp"
7-
"fmt"
8-
"encoding/json"
94
"bytes"
5+
"encoding/json"
6+
"fmt"
107
"io"
8+
"net/http"
9+
"net/url"
1110
"strings"
11+
12+
"github.com/hashicorp/go-cleanhttp"
1213
)
1314

1415
type Client struct {
1516
// Location of PowerDNS server to use
1617
ServerUrl string
1718
// REST API Static authentication key
18-
ApiKey string
19-
Http *http.Client
19+
ApiKey string
20+
Http *http.Client
2021
}
2122

2223
// NewClient returns a new PowerDNS client
2324
func NewClient(serverUrl string, apiKey string) (*Client, error) {
2425
client := Client{
25-
ServerUrl:serverUrl,
26-
ApiKey:apiKey,
27-
Http: cleanhttp.DefaultClient(),
26+
ServerUrl: serverUrl,
27+
ApiKey: apiKey,
28+
Http: cleanhttp.DefaultClient(),
2829
}
2930
return &client, nil
3031
}
@@ -58,27 +59,27 @@ func (c *Client) newRequest(method string, endpoint string, body []byte) (*http.
5859
}
5960

6061
type ZoneInfo struct {
61-
Id string `json:"id"`
62-
Name string `json:"name"`
63-
URL string `json:"url"`
64-
Kind string `json:"kind"`
65-
DnsSec bool `json:"dnsssec"`
66-
Serial int64 `json:"serial"`
67-
Records []Record `json:"records,omitempty"`
62+
Id string `json:"id"`
63+
Name string `json:"name"`
64+
URL string `json:"url"`
65+
Kind string `json:"kind"`
66+
DnsSec bool `json:"dnsssec"`
67+
Serial int64 `json:"serial"`
68+
Records []Record `json:"records,omitempty"`
6869
}
6970

7071
type Record struct {
7172
Name string `json:"name"`
7273
Type string `json:"type"`
7374
Content string `json:"content"`
74-
TTL int `json:"ttl"`
75-
Disabled bool `json:"disabled"`
75+
TTL int `json:"ttl"`
76+
Disabled bool `json:"disabled"`
7677
}
7778

7879
type ResourceRecordSet struct {
79-
Name string `json:"name"`
80-
Type string `json:"type"`
81-
ChangeType string `json:"changetype"`
80+
Name string `json:"name"`
81+
Type string `json:"type"`
82+
ChangeType string `json:"changetype"`
8283
Records []Record `json:"records,omitempty"`
8384
}
8485

@@ -101,7 +102,7 @@ func (rrSet *ResourceRecordSet) Id() string {
101102
// Returns name and type of record or record set based on it's ID
102103
func parseId(recId string) (string, string, error) {
103104
s := strings.Split(recId, "-")
104-
if (len(s) == 2) {
105+
if len(s) == 2 {
105106
return s[0], s[1], nil
106107
} else {
107108
return "", "", fmt.Errorf("Unknown record ID format")
@@ -209,11 +210,11 @@ func (client *Client) RecordExistsByID(zone string, recId string) (bool, error)
209210
func (client *Client) CreateRecord(zone string, record Record) (string, error) {
210211
reqBody, _ := json.Marshal(zonePatchRequest{
211212
RecordSets: []ResourceRecordSet{
212-
ResourceRecordSet{
213-
Name: record.Name,
214-
Type: record.Type,
213+
{
214+
Name: record.Name,
215+
Type: record.Type,
215216
ChangeType: "REPLACE",
216-
Records: []Record{record},
217+
Records: []Record{record},
217218
},
218219
},
219220
})
@@ -246,7 +247,7 @@ func (client *Client) ReplaceRecordSet(zone string, rrSet ResourceRecordSet) (st
246247
rrSet.ChangeType = "REPLACE"
247248

248249
reqBody, _ := json.Marshal(zonePatchRequest{
249-
RecordSets: []ResourceRecordSet{rrSet },
250+
RecordSets: []ResourceRecordSet{rrSet},
250251
})
251252

252253
req, err := client.newRequest("PATCH", fmt.Sprintf("/servers/localhost/zones/%s", zone), reqBody)
@@ -276,9 +277,9 @@ func (client *Client) ReplaceRecordSet(zone string, rrSet ResourceRecordSet) (st
276277
func (client *Client) DeleteRecordSet(zone string, name string, tpe string) error {
277278
reqBody, _ := json.Marshal(zonePatchRequest{
278279
RecordSets: []ResourceRecordSet{
279-
ResourceRecordSet{
280-
Name: name,
281-
Type: tpe,
280+
{
281+
Name: name,
282+
Type: tpe,
282283
ChangeType: "DELETE",
283284
},
284285
},
@@ -315,4 +316,4 @@ func (client *Client) DeleteRecordSetByID(zone string, recId string) error {
315316
} else {
316317
return client.DeleteRecordSet(zone, name, tpe)
317318
}
318-
}
319+
}

builtin/providers/powerdns/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package powerdns
22

33
import (
4-
"log"
54
"fmt"
5+
"log"
66
)
77

88
type Config struct {

builtin/providers/powerdns/provider.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
func Provider() terraform.ResourceProvider {
1111
return &schema.Provider{
1212
Schema: map[string]*schema.Schema{
13-
"api_key": &schema.Schema{
13+
"api_key": {
1414
Type: schema.TypeString,
1515
Required: true,
1616
DefaultFunc: envDefaultFunc("PDNS_API_KEY"),
1717
Description: "REST API authentication key",
1818
},
19-
"server_url": &schema.Schema{
19+
"server_url": {
2020
Type: schema.TypeString,
2121
Required: true,
2222
DefaultFunc: envDefaultFunc("PDNS_SERVER_URL"),
@@ -34,7 +34,7 @@ func Provider() terraform.ResourceProvider {
3434

3535
func providerConfigure(data *schema.ResourceData) (interface{}, error) {
3636
config := Config{
37-
ApiKey: data.Get("api_key").(string),
37+
ApiKey: data.Get("api_key").(string),
3838
ServerUrl: data.Get("server_url").(string),
3939
}
4040

@@ -50,4 +50,3 @@ func envDefaultFunc(k string) schema.SchemaDefaultFunc {
5050
return nil, nil
5151
}
5252
}
53-

builtin/providers/powerdns/resource_powerdns_record.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package powerdns
33
import (
44
"log"
55

6-
"github.com/hashicorp/terraform/helper/schema"
76
"fmt"
7+
8+
"github.com/hashicorp/terraform/helper/schema"
89
)
910

1011
func resourcePDNSRecord() *schema.Resource {
@@ -15,43 +16,41 @@ func resourcePDNSRecord() *schema.Resource {
1516
Exists: resourcePDNSRecordExists,
1617

1718
Schema: map[string]*schema.Schema{
18-
"zone": &schema.Schema{
19+
"zone": {
1920
Type: schema.TypeString,
2021
Required: true,
2122
ForceNew: true,
2223
},
2324

24-
"name": &schema.Schema{
25+
"name": {
2526
Type: schema.TypeString,
2627
Required: true,
2728
ForceNew: true,
2829
},
2930

30-
"type": &schema.Schema{
31+
"type": {
3132
Type: schema.TypeString,
3233
Required: true,
3334
ForceNew: true,
3435
},
3536

36-
"ttl": &schema.Schema{
37+
"ttl": {
3738
Type: schema.TypeInt,
3839
Required: true,
3940
ForceNew: true,
4041
},
4142

42-
"records": &schema.Schema{
43+
"records": {
4344
Type: schema.TypeSet,
4445
Elem: &schema.Schema{Type: schema.TypeString},
4546
Required: true,
4647
ForceNew: true,
4748
Set: schema.HashString,
4849
},
49-
5050
},
5151
}
5252
}
5353

54-
5554
func resourcePDNSRecordCreate(d *schema.ResourceData, meta interface{}) error {
5655
client := meta.(*Client)
5756

@@ -64,10 +63,10 @@ func resourcePDNSRecordCreate(d *schema.ResourceData, meta interface{}) error {
6463
ttl := d.Get("ttl").(int)
6564
recs := d.Get("records").(*schema.Set).List()
6665

67-
if (len(recs) > 0) {
66+
if len(recs) > 0 {
6867
records := make([]Record, 0, len(recs))
6968
for _, recContent := range recs {
70-
records = append(records, Record{Name: rrSet.Name, Type:rrSet.Type, TTL: ttl, Content: recContent.(string)})
69+
records = append(records, Record{Name: rrSet.Name, Type: rrSet.Type, TTL: ttl, Content: recContent.(string)})
7170
}
7271
rrSet.Records = records
7372

@@ -109,7 +108,7 @@ func resourcePDNSRecordRead(d *schema.ResourceData, meta interface{}) error {
109108
}
110109
d.Set("records", recs)
111110

112-
if (len(records) > 0) {
111+
if len(records) > 0 {
113112
d.Set("ttl", records[0].TTL)
114113
}
115114

@@ -144,4 +143,4 @@ func resourcePDNSRecordExists(d *schema.ResourceData, meta interface{}) (bool, e
144143
} else {
145144
return exists, nil
146145
}
147-
}
146+
}

builtin/providers/powerdns/resource_powerdns_record_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestAccPDNSRecord_A(t *testing.T) {
1414
Providers: testAccProviders,
1515
CheckDestroy: testAccCheckPDNSRecordDestroy,
1616
Steps: []resource.TestStep{
17-
resource.TestStep{
17+
{
1818
Config: testPDNSRecordConfigA,
1919
Check: resource.ComposeTestCheckFunc(
2020
testAccCheckPDNSRecordExists("powerdns_record.test-a"),
@@ -30,7 +30,7 @@ func TestAccPDNSRecord_AAAA(t *testing.T) {
3030
Providers: testAccProviders,
3131
CheckDestroy: testAccCheckPDNSRecordDestroy,
3232
Steps: []resource.TestStep{
33-
resource.TestStep{
33+
{
3434
Config: testPDNSRecordConfigAAAA,
3535
Check: resource.ComposeTestCheckFunc(
3636
testAccCheckPDNSRecordExists("powerdns_record.test-aaaa"),
@@ -46,7 +46,7 @@ func TestAccPDNSRecord_CNAME(t *testing.T) {
4646
Providers: testAccProviders,
4747
CheckDestroy: testAccCheckPDNSRecordDestroy,
4848
Steps: []resource.TestStep{
49-
resource.TestStep{
49+
{
5050
Config: testPDNSRecordConfigCNAME,
5151
Check: resource.ComposeTestCheckFunc(
5252
testAccCheckPDNSRecordExists("powerdns_record.test-cname"),
@@ -62,7 +62,7 @@ func TestAccPDNSRecord_HINFO(t *testing.T) {
6262
Providers: testAccProviders,
6363
CheckDestroy: testAccCheckPDNSRecordDestroy,
6464
Steps: []resource.TestStep{
65-
resource.TestStep{
65+
{
6666
Config: testPDNSRecordConfigHINFO,
6767
Check: resource.ComposeTestCheckFunc(
6868
testAccCheckPDNSRecordExists("powerdns_record.test-hinfo"),
@@ -78,7 +78,7 @@ func TestAccPDNSRecord_LOC(t *testing.T) {
7878
Providers: testAccProviders,
7979
CheckDestroy: testAccCheckPDNSRecordDestroy,
8080
Steps: []resource.TestStep{
81-
resource.TestStep{
81+
{
8282
Config: testPDNSRecordConfigLOC,
8383
Check: resource.ComposeTestCheckFunc(
8484
testAccCheckPDNSRecordExists("powerdns_record.test-loc"),
@@ -94,13 +94,13 @@ func TestAccPDNSRecord_MX(t *testing.T) {
9494
Providers: testAccProviders,
9595
CheckDestroy: testAccCheckPDNSRecordDestroy,
9696
Steps: []resource.TestStep{
97-
resource.TestStep{
97+
{
9898
Config: testPDNSRecordConfigMX,
9999
Check: resource.ComposeTestCheckFunc(
100100
testAccCheckPDNSRecordExists("powerdns_record.test-mx"),
101101
),
102102
},
103-
resource.TestStep{
103+
{
104104
Config: testPDNSRecordConfigMXMulti,
105105
Check: resource.ComposeTestCheckFunc(
106106
testAccCheckPDNSRecordExists("powerdns_record.test-mx-multi"),
@@ -116,7 +116,7 @@ func TestAccPDNSRecord_NAPTR(t *testing.T) {
116116
Providers: testAccProviders,
117117
CheckDestroy: testAccCheckPDNSRecordDestroy,
118118
Steps: []resource.TestStep{
119-
resource.TestStep{
119+
{
120120
Config: testPDNSRecordConfigNAPTR,
121121
Check: resource.ComposeTestCheckFunc(
122122
testAccCheckPDNSRecordExists("powerdns_record.test-naptr"),
@@ -132,7 +132,7 @@ func TestAccPDNSRecord_NS(t *testing.T) {
132132
Providers: testAccProviders,
133133
CheckDestroy: testAccCheckPDNSRecordDestroy,
134134
Steps: []resource.TestStep{
135-
resource.TestStep{
135+
{
136136
Config: testPDNSRecordConfigNS,
137137
Check: resource.ComposeTestCheckFunc(
138138
testAccCheckPDNSRecordExists("powerdns_record.test-ns"),
@@ -148,7 +148,7 @@ func TestAccPDNSRecord_SPF(t *testing.T) {
148148
Providers: testAccProviders,
149149
CheckDestroy: testAccCheckPDNSRecordDestroy,
150150
Steps: []resource.TestStep{
151-
resource.TestStep{
151+
{
152152
Config: testPDNSRecordConfigSPF,
153153
Check: resource.ComposeTestCheckFunc(
154154
testAccCheckPDNSRecordExists("powerdns_record.test-spf"),
@@ -164,7 +164,7 @@ func TestAccPDNSRecord_SSHFP(t *testing.T) {
164164
Providers: testAccProviders,
165165
CheckDestroy: testAccCheckPDNSRecordDestroy,
166166
Steps: []resource.TestStep{
167-
resource.TestStep{
167+
{
168168
Config: testPDNSRecordConfigSSHFP,
169169
Check: resource.ComposeTestCheckFunc(
170170
testAccCheckPDNSRecordExists("powerdns_record.test-sshfp"),
@@ -180,7 +180,7 @@ func TestAccPDNSRecord_SRV(t *testing.T) {
180180
Providers: testAccProviders,
181181
CheckDestroy: testAccCheckPDNSRecordDestroy,
182182
Steps: []resource.TestStep{
183-
resource.TestStep{
183+
{
184184
Config: testPDNSRecordConfigSRV,
185185
Check: resource.ComposeTestCheckFunc(
186186
testAccCheckPDNSRecordExists("powerdns_record.test-srv"),
@@ -196,7 +196,7 @@ func TestAccPDNSRecord_TXT(t *testing.T) {
196196
Providers: testAccProviders,
197197
CheckDestroy: testAccCheckPDNSRecordDestroy,
198198
Steps: []resource.TestStep{
199-
resource.TestStep{
199+
{
200200
Config: testPDNSRecordConfigTXT,
201201
Check: resource.ComposeTestCheckFunc(
202202
testAccCheckPDNSRecordExists("powerdns_record.test-txt"),
@@ -364,4 +364,4 @@ resource "powerdns_record" "test-txt" {
364364
type = "TXT"
365365
ttl = 60
366366
records = [ "\"text record payload\"" ]
367-
}`
367+
}`

0 commit comments

Comments
 (0)