File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ func (c *PlanCommand) Run(args []string) int {
6161 // This is going to keep track of shadow errors
6262 var shadowErr error
6363
64- ctx , _ , err := c .Context (contextOpts {
64+ ctx , planned , err := c .Context (contextOpts {
6565 Destroy : destroy ,
6666 Path : path ,
6767 StatePath : c .Meta .statePath ,
@@ -71,6 +71,13 @@ func (c *PlanCommand) Run(args []string) int {
7171 c .Ui .Error (err .Error ())
7272 return 1
7373 }
74+ if planned {
75+ c .Ui .Error (
76+ "The plan command cannot be called with a saved plan file.\n \n " +
77+ "The plan command expects a configuration directory as an argument." ,
78+ )
79+ return 1
80+ }
7481
7582 err = terraform .SetDebugInfo (DefaultDataDir )
7683 if err != nil {
Original file line number Diff line number Diff line change @@ -37,6 +37,29 @@ func TestPlan(t *testing.T) {
3737 }
3838}
3939
40+ func TestPlan_plan (t * testing.T ) {
41+ tmp , cwd := testCwd (t )
42+ defer testFixCwd (t , tmp , cwd )
43+
44+ planPath := testPlanFile (t , & terraform.Plan {
45+ Module : testModule (t , "apply" ),
46+ })
47+
48+ p := testProvider ()
49+ ui := new (cli.MockUi )
50+ c := & PlanCommand {
51+ Meta : Meta {
52+ ContextOpts : testCtxConfig (p ),
53+ Ui : ui ,
54+ },
55+ }
56+
57+ args := []string {planPath }
58+ if code := c .Run (args ); code != 1 {
59+ t .Fatalf ("bad: %d\n \n %s" , code , ui .ErrorWriter .String ())
60+ }
61+ }
62+
4063func TestPlan_destroy (t * testing.T ) {
4164 originalState := & terraform.State {
4265 Modules : []* terraform.ModuleState {
You can’t perform that action at this time.
0 commit comments