command: apply uses the new plan structure

This commit is contained in:
Mitchell Hashimoto 2014-06-20 12:51:42 -07:00
parent 3aab0cd21b
commit 84cf644a30
4 changed files with 10 additions and 4 deletions

View File

@ -95,13 +95,13 @@ func (c *ApplyCommand) Run(args []string) int {
return 1
}
_, err = tf.Plan(state)
plan, err := tf.Plan(state)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error running plan: %s", err))
return 1
}
state, err = tf.Apply(state, nil)
state, err = tf.Apply(plan)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error applying plan: %s", err))
return 1

View File

@ -25,6 +25,10 @@ func testTFConfig(p terraform.ResourceProvider) *terraform.Config {
func testProvider() *terraform.MockResourceProvider {
p := new(terraform.MockResourceProvider)
p.RefreshFn = func(
s *terraform.ResourceState) (*terraform.ResourceState, error) {
return s, nil
}
p.ResourcesReturn = []terraform.ResourceType{
terraform.ResourceType{
Name: "test_instance",

View File

@ -201,8 +201,10 @@ func (t *Terraform) planWalkFn(
if !diff.Empty() {
rs = r.State.MergeDiff(diff)
}
for ak, av := range rs.Attributes {
vars[fmt.Sprintf("%s.%s", r.Id, ak)] = av
if rs != nil {
for ak, av := range rs.Attributes {
vars[fmt.Sprintf("%s.%s", r.Id, ak)] = av
}
}
return vars, nil