Skip to content

Commit

Permalink
Fix bug where apply -d was using parent dir.
Browse files Browse the repository at this point in the history
- Fixes #22. We were running apply in the parent directory.
- Also changes error message if no plans are found to apply.
  • Loading branch information
lkysow committed Mar 6, 2018
1 parent 4bd6128 commit e6cdf15
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/events/apply_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ func (a *ApplyExecutor) Execute(ctx *CommandContext) CommandResponse {
} else {
// If they did specify a dir, we apply just the plan in that directory
// for this workspace.
path := filepath.Join(repoDir, ctx.Command.Dir, ctx.Command.Workspace+".tfplan")
stat, err := os.Stat(path)
planPath := filepath.Join(repoDir, ctx.Command.Dir, ctx.Command.Workspace+".tfplan")
stat, err := os.Stat(planPath)
if err != nil || stat.IsDir() {
return CommandResponse{Error: errors.Wrapf(err, "finding plan for dir %q and workspace %q", ctx.Command.Dir, ctx.Command.Workspace)}
return CommandResponse{Error: fmt.Errorf("no plan found at path %q and workspace %q–did you run plan?", ctx.Command.Dir, ctx.Command.Workspace)}
}
rel, _ := filepath.Rel(repoDir, filepath.Dir(path))
relProjectPath, _ := filepath.Rel(repoDir, filepath.Dir(planPath))
plans = append(plans, models.Plan{
Project: models.NewProject(ctx.BaseRepo.FullName, filepath.Dir(rel)),
LocalPath: path,
Project: models.NewProject(ctx.BaseRepo.FullName, relProjectPath),
LocalPath: planPath,
})
}
if len(plans) == 0 {
Expand Down

0 comments on commit e6cdf15

Please sign in to comment.