Skip to content

Commit 6ef567f

Browse files
authored
Merge pull request #23 from runatlantis/apply-bugfix
Fix bug where apply -d was using parent dir.
2 parents 4bd6128 + e6cdf15 commit 6ef567f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

server/events/apply_executor.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ func (a *ApplyExecutor) Execute(ctx *CommandContext) CommandResponse {
6969
} else {
7070
// If they did specify a dir, we apply just the plan in that directory
7171
// for this workspace.
72-
path := filepath.Join(repoDir, ctx.Command.Dir, ctx.Command.Workspace+".tfplan")
73-
stat, err := os.Stat(path)
72+
planPath := filepath.Join(repoDir, ctx.Command.Dir, ctx.Command.Workspace+".tfplan")
73+
stat, err := os.Stat(planPath)
7474
if err != nil || stat.IsDir() {
75-
return CommandResponse{Error: errors.Wrapf(err, "finding plan for dir %q and workspace %q", ctx.Command.Dir, ctx.Command.Workspace)}
75+
return CommandResponse{Error: fmt.Errorf("no plan found at path %q and workspace %q–did you run plan?", ctx.Command.Dir, ctx.Command.Workspace)}
7676
}
77-
rel, _ := filepath.Rel(repoDir, filepath.Dir(path))
77+
relProjectPath, _ := filepath.Rel(repoDir, filepath.Dir(planPath))
7878
plans = append(plans, models.Plan{
79-
Project: models.NewProject(ctx.BaseRepo.FullName, filepath.Dir(rel)),
80-
LocalPath: path,
79+
Project: models.NewProject(ctx.BaseRepo.FullName, relProjectPath),
80+
LocalPath: planPath,
8181
})
8282
}
8383
if len(plans) == 0 {

0 commit comments

Comments
 (0)