From 72d67c1d181ae0ac07297fae4b4deb8e67431831 Mon Sep 17 00:00:00 2001 From: Sargurunathan Mohan Date: Mon, 11 Jan 2016 10:46:56 -0800 Subject: [PATCH 1/3] Fix #4 and #11 --- nsone/resource_record.go | 23 ++++++++++++++++++++++- yelppack/Makefile | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/nsone/resource_record.go b/nsone/resource_record.go index 060bf3c3b744..d062da241cbc 100644 --- a/nsone/resource_record.go +++ b/nsone/resource_record.go @@ -4,9 +4,9 @@ import ( "bytes" "errors" "fmt" - "github.com/bobtfish/go-nsone-api" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" + "github.com/bobtfish/go-nsone-api" "log" "regexp" "sort" @@ -55,6 +55,10 @@ func recordResource() *schema.Resource { Optional: true, ForceNew: true, }, + "use_client_subnet": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + }, "answers": &schema.Schema{ Type: schema.TypeSet, Optional: true, @@ -124,6 +128,10 @@ func recordResource() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "up": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + }, }, }, Set: regionsToHash, @@ -163,6 +171,7 @@ func regionsToHash(v interface{}) int { buf.WriteString(fmt.Sprintf("%s-", r["georegion"].(string))) buf.WriteString(fmt.Sprintf("%s-", r["country"].(string))) buf.WriteString(fmt.Sprintf("%s-", r["us_state"].(string))) + buf.WriteString(fmt.Sprintf("%t-", r["up"].(bool))) return hashcode.String(buf.String()) } @@ -263,6 +272,11 @@ func recordToResourceData(d *schema.ResourceData, r *nsone.Record) error { if len(region.Meta.USState) > 0 { new_region["us_state"] = region.Meta.USState[0] } + if region.Meta.Up { + new_region["up"] = region.Meta.Up + } else { + new_region["up"] = false + } regions = append(regions, new_region) } log.Printf("Setting regions %+v", regions) @@ -369,6 +383,9 @@ func resourceDataToRecord(r *nsone.Record, d *schema.ResourceData) error { if v, ok := d.GetOk("link"); ok { r.LinkTo(v.(string)) } + if v, ok := d.GetOk("useClientSubnet"); ok { + r.UseClientSubnet = (v.(bool)) + } if rawFilters := d.Get("filters").([]interface{}); len(rawFilters) > 0 { f := make([]nsone.Filter, len(rawFilters)) for i, filter_raw := range rawFilters { @@ -410,6 +427,10 @@ func resourceDataToRecord(r *nsone.Record, d *schema.ResourceData) error { if g := region["us_state"].(string); g != "" { nsone_r.Meta.USState = []string{g} } + if g := region["up"].(bool); g { + nsone_r.Meta.Up = g + } + rm[region["name"].(string)] = nsone_r } r.Regions = rm diff --git a/yelppack/Makefile b/yelppack/Makefile index af44e44b09ba..5c03f60fc0b3 100644 --- a/yelppack/Makefile +++ b/yelppack/Makefile @@ -8,7 +8,7 @@ ifdef upstream_build_number else REAL_BUILD_NUMBER?=$(BUILD_NUMBER) endif -VERSION = 0.3 +VERSION = 0.4 ITERATION = yelp$(REAL_BUILD_NUMBER) ARCH := $(shell dpkg --print-architecture) From 016fb2a0621f1d78762b4888816f58b5ec9879fb Mon Sep 17 00:00:00 2001 From: Sargurunathan Mohan Date: Mon, 11 Jan 2016 10:48:40 -0800 Subject: [PATCH 2/3] go fmt --- nsone/resource_record.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nsone/resource_record.go b/nsone/resource_record.go index d062da241cbc..1c42ad3e93b1 100644 --- a/nsone/resource_record.go +++ b/nsone/resource_record.go @@ -4,9 +4,9 @@ import ( "bytes" "errors" "fmt" + "github.com/bobtfish/go-nsone-api" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" - "github.com/bobtfish/go-nsone-api" "log" "regexp" "sort" From f3251fb4e3b5b9ccde8ba8801e2443ad02f4cc84 Mon Sep 17 00:00:00 2001 From: Sargurunathan Mohan Date: Mon, 11 Jan 2016 17:34:23 -0800 Subject: [PATCH 3/3] Boolean and GetOK doesnt play very well --- nsone/resource_record.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nsone/resource_record.go b/nsone/resource_record.go index 1c42ad3e93b1..f96b68da1ea2 100644 --- a/nsone/resource_record.go +++ b/nsone/resource_record.go @@ -58,6 +58,7 @@ func recordResource() *schema.Resource { "use_client_subnet": &schema.Schema{ Type: schema.TypeBool, Optional: true, + Default: true, }, "answers": &schema.Schema{ Type: schema.TypeSet, @@ -383,9 +384,11 @@ func resourceDataToRecord(r *nsone.Record, d *schema.ResourceData) error { if v, ok := d.GetOk("link"); ok { r.LinkTo(v.(string)) } - if v, ok := d.GetOk("useClientSubnet"); ok { - r.UseClientSubnet = (v.(bool)) + useClientSubnetVal := d.Get("use_client_subnet").(bool) + if v := strconv.FormatBool(useClientSubnetVal); v != "" { + r.UseClientSubnet = useClientSubnetVal } + if rawFilters := d.Get("filters").([]interface{}); len(rawFilters) > 0 { f := make([]nsone.Filter, len(rawFilters)) for i, filter_raw := range rawFilters {