Skip to content

Commit

Permalink
Merge pull request hashicorp#13 from sarguru/master
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Jan 12, 2016
2 parents 8950844 + f3251fb commit 12c59f5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions nsone/resource_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func recordResource() *schema.Resource {
Optional: true,
ForceNew: true,
},
"use_client_subnet": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"answers": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -124,6 +129,10 @@ func recordResource() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"up": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
},
},
},
Set: regionsToHash,
Expand Down Expand Up @@ -163,6 +172,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())
}

Expand Down Expand Up @@ -263,6 +273,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)
Expand Down Expand Up @@ -369,6 +384,11 @@ func resourceDataToRecord(r *nsone.Record, d *schema.ResourceData) error {
if v, ok := d.GetOk("link"); ok {
r.LinkTo(v.(string))
}
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 {
Expand Down Expand Up @@ -410,6 +430,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
Expand Down
2 changes: 1 addition & 1 deletion yelppack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 12c59f5

Please sign in to comment.