@@ -13,7 +13,7 @@ import (
13
13
"github.com/hootsuite/atlantis/github"
14
14
"github.com/hootsuite/atlantis/locking"
15
15
"github.com/hootsuite/atlantis/models"
16
- "github.com/hootsuite/atlantis/prerun "
16
+ "github.com/hootsuite/atlantis/run "
17
17
"github.com/hootsuite/atlantis/terraform"
18
18
)
19
19
@@ -25,7 +25,7 @@ type ApplyExecutor struct {
25
25
githubCommentRenderer * GithubCommentRenderer
26
26
lockingClient * locking.Client
27
27
requireApproval bool
28
- preRun * prerun. PreRun
28
+ run * run. Run
29
29
configReader * ConfigReader
30
30
concurrentRunLocker * ConcurrentRunLocker
31
31
workspace * Workspace
@@ -117,7 +117,7 @@ func (a *ApplyExecutor) apply(ctx *CommandContext, repoDir string, plan models.P
117
117
var applyExtraArgs []string
118
118
var config ProjectConfig
119
119
if a .configReader .Exists (absolutePath ) {
120
- config , err : = a .configReader .Read (absolutePath )
120
+ config , err = a .configReader .Read (absolutePath )
121
121
if err != nil {
122
122
return ProjectResult {Error : err }
123
123
}
@@ -132,6 +132,7 @@ func (a *ApplyExecutor) apply(ctx *CommandContext, repoDir string, plan models.P
132
132
if a .awsConfig != nil {
133
133
awsSession , err := a .awsConfig .CreateSession (ctx .User .Username )
134
134
if err != nil {
135
+ ctx .Log .Err (err .Error ())
135
136
return ProjectResult {Error : err }
136
137
}
137
138
creds , err := awsSession .Config .Credentials .Get ()
@@ -156,7 +157,7 @@ func (a *ApplyExecutor) apply(ctx *CommandContext, repoDir string, plan models.P
156
157
}
157
158
constraints , _ := version .NewConstraint (">= 0.9.0" )
158
159
if constraints .Check (terraformVersion ) {
159
- ctx .Log .Info ("determined that we are running terraform with version >= 0.9.0" )
160
+ ctx .Log .Info ("determined that we are running terraform with version >= 0.9.0. Running version %s" , terraformVersion )
160
161
_ , err := a .terraform .RunInitAndEnv (ctx .Log , absolutePath , tfEnv , config .GetExtraArguments ("init" ), credsEnvVars , terraformVersion )
161
162
if err != nil {
162
163
return ProjectResult {Error : err }
@@ -165,9 +166,9 @@ func (a *ApplyExecutor) apply(ctx *CommandContext, repoDir string, plan models.P
165
166
166
167
// if there are pre apply commands then run them
167
168
if len (config .PreApply .Commands ) > 0 {
168
- _ , err := a .preRun .Execute (ctx .Log , config .PreApply .Commands , absolutePath , ctx . Command . Environment , config . TerraformVersion )
169
+ _ , err := a .run .Execute (ctx .Log , config .PreApply .Commands , absolutePath , tfEnv , terraformVersion , "pre_apply" )
169
170
if err != nil {
170
- return ProjectResult {Error : err }
171
+ return ProjectResult {Error : errors . Wrap ( err , "running pre apply commands" ) }
171
172
}
172
173
}
173
174
@@ -178,6 +179,14 @@ func (a *ApplyExecutor) apply(ctx *CommandContext, repoDir string, plan models.P
178
179
}
179
180
ctx .Log .Info ("apply succeeded" )
180
181
182
+ // if there are post apply commands then run them
183
+ if len (config .PostApply .Commands ) > 0 {
184
+ _ , err := a .run .Execute (ctx .Log , config .PostApply .Commands , absolutePath , tfEnv , terraformVersion , "post_apply" )
185
+ if err != nil {
186
+ return ProjectResult {Error : errors .Wrap (err , "running post apply commands" )}
187
+ }
188
+ }
189
+
181
190
return ProjectResult {ApplySuccess : output }
182
191
}
183
192
0 commit comments