Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid auto-search running non-interactively #483

Merged
merged 1 commit into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion action/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *Action) show(ctx context.Context, c *cli.Context, name, key string, rec

sec, err := s.Store.Get(ctx, name)
if err != nil {
if err != store.ErrNotFound || !recurse {
if err != store.ErrNotFound || !recurse || !ctxutil.IsTerminal(ctx) {
return s.exitError(ctx, ExitUnknown, err, "failed to retrieve secret '%s': %s", name, err)
}
color.Yellow("Entry '%s' not found. Starting search...", name)
Expand Down
2 changes: 1 addition & 1 deletion tests/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestSingleMount(t *testing.T) {

out, err = ts.run("show mnt/m1/secret")
assert.Error(t, err)
assert.Equal(t, "Entry 'mnt/m1/secret' not found. Starting search...\nfixed/secret\n", out)
assert.Equal(t, "\nError: failed to retrieve secret 'mnt/m1/secret': Entry is not in the password store\n", out)

ts.initSecrets("mnt/m1/")

Expand Down
2 changes: 1 addition & 1 deletion tests/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestShow(t *testing.T) {

out, err = ts.run("show foo")
assert.Error(t, err)
assert.Equal(t, "Entry 'foo' not found. Starting search...\n\nError: no results found\n", out)
assert.Equal(t, "\nError: failed to retrieve secret 'foo': Entry is not in the password store\n", out)

ts.initSecrets("")

Expand Down
4 changes: 2 additions & 2 deletions tests/yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestYAMLAndSecret(t *testing.T) {

out, err := ts.run("foo/bar baz")
assert.Error(t, err)
assert.Equal(t, "Entry 'foo/bar' not found. Starting search...\n\nError: no results found\n", out)
assert.Equal(t, "\nError: failed to retrieve secret 'foo/bar': Entry is not in the password store\n", out)

_, err = ts.runCmd([]string{ts.Binary, "insert", "foo/bar"}, []byte("moar"))
assert.NoError(t, err)
Expand Down Expand Up @@ -48,7 +48,7 @@ url: http://www.test.com/`

out, err := ts.run("foo/bar")
assert.Error(t, err)
assert.Equal(t, "Entry 'foo/bar' not found. Starting search...\n\nError: no results found\n", out)
assert.Equal(t, "\nError: failed to retrieve secret 'foo/bar': Entry is not in the password store\n", out)

_, err = ts.runCmd([]string{ts.Binary, "insert", "foo/bar"}, []byte(testBody))
assert.NoError(t, err)
Expand Down
4 changes: 1 addition & 3 deletions utils/protect/protect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ package protect
var ProtectEnabled = false

// Pledge on any other system than OpenBSD doesn't do anything
func Pledge(s string) {
return
}
func Pledge(s string) {}