From 2cf63d068f606045a99219a3a35dbb7c62ff6a64 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 19 Dec 2018 12:12:24 -0800 Subject: [PATCH] command: Always normalize config path before operations 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. --- command/meta.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/command/meta.go b/command/meta.go index 53c59831bc..7658520e62 100644 --- a/command/meta.go +++ b/command/meta.go @@ -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)