repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gopasspw/gopass | pkg/store/sub/store.go | Path | func (s *Store) Path() string {
if s.url == nil {
return ""
}
return s.url.Path
} | go | func (s *Store) Path() string {
if s.url == nil {
return ""
}
return s.url.Path
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Path",
"(",
")",
"string",
"{",
"if",
"s",
".",
"url",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"s",
".",
"url",
".",
"Path",
"\n",
"}"
] | // Path returns the value of path | [
"Path",
"returns",
"the",
"value",
"of",
"path"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/store.go#L283-L288 | train |
gopasspw/gopass | pkg/action/xc/xc.go | ListPrivateKeys | func ListPrivateKeys(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
kl, err := crypto.ListPrivateKeyIDs(ctx)
if err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to list priv... | go | func ListPrivateKeys(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
kl, err := crypto.ListPrivateKeyIDs(ctx)
if err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to list priv... | [
"func",
"ListPrivateKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"initCrypto",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"action",
".",
"ExitError",
"(",
"ctx",
",",... | // ListPrivateKeys list the XC private keys | [
"ListPrivateKeys",
"list",
"the",
"XC",
"private",
"keys"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/xc/xc.go#L38-L54 | train |
gopasspw/gopass | pkg/action/xc/xc.go | GenerateKeypair | func GenerateKeypair(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
name := c.String("name")
email := c.String("email")
pw := c.String("passphrase")
if name == "" {
var err error
name, err = ter... | go | func GenerateKeypair(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
name := c.String("name")
email := c.String("email")
pw := c.String("passphrase")
if name == "" {
var err error
name, err = ter... | [
"func",
"GenerateKeypair",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"initCrypto",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"action",
".",
"ExitError",
"(",
"ctx",
",",... | // GenerateKeypair generates a new XC keypair | [
"GenerateKeypair",
"generates",
"a",
"new",
"XC",
"keypair"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/xc/xc.go#L76-L111 | train |
gopasspw/gopass | pkg/action/xc/xc.go | ExportPrivateKey | func ExportPrivateKey(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
id := c.String("id")
file := c.String("file")
if id == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "need id")
}
i... | go | func ExportPrivateKey(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
id := c.String("id")
file := c.String("file")
if id == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "need id")
}
i... | [
"func",
"ExportPrivateKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"initCrypto",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"action",
".",
"ExitError",
"(",
"ctx",
","... | // ExportPrivateKey exports an XC key | [
"ExportPrivateKey",
"exports",
"an",
"XC",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/xc/xc.go#L183-L211 | train |
gopasspw/gopass | pkg/action/xc/xc.go | ImportPrivateKey | func ImportPrivateKey(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
file := c.String("file")
if file == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "need file")
}
if !fsutil.IsFile(... | go | func ImportPrivateKey(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
file := c.String("file")
if file == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "need file")
}
if !fsutil.IsFile(... | [
"func",
"ImportPrivateKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"initCrypto",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"action",
".",
"ExitError",
"(",
"ctx",
","... | // ImportPrivateKey imports an XC key | [
"ImportPrivateKey",
"imports",
"an",
"XC",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/xc/xc.go#L214-L234 | train |
gopasspw/gopass | pkg/action/xc/xc.go | EncryptFile | func EncryptFile(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
if c.Bool("stream") {
return EncryptFileStream(ctx, c)
}
inFile := c.String("file")
if inFile == "" {
return action.ExitError(ctx,... | go | func EncryptFile(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
if c.Bool("stream") {
return EncryptFileStream(ctx, c)
}
inFile := c.String("file")
if inFile == "" {
return action.ExitError(ctx,... | [
"func",
"EncryptFile",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"initCrypto",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"action",
".",
"ExitError",
"(",
"ctx",
",",
"... | // EncryptFile encrypts a single file | [
"EncryptFile",
"encrypts",
"a",
"single",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/xc/xc.go#L237-L273 | train |
gopasspw/gopass | pkg/action/xc/xc.go | DecryptFile | func DecryptFile(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
if c.Bool("stream") {
return DecryptFileStream(ctx, c)
}
inFile := c.String("file")
if inFile == "" {
return action.ExitError(ctx,... | go | func DecryptFile(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
if c.Bool("stream") {
return DecryptFileStream(ctx, c)
}
inFile := c.String("file")
if inFile == "" {
return action.ExitError(ctx,... | [
"func",
"DecryptFile",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"initCrypto",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"action",
".",
"ExitError",
"(",
"ctx",
",",
"... | // DecryptFile decrypts a single file | [
"DecryptFile",
"decrypts",
"a",
"single",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/xc/xc.go#L276-L315 | train |
gopasspw/gopass | pkg/action/xc/xc.go | EncryptFileStream | func EncryptFileStream(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
inFile := c.String("file")
if inFile == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "need file")
}
recipients := ... | go | func EncryptFileStream(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
inFile := c.String("file")
if inFile == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "need file")
}
recipients := ... | [
"func",
"EncryptFileStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"initCrypto",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"action",
".",
"ExitError",
"(",
"ctx",
",... | // EncryptFileStream encrypts a single file | [
"EncryptFileStream",
"encrypts",
"a",
"single",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/xc/xc.go#L318-L356 | train |
gopasspw/gopass | pkg/action/xc/xc.go | DecryptFileStream | func DecryptFileStream(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
inFile := c.String("file")
if inFile == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "need file")
}
if !strings.Has... | go | func DecryptFileStream(ctx context.Context, c *cli.Context) error {
if err := initCrypto(); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC")
}
inFile := c.String("file")
if inFile == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "need file")
}
if !strings.Has... | [
"func",
"DecryptFileStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"err",
":=",
"initCrypto",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"action",
".",
"ExitError",
"(",
"ctx",
",... | // DecryptFileStream decrypts a single file | [
"DecryptFileStream",
"decrypts",
"a",
"single",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/xc/xc.go#L359-L397 | train |
gopasspw/gopass | pkg/action/git-credential.go | WriteTo | func (c *gitCredentials) WriteTo(w io.Writer) (int64, error) {
var n int64
if c.Protocol != "" {
i, err := io.WriteString(w, "protocol="+c.Protocol+"\n")
n += int64(i)
if err != nil {
return n, err
}
}
if c.Host != "" {
i, err := io.WriteString(w, "host="+c.Host+"\n")
n += int64(i)
if err != nil {
... | go | func (c *gitCredentials) WriteTo(w io.Writer) (int64, error) {
var n int64
if c.Protocol != "" {
i, err := io.WriteString(w, "protocol="+c.Protocol+"\n")
n += int64(i)
if err != nil {
return n, err
}
}
if c.Host != "" {
i, err := io.WriteString(w, "host="+c.Host+"\n")
n += int64(i)
if err != nil {
... | [
"func",
"(",
"c",
"*",
"gitCredentials",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"n",
"int64",
"\n",
"if",
"c",
".",
"Protocol",
"!=",
"\"",
"\"",
"{",
"i",
",",
"err",
":=",
"io",
".",
... | // WriteTo writes the given credentials to the given io.Writer in the git-credential format | [
"WriteTo",
"writes",
"the",
"given",
"credentials",
"to",
"the",
"given",
"io",
".",
"Writer",
"in",
"the",
"git",
"-",
"credential",
"format"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git-credential.go#L31-L69 | train |
gopasspw/gopass | pkg/action/git-credential.go | GitCredentialBefore | func (s *Action) GitCredentialBefore(ctx context.Context, c *cli.Context) error {
err := s.Initialized(ctx, c)
if err != nil {
return err
}
if !ctxutil.IsStdin(ctx) {
return ExitError(ctx, ExitUsage, nil, "missing stdin from git")
}
return nil
} | go | func (s *Action) GitCredentialBefore(ctx context.Context, c *cli.Context) error {
err := s.Initialized(ctx, c)
if err != nil {
return err
}
if !ctxutil.IsStdin(ctx) {
return ExitError(ctx, ExitUsage, nil, "missing stdin from git")
}
return nil
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"GitCredentialBefore",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"err",
":=",
"s",
".",
"Initialized",
"(",
"ctx",
",",
"c",
")",
"\n",
"if",
"err",
"!=",
... | // GitCredentialBefore is executed before another git-credential command | [
"GitCredentialBefore",
"is",
"executed",
"before",
"another",
"git",
"-",
"credential",
"command"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git-credential.go#L110-L119 | train |
gopasspw/gopass | pkg/action/git-credential.go | GitCredentialGet | func (s *Action) GitCredentialGet(ctx context.Context, c *cli.Context) error {
ctx = sub.WithAutoSync(ctx, false)
cred, err := parseGitCredentials(termio.Stdin)
if err != nil {
return ExitError(ctx, ExitUnsupported, err, "Error: %v while parsing git-credential", err)
}
// try git/host/username... If username is ... | go | func (s *Action) GitCredentialGet(ctx context.Context, c *cli.Context) error {
ctx = sub.WithAutoSync(ctx, false)
cred, err := parseGitCredentials(termio.Stdin)
if err != nil {
return ExitError(ctx, ExitUnsupported, err, "Error: %v while parsing git-credential", err)
}
// try git/host/username... If username is ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"GitCredentialGet",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"ctx",
"=",
"sub",
".",
"WithAutoSync",
"(",
"ctx",
",",
"false",
")",
"\n",
"cred",
",",
"err... | // GitCredentialGet returns a credential to git | [
"GitCredentialGet",
"returns",
"a",
"credential",
"to",
"git"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git-credential.go#L122-L167 | train |
gopasspw/gopass | pkg/action/git-credential.go | GitCredentialStore | func (s *Action) GitCredentialStore(ctx context.Context, c *cli.Context) error {
cred, err := parseGitCredentials(termio.Stdin)
if err != nil {
return ExitError(ctx, ExitUnsupported, err, "Error: %v while parsing git-credential", err)
}
path := "git/" + fsutil.CleanFilename(cred.Host) + "/" + fsutil.CleanFilename... | go | func (s *Action) GitCredentialStore(ctx context.Context, c *cli.Context) error {
cred, err := parseGitCredentials(termio.Stdin)
if err != nil {
return ExitError(ctx, ExitUnsupported, err, "Error: %v while parsing git-credential", err)
}
path := "git/" + fsutil.CleanFilename(cred.Host) + "/" + fsutil.CleanFilename... | [
"func",
"(",
"s",
"*",
"Action",
")",
"GitCredentialStore",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"cred",
",",
"err",
":=",
"parseGitCredentials",
"(",
"termio",
".",
"Stdin",
")",
"\n",
"if",
... | // GitCredentialStore stores a credential got from git | [
"GitCredentialStore",
"stores",
"a",
"credential",
"got",
"from",
"git"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git-credential.go#L170-L195 | train |
gopasspw/gopass | pkg/action/git-credential.go | GitCredentialErase | func (s *Action) GitCredentialErase(ctx context.Context, c *cli.Context) error {
cred, err := parseGitCredentials(termio.Stdin)
if err != nil {
return ExitError(ctx, ExitUnsupported, err, "Error: %v while parsing git-credential", err)
}
path := "git/" + fsutil.CleanFilename(cred.Host) + "/" + fsutil.CleanFilename... | go | func (s *Action) GitCredentialErase(ctx context.Context, c *cli.Context) error {
cred, err := parseGitCredentials(termio.Stdin)
if err != nil {
return ExitError(ctx, ExitUnsupported, err, "Error: %v while parsing git-credential", err)
}
path := "git/" + fsutil.CleanFilename(cred.Host) + "/" + fsutil.CleanFilename... | [
"func",
"(",
"s",
"*",
"Action",
")",
"GitCredentialErase",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"cred",
",",
"err",
":=",
"parseGitCredentials",
"(",
"termio",
".",
"Stdin",
")",
"\n",
"if",
... | // GitCredentialErase removes a credential got from git | [
"GitCredentialErase",
"removes",
"a",
"credential",
"got",
"from",
"git"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git-credential.go#L198-L209 | train |
gopasspw/gopass | pkg/action/git-credential.go | GitCredentialConfigure | func (s *Action) GitCredentialConfigure(ctx context.Context, c *cli.Context) error {
flags := 0
flag := "--global"
if c.Bool("local") {
flag = "--local"
flags++
}
if c.Bool("global") {
flag = "--global"
flags++
}
if c.Bool("system") {
flag = "--system"
flags++
}
if flags >= 2 {
return ExitError(c... | go | func (s *Action) GitCredentialConfigure(ctx context.Context, c *cli.Context) error {
flags := 0
flag := "--global"
if c.Bool("local") {
flag = "--local"
flags++
}
if c.Bool("global") {
flag = "--global"
flags++
}
if c.Bool("system") {
flag = "--system"
flags++
}
if flags >= 2 {
return ExitError(c... | [
"func",
"(",
"s",
"*",
"Action",
")",
"GitCredentialConfigure",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"flags",
":=",
"0",
"\n",
"flag",
":=",
"\"",
"\"",
"\n",
"if",
"c",
".",
"Bool",
"(",
... | // GitCredentialConfigure configures gopass as git's credential.helper | [
"GitCredentialConfigure",
"configures",
"gopass",
"as",
"git",
"s",
"credential",
".",
"helper"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git-credential.go#L212-L237 | train |
gopasspw/gopass | pkg/tree/simple/file.go | format | func (f File) format(prefix string, last bool, _, _ int) string {
sym := symBranch
if last {
sym = symLeaf
}
ft := ""
if f.Metadata != nil {
switch f.Metadata["Content-Type"] {
case "application/octet-stream":
ft = " " + colBin("(binary)")
case "text/yaml":
ft = " " + colYaml("(yaml)")
}
}
return... | go | func (f File) format(prefix string, last bool, _, _ int) string {
sym := symBranch
if last {
sym = symLeaf
}
ft := ""
if f.Metadata != nil {
switch f.Metadata["Content-Type"] {
case "application/octet-stream":
ft = " " + colBin("(binary)")
case "text/yaml":
ft = " " + colYaml("(yaml)")
}
}
return... | [
"func",
"(",
"f",
"File",
")",
"format",
"(",
"prefix",
"string",
",",
"last",
"bool",
",",
"_",
",",
"_",
"int",
")",
"string",
"{",
"sym",
":=",
"symBranch",
"\n",
"if",
"last",
"{",
"sym",
"=",
"symLeaf",
"\n",
"}",
"\n",
"ft",
":=",
"\"",
"... | // format will format this leaf node for pretty printing | [
"format",
"will",
"format",
"this",
"leaf",
"node",
"for",
"pretty",
"printing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/file.go#L15-L30 | train |
gopasspw/gopass | pkg/cui/actions.go | Selection | func (ca Actions) Selection() []string {
keys := make([]string, 0, len(ca))
for _, a := range ca {
keys = append(keys, a.Name)
}
return keys
} | go | func (ca Actions) Selection() []string {
keys := make([]string, 0, len(ca))
for _, a := range ca {
keys = append(keys, a.Name)
}
return keys
} | [
"func",
"(",
"ca",
"Actions",
")",
"Selection",
"(",
")",
"[",
"]",
"string",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"ca",
")",
")",
"\n",
"for",
"_",
",",
"a",
":=",
"range",
"ca",
"{",
"keys",
"=",
... | // Selection return the list of actions | [
"Selection",
"return",
"the",
"list",
"of",
"actions"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/cui/actions.go#L20-L26 | train |
gopasspw/gopass | pkg/cui/actions.go | Run | func (ca Actions) Run(ctx context.Context, c *cli.Context, i int) error {
if len(ca) < i || i >= len(ca) {
return errors.New("action not found")
}
if ca[i].Fn == nil {
return errors.New("action invalid")
}
return ca[i].Fn(ctx, c)
} | go | func (ca Actions) Run(ctx context.Context, c *cli.Context, i int) error {
if len(ca) < i || i >= len(ca) {
return errors.New("action not found")
}
if ca[i].Fn == nil {
return errors.New("action invalid")
}
return ca[i].Fn(ctx, c)
} | [
"func",
"(",
"ca",
"Actions",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"i",
"int",
")",
"error",
"{",
"if",
"len",
"(",
"ca",
")",
"<",
"i",
"||",
"i",
">=",
"len",
"(",
"ca",
")",
"{",
"... | // Run executes the selected action | [
"Run",
"executes",
"the",
"selected",
"action"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/cui/actions.go#L29-L37 | train |
gopasspw/gopass | pkg/hibp/dump/scanner.go | New | func New(dumps ...string) (*Scanner, error) {
ok := make([]string, 0, len(dumps))
for _, dump := range dumps {
if !fsutil.IsFile(dump) {
continue
}
ok = append(ok, dump)
}
if len(ok) < 1 {
return nil, fmt.Errorf("no valid dumps given")
}
return &Scanner{
dumps: ok,
}, nil
} | go | func New(dumps ...string) (*Scanner, error) {
ok := make([]string, 0, len(dumps))
for _, dump := range dumps {
if !fsutil.IsFile(dump) {
continue
}
ok = append(ok, dump)
}
if len(ok) < 1 {
return nil, fmt.Errorf("no valid dumps given")
}
return &Scanner{
dumps: ok,
}, nil
} | [
"func",
"New",
"(",
"dumps",
"...",
"string",
")",
"(",
"*",
"Scanner",
",",
"error",
")",
"{",
"ok",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"dumps",
")",
")",
"\n",
"for",
"_",
",",
"dump",
":=",
"range",
"dumps",
... | // New creates a new scanner | [
"New",
"creates",
"a",
"new",
"scanner"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/hibp/dump/scanner.go#L24-L38 | train |
gopasspw/gopass | pkg/hibp/dump/scanner.go | LookupBatch | func (s *Scanner) LookupBatch(ctx context.Context, in []string) []string {
if len(in) < 1 {
return nil
}
sort.Strings(in)
for i, hash := range in {
in[i] = strings.ToUpper(hash)
}
out := make([]string, 0, len(in))
results := make(chan string, len(in))
done := make(chan struct{}, len(s.dumps))
for _, fn ... | go | func (s *Scanner) LookupBatch(ctx context.Context, in []string) []string {
if len(in) < 1 {
return nil
}
sort.Strings(in)
for i, hash := range in {
in[i] = strings.ToUpper(hash)
}
out := make([]string, 0, len(in))
results := make(chan string, len(in))
done := make(chan struct{}, len(s.dumps))
for _, fn ... | [
"func",
"(",
"s",
"*",
"Scanner",
")",
"LookupBatch",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"in",
")",
"<",
"1",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"sort",
".... | // LookupBatch takes a slice SHA1 hashes and matches them against
// the provided dumps | [
"LookupBatch",
"takes",
"a",
"slice",
"SHA1",
"hashes",
"and",
"matches",
"them",
"against",
"the",
"provided",
"dumps"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/hibp/dump/scanner.go#L42-L72 | train |
gopasspw/gopass | pkg/backend/rcs/noop/backend.go | Add | func (g *Noop) Add(ctx context.Context, args ...string) error {
return nil
} | go | func (g *Noop) Add(ctx context.Context, args ...string) error {
return nil
} | [
"func",
"(",
"g",
"*",
"Noop",
")",
"Add",
"(",
"ctx",
"context",
".",
"Context",
",",
"args",
"...",
"string",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // Add does nothing | [
"Add",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/noop/backend.go#L21-L23 | train |
gopasspw/gopass | pkg/backend/rcs/noop/backend.go | Commit | func (g *Noop) Commit(ctx context.Context, msg string) error {
return nil
} | go | func (g *Noop) Commit(ctx context.Context, msg string) error {
return nil
} | [
"func",
"(",
"g",
"*",
"Noop",
")",
"Commit",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"string",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // Commit does nothing | [
"Commit",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/noop/backend.go#L26-L28 | train |
gopasspw/gopass | pkg/backend/rcs/noop/backend.go | Push | func (g *Noop) Push(ctx context.Context, origin, branch string) error {
return nil
} | go | func (g *Noop) Push(ctx context.Context, origin, branch string) error {
return nil
} | [
"func",
"(",
"g",
"*",
"Noop",
")",
"Push",
"(",
"ctx",
"context",
".",
"Context",
",",
"origin",
",",
"branch",
"string",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // Push does nothing | [
"Push",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/noop/backend.go#L31-L33 | train |
gopasspw/gopass | pkg/backend/rcs/noop/backend.go | Cmd | func (g *Noop) Cmd(ctx context.Context, name string, args ...string) error {
return nil
} | go | func (g *Noop) Cmd(ctx context.Context, name string, args ...string) error {
return nil
} | [
"func",
"(",
"g",
"*",
"Noop",
")",
"Cmd",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"args",
"...",
"string",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // Cmd does nothing | [
"Cmd",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/noop/backend.go#L41-L43 | train |
gopasspw/gopass | pkg/backend/rcs/noop/backend.go | AddRemote | func (g *Noop) AddRemote(ctx context.Context, remote, url string) error {
return nil
} | go | func (g *Noop) AddRemote(ctx context.Context, remote, url string) error {
return nil
} | [
"func",
"(",
"g",
"*",
"Noop",
")",
"AddRemote",
"(",
"ctx",
"context",
".",
"Context",
",",
"remote",
",",
"url",
"string",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // AddRemote does nothing | [
"AddRemote",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/noop/backend.go#L66-L68 | train |
gopasspw/gopass | pkg/backend/rcs/noop/backend.go | RemoveRemote | func (g *Noop) RemoveRemote(ctx context.Context, remote string) error {
return nil
} | go | func (g *Noop) RemoveRemote(ctx context.Context, remote string) error {
return nil
} | [
"func",
"(",
"g",
"*",
"Noop",
")",
"RemoveRemote",
"(",
"ctx",
"context",
".",
"Context",
",",
"remote",
"string",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] | // RemoveRemote does nothing | [
"RemoveRemote",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/noop/backend.go#L71-L73 | train |
gopasspw/gopass | pkg/backend/rcs/noop/backend.go | Revisions | func (g *Noop) Revisions(context.Context, string) ([]backend.Revision, error) {
return nil, fmt.Errorf("not yet implemented for %s", g.Name())
} | go | func (g *Noop) Revisions(context.Context, string) ([]backend.Revision, error) {
return nil, fmt.Errorf("not yet implemented for %s", g.Name())
} | [
"func",
"(",
"g",
"*",
"Noop",
")",
"Revisions",
"(",
"context",
".",
"Context",
",",
"string",
")",
"(",
"[",
"]",
"backend",
".",
"Revision",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"g",
".",
... | // Revisions is not implemented | [
"Revisions",
"is",
"not",
"implemented"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/noop/backend.go#L76-L78 | train |
gopasspw/gopass | pkg/termio/context.go | WithPassPromptFunc | func WithPassPromptFunc(ctx context.Context, ppf PassPromptFunc) context.Context {
return context.WithValue(ctx, ctxKeyPassPromptFunc, ppf)
} | go | func WithPassPromptFunc(ctx context.Context, ppf PassPromptFunc) context.Context {
return context.WithValue(ctx, ctxKeyPassPromptFunc, ppf)
} | [
"func",
"WithPassPromptFunc",
"(",
"ctx",
"context",
".",
"Context",
",",
"ppf",
"PassPromptFunc",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyPassPromptFunc",
",",
"ppf",
")",
"\n",
"}"
] | // WithPassPromptFunc returns a context with the password prompt function set | [
"WithPassPromptFunc",
"returns",
"a",
"context",
"with",
"the",
"password",
"prompt",
"function",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/termio/context.go#L15-L17 | train |
gopasspw/gopass | pkg/termio/context.go | HasPassPromptFunc | func HasPassPromptFunc(ctx context.Context) bool {
ppf, ok := ctx.Value(ctxKeyPassPromptFunc).(PassPromptFunc)
return ok && ppf != nil
} | go | func HasPassPromptFunc(ctx context.Context) bool {
ppf, ok := ctx.Value(ctxKeyPassPromptFunc).(PassPromptFunc)
return ok && ppf != nil
} | [
"func",
"HasPassPromptFunc",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"ppf",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyPassPromptFunc",
")",
".",
"(",
"PassPromptFunc",
")",
"\n",
"return",
"ok",
"&&",
"ppf",
"!=",
"nil",
"\n",
... | // HasPassPromptFunc returns true if a value for the pass prompt func has been
// set in this context | [
"HasPassPromptFunc",
"returns",
"true",
"if",
"a",
"value",
"for",
"the",
"pass",
"prompt",
"func",
"has",
"been",
"set",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/termio/context.go#L21-L24 | train |
gopasspw/gopass | pkg/store/sub/templates.go | ListTemplates | func (s *Store) ListTemplates(ctx context.Context, prefix string) []string {
lst, err := s.storage.List(ctx, "")
if err != nil {
out.Debug(ctx, "failed to list templates: %s", err)
return nil
}
tpls := make(map[string]struct{}, len(lst))
for _, path := range lst {
if !strings.HasSuffix(path, TemplateFile) {
... | go | func (s *Store) ListTemplates(ctx context.Context, prefix string) []string {
lst, err := s.storage.List(ctx, "")
if err != nil {
out.Debug(ctx, "failed to list templates: %s", err)
return nil
}
tpls := make(map[string]struct{}, len(lst))
for _, path := range lst {
if !strings.HasSuffix(path, TemplateFile) {
... | [
"func",
"(",
"s",
"*",
"Store",
")",
"ListTemplates",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"[",
"]",
"string",
"{",
"lst",
",",
"err",
":=",
"s",
".",
"storage",
".",
"List",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",... | // ListTemplates will list all templates in this store | [
"ListTemplates",
"will",
"list",
"all",
"templates",
"in",
"this",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/templates.go#L46-L69 | train |
gopasspw/gopass | pkg/store/sub/templates.go | templatefile | func (s *Store) templatefile(name string) string {
return strings.TrimPrefix(filepath.Join(name, TemplateFile), string(filepath.Separator))
} | go | func (s *Store) templatefile(name string) string {
return strings.TrimPrefix(filepath.Join(name, TemplateFile), string(filepath.Separator))
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"templatefile",
"(",
"name",
"string",
")",
"string",
"{",
"return",
"strings",
".",
"TrimPrefix",
"(",
"filepath",
".",
"Join",
"(",
"name",
",",
"TemplateFile",
")",
",",
"string",
"(",
"filepath",
".",
"Separator",... | // templatefile returns the name of the given template on disk | [
"templatefile",
"returns",
"the",
"name",
"of",
"the",
"given",
"template",
"on",
"disk"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/templates.go#L84-L86 | train |
gopasspw/gopass | pkg/store/sub/templates.go | HasTemplate | func (s *Store) HasTemplate(ctx context.Context, name string) bool {
return s.storage.Exists(ctx, s.templatefile(name))
} | go | func (s *Store) HasTemplate(ctx context.Context, name string) bool {
return s.storage.Exists(ctx, s.templatefile(name))
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"HasTemplate",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"return",
"s",
".",
"storage",
".",
"Exists",
"(",
"ctx",
",",
"s",
".",
"templatefile",
"(",
"name",
")",
")",
"\n"... | // HasTemplate returns true if the template exists | [
"HasTemplate",
"returns",
"true",
"if",
"the",
"template",
"exists"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/templates.go#L89-L91 | train |
gopasspw/gopass | pkg/store/sub/templates.go | GetTemplate | func (s *Store) GetTemplate(ctx context.Context, name string) ([]byte, error) {
return s.storage.Get(ctx, s.templatefile(name))
} | go | func (s *Store) GetTemplate(ctx context.Context, name string) ([]byte, error) {
return s.storage.Get(ctx, s.templatefile(name))
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"GetTemplate",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"s",
".",
"storage",
".",
"Get",
"(",
"ctx",
",",
"s",
".",
"templatef... | // GetTemplate will return the content of the named template | [
"GetTemplate",
"will",
"return",
"the",
"content",
"of",
"the",
"named",
"template"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/templates.go#L94-L96 | train |
gopasspw/gopass | pkg/backend/url.go | ParseURL | func ParseURL(us string) (*URL, error) {
// if it's no URL build file URL and parse that
nu, err := url.Parse(us)
if err != nil {
nu, err = url.Parse("gpgcli-gitcli-fs+file://" + us)
if err != nil {
return nil, err
}
}
u := &URL{
url: nu,
}
if err := u.parseScheme(); err != nil {
return u, err
}
u... | go | func ParseURL(us string) (*URL, error) {
// if it's no URL build file URL and parse that
nu, err := url.Parse(us)
if err != nil {
nu, err = url.Parse("gpgcli-gitcli-fs+file://" + us)
if err != nil {
return nil, err
}
}
u := &URL{
url: nu,
}
if err := u.parseScheme(); err != nil {
return u, err
}
u... | [
"func",
"ParseURL",
"(",
"us",
"string",
")",
"(",
"*",
"URL",
",",
"error",
")",
"{",
"// if it's no URL build file URL and parse that",
"nu",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"us",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"nu",
",",
"err"... | // ParseURL attempts to parse an backend URL | [
"ParseURL",
"attempts",
"to",
"parse",
"an",
"backend",
"URL"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/url.go#L43-L86 | train |
gopasspw/gopass | pkg/backend/url.go | UnmarshalYAML | func (u *URL) UnmarshalYAML(umf func(interface{}) error) error {
path := ""
if err := umf(&path); err != nil {
return err
}
um, err := ParseURL(path)
if err != nil {
return err
}
*u = *um
return nil
} | go | func (u *URL) UnmarshalYAML(umf func(interface{}) error) error {
path := ""
if err := umf(&path); err != nil {
return err
}
um, err := ParseURL(path)
if err != nil {
return err
}
*u = *um
return nil
} | [
"func",
"(",
"u",
"*",
"URL",
")",
"UnmarshalYAML",
"(",
"umf",
"func",
"(",
"interface",
"{",
"}",
")",
"error",
")",
"error",
"{",
"path",
":=",
"\"",
"\"",
"\n",
"if",
"err",
":=",
"umf",
"(",
"&",
"path",
")",
";",
"err",
"!=",
"nil",
"{",
... | // UnmarshalYAML implements yaml.Unmarshaler | [
"UnmarshalYAML",
"implements",
"yaml",
".",
"Unmarshaler"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/url.go#L143-L154 | train |
gopasspw/gopass | pkg/store/sub/git.go | GitInit | func (s *Store) GitInit(ctx context.Context, un, ue string) error {
rcs, err := backend.InitRCS(ctx, backend.GetRCSBackend(ctx), s.url.Path, un, ue)
if err != nil {
return err
}
s.rcs = rcs
return nil
} | go | func (s *Store) GitInit(ctx context.Context, un, ue string) error {
rcs, err := backend.InitRCS(ctx, backend.GetRCSBackend(ctx), s.url.Path, un, ue)
if err != nil {
return err
}
s.rcs = rcs
return nil
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"GitInit",
"(",
"ctx",
"context",
".",
"Context",
",",
"un",
",",
"ue",
"string",
")",
"error",
"{",
"rcs",
",",
"err",
":=",
"backend",
".",
"InitRCS",
"(",
"ctx",
",",
"backend",
".",
"GetRCSBackend",
"(",
"ct... | // GitInit initializes the the git repo in the store | [
"GitInit",
"initializes",
"the",
"the",
"git",
"repo",
"in",
"the",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/git.go#L21-L28 | train |
gopasspw/gopass | pkg/store/sub/git.go | ListRevisions | func (s *Store) ListRevisions(ctx context.Context, name string) ([]backend.Revision, error) {
p := s.passfile(name)
return s.rcs.Revisions(ctx, p)
} | go | func (s *Store) ListRevisions(ctx context.Context, name string) ([]backend.Revision, error) {
p := s.passfile(name)
return s.rcs.Revisions(ctx, p)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"ListRevisions",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"[",
"]",
"backend",
".",
"Revision",
",",
"error",
")",
"{",
"p",
":=",
"s",
".",
"passfile",
"(",
"name",
")",
"\n",
"... | // ListRevisions will list all revisions for a secret | [
"ListRevisions",
"will",
"list",
"all",
"revisions",
"for",
"a",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/git.go#L31-L34 | train |
gopasspw/gopass | pkg/store/sub/git.go | GetRevision | func (s *Store) GetRevision(ctx context.Context, name, revision string) (store.Secret, error) {
p := s.passfile(name)
ciphertext, err := s.rcs.GetRevision(ctx, p, revision)
if err != nil {
return nil, errors.Wrapf(err, "failed to get ciphertext of '%s'@'%s'", name, revision)
}
content, err := s.crypto.Decrypt(c... | go | func (s *Store) GetRevision(ctx context.Context, name, revision string) (store.Secret, error) {
p := s.passfile(name)
ciphertext, err := s.rcs.GetRevision(ctx, p, revision)
if err != nil {
return nil, errors.Wrapf(err, "failed to get ciphertext of '%s'@'%s'", name, revision)
}
content, err := s.crypto.Decrypt(c... | [
"func",
"(",
"s",
"*",
"Store",
")",
"GetRevision",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
",",
"revision",
"string",
")",
"(",
"store",
".",
"Secret",
",",
"error",
")",
"{",
"p",
":=",
"s",
".",
"passfile",
"(",
"name",
")",
"\n",
... | // GetRevision will retrieve a single revision from the backend | [
"GetRevision",
"will",
"retrieve",
"a",
"single",
"revision",
"from",
"the",
"backend"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/git.go#L37-L55 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/key.go | IsUseable | func (k Key) IsUseable() bool {
if !k.ExpirationDate.IsZero() && k.ExpirationDate.Before(time.Now()) {
return false
}
switch k.Validity {
case "m":
return true
case "f":
return true
case "u":
return true
}
return false
} | go | func (k Key) IsUseable() bool {
if !k.ExpirationDate.IsZero() && k.ExpirationDate.Before(time.Now()) {
return false
}
switch k.Validity {
case "m":
return true
case "f":
return true
case "u":
return true
}
return false
} | [
"func",
"(",
"k",
"Key",
")",
"IsUseable",
"(",
")",
"bool",
"{",
"if",
"!",
"k",
".",
"ExpirationDate",
".",
"IsZero",
"(",
")",
"&&",
"k",
".",
"ExpirationDate",
".",
"Before",
"(",
"time",
".",
"Now",
"(",
")",
")",
"{",
"return",
"false",
"\n... | // IsUseable returns true if GPG would assume this key is useable for encryption | [
"IsUseable",
"returns",
"true",
"if",
"GPG",
"would",
"assume",
"this",
"key",
"is",
"useable",
"for",
"encryption"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/key.go#L23-L36 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/key.go | String | func (k Key) String() string {
fp := ""
if len(k.Fingerprint) > 24 {
fp = k.Fingerprint[24:]
}
out := fmt.Sprintf("%s %dD/0x%s %s", k.KeyType, k.KeyLength, fp, k.CreationDate.Format("2006-01-02"))
if !k.ExpirationDate.IsZero() {
out += fmt.Sprintf(" [expires: %s]", k.ExpirationDate.Format("2006-01-02"))
}
... | go | func (k Key) String() string {
fp := ""
if len(k.Fingerprint) > 24 {
fp = k.Fingerprint[24:]
}
out := fmt.Sprintf("%s %dD/0x%s %s", k.KeyType, k.KeyLength, fp, k.CreationDate.Format("2006-01-02"))
if !k.ExpirationDate.IsZero() {
out += fmt.Sprintf(" [expires: %s]", k.ExpirationDate.Format("2006-01-02"))
}
... | [
"func",
"(",
"k",
"Key",
")",
"String",
"(",
")",
"string",
"{",
"fp",
":=",
"\"",
"\"",
"\n",
"if",
"len",
"(",
"k",
".",
"Fingerprint",
")",
">",
"24",
"{",
"fp",
"=",
"k",
".",
"Fingerprint",
"[",
"24",
":",
"]",
"\n",
"}",
"\n",
"out",
... | // String implement fmt.Stringer. This method produces output that is close to, but
// not exactly the same, as the output form GPG itself | [
"String",
"implement",
"fmt",
".",
"Stringer",
".",
"This",
"method",
"produces",
"output",
"that",
"is",
"close",
"to",
"but",
"not",
"exactly",
"the",
"same",
"as",
"the",
"output",
"form",
"GPG",
"itself"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/key.go#L40-L54 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/key.go | Identity | func (k Key) Identity() Identity {
ids := make([]Identity, 0, len(k.Identities))
for _, i := range k.Identities {
ids = append(ids, i)
}
sort.Slice(ids, func(i, j int) bool {
return ids[i].CreationDate.After(ids[j].CreationDate)
})
for _, i := range ids {
return i
}
return Identity{}
} | go | func (k Key) Identity() Identity {
ids := make([]Identity, 0, len(k.Identities))
for _, i := range k.Identities {
ids = append(ids, i)
}
sort.Slice(ids, func(i, j int) bool {
return ids[i].CreationDate.After(ids[j].CreationDate)
})
for _, i := range ids {
return i
}
return Identity{}
} | [
"func",
"(",
"k",
"Key",
")",
"Identity",
"(",
")",
"Identity",
"{",
"ids",
":=",
"make",
"(",
"[",
"]",
"Identity",
",",
"0",
",",
"len",
"(",
"k",
".",
"Identities",
")",
")",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"k",
".",
"Identities",... | // Identity returns the first identity | [
"Identity",
"returns",
"the",
"first",
"identity"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/key.go#L66-L78 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/key.go | ID | func (k Key) ID() string {
if len(k.Fingerprint) < 25 {
return ""
}
return fmt.Sprintf("0x%s", k.Fingerprint[24:])
} | go | func (k Key) ID() string {
if len(k.Fingerprint) < 25 {
return ""
}
return fmt.Sprintf("0x%s", k.Fingerprint[24:])
} | [
"func",
"(",
"k",
"Key",
")",
"ID",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"k",
".",
"Fingerprint",
")",
"<",
"25",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"k",
".",
"Fingerprint",
... | // ID returns the short fingerprint | [
"ID",
"returns",
"the",
"short",
"fingerprint"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/key.go#L81-L86 | train |
gopasspw/gopass | pkg/action/clone.go | Clone | func (s *Action) Clone(ctx context.Context, c *cli.Context) error {
if c.IsSet("crypto") {
ctx = backend.WithCryptoBackendString(ctx, c.String("crypto"))
}
if c.IsSet("sync") {
ctx = backend.WithRCSBackendString(ctx, c.String("sync"))
}
if len(c.Args()) < 1 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s... | go | func (s *Action) Clone(ctx context.Context, c *cli.Context) error {
if c.IsSet("crypto") {
ctx = backend.WithCryptoBackendString(ctx, c.String("crypto"))
}
if c.IsSet("sync") {
ctx = backend.WithRCSBackendString(ctx, c.String("sync"))
}
if len(c.Args()) < 1 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Clone",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"c",
".",
"IsSet",
"(",
"\"",
"\"",
")",
"{",
"ctx",
"=",
"backend",
".",
"WithCryptoBackendString"... | // Clone will fetch and mount a new password store from a git repo | [
"Clone",
"will",
"fetch",
"and",
"mount",
"a",
"new",
"password",
"store",
"from",
"a",
"git",
"repo"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/clone.go#L21-L42 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/key_list.go | Recipients | func (kl KeyList) Recipients() []string {
l := make([]string, 0, len(kl))
for _, k := range kl {
l = append(l, k.ID())
}
sort.Strings(l)
return l
} | go | func (kl KeyList) Recipients() []string {
l := make([]string, 0, len(kl))
for _, k := range kl {
l = append(l, k.ID())
}
sort.Strings(l)
return l
} | [
"func",
"(",
"kl",
"KeyList",
")",
"Recipients",
"(",
")",
"[",
"]",
"string",
"{",
"l",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"kl",
")",
")",
"\n",
"for",
"_",
",",
"k",
":=",
"range",
"kl",
"{",
"l",
"=",
"appe... | // Recipients returns the KeyList formatted as a recipient list | [
"Recipients",
"returns",
"the",
"KeyList",
"formatted",
"as",
"a",
"recipient",
"list"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/key_list.go#L14-L21 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/key_list.go | FindKey | func (kl KeyList) FindKey(id string) (Key, error) {
id = strings.TrimPrefix(id, "0x")
for _, k := range kl {
if k.Fingerprint == id {
return k, nil
}
if strings.HasSuffix(k.Fingerprint, id) {
return k, nil
}
for _, ident := range k.Identities {
if ident.Name == id {
return k, nil
}
if ide... | go | func (kl KeyList) FindKey(id string) (Key, error) {
id = strings.TrimPrefix(id, "0x")
for _, k := range kl {
if k.Fingerprint == id {
return k, nil
}
if strings.HasSuffix(k.Fingerprint, id) {
return k, nil
}
for _, ident := range k.Identities {
if ident.Name == id {
return k, nil
}
if ide... | [
"func",
"(",
"kl",
"KeyList",
")",
"FindKey",
"(",
"id",
"string",
")",
"(",
"Key",
",",
"error",
")",
"{",
"id",
"=",
"strings",
".",
"TrimPrefix",
"(",
"id",
",",
"\"",
"\"",
")",
"\n",
"for",
"_",
",",
"k",
":=",
"range",
"kl",
"{",
"if",
... | // FindKey will try to find the requested key | [
"FindKey",
"will",
"try",
"to",
"find",
"the",
"requested",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/key_list.go#L50-L74 | train |
gopasspw/gopass | pkg/backend/crypto/xc/stream.go | EncryptStream | func (x *XC) EncryptStream(ctx context.Context, plaintext io.Reader, recipients []string, ciphertext io.Writer) error {
privKeyIDs := x.secring.KeyIDs()
if len(privKeyIDs) < 1 {
return fmt.Errorf("no signing keys available on our keyring")
}
privKey := x.secring.Get(privKeyIDs[0])
// generate session / encrypti... | go | func (x *XC) EncryptStream(ctx context.Context, plaintext io.Reader, recipients []string, ciphertext io.Writer) error {
privKeyIDs := x.secring.KeyIDs()
if len(privKeyIDs) < 1 {
return fmt.Errorf("no signing keys available on our keyring")
}
privKey := x.secring.Get(privKeyIDs[0])
// generate session / encrypti... | [
"func",
"(",
"x",
"*",
"XC",
")",
"EncryptStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"plaintext",
"io",
".",
"Reader",
",",
"recipients",
"[",
"]",
"string",
",",
"ciphertext",
"io",
".",
"Writer",
")",
"error",
"{",
"privKeyIDs",
":=",
"x",
... | // EncryptStream encrypts the plaintext using a slightly modified on disk-format
// suitable for streaming | [
"EncryptStream",
"encrypts",
"the",
"plaintext",
"using",
"a",
"slightly",
"modified",
"on",
"disk",
"-",
"format",
"suitable",
"for",
"streaming"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/stream.go#L18-L65 | train |
gopasspw/gopass | pkg/backend/crypto/xc/stream.go | DecryptStream | func (x *XC) DecryptStream(ctx context.Context, ciphertext io.Reader, plaintext io.Writer) error {
dec := binary.NewDecoder(ciphertext)
// read version
ver := 0
if err := dec.Decode(&ver); err != nil {
return err
}
if ver != 0x1 {
return fmt.Errorf("wrong version")
}
// read header
header := &xcpb.Header{... | go | func (x *XC) DecryptStream(ctx context.Context, ciphertext io.Reader, plaintext io.Writer) error {
dec := binary.NewDecoder(ciphertext)
// read version
ver := 0
if err := dec.Decode(&ver); err != nil {
return err
}
if ver != 0x1 {
return fmt.Errorf("wrong version")
}
// read header
header := &xcpb.Header{... | [
"func",
"(",
"x",
"*",
"XC",
")",
"DecryptStream",
"(",
"ctx",
"context",
".",
"Context",
",",
"ciphertext",
"io",
".",
"Reader",
",",
"plaintext",
"io",
".",
"Writer",
")",
"error",
"{",
"dec",
":=",
"binary",
".",
"NewDecoder",
"(",
"ciphertext",
")"... | // DecryptStream decrypts an stream encrypted with EncryptStream | [
"DecryptStream",
"decrypts",
"an",
"stream",
"encrypted",
"with",
"EncryptStream"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/stream.go#L89-L140 | train |
gopasspw/gopass | pkg/action/errors.go | ExitError | func ExitError(ctx context.Context, exitCode int, err error, format string, args ...interface{}) error {
if err != nil {
out.Debug(ctx, "Stacktrace: %+v", err)
}
return cli.NewExitError(fmt.Sprintf(format, args...), exitCode)
} | go | func ExitError(ctx context.Context, exitCode int, err error, format string, args ...interface{}) error {
if err != nil {
out.Debug(ctx, "Stacktrace: %+v", err)
}
return cli.NewExitError(fmt.Sprintf(format, args...), exitCode)
} | [
"func",
"ExitError",
"(",
"ctx",
"context",
".",
"Context",
",",
"exitCode",
"int",
",",
"err",
"error",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"err",
"!=",
"nil",
"{",
"out",
".",
"Debug",
"(",
... | // ExitError returns a user friendly CLI error | [
"ExitError",
"returns",
"a",
"user",
"friendly",
"CLI",
"error"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/errors.go#L58-L63 | train |
gopasspw/gopass | pkg/store/sub/write.go | Set | func (s *Store) Set(ctx context.Context, name string, sec store.Secret) error {
if strings.Contains(name, "//") {
return errors.Errorf("invalid secret name: %s", name)
}
p := s.passfile(name)
if s.IsDir(ctx, name) {
return errors.Errorf("a folder named %s already exists", name)
}
recipients, err := s.useab... | go | func (s *Store) Set(ctx context.Context, name string, sec store.Secret) error {
if strings.Contains(name, "//") {
return errors.Errorf("invalid secret name: %s", name)
}
p := s.passfile(name)
if s.IsDir(ctx, name) {
return errors.Errorf("a folder named %s already exists", name)
}
recipients, err := s.useab... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Set",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"sec",
"store",
".",
"Secret",
")",
"error",
"{",
"if",
"strings",
".",
"Contains",
"(",
"name",
",",
"\"",
"\"",
")",
"{",
"return",
"... | // Set encodes and writes the cipertext of one entry to disk | [
"Set",
"encodes",
"and",
"writes",
"the",
"cipertext",
"of",
"one",
"entry",
"to",
"disk"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/write.go#L16-L77 | train |
gopasspw/gopass | pkg/store/sub/move.go | Move | func (s *Store) Move(ctx context.Context, from, to string) error {
// recursive move?
if s.IsDir(ctx, from) {
return errors.Errorf("recursive operations are not supported")
}
content, err := s.Get(ctx, from)
if err != nil {
return errors.Wrapf(err, "failed to decrypt '%s'", from)
}
if err := s.Set(WithReaso... | go | func (s *Store) Move(ctx context.Context, from, to string) error {
// recursive move?
if s.IsDir(ctx, from) {
return errors.Errorf("recursive operations are not supported")
}
content, err := s.Get(ctx, from)
if err != nil {
return errors.Wrapf(err, "failed to decrypt '%s'", from)
}
if err := s.Set(WithReaso... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Move",
"(",
"ctx",
"context",
".",
"Context",
",",
"from",
",",
"to",
"string",
")",
"error",
"{",
"// recursive move?",
"if",
"s",
".",
"IsDir",
"(",
"ctx",
",",
"from",
")",
"{",
"return",
"errors",
".",
"Err... | // Move will move one entry from one location to another.
// Moving an entry will decode it from the old location, encode it
// for the destination store with the right set of recipients and remove it
// from the old location afterwards. | [
"Move",
"will",
"move",
"one",
"entry",
"from",
"one",
"location",
"to",
"another",
".",
"Moving",
"an",
"entry",
"will",
"decode",
"it",
"from",
"the",
"old",
"location",
"encode",
"it",
"for",
"the",
"destination",
"store",
"with",
"the",
"right",
"set",... | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/move.go#L39-L56 | train |
gopasspw/gopass | pkg/store/sub/move.go | delete | func (s *Store) delete(ctx context.Context, name string, recurse bool) error {
path := s.passfile(name)
if recurse {
if err := s.deleteRecurse(ctx, name, path); err != nil {
return err
}
}
if err := s.deleteSingle(ctx, path); err != nil {
if !recurse {
return err
}
}
if !ctxutil.IsGitCommit(ctx) {... | go | func (s *Store) delete(ctx context.Context, name string, recurse bool) error {
path := s.passfile(name)
if recurse {
if err := s.deleteRecurse(ctx, name, path); err != nil {
return err
}
}
if err := s.deleteSingle(ctx, path); err != nil {
if !recurse {
return err
}
}
if !ctxutil.IsGitCommit(ctx) {... | [
"func",
"(",
"s",
"*",
"Store",
")",
"delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"recurse",
"bool",
")",
"error",
"{",
"path",
":=",
"s",
".",
"passfile",
"(",
"name",
")",
"\n\n",
"if",
"recurse",
"{",
"if",
"err",... | // delete will either delete one file or an directory tree depending on the
// recurse flag | [
"delete",
"will",
"either",
"delete",
"one",
"file",
"or",
"an",
"directory",
"tree",
"depending",
"on",
"the",
"recurse",
"flag"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/move.go#L70-L108 | train |
gopasspw/gopass | pkg/action/action.go | New | func New(ctx context.Context, cfg *config.Config, sv semver.Version) (*Action, error) {
return newAction(ctx, cfg, sv)
} | go | func New(ctx context.Context, cfg *config.Config, sv semver.Version) (*Action, error) {
return newAction(ctx, cfg, sv)
} | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"cfg",
"*",
"config",
".",
"Config",
",",
"sv",
"semver",
".",
"Version",
")",
"(",
"*",
"Action",
",",
"error",
")",
"{",
"return",
"newAction",
"(",
"ctx",
",",
"cfg",
",",
"sv",
")",
"... | // New returns a new Action wrapper | [
"New",
"returns",
"a",
"new",
"Action",
"wrapper"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/action.go#L30-L32 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/cli/generate.go | CreatePrivateKeyBatch | func (g *GPG) CreatePrivateKeyBatch(ctx context.Context, name, email, passphrase string) error {
buf := &bytes.Buffer{}
// https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/DETAILS;h=de0f21ccba60c3037c2a155156202df1cd098507;hb=refs/heads/STABLE-BRANCH-1-4#l716
_, _ = buf.WriteString(`%echo Generating... | go | func (g *GPG) CreatePrivateKeyBatch(ctx context.Context, name, email, passphrase string) error {
buf := &bytes.Buffer{}
// https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=doc/DETAILS;h=de0f21ccba60c3037c2a155156202df1cd098507;hb=refs/heads/STABLE-BRANCH-1-4#l716
_, _ = buf.WriteString(`%echo Generating... | [
"func",
"(",
"g",
"*",
"GPG",
")",
"CreatePrivateKeyBatch",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
",",
"email",
",",
"passphrase",
"string",
")",
"error",
"{",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"// https://git.gnupg.... | // CreatePrivateKeyBatch will create a new GPG keypair in batch mode | [
"CreatePrivateKeyBatch",
"will",
"create",
"a",
"new",
"GPG",
"keypair",
"in",
"batch",
"mode"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/generate.go#L15-L42 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/cli/generate.go | CreatePrivateKey | func (g *GPG) CreatePrivateKey(ctx context.Context) error {
args := []string{"--gen-key"}
cmd := exec.CommandContext(ctx, g.binary, args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
out.Debug(ctx, "gpg.CreatePrivateKey: %s %+v", cmd.Path, cmd.Args)
if err := cmd.Run(); err != nil {
r... | go | func (g *GPG) CreatePrivateKey(ctx context.Context) error {
args := []string{"--gen-key"}
cmd := exec.CommandContext(ctx, g.binary, args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
out.Debug(ctx, "gpg.CreatePrivateKey: %s %+v", cmd.Path, cmd.Args)
if err := cmd.Run(); err != nil {
r... | [
"func",
"(",
"g",
"*",
"GPG",
")",
"CreatePrivateKey",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
"\n",
"cmd",
":=",
"exec",
".",
"CommandContext",
"(",
"ctx",
",",
"g",
".",
... | // CreatePrivateKey will create a new GPG key in interactive mode | [
"CreatePrivateKey",
"will",
"create",
"a",
"new",
"GPG",
"key",
"in",
"interactive",
"mode"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/generate.go#L45-L60 | train |
gopasspw/gopass | pkg/backend/rcs/git/cli/config.go | InitConfig | func (g *Git) InitConfig(ctx context.Context, userName, userEmail string) error {
if userName == "" || userEmail == "" || !strings.Contains(userEmail, "@") {
return fmt.Errorf("username and email must not be empty and valid")
}
// set commit identity
if err := g.ConfigSet(ctx, "user.name", userName); err != nil {... | go | func (g *Git) InitConfig(ctx context.Context, userName, userEmail string) error {
if userName == "" || userEmail == "" || !strings.Contains(userEmail, "@") {
return fmt.Errorf("username and email must not be empty and valid")
}
// set commit identity
if err := g.ConfigSet(ctx, "user.name", userName); err != nil {... | [
"func",
"(",
"g",
"*",
"Git",
")",
"InitConfig",
"(",
"ctx",
"context",
".",
"Context",
",",
"userName",
",",
"userEmail",
"string",
")",
"error",
"{",
"if",
"userName",
"==",
"\"",
"\"",
"||",
"userEmail",
"==",
"\"",
"\"",
"||",
"!",
"strings",
"."... | // InitConfig initialized and preparse the git config | [
"InitConfig",
"initialized",
"and",
"preparse",
"the",
"git",
"config"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/config.go#L42-L70 | train |
gopasspw/gopass | pkg/backend/rcs/git/cli/config.go | ConfigSet | func (g *Git) ConfigSet(ctx context.Context, key, value string) error {
return g.Cmd(ctx, "gitConfigSet", "config", "--local", key, value)
} | go | func (g *Git) ConfigSet(ctx context.Context, key, value string) error {
return g.Cmd(ctx, "gitConfigSet", "config", "--local", key, value)
} | [
"func",
"(",
"g",
"*",
"Git",
")",
"ConfigSet",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
",",
"value",
"string",
")",
"error",
"{",
"return",
"g",
".",
"Cmd",
"(",
"ctx",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"key",
... | // ConfigSet sets a local config value | [
"ConfigSet",
"sets",
"a",
"local",
"config",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/config.go#L73-L75 | train |
gopasspw/gopass | pkg/backend/rcs/git/cli/config.go | ConfigGet | func (g *Git) ConfigGet(ctx context.Context, key string) (string, error) {
if !g.IsInitialized() {
return "", store.ErrGitNotInit
}
buf := &strings.Builder{}
cmd := exec.CommandContext(ctx, "git", "config", "--get", key)
cmd.Dir = g.path
cmd.Stdout = buf
cmd.Stderr = os.Stderr
out.Debug(ctx, "store.gitConf... | go | func (g *Git) ConfigGet(ctx context.Context, key string) (string, error) {
if !g.IsInitialized() {
return "", store.ErrGitNotInit
}
buf := &strings.Builder{}
cmd := exec.CommandContext(ctx, "git", "config", "--get", key)
cmd.Dir = g.path
cmd.Stdout = buf
cmd.Stderr = os.Stderr
out.Debug(ctx, "store.gitConf... | [
"func",
"(",
"g",
"*",
"Git",
")",
"ConfigGet",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"!",
"g",
".",
"IsInitialized",
"(",
")",
"{",
"return",
"\"",
"\"",
",",
"store",
".",... | // ConfigGet returns a given config value | [
"ConfigGet",
"returns",
"a",
"given",
"config",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/config.go#L78-L96 | train |
gopasspw/gopass | pkg/backend/rcs/git/cli/config.go | ConfigList | func (g *Git) ConfigList(ctx context.Context) (map[string]string, error) {
if !g.IsInitialized() {
return nil, store.ErrGitNotInit
}
buf := &strings.Builder{}
cmd := exec.CommandContext(ctx, "git", "config", "--list")
cmd.Dir = g.path
cmd.Stdout = buf
cmd.Stderr = os.Stderr
out.Debug(ctx, "store.gitConfigL... | go | func (g *Git) ConfigList(ctx context.Context) (map[string]string, error) {
if !g.IsInitialized() {
return nil, store.ErrGitNotInit
}
buf := &strings.Builder{}
cmd := exec.CommandContext(ctx, "git", "config", "--list")
cmd.Dir = g.path
cmd.Stdout = buf
cmd.Stderr = os.Stderr
out.Debug(ctx, "store.gitConfigL... | [
"func",
"(",
"g",
"*",
"Git",
")",
"ConfigList",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"if",
"!",
"g",
".",
"IsInitialized",
"(",
")",
"{",
"return",
"nil",
",",
"store",
"."... | // ConfigList returns all git config settings | [
"ConfigList",
"returns",
"all",
"git",
"config",
"settings"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/config.go#L99-L127 | train |
gopasspw/gopass | pkg/action/recipients.go | RecipientsPrint | func (s *Action) RecipientsPrint(ctx context.Context, c *cli.Context) error {
out.Cyan(ctx, "Hint: run 'gopass sync' to import any missing public keys")
tree, err := s.Store.RecipientsTree(ctx, true)
if err != nil {
return ExitError(ctx, ExitList, err, "failed to list recipients: %s", err)
}
fmt.Fprintln(stdou... | go | func (s *Action) RecipientsPrint(ctx context.Context, c *cli.Context) error {
out.Cyan(ctx, "Hint: run 'gopass sync' to import any missing public keys")
tree, err := s.Store.RecipientsTree(ctx, true)
if err != nil {
return ExitError(ctx, ExitList, err, "failed to list recipients: %s", err)
}
fmt.Fprintln(stdou... | [
"func",
"(",
"s",
"*",
"Action",
")",
"RecipientsPrint",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"out",
".",
"Cyan",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n\n",
"tree",
",",
"err",
":=",
"s",
... | // RecipientsPrint prints all recipients per store | [
"RecipientsPrint",
"prints",
"all",
"recipients",
"per",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/recipients.go#L38-L48 | train |
gopasspw/gopass | pkg/action/recipients.go | RecipientsComplete | func (s *Action) RecipientsComplete(ctx context.Context, c *cli.Context) {
tree, err := s.Store.RecipientsTree(out.WithHidden(ctx, true), false)
if err != nil {
fmt.Fprintln(stdout, err)
return
}
for _, v := range tree.List(0) {
fmt.Fprintln(stdout, v)
}
} | go | func (s *Action) RecipientsComplete(ctx context.Context, c *cli.Context) {
tree, err := s.Store.RecipientsTree(out.WithHidden(ctx, true), false)
if err != nil {
fmt.Fprintln(stdout, err)
return
}
for _, v := range tree.List(0) {
fmt.Fprintln(stdout, v)
}
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"RecipientsComplete",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"tree",
",",
"err",
":=",
"s",
".",
"Store",
".",
"RecipientsTree",
"(",
"out",
".",
"WithHidden",
"(",... | // RecipientsComplete will print a list of recipients for bash
// completion | [
"RecipientsComplete",
"will",
"print",
"a",
"list",
"of",
"recipients",
"for",
"bash",
"completion"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/recipients.go#L52-L62 | train |
gopasspw/gopass | pkg/action/recipients.go | RecipientsAdd | func (s *Action) RecipientsAdd(ctx context.Context, c *cli.Context) error {
store := c.String("store")
force := c.Bool("force")
added := 0
// select store
if store == "" {
store = cui.AskForStore(ctx, s.Store)
}
crypto := s.Store.Crypto(ctx, store)
// select recipient
recipients := []string(c.Args())
if ... | go | func (s *Action) RecipientsAdd(ctx context.Context, c *cli.Context) error {
store := c.String("store")
force := c.Bool("force")
added := 0
// select store
if store == "" {
store = cui.AskForStore(ctx, s.Store)
}
crypto := s.Store.Crypto(ctx, store)
// select recipient
recipients := []string(c.Args())
if ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"RecipientsAdd",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"store",
":=",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"force",
":=",
"c",
".",
"Bool",... | // RecipientsAdd adds new recipients | [
"RecipientsAdd",
"adds",
"new",
"recipients"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/recipients.go#L65-L125 | train |
gopasspw/gopass | pkg/action/recipients.go | RecipientsRemove | func (s *Action) RecipientsRemove(ctx context.Context, c *cli.Context) error {
store := c.String("store")
force := c.Bool("force")
removed := 0
// select store
if store == "" {
store = cui.AskForStore(ctx, s.Store)
}
crypto := s.Store.Crypto(ctx, store)
// select recipient
recipients := []string(c.Args())... | go | func (s *Action) RecipientsRemove(ctx context.Context, c *cli.Context) error {
store := c.String("store")
force := c.Bool("force")
removed := 0
// select store
if store == "" {
store = cui.AskForStore(ctx, s.Store)
}
crypto := s.Store.Crypto(ctx, store)
// select recipient
recipients := []string(c.Args())... | [
"func",
"(",
"s",
"*",
"Action",
")",
"RecipientsRemove",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"store",
":=",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"force",
":=",
"c",
".",
"Boo... | // RecipientsRemove removes recipients | [
"RecipientsRemove",
"removes",
"recipients"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/recipients.go#L128-L194 | train |
gopasspw/gopass | pkg/action/recipients.go | RecipientsUpdate | func (s *Action) RecipientsUpdate(ctx context.Context, c *cli.Context) error {
changed := 0
mps := s.Store.MountPoints()
sort.Sort(store.ByPathLen(mps))
for _, alias := range append(mps, "") {
subs, err := s.Store.GetSubStore(alias)
if err != nil || subs == nil {
continue
}
recp, err := subs.GetRecipien... | go | func (s *Action) RecipientsUpdate(ctx context.Context, c *cli.Context) error {
changed := 0
mps := s.Store.MountPoints()
sort.Sort(store.ByPathLen(mps))
for _, alias := range append(mps, "") {
subs, err := s.Store.GetSubStore(alias)
if err != nil || subs == nil {
continue
}
recp, err := subs.GetRecipien... | [
"func",
"(",
"s",
"*",
"Action",
")",
"RecipientsUpdate",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"changed",
":=",
"0",
"\n\n",
"mps",
":=",
"s",
".",
"Store",
".",
"MountPoints",
"(",
")",
"\... | // RecipientsUpdate will recompute and update any changed recipients list checksums | [
"RecipientsUpdate",
"will",
"recompute",
"and",
"update",
"any",
"changed",
"recipients",
"list",
"checksums"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/recipients.go#L197-L240 | train |
gopasspw/gopass | pkg/action/otp.go | OTP | func (s *Action) OTP(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
if name == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s otp <NAME>", s.Name)
}
qrf := c.String("qr")
clip := c.Bool("clip")
return s.otp(ctx, c, name, qrf, clip, true)
} | go | func (s *Action) OTP(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
if name == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s otp <NAME>", s.Name)
}
qrf := c.String("qr")
clip := c.Bool("clip")
return s.otp(ctx, c, name, qrf, clip, true)
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"OTP",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"name",
":=",
"c",
".",
"Args",
"(",
")",
".",
"First",
"(",
")",
"\n",
"if",
"name",
"==",
"\"",
"\"... | // OTP implements OTP token handling for TOTP and HOTP | [
"OTP",
"implements",
"OTP",
"token",
"handling",
"for",
"TOTP",
"and",
"HOTP"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/otp.go#L26-L36 | train |
gopasspw/gopass | pkg/backend/crypto/xc/decrypt.go | Decrypt | func (x *XC) Decrypt(ctx context.Context, buf []byte) ([]byte, error) {
// unmarshal the protobuf message, the header and body are still encrypted
// afterwards (parts of the header are plaintext!)
msg := &xcpb.Message{}
if err := proto.Unmarshal(buf, msg); err != nil {
return nil, err
}
// try to find a suite... | go | func (x *XC) Decrypt(ctx context.Context, buf []byte) ([]byte, error) {
// unmarshal the protobuf message, the header and body are still encrypted
// afterwards (parts of the header are plaintext!)
msg := &xcpb.Message{}
if err := proto.Unmarshal(buf, msg); err != nil {
return nil, err
}
// try to find a suite... | [
"func",
"(",
"x",
"*",
"XC",
")",
"Decrypt",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// unmarshal the protobuf message, the header and body are still encrypted",
"// afterwards (pa... | // Decrypt tries to decrypt the given ciphertext and returns the plaintext | [
"Decrypt",
"tries",
"to",
"decrypt",
"the",
"given",
"ciphertext",
"and",
"returns",
"the",
"plaintext"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/decrypt.go#L25-L66 | train |
gopasspw/gopass | pkg/backend/crypto/xc/decrypt.go | findDecryptionKey | func (x *XC) findDecryptionKey(hdr *xcpb.Header) (*keyring.PrivateKey, error) {
for _, pk := range x.secring.KeyIDs() {
if _, found := hdr.Recipients[pk]; found {
return x.secring.Get(pk), nil
}
}
return nil, fmt.Errorf("no decryption key found for: %+v", hdr.Recipients)
} | go | func (x *XC) findDecryptionKey(hdr *xcpb.Header) (*keyring.PrivateKey, error) {
for _, pk := range x.secring.KeyIDs() {
if _, found := hdr.Recipients[pk]; found {
return x.secring.Get(pk), nil
}
}
return nil, fmt.Errorf("no decryption key found for: %+v", hdr.Recipients)
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"findDecryptionKey",
"(",
"hdr",
"*",
"xcpb",
".",
"Header",
")",
"(",
"*",
"keyring",
".",
"PrivateKey",
",",
"error",
")",
"{",
"for",
"_",
",",
"pk",
":=",
"range",
"x",
".",
"secring",
".",
"KeyIDs",
"(",
")"... | // findDecryptionKey tries to find a suiteable decryption key from the available
// decryption keys and the recipients | [
"findDecryptionKey",
"tries",
"to",
"find",
"a",
"suiteable",
"decryption",
"key",
"from",
"the",
"available",
"decryption",
"keys",
"and",
"the",
"recipients"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/decrypt.go#L70-L77 | train |
gopasspw/gopass | pkg/backend/crypto/xc/decrypt.go | findPublicKey | func (x *XC) findPublicKey(needle string) (*keyring.PublicKey, error) {
for _, id := range x.pubring.KeyIDs() {
if id == needle {
return x.pubring.Get(id), nil
}
}
return nil, fmt.Errorf("no sender found for id '%s'", needle)
} | go | func (x *XC) findPublicKey(needle string) (*keyring.PublicKey, error) {
for _, id := range x.pubring.KeyIDs() {
if id == needle {
return x.pubring.Get(id), nil
}
}
return nil, fmt.Errorf("no sender found for id '%s'", needle)
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"findPublicKey",
"(",
"needle",
"string",
")",
"(",
"*",
"keyring",
".",
"PublicKey",
",",
"error",
")",
"{",
"for",
"_",
",",
"id",
":=",
"range",
"x",
".",
"pubring",
".",
"KeyIDs",
"(",
")",
"{",
"if",
"id",
... | // findPublicKey tries to find a given public key in the keyring | [
"findPublicKey",
"tries",
"to",
"find",
"a",
"given",
"public",
"key",
"in",
"the",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/decrypt.go#L80-L87 | train |
gopasspw/gopass | pkg/backend/crypto/xc/decrypt.go | decryptPrivateKey | func (x *XC) decryptPrivateKey(ctx context.Context, recp *keyring.PrivateKey) error {
fp := recp.Fingerprint()
for i := 0; i < maxUnlockAttempts; i++ {
// retry asking for key in case it's wrong
passphrase, err := x.client.Passphrase(ctx, fp, fmt.Sprintf("Unlock private key %s", recp.Fingerprint()))
if err != ... | go | func (x *XC) decryptPrivateKey(ctx context.Context, recp *keyring.PrivateKey) error {
fp := recp.Fingerprint()
for i := 0; i < maxUnlockAttempts; i++ {
// retry asking for key in case it's wrong
passphrase, err := x.client.Passphrase(ctx, fp, fmt.Sprintf("Unlock private key %s", recp.Fingerprint()))
if err != ... | [
"func",
"(",
"x",
"*",
"XC",
")",
"decryptPrivateKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"recp",
"*",
"keyring",
".",
"PrivateKey",
")",
"error",
"{",
"fp",
":=",
"recp",
".",
"Fingerprint",
"(",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"... | // decryptPrivateKey will ask the agent to unlock the private key | [
"decryptPrivateKey",
"will",
"ask",
"the",
"agent",
"to",
"unlock",
"the",
"private",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/decrypt.go#L90-L113 | train |
gopasspw/gopass | pkg/backend/crypto/xc/decrypt.go | decryptSessionKey | func (x *XC) decryptSessionKey(ctx context.Context, hdr *xcpb.Header) ([]byte, error) {
// find a suiteable decryption key, i.e. a recipient entry which was encrypted
// for one of our private keys
recp, err := x.findDecryptionKey(hdr)
if err != nil {
return nil, errors.Wrapf(err, "unable to find decryption key")... | go | func (x *XC) decryptSessionKey(ctx context.Context, hdr *xcpb.Header) ([]byte, error) {
// find a suiteable decryption key, i.e. a recipient entry which was encrypted
// for one of our private keys
recp, err := x.findDecryptionKey(hdr)
if err != nil {
return nil, errors.Wrapf(err, "unable to find decryption key")... | [
"func",
"(",
"x",
"*",
"XC",
")",
"decryptSessionKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"hdr",
"*",
"xcpb",
".",
"Header",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// find a suiteable decryption key, i.e. a recipient entry which was encryp... | // decryptSessionKey will attempt to find a readable recipient entry in the
// header and decrypt it's session key | [
"decryptSessionKey",
"will",
"attempt",
"to",
"find",
"a",
"readable",
"recipient",
"entry",
"in",
"the",
"header",
"and",
"decrypt",
"it",
"s",
"session",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/decrypt.go#L117-L158 | train |
gopasspw/gopass | pkg/action/mount.go | MountRemove | func (s *Action) MountRemove(ctx context.Context, c *cli.Context) error {
if len(c.Args()) != 1 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s mount remove [alias]", s.Name)
}
if err := s.Store.RemoveMount(ctx, c.Args()[0]); err != nil {
out.Error(ctx, "Failed to remove mount: %s", err)
}
if err := s.cfg... | go | func (s *Action) MountRemove(ctx context.Context, c *cli.Context) error {
if len(c.Args()) != 1 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s mount remove [alias]", s.Name)
}
if err := s.Store.RemoveMount(ctx, c.Args()[0]); err != nil {
out.Error(ctx, "Failed to remove mount: %s", err)
}
if err := s.cfg... | [
"func",
"(",
"s",
"*",
"Action",
")",
"MountRemove",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"len",
"(",
"c",
".",
"Args",
"(",
")",
")",
"!=",
"1",
"{",
"return",
"ExitError",
"(",
... | // MountRemove removes an existing mount | [
"MountRemove",
"removes",
"an",
"existing",
"mount"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/mount.go#L20-L35 | train |
gopasspw/gopass | pkg/action/mount.go | MountsPrint | func (s *Action) MountsPrint(ctx context.Context, c *cli.Context) error {
if len(s.Store.Mounts()) < 1 {
out.Cyan(ctx, "No mounts")
return nil
}
root := simple.New(color.GreenString(fmt.Sprintf("gopass (%s)", s.Store.Path())))
mounts := s.Store.Mounts()
mps := s.Store.MountPoints()
sort.Sort(store.ByPathLen(... | go | func (s *Action) MountsPrint(ctx context.Context, c *cli.Context) error {
if len(s.Store.Mounts()) < 1 {
out.Cyan(ctx, "No mounts")
return nil
}
root := simple.New(color.GreenString(fmt.Sprintf("gopass (%s)", s.Store.Path())))
mounts := s.Store.Mounts()
mps := s.Store.MountPoints()
sort.Sort(store.ByPathLen(... | [
"func",
"(",
"s",
"*",
"Action",
")",
"MountsPrint",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"len",
"(",
"s",
".",
"Store",
".",
"Mounts",
"(",
")",
")",
"<",
"1",
"{",
"out",
".",
... | // MountsPrint prints all existing mounts | [
"MountsPrint",
"prints",
"all",
"existing",
"mounts"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/mount.go#L38-L57 | train |
gopasspw/gopass | pkg/action/mount.go | MountsComplete | func (s *Action) MountsComplete(*cli.Context) {
for alias := range s.Store.Mounts() {
fmt.Fprintln(stdout, alias)
}
} | go | func (s *Action) MountsComplete(*cli.Context) {
for alias := range s.Store.Mounts() {
fmt.Fprintln(stdout, alias)
}
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"MountsComplete",
"(",
"*",
"cli",
".",
"Context",
")",
"{",
"for",
"alias",
":=",
"range",
"s",
".",
"Store",
".",
"Mounts",
"(",
")",
"{",
"fmt",
".",
"Fprintln",
"(",
"stdout",
",",
"alias",
")",
"\n",
"}"... | // MountsComplete will print a list of existings mount points for bash
// completion | [
"MountsComplete",
"will",
"print",
"a",
"list",
"of",
"existings",
"mount",
"points",
"for",
"bash",
"completion"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/mount.go#L61-L65 | train |
gopasspw/gopass | pkg/action/mount.go | MountAdd | func (s *Action) MountAdd(ctx context.Context, c *cli.Context) error {
alias := c.Args().Get(0)
localPath := c.Args().Get(1)
if alias == "" {
return ExitError(ctx, ExitUsage, nil, "usage: %s mounts add <alias> [local path]", s.Name)
}
if localPath == "" {
localPath = config.PwStoreDir(alias)
}
keys := make... | go | func (s *Action) MountAdd(ctx context.Context, c *cli.Context) error {
alias := c.Args().Get(0)
localPath := c.Args().Get(1)
if alias == "" {
return ExitError(ctx, ExitUsage, nil, "usage: %s mounts add <alias> [local path]", s.Name)
}
if localPath == "" {
localPath = config.PwStoreDir(alias)
}
keys := make... | [
"func",
"(",
"s",
"*",
"Action",
")",
"MountAdd",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"alias",
":=",
"c",
".",
"Args",
"(",
")",
".",
"Get",
"(",
"0",
")",
"\n",
"localPath",
":=",
"c"... | // MountAdd adds a new mount | [
"MountAdd",
"adds",
"a",
"new",
"mount"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/mount.go#L68-L109 | train |
gopasspw/gopass | pkg/backend/crypto/plain/backend.go | FindPublicKeys | func (m *Mocker) FindPublicKeys(ctx context.Context, keys ...string) ([]string, error) {
rs := staticPrivateKeyList.Recipients()
res := make([]string, 0, len(rs))
for _, r := range rs {
for _, needle := range keys {
if strings.HasSuffix(r, needle) {
res = append(res, r)
}
}
}
return res, nil
} | go | func (m *Mocker) FindPublicKeys(ctx context.Context, keys ...string) ([]string, error) {
rs := staticPrivateKeyList.Recipients()
res := make([]string, 0, len(rs))
for _, r := range rs {
for _, needle := range keys {
if strings.HasSuffix(r, needle) {
res = append(res, r)
}
}
}
return res, nil
} | [
"func",
"(",
"m",
"*",
"Mocker",
")",
"FindPublicKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"keys",
"...",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"rs",
":=",
"staticPrivateKeyList",
".",
"Recipients",
"(",
")",
"\n",
... | // FindPublicKeys does nothing | [
"FindPublicKeys",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/plain/backend.go#L61-L72 | train |
gopasspw/gopass | pkg/backend/crypto/plain/backend.go | RecipientIDs | func (m *Mocker) RecipientIDs(context.Context, []byte) ([]string, error) {
return staticPrivateKeyList.Recipients(), nil
} | go | func (m *Mocker) RecipientIDs(context.Context, []byte) ([]string, error) {
return staticPrivateKeyList.Recipients(), nil
} | [
"func",
"(",
"m",
"*",
"Mocker",
")",
"RecipientIDs",
"(",
"context",
".",
"Context",
",",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"staticPrivateKeyList",
".",
"Recipients",
"(",
")",
",",
"nil",
"\n",
"}"
] | // RecipientIDs does nothing | [
"RecipientIDs",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/plain/backend.go#L85-L87 | train |
gopasspw/gopass | pkg/backend/crypto/plain/backend.go | Encrypt | func (m *Mocker) Encrypt(ctx context.Context, content []byte, recipients []string) ([]byte, error) {
return content, nil
} | go | func (m *Mocker) Encrypt(ctx context.Context, content []byte, recipients []string) ([]byte, error) {
return content, nil
} | [
"func",
"(",
"m",
"*",
"Mocker",
")",
"Encrypt",
"(",
"ctx",
"context",
".",
"Context",
",",
"content",
"[",
"]",
"byte",
",",
"recipients",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"content",
",",
"nil",
... | // Encrypt writes the input to disk unaltered | [
"Encrypt",
"writes",
"the",
"input",
"to",
"disk",
"unaltered"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/plain/backend.go#L90-L92 | train |
gopasspw/gopass | pkg/backend/crypto/plain/backend.go | Decrypt | func (m *Mocker) Decrypt(ctx context.Context, ciphertext []byte) ([]byte, error) {
return ciphertext, nil
} | go | func (m *Mocker) Decrypt(ctx context.Context, ciphertext []byte) ([]byte, error) {
return ciphertext, nil
} | [
"func",
"(",
"m",
"*",
"Mocker",
")",
"Decrypt",
"(",
"ctx",
"context",
".",
"Context",
",",
"ciphertext",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"ciphertext",
",",
"nil",
"\n",
"}"
] | // Decrypt read the file from disk unaltered | [
"Decrypt",
"read",
"the",
"file",
"from",
"disk",
"unaltered"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/plain/backend.go#L95-L97 | train |
gopasspw/gopass | pkg/backend/crypto/plain/backend.go | Sign | func (m *Mocker) Sign(ctx context.Context, in string, sigf string) error {
buf, err := ioutil.ReadFile(in)
if err != nil {
return err
}
sum := sha256.New()
_, _ = sum.Write(buf)
hexsum := fmt.Sprintf("%X", sum.Sum(nil))
return ioutil.WriteFile(sigf, []byte(hexsum), 0644)
} | go | func (m *Mocker) Sign(ctx context.Context, in string, sigf string) error {
buf, err := ioutil.ReadFile(in)
if err != nil {
return err
}
sum := sha256.New()
_, _ = sum.Write(buf)
hexsum := fmt.Sprintf("%X", sum.Sum(nil))
return ioutil.WriteFile(sigf, []byte(hexsum), 0644)
} | [
"func",
"(",
"m",
"*",
"Mocker",
")",
"Sign",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"string",
",",
"sigf",
"string",
")",
"error",
"{",
"buf",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"in",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // Sign writes the hashsum to the given file | [
"Sign",
"writes",
"the",
"hashsum",
"to",
"the",
"given",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/plain/backend.go#L120-L129 | train |
gopasspw/gopass | pkg/backend/crypto/plain/backend.go | Verify | func (m *Mocker) Verify(ctx context.Context, sigf string, in string) error {
sigb, err := ioutil.ReadFile(sigf)
if err != nil {
return err
}
buf, err := ioutil.ReadFile(in)
if err != nil {
return err
}
sum := sha256.New()
_, _ = sum.Write(buf)
hexsum := fmt.Sprintf("%X", sum.Sum(nil))
if string(sigb) !=... | go | func (m *Mocker) Verify(ctx context.Context, sigf string, in string) error {
sigb, err := ioutil.ReadFile(sigf)
if err != nil {
return err
}
buf, err := ioutil.ReadFile(in)
if err != nil {
return err
}
sum := sha256.New()
_, _ = sum.Write(buf)
hexsum := fmt.Sprintf("%X", sum.Sum(nil))
if string(sigb) !=... | [
"func",
"(",
"m",
"*",
"Mocker",
")",
"Verify",
"(",
"ctx",
"context",
".",
"Context",
",",
"sigf",
"string",
",",
"in",
"string",
")",
"error",
"{",
"sigb",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"sigf",
")",
"\n",
"if",
"err",
"!=",
... | // Verify does a pseudo-verification | [
"Verify",
"does",
"a",
"pseudo",
"-",
"verification"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/plain/backend.go#L132-L151 | train |
gopasspw/gopass | pkg/backend/crypto/plain/backend.go | ReadNamesFromKey | func (m *Mocker) ReadNamesFromKey(ctx context.Context, buf []byte) ([]string, error) {
return []string{"unsupported"}, nil
} | go | func (m *Mocker) ReadNamesFromKey(ctx context.Context, buf []byte) ([]string, error) {
return []string{"unsupported"}, nil
} | [
"func",
"(",
"m",
"*",
"Mocker",
")",
"ReadNamesFromKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"nil",
... | // ReadNamesFromKey does nothing | [
"ReadNamesFromKey",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/plain/backend.go#L204-L206 | train |
gopasspw/gopass | pkg/backend/rcs/git/cli/loader.go | Clone | func (l loader) Clone(ctx context.Context, repo, path string) (backend.RCS, error) {
return Clone(ctx, repo, path)
} | go | func (l loader) Clone(ctx context.Context, repo, path string) (backend.RCS, error) {
return Clone(ctx, repo, path)
} | [
"func",
"(",
"l",
"loader",
")",
"Clone",
"(",
"ctx",
"context",
".",
"Context",
",",
"repo",
",",
"path",
"string",
")",
"(",
"backend",
".",
"RCS",
",",
"error",
")",
"{",
"return",
"Clone",
"(",
"ctx",
",",
"repo",
",",
"path",
")",
"\n",
"}"
... | // Clone implements backend.RCSLoader | [
"Clone",
"implements",
"backend",
".",
"RCSLoader"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/loader.go#L27-L29 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/cli/import.go | ImportPublicKey | func (g *GPG) ImportPublicKey(ctx context.Context, buf []byte) error {
if len(buf) < 1 {
return errors.Errorf("empty input")
}
args := append(g.args, "--import")
cmd := exec.CommandContext(ctx, g.binary, args...)
cmd.Stdin = bytes.NewReader(buf)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
out.Debug(ctx, "... | go | func (g *GPG) ImportPublicKey(ctx context.Context, buf []byte) error {
if len(buf) < 1 {
return errors.Errorf("empty input")
}
args := append(g.args, "--import")
cmd := exec.CommandContext(ctx, g.binary, args...)
cmd.Stdin = bytes.NewReader(buf)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
out.Debug(ctx, "... | [
"func",
"(",
"g",
"*",
"GPG",
")",
"ImportPublicKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"buf",
")",
"<",
"1",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
... | // ImportPublicKey will import a key from the given location | [
"ImportPublicKey",
"will",
"import",
"a",
"key",
"from",
"the",
"given",
"location"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/import.go#L15-L35 | train |
gopasspw/gopass | pkg/action/binary/copy.go | Copy | func Copy(ctx context.Context, c *cli.Context, store storer) error {
from := c.Args().Get(0)
to := c.Args().Get(1)
// argument checking is in s.binaryCopy
if err := binaryCopy(ctx, c, from, to, false, store); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "%s", err)
}
return nil
} | go | func Copy(ctx context.Context, c *cli.Context, store storer) error {
from := c.Args().Get(0)
to := c.Args().Get(1)
// argument checking is in s.binaryCopy
if err := binaryCopy(ctx, c, from, to, false, store); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "%s", err)
}
return nil
} | [
"func",
"Copy",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"store",
"storer",
")",
"error",
"{",
"from",
":=",
"c",
".",
"Args",
"(",
")",
".",
"Get",
"(",
"0",
")",
"\n",
"to",
":=",
"c",
".",
"Args",
"... | // Copy copies either from the filesystem to the store or from the store
// to the filesystem | [
"Copy",
"copies",
"either",
"from",
"the",
"filesystem",
"to",
"the",
"store",
"or",
"from",
"the",
"store",
"to",
"the",
"filesystem"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/binary/copy.go#L22-L31 | train |
gopasspw/gopass | pkg/action/fsck.go | Fsck | func (s *Action) Fsck(ctx context.Context, c *cli.Context) error {
out.Print(ctx, "Checking store integrity ...")
// make sure config is in the right place
// we may have loaded it from one of the fallback locations
if err := s.cfg.Save(); err != nil {
return ExitError(ctx, ExitConfig, err, "failed to save config... | go | func (s *Action) Fsck(ctx context.Context, c *cli.Context) error {
out.Print(ctx, "Checking store integrity ...")
// make sure config is in the right place
// we may have loaded it from one of the fallback locations
if err := s.cfg.Save(); err != nil {
return ExitError(ctx, ExitConfig, err, "failed to save config... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Fsck",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"out",
".",
"Print",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"// make sure config is in the right place",
"// ... | // Fsck checks the store integrity | [
"Fsck",
"checks",
"the",
"store",
"integrity"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/fsck.go#L20-L68 | train |
gopasspw/gopass | pkg/notify/notify_others.go | Notify | func Notify(ctx context.Context, subj, msg string) error {
return errors.Errorf("GOOS %s not yet supported", runtime.GOOS)
} | go | func Notify(ctx context.Context, subj, msg string) error {
return errors.Errorf("GOOS %s not yet supported", runtime.GOOS)
} | [
"func",
"Notify",
"(",
"ctx",
"context",
".",
"Context",
",",
"subj",
",",
"msg",
"string",
")",
"error",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"runtime",
".",
"GOOS",
")",
"\n",
"}"
] | // Notify is not yet implemented on this platform | [
"Notify",
"is",
"not",
"yet",
"implemented",
"on",
"this",
"platform"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/notify/notify_others.go#L13-L15 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/cli/export.go | ExportPublicKey | func (g *GPG) ExportPublicKey(ctx context.Context, id string) ([]byte, error) {
if id == "" {
return nil, errors.Errorf("id is empty")
}
args := append(g.args, "--armor", "--export", id)
cmd := exec.CommandContext(ctx, g.binary, args...)
out.Debug(ctx, "gpg.ExportPublicKey: %s %+v", cmd.Path, cmd.Args)
out, e... | go | func (g *GPG) ExportPublicKey(ctx context.Context, id string) ([]byte, error) {
if id == "" {
return nil, errors.Errorf("id is empty")
}
args := append(g.args, "--armor", "--export", id)
cmd := exec.CommandContext(ctx, g.binary, args...)
out.Debug(ctx, "gpg.ExportPublicKey: %s %+v", cmd.Path, cmd.Args)
out, e... | [
"func",
"(",
"g",
"*",
"GPG",
")",
"ExportPublicKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"id",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"Errorf"... | // ExportPublicKey will export the named public key to the location given | [
"ExportPublicKey",
"will",
"export",
"the",
"named",
"public",
"key",
"to",
"the",
"location",
"given"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/export.go#L13-L32 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/cli/utils.go | parseTS | func parseTS(str string) time.Time {
t := time.Time{}
if sec, err := strconv.ParseInt(str, 10, 64); err == nil {
t = time.Unix(sec, 0)
}
return t
} | go | func parseTS(str string) time.Time {
t := time.Time{}
if sec, err := strconv.ParseInt(str, 10, 64); err == nil {
t = time.Unix(sec, 0)
}
return t
} | [
"func",
"parseTS",
"(",
"str",
"string",
")",
"time",
".",
"Time",
"{",
"t",
":=",
"time",
".",
"Time",
"{",
"}",
"\n\n",
"if",
"sec",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"str",
",",
"10",
",",
"64",
")",
";",
"err",
"==",
"nil",... | // parseTS parses the passed string as an Epoch int and returns
// the time struct or the zero time struct | [
"parseTS",
"parses",
"the",
"passed",
"string",
"as",
"an",
"Epoch",
"int",
"and",
"returns",
"the",
"time",
"struct",
"or",
"the",
"zero",
"time",
"struct"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/utils.go#L12-L20 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/cli/utils.go | parseInt | func parseInt(str string) int {
i := 0
if iv, err := strconv.ParseInt(str, 10, 32); err == nil {
i = int(iv)
}
return i
} | go | func parseInt(str string) int {
i := 0
if iv, err := strconv.ParseInt(str, 10, 32); err == nil {
i = int(iv)
}
return i
} | [
"func",
"parseInt",
"(",
"str",
"string",
")",
"int",
"{",
"i",
":=",
"0",
"\n\n",
"if",
"iv",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"str",
",",
"10",
",",
"32",
")",
";",
"err",
"==",
"nil",
"{",
"i",
"=",
"int",
"(",
"iv",
")",... | // parseInt parses the passed string as an int and returns it
// or 0 on errors | [
"parseInt",
"parses",
"the",
"passed",
"string",
"as",
"an",
"int",
"and",
"returns",
"it",
"or",
"0",
"on",
"errors"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/utils.go#L24-L32 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/cli/utils.go | GPGOpts | func GPGOpts() []string {
for _, en := range []string{"GOPASS_GPG_OPTS", "PASSWORD_STORE_GPG_OPTS"} {
if opts := os.Getenv(en); opts != "" {
return strings.Fields(opts)
}
}
return nil
} | go | func GPGOpts() []string {
for _, en := range []string{"GOPASS_GPG_OPTS", "PASSWORD_STORE_GPG_OPTS"} {
if opts := os.Getenv(en); opts != "" {
return strings.Fields(opts)
}
}
return nil
} | [
"func",
"GPGOpts",
"(",
")",
"[",
"]",
"string",
"{",
"for",
"_",
",",
"en",
":=",
"range",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"{",
"if",
"opts",
":=",
"os",
".",
"Getenv",
"(",
"en",
")",
";",
"opts",
"!=",
"\"",
"\... | // GPGOpts parses extra GPG options from the environment | [
"GPGOpts",
"parses",
"extra",
"GPG",
"options",
"from",
"the",
"environment"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/utils.go#L48-L55 | train |
gopasspw/gopass | pkg/store/vault/store.go | Exists | func (s *Store) Exists(ctx context.Context, name string) bool {
_, err := s.Get(ctx, name)
return err == nil
} | go | func (s *Store) Exists(ctx context.Context, name string) bool {
_, err := s.Get(ctx, name)
return err == nil
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Exists",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"_",
",",
"err",
":=",
"s",
".",
"Get",
"(",
"ctx",
",",
"name",
")",
"\n",
"return",
"err",
"==",
"nil",
"\n",
"}"
] | // Exists checks if a given secret exists | [
"Exists",
"checks",
"if",
"a",
"given",
"secret",
"exists"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/store.go#L195-L198 | train |
gopasspw/gopass | pkg/store/vault/store.go | Get | func (s *Store) Get(ctx context.Context, name string) (store.Secret, error) {
key := path.Join(s.path, name)
out.Debug(ctx, "Get(%s) %s", name, key)
sec, err := s.api.Logical().Read(key)
if err != nil {
return nil, err
}
if sec == nil || sec.Data == nil {
return nil, fmt.Errorf("not found")
}
return &Secret... | go | func (s *Store) Get(ctx context.Context, name string) (store.Secret, error) {
key := path.Join(s.path, name)
out.Debug(ctx, "Get(%s) %s", name, key)
sec, err := s.api.Logical().Read(key)
if err != nil {
return nil, err
}
if sec == nil || sec.Data == nil {
return nil, fmt.Errorf("not found")
}
return &Secret... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"store",
".",
"Secret",
",",
"error",
")",
"{",
"key",
":=",
"path",
".",
"Join",
"(",
"s",
".",
"path",
",",
"name",
")",
"\n",... | // Get returns a secret | [
"Get",
"returns",
"a",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/store.go#L201-L212 | train |
gopasspw/gopass | pkg/store/vault/store.go | Initialized | func (s *Store) Initialized(ctx context.Context) bool {
_, err := s.List(ctx, "")
return err == nil
} | go | func (s *Store) Initialized(ctx context.Context) bool {
_, err := s.List(ctx, "")
return err == nil
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Initialized",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"err",
":=",
"s",
".",
"List",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"return",
"err",
"==",
"nil",
"\n",
"}"
] | // Initialized returns true if the backend can communicate with Vault | [
"Initialized",
"returns",
"true",
"if",
"the",
"backend",
"can",
"communicate",
"with",
"Vault"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/store.go#L220-L223 | train |
gopasspw/gopass | pkg/store/vault/store.go | IsDir | func (s *Store) IsDir(ctx context.Context, name string) bool {
ls, err := s.List(ctx, name)
if err != nil {
return false
}
return len(ls) > 1
} | go | func (s *Store) IsDir(ctx context.Context, name string) bool {
ls, err := s.List(ctx, name)
if err != nil {
return false
}
return len(ls) > 1
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"IsDir",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"ls",
",",
"err",
":=",
"s",
".",
"List",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",... | // IsDir returns true if the given name is a dir | [
"IsDir",
"returns",
"true",
"if",
"the",
"given",
"name",
"is",
"a",
"dir"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/store.go#L226-L232 | train |
gopasspw/gopass | pkg/store/vault/store.go | List | func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
keys, err := s.list(ctx, prefix)
if err != nil {
return nil, err
}
for i, e := range keys {
keys[i] = path.Join(s.alias, e)
}
return keys, nil
} | go | func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
keys, err := s.list(ctx, prefix)
if err != nil {
return nil, err
}
for i, e := range keys {
keys[i] = path.Join(s.alias, e)
}
return keys, nil
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"keys",
",",
"err",
":=",
"s",
".",
"list",
"(",
"ctx",
",",
"prefix",
")",
"\n",... | // List returns a list of entries with the given prefix | [
"List",
"returns",
"a",
"list",
"of",
"entries",
"with",
"the",
"given",
"prefix"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/store.go#L253-L262 | train |
gopasspw/gopass | pkg/store/vault/store.go | Move | func (s *Store) Move(ctx context.Context, from string, to string) error {
// recursive move?
if s.IsDir(ctx, from) {
if s.Exists(ctx, to) {
return errors.Errorf("Can not move dir to file")
}
sf, err := s.List(ctx, "")
if err != nil {
return errors.Wrapf(err, "failed to list store")
}
destPrefix := t... | go | func (s *Store) Move(ctx context.Context, from string, to string) error {
// recursive move?
if s.IsDir(ctx, from) {
if s.Exists(ctx, to) {
return errors.Errorf("Can not move dir to file")
}
sf, err := s.List(ctx, "")
if err != nil {
return errors.Wrapf(err, "failed to list store")
}
destPrefix := t... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Move",
"(",
"ctx",
"context",
".",
"Context",
",",
"from",
"string",
",",
"to",
"string",
")",
"error",
"{",
"// recursive move?",
"if",
"s",
".",
"IsDir",
"(",
"ctx",
",",
"from",
")",
"{",
"if",
"s",
".",
"... | // Move moves one or many secrets | [
"Move",
"moves",
"one",
"or",
"many",
"secrets"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/store.go#L290-L327 | train |
gopasspw/gopass | pkg/store/vault/store.go | Set | func (s *Store) Set(ctx context.Context, name string, sec store.Secret) error {
d := sec.Data()
if d == nil {
d = make(map[string]interface{}, 1)
}
d[passwordKey] = sec.Password()
_, err := s.api.Logical().Write(path.Join(s.path, name), d)
return err
} | go | func (s *Store) Set(ctx context.Context, name string, sec store.Secret) error {
d := sec.Data()
if d == nil {
d = make(map[string]interface{}, 1)
}
d[passwordKey] = sec.Password()
_, err := s.api.Logical().Write(path.Join(s.path, name), d)
return err
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Set",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"sec",
"store",
".",
"Secret",
")",
"error",
"{",
"d",
":=",
"sec",
".",
"Data",
"(",
")",
"\n",
"if",
"d",
"==",
"nil",
"{",
"d",
... | // Set writes a secret | [
"Set",
"writes",
"a",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/store.go#L330-L338 | train |
gopasspw/gopass | pkg/store/vault/store.go | Prune | func (s *Store) Prune(ctx context.Context, name string) error {
ls, err := s.List(ctx, name)
if err != nil {
return err
}
for _, e := range ls {
if err := s.Delete(ctx, e); err != nil {
return err
}
}
return nil
} | go | func (s *Store) Prune(ctx context.Context, name string) error {
ls, err := s.List(ctx, name)
if err != nil {
return err
}
for _, e := range ls {
if err := s.Delete(ctx, e); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Prune",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"error",
"{",
"ls",
",",
"err",
":=",
"s",
".",
"List",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return"... | // Prune removes a directory tree | [
"Prune",
"removes",
"a",
"directory",
"tree"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/store.go#L341-L352 | train |
gopasspw/gopass | pkg/termio/ask.go | AskForInt | func AskForInt(ctx context.Context, text string, def int) (int, error) {
if ctxutil.IsAlwaysYes(ctx) {
return def, nil
}
str, err := AskForString(ctx, text, strconv.Itoa(def))
if err != nil {
return 0, err
}
if str == "q" {
return 0, ErrAborted
}
intVal, err := strconv.Atoi(str)
if err != nil {
return... | go | func AskForInt(ctx context.Context, text string, def int) (int, error) {
if ctxutil.IsAlwaysYes(ctx) {
return def, nil
}
str, err := AskForString(ctx, text, strconv.Itoa(def))
if err != nil {
return 0, err
}
if str == "q" {
return 0, ErrAborted
}
intVal, err := strconv.Atoi(str)
if err != nil {
return... | [
"func",
"AskForInt",
"(",
"ctx",
"context",
".",
"Context",
",",
"text",
"string",
",",
"def",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"ctxutil",
".",
"IsAlwaysYes",
"(",
"ctx",
")",
"{",
"return",
"def",
",",
"nil",
"\n",
"}",
"\n\n"... | // AskForInt asks for an valid interger once. If the input
// can not be converted to an int it returns an error | [
"AskForInt",
"asks",
"for",
"an",
"valid",
"interger",
"once",
".",
"If",
"the",
"input",
"can",
"not",
"be",
"converted",
"to",
"an",
"int",
"it",
"returns",
"an",
"error"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/termio/ask.go#L95-L112 | train |
gopasspw/gopass | pkg/termio/ask.go | AskForKeyImport | func AskForKeyImport(ctx context.Context, key string, names []string) bool {
if ctxutil.IsAlwaysYes(ctx) {
return true
}
if !ctxutil.IsInteractive(ctx) {
return false
}
ok, err := AskForBool(ctx, fmt.Sprintf("Do you want to import the public key '%s' (Names: %+v) into your keyring?", key, names), false)
if e... | go | func AskForKeyImport(ctx context.Context, key string, names []string) bool {
if ctxutil.IsAlwaysYes(ctx) {
return true
}
if !ctxutil.IsInteractive(ctx) {
return false
}
ok, err := AskForBool(ctx, fmt.Sprintf("Do you want to import the public key '%s' (Names: %+v) into your keyring?", key, names), false)
if e... | [
"func",
"AskForKeyImport",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
",",
"names",
"[",
"]",
"string",
")",
"bool",
"{",
"if",
"ctxutil",
".",
"IsAlwaysYes",
"(",
"ctx",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"!",
"ctxu... | // AskForKeyImport asks for permissions to import the named key | [
"AskForKeyImport",
"asks",
"for",
"permissions",
"to",
"import",
"the",
"named",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/termio/ask.go#L134-L148 | train |
gopasspw/gopass | pkg/termio/ask.go | AskForPassword | func AskForPassword(ctx context.Context, name string) (string, error) {
if ctxutil.IsAlwaysYes(ctx) {
return "", nil
}
askFn := GetPassPromptFunc(ctx)
for i := 0; i < maxTries; i++ {
// check for context cancelation
select {
case <-ctx.Done():
return "", ErrAborted
default:
}
pass, err := askFn(c... | go | func AskForPassword(ctx context.Context, name string) (string, error) {
if ctxutil.IsAlwaysYes(ctx) {
return "", nil
}
askFn := GetPassPromptFunc(ctx)
for i := 0; i < maxTries; i++ {
// check for context cancelation
select {
case <-ctx.Done():
return "", ErrAborted
default:
}
pass, err := askFn(c... | [
"func",
"AskForPassword",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"ctxutil",
".",
"IsAlwaysYes",
"(",
"ctx",
")",
"{",
"return",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n\n",
"askFn... | // AskForPassword prompts for a password twice until both match | [
"AskForPassword",
"prompts",
"for",
"a",
"password",
"twice",
"until",
"both",
"match"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/termio/ask.go#L151-L182 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.