Skip to content

Commit

Permalink
Happy linter is happy
Browse files Browse the repository at this point in the history
  • Loading branch information
AnomalRoil committed Oct 2, 2024
1 parent 3e9a9de commit 931a3a8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/action/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (s *Action) init(ctx context.Context, alias, path string, keys ...string) e
nk, err := cui.AskForPrivateKey(ctx, crypto, "🎮 Please select a private key for encrypting secrets:")
if err != nil {
out.Noticef(ctx, "Hint: Use 'gopass setup --crypto %s' to be guided through an initial setup instead of 'gopass init'", crypto.Name())

return fmt.Errorf("failed to read user input: %w", err)
}
keys = []string{nk}
Expand Down
8 changes: 6 additions & 2 deletions internal/backend/crypto/age/clientUI.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import (
var pluginTerminalUI = &plugin.ClientUI{
DisplayMessage: func(name, message string) error {
out.Printf(context.Background(), "%s plugin: %s", name, message)

return nil
},
RequestValue: func(name, message string, _ bool) (s string, err error) {
RequestValue: func(name, message string, _ bool) (string, error) {
var err error
defer func() {
if err != nil {
out.Warningf(context.Background(), "could not read value for age-plugin-%s: %v", name, err)
Expand All @@ -24,13 +26,15 @@ var pluginTerminalUI = &plugin.ClientUI{
if err != nil {
return "", err
}

return secret, nil
},
Confirm: func(name, message, yes, no string) (choseYes bool, err error) {
Confirm: func(name, message, yes, no string) (bool, error) {
rep, _ := cui.GetSelection(context.Background(), message, []string{yes, no})
if rep == yes {
return true, nil
}

return false, nil
},

Expand Down
3 changes: 3 additions & 0 deletions internal/backend/crypto/age/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/urfave/cli/v2"
)

//nolint:cyclop
func (l loader) Commands() []*cli.Command {
return []*cli.Command{
{
Expand Down Expand Up @@ -152,6 +153,7 @@ func (l loader) Commands() []*cli.Command {
case *age.X25519Identity:
if x.Recipient().String() == victim {
debug.Log("removed X25519Identity %s", x.Recipient())

continue
}
case *wrappedIdentity:
Expand All @@ -164,6 +166,7 @@ func (l loader) Commands() []*cli.Command {
}
if skip {
debug.Log("removed Plugin Identity %s", x)

continue
}
}
Expand Down
5 changes: 5 additions & 0 deletions internal/backend/crypto/age/identities.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ func parseIdentity(s string) (age.Identity, error) {
} else {
rec = id.Recipient()
}

return &wrappedIdentity{
id: id,
encoding: s,
rec: rec,
}, err
case strings.HasPrefix(s, "AGE-SECRET-KEY-1"):
sp := strings.Split(s, "|")

return age.ParseX25519Identity(sp[0])
default:
return nil, fmt.Errorf("unknown identity type")
Expand Down Expand Up @@ -134,6 +136,7 @@ func parseIdentities(f io.Reader) ([]age.Identity, error) {
if len(ids) == 0 {
return nil, fmt.Errorf("no secret keys found")
}

return ids, nil
}

Expand Down Expand Up @@ -199,6 +202,7 @@ func IdentityToRecipient(id age.Identity) age.Recipient {
return id.Recipient()
default:
debug.Log("unexpected age identity type: %T", id)

return nil
}
}
Expand Down Expand Up @@ -294,6 +298,7 @@ func (a *Age) addIdentity(ctx context.Context, id age.Identity) error {
ids, _ := a.Identities(ctx)

ids = append(ids, id)

return a.saveIdentities(ctx, identitiesToString(ids), true)
}

Expand Down

0 comments on commit 931a3a8

Please sign in to comment.