feat(pass): add --force flag to set command#519
Conversation
| errUpsert := errors.New("upsert error") | ||
| mock := teststore.NewMockStore(teststore.WithStoreUpsertErr(errUpsert)) | ||
| out, err := executeCommand(Root(t.Context(), mock, mockInfo), "set", "foo=bar", "--force") | ||
| assert.ErrorIs(t, errUpsert, err) |
There was a problem hiding this comment.
MEDIUM — Swapped assert.ErrorIs arguments in '--force surfaces upsert error' test
assert.ErrorIs(t, errUpsert, err) has its arguments reversed. The testify signature is assert.ErrorIs(t, actual, target), mirroring errors.Is(actual, target). As written, the test checks whether the sentinel errUpsert wraps the command's returned error — not the other way around.
The test passes today because cobra's RunE forwards the error without wrapping, making errors.Is(errUpsert, errUpsert) trivially true. If any future middleware wraps the error (e.g. fmt.Errorf("set: %w", errUpsert)), this assertion becomes a silent false-negative rather than a test failure.
Fix: reverse the arguments:
assert.ErrorIs(t, err, errUpsert)This is consistent with the existing pattern used in the pre-existing "get" > "store error" and "rm" > "store error" subtests.
Adds a --force/-f flag to `docker pass set` that routes through store.Upsert instead of store.Save, allowing callers to overwrite an existing secret atomically on every platform. Without --force the default Save behavior is preserved (errors on macOS when the secret already exists; silently overwrites on Linux and Windows). Documents the platform-dependent overwrite semantics in the command's Long description. Signed-off-by: Johannes Großmann <grossmann.johannes@t-online.de>
Adds a --force/-f flag to
docker pass setthat routes through store.Upsert instead of store.Save, allowing callers to overwrite an existing secret atomically on every platform. Without --force the default Save behavior is preserved (errors on macOS when the secret already exists; silently overwrites on Linux and Windows). Documents the platform-dependent overwrite semantics in the command's Long description.