provider/powerdns: Clean up gofmt errors

This commit is contained in:
James Nugent 2016-01-25 12:50:58 -06:00
parent 3cfe3374a3
commit ff8cb7270e
5 changed files with 62 additions and 63 deletions

View File

@ -1,14 +1,15 @@
package powerdns
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"github.com/hashicorp/go-cleanhttp"
"fmt"
"encoding/json"
"bytes"
"io"
"strings"
"github.com/hashicorp/go-cleanhttp"
)
type Client struct {
@ -101,7 +102,7 @@ func (rrSet *ResourceRecordSet) Id() string {
// Returns name and type of record or record set based on it's ID
func parseId(recId string) (string, string, error) {
s := strings.Split(recId, "-")
if (len(s) == 2) {
if len(s) == 2 {
return s[0], s[1], nil
} else {
return "", "", fmt.Errorf("Unknown record ID format")
@ -209,7 +210,7 @@ func (client *Client) RecordExistsByID(zone string, recId string) (bool, error)
func (client *Client) CreateRecord(zone string, record Record) (string, error) {
reqBody, _ := json.Marshal(zonePatchRequest{
RecordSets: []ResourceRecordSet{
ResourceRecordSet{
{
Name: record.Name,
Type: record.Type,
ChangeType: "REPLACE",
@ -276,7 +277,7 @@ func (client *Client) ReplaceRecordSet(zone string, rrSet ResourceRecordSet) (st
func (client *Client) DeleteRecordSet(zone string, name string, tpe string) error {
reqBody, _ := json.Marshal(zonePatchRequest{
RecordSets: []ResourceRecordSet{
ResourceRecordSet{
{
Name: name,
Type: tpe,
ChangeType: "DELETE",

View File

@ -1,8 +1,8 @@
package powerdns
import (
"log"
"fmt"
"log"
)
type Config struct {

View File

@ -10,13 +10,13 @@ import (
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"api_key": &schema.Schema{
"api_key": {
Type: schema.TypeString,
Required: true,
DefaultFunc: envDefaultFunc("PDNS_API_KEY"),
Description: "REST API authentication key",
},
"server_url": &schema.Schema{
"server_url": {
Type: schema.TypeString,
Required: true,
DefaultFunc: envDefaultFunc("PDNS_SERVER_URL"),
@ -50,4 +50,3 @@ func envDefaultFunc(k string) schema.SchemaDefaultFunc {
return nil, nil
}
}

View File

@ -3,8 +3,9 @@ package powerdns
import (
"log"
"github.com/hashicorp/terraform/helper/schema"
"fmt"
"github.com/hashicorp/terraform/helper/schema"
)
func resourcePDNSRecord() *schema.Resource {
@ -15,43 +16,41 @@ func resourcePDNSRecord() *schema.Resource {
Exists: resourcePDNSRecordExists,
Schema: map[string]*schema.Schema{
"zone": &schema.Schema{
"zone": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"name": &schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"type": &schema.Schema{
"type": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"ttl": &schema.Schema{
"ttl": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
},
"records": &schema.Schema{
"records": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Required: true,
ForceNew: true,
Set: schema.HashString,
},
},
}
}
func resourcePDNSRecordCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Client)
@ -64,7 +63,7 @@ func resourcePDNSRecordCreate(d *schema.ResourceData, meta interface{}) error {
ttl := d.Get("ttl").(int)
recs := d.Get("records").(*schema.Set).List()
if (len(recs) > 0) {
if len(recs) > 0 {
records := make([]Record, 0, len(recs))
for _, recContent := range recs {
records = append(records, Record{Name: rrSet.Name, Type: rrSet.Type, TTL: ttl, Content: recContent.(string)})
@ -109,7 +108,7 @@ func resourcePDNSRecordRead(d *schema.ResourceData, meta interface{}) error {
}
d.Set("records", recs)
if (len(records) > 0) {
if len(records) > 0 {
d.Set("ttl", records[0].TTL)
}

View File

@ -14,7 +14,7 @@ func TestAccPDNSRecord_A(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigA,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-a"),
@ -30,7 +30,7 @@ func TestAccPDNSRecord_AAAA(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigAAAA,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-aaaa"),
@ -46,7 +46,7 @@ func TestAccPDNSRecord_CNAME(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigCNAME,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-cname"),
@ -62,7 +62,7 @@ func TestAccPDNSRecord_HINFO(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigHINFO,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-hinfo"),
@ -78,7 +78,7 @@ func TestAccPDNSRecord_LOC(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigLOC,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-loc"),
@ -94,13 +94,13 @@ func TestAccPDNSRecord_MX(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigMX,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-mx"),
),
},
resource.TestStep{
{
Config: testPDNSRecordConfigMXMulti,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-mx-multi"),
@ -116,7 +116,7 @@ func TestAccPDNSRecord_NAPTR(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigNAPTR,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-naptr"),
@ -132,7 +132,7 @@ func TestAccPDNSRecord_NS(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigNS,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-ns"),
@ -148,7 +148,7 @@ func TestAccPDNSRecord_SPF(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigSPF,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-spf"),
@ -164,7 +164,7 @@ func TestAccPDNSRecord_SSHFP(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigSSHFP,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-sshfp"),
@ -180,7 +180,7 @@ func TestAccPDNSRecord_SRV(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigSRV,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-srv"),
@ -196,7 +196,7 @@ func TestAccPDNSRecord_TXT(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckPDNSRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testPDNSRecordConfigTXT,
Check: resource.ComposeTestCheckFunc(
testAccCheckPDNSRecordExists("powerdns_record.test-txt"),