Skip to content

feat(pass): add --force flag to set command#519

Merged
joe0BAB merged 1 commit into
mainfrom
pass/force-flag
May 18, 2026
Merged

feat(pass): add --force flag to set command#519
joe0BAB merged 1 commit into
mainfrom
pass/force-flag

Conversation

@joe0BAB
Copy link
Copy Markdown
Collaborator

@joe0BAB joe0BAB commented May 18, 2026

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.

@joe0BAB joe0BAB marked this pull request as ready for review May 18, 2026 11:52
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread plugins/pass/commands/set.go Outdated
Benehiko
Benehiko previously approved these changes May 18, 2026
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>
@joe0BAB joe0BAB merged commit 645f157 into main May 18, 2026
11 checks passed
@joe0BAB joe0BAB deleted the pass/force-flag branch May 18, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants