This commit is contained in:
Mitchell Hashimoto 2014-10-10 14:50:35 -07:00
parent b43cfa3bb0
commit 36f225dea0
13 changed files with 68 additions and 69 deletions

View File

@ -92,7 +92,7 @@ func resource_aws_subnet_destroy(
_, err := ec2conn.DeleteSubnet(s.ID) _, err := ec2conn.DeleteSubnet(s.ID)
return err return err
} }
if err := resource.Retry(10 * time.Second, f); err != nil { if err := resource.Retry(10*time.Second, f); err != nil {
ec2err, ok := err.(*ec2.Error) ec2err, ok := err.(*ec2.Error)
if ok && ec2err.Code == "InvalidSubnetID.NotFound" { if ok && ec2err.Code == "InvalidSubnetID.NotFound" {
return nil return nil

View File

@ -172,10 +172,10 @@ func Test_flattenIPPerms(t *testing.T) {
func Test_expandListeners(t *testing.T) { func Test_expandListeners(t *testing.T) {
expanded := []interface{}{ expanded := []interface{}{
map[string]interface{}{ map[string]interface{}{
"instance_port": 8000, "instance_port": 8000,
"lb_port": 80, "lb_port": 80,
"instance_protocol": "http", "instance_protocol": "http",
"lb_protocol": "http", "lb_protocol": "http",
}, },
} }
listeners, err := expandListeners(expanded) listeners, err := expandListeners(expanded)

View File

@ -42,7 +42,7 @@ func resourceComputeDisk() *schema.Resource {
}, },
"type": &schema.Schema{ "type": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },

View File

@ -211,7 +211,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
} }
} }
if v, ok := d.GetOk(prefix + ".type"); ok { if v, ok := d.GetOk(prefix + ".type"); ok {
diskTypeName := v.(string) diskTypeName := v.(string)
diskType, err := readDiskType(config, zone, diskTypeName) diskType, err := readDiskType(config, zone, diskTypeName)
if err != nil { if err != nil {

View File

@ -243,7 +243,7 @@ func TestConfigValidate_varModuleInvalid(t *testing.T) {
} }
func TestNameRegexp(t *testing.T) { func TestNameRegexp(t *testing.T) {
cases := []struct{ cases := []struct {
Input string Input string
Match bool Match bool
}{ }{

View File

@ -26,8 +26,8 @@ type interpolationWalker struct {
// //
// If Replace is true, then the return value of F will be used to // If Replace is true, then the return value of F will be used to
// replace the interpolation. // replace the interpolation.
F interpolationWalkerFunc F interpolationWalkerFunc
Replace bool Replace bool
// ContextF is an advanced version of F that also receives the // ContextF is an advanced version of F that also receives the
// location of where it is in the structure. This lets you do // location of where it is in the structure. This lets you do

View File

@ -19,7 +19,7 @@ func TestRetry(t *testing.T) {
return fmt.Errorf("error") return fmt.Errorf("error")
} }
err := Retry(2 * time.Second, f) err := Retry(2*time.Second, f)
if err != nil { if err != nil {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
@ -32,7 +32,7 @@ func TestRetry_timeout(t *testing.T) {
return fmt.Errorf("always") return fmt.Errorf("always")
} }
err := Retry(1 * time.Second, f) err := Retry(1*time.Second, f)
if err == nil { if err == nil {
t.Fatal("should error") t.Fatal("should error")
} }

View File

@ -451,8 +451,8 @@ func TestSchemaMap_Diff(t *testing.T) {
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{
"ports.#": &terraform.ResourceAttrDiff{ "ports.#": &terraform.ResourceAttrDiff{
Old: "0", Old: "0",
New: "", New: "",
NewComputed: true, NewComputed: true,
}, },
}, },
@ -713,8 +713,8 @@ func TestSchemaMap_Diff(t *testing.T) {
Diff: &terraform.InstanceDiff{ Diff: &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{
"ports.#": &terraform.ResourceAttrDiff{ "ports.#": &terraform.ResourceAttrDiff{
Old: "0", Old: "0",
New: "", New: "",
NewComputed: true, NewComputed: true,
}, },
}, },

2
log.go
View File

@ -7,7 +7,7 @@ import (
// These are the environmental variables that determine if we log, and if // These are the environmental variables that determine if we log, and if
// we log whether or not the log should go to a file. // we log whether or not the log should go to a file.
const EnvLog = "TF_LOG" //Set to True const EnvLog = "TF_LOG" //Set to True
const EnvLogFile = "TF_LOG_PATH" //Set to a file const EnvLogFile = "TF_LOG_PATH" //Set to a file
// logOutput determines where we should send logs (if anywhere). // logOutput determines where we should send logs (if anywhere).

View File

@ -221,49 +221,49 @@ func graphDotAddResources(
// Handle the meta resources // Handle the meta resources
/* /*
edgeBuf.Reset() edgeBuf.Reset()
for _, n := range g.Nouns { for _, n := range g.Nouns {
_, ok := n.Meta.(*GraphNodeResourceMeta) _, ok := n.Meta.(*GraphNodeResourceMeta)
if !ok { if !ok {
continue continue
}
// Determine which edges to add
var edges []digraph.Edge
if hasDiff {
for _, e := range n.Edges() {
rn, ok := e.Tail().(*depgraph.Noun).Meta.(*GraphNodeResource)
if !ok {
continue
}
if rn.Resource.Diff == nil || rn.Resource.Diff.Empty() {
continue
}
edges = append(edges, e)
} }
} else {
edges = n.Edges()
}
// Do not draw if we have no edges // Determine which edges to add
if len(edges) == 0 { var edges []digraph.Edge
continue if hasDiff {
} for _, e := range n.Edges() {
rn, ok := e.Tail().(*depgraph.Noun).Meta.(*GraphNodeResource)
if !ok {
continue
}
if rn.Resource.Diff == nil || rn.Resource.Diff.Empty() {
continue
}
edges = append(edges, e)
}
} else {
edges = n.Edges()
}
uniqueName := fmt.Sprintf("%d_%s", opts.depth, n) // Do not draw if we have no edges
for _, e := range edges { if len(edges) == 0 {
target := e.Tail() continue
uniqueTarget := fmt.Sprintf("%d_%s", opts.depth, target) }
edgeBuf.WriteString(fmt.Sprintf(
"\t\"%s\" -> \"%s\";\n", uniqueName := fmt.Sprintf("%d_%s", opts.depth, n)
uniqueName, for _, e := range edges {
uniqueTarget)) target := e.Tail()
uniqueTarget := fmt.Sprintf("%d_%s", opts.depth, target)
edgeBuf.WriteString(fmt.Sprintf(
"\t\"%s\" -> \"%s\";\n",
uniqueName,
uniqueTarget))
}
}
if edgeBuf.Len() > 0 {
buf.WriteString(edgeBuf.String())
buf.WriteString("\n")
} }
}
if edgeBuf.Len() > 0 {
buf.WriteString(edgeBuf.String())
buf.WriteString("\n")
}
*/ */
} }

View File

@ -463,16 +463,16 @@ func TestGraphAddDiff(t *testing.T) {
} }
/* /*
TODO: test this somewhere TODO: test this somewhere
// Verify that the state has been added // Verify that the state has been added
n := g.Noun("aws_instance.foo") n := g.Noun("aws_instance.foo")
rn := n.Meta.(*GraphNodeResource) rn := n.Meta.(*GraphNodeResource)
expected2 := diff.RootModule().Resources["aws_instance.foo"] expected2 := diff.RootModule().Resources["aws_instance.foo"]
actual2 := rn.Resource.Diff actual2 := rn.Resource.Diff
if !reflect.DeepEqual(actual2, expected2) { if !reflect.DeepEqual(actual2, expected2) {
t.Fatalf("bad: %#v", actual2) t.Fatalf("bad: %#v", actual2)
} }
*/ */
} }

View File

@ -921,4 +921,3 @@ STATE:
<no state> <no state>
` `

View File

@ -2,14 +2,14 @@ package terraform
// MockUIOutput is an implementation of UIOutput that can be used for tests. // MockUIOutput is an implementation of UIOutput that can be used for tests.
type MockUIOutput struct { type MockUIOutput struct {
OutputCalled bool OutputCalled bool
OutputMessage string OutputMessage string
OutputFn func(string) OutputFn func(string)
} }
func (o *MockUIOutput) Output(v string) { func (o *MockUIOutput) Output(v string) {
o.OutputCalled = true o.OutputCalled = true
o.OutputMessage= v o.OutputMessage = v
if o.OutputFn != nil { if o.OutputFn != nil {
o.OutputFn(v) o.OutputFn(v)
} }