Skip to content

Commit

Permalink
command: Always normalize config path before operations
Browse files Browse the repository at this point in the history
Previously we were doing this rather inconsistently: some commands would
do it and others would not. By doing it here we ensure we always apply the
same normalization, regardless of which operation we're running.

This normalization is mostly for cosmetic purposes in error messages, but
it also ends up being used to populate path.module and path.root and so
it's important that we always produce consistent results here so that
we don't produce flappy changes as users work with different commands.

The fact that thus mutates a data structure as a side-effect is not ideal
but this is the best place to ensure it always gets applied without doing
any significant refactoring, since everything after this point happens in
the backend package where the normalizePath method is not available.
  • Loading branch information
apparentlymart committed Dec 19, 2018
1 parent 80a9c14 commit 2cf63d0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions command/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ func (m *Meta) StdinPiped() bool {
// operation itself is unsuccessful. Use the "Result" field of the
// returned operation object to recognize operation-level failure.
func (m *Meta) RunOperation(b backend.Enhanced, opReq *backend.Operation) (*backend.RunningOperation, error) {
if opReq.ConfigDir != "" {
opReq.ConfigDir = m.normalizePath(opReq.ConfigDir)
}

op, err := b.Operation(context.Background(), opReq)
if err != nil {
return nil, fmt.Errorf("error starting operation: %s", err)
Expand Down

0 comments on commit 2cf63d0

Please sign in to comment.