id int32 0 167k | 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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
29,100 | gopasspw/gopass | pkg/ctxutil/ctxutil.go | GetAlias | func GetAlias(ctx context.Context) string {
a, ok := ctx.Value(ctxKeyAlias).(string)
if !ok {
return ""
}
return a
} | go | func GetAlias(ctx context.Context) string {
a, ok := ctx.Value(ctxKeyAlias).(string)
if !ok {
return ""
}
return a
} | [
"func",
"GetAlias",
"(",
"ctx",
"context",
".",
"Context",
")",
"string",
"{",
"a",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAlias",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return... | // GetAlias returns an alias if it has been set or an empty string otherwise. | [
"GetAlias",
"returns",
"an",
"alias",
"if",
"it",
"has",
"been",
"set",
"or",
"an",
"empty",
"string",
"otherwise",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L497-L503 |
29,101 | gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithAutoPrint | func WithAutoPrint(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyAutoPrint, bv)
} | go | func WithAutoPrint(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyAutoPrint, bv)
} | [
"func",
"WithAutoPrint",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyAutoPrint",
",",
"bv",
")",
"\n",
"}"
] | // WithAutoPrint returns a context with the value for auto print set. | [
"WithAutoPrint",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"auto",
"print",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L506-L508 |
29,102 | gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasAutoPrint | func HasAutoPrint(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAutoPrint).(bool)
return ok
} | go | func HasAutoPrint(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAutoPrint).(bool)
return ok
} | [
"func",
"HasAutoPrint",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAutoPrint",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasAutoPrint returns true if a specific value for auto print was set. | [
"HasAutoPrint",
"returns",
"true",
"if",
"a",
"specific",
"value",
"for",
"auto",
"print",
"was",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L511-L514 |
29,103 | gopasspw/gopass | pkg/ctxutil/ctxutil.go | IsAutoPrint | func IsAutoPrint(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyAutoPrint).(bool)
if !ok {
return false
}
return bv
} | go | func IsAutoPrint(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyAutoPrint).(bool)
if !ok {
return false
}
return bv
} | [
"func",
"IsAutoPrint",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"bv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAutoPrint",
")",
".",
"(",
"bool",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return"... | // IsAutoPrint returns the value of auto print or false if none was set. | [
"IsAutoPrint",
"returns",
"the",
"value",
"of",
"auto",
"print",
"or",
"false",
"if",
"none",
"was",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L517-L523 |
29,104 | gopasspw/gopass | pkg/ctxutil/ctxutil.go | WithGitInit | func WithGitInit(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyGitInit, bv)
} | go | func WithGitInit(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyGitInit, bv)
} | [
"func",
"WithGitInit",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyGitInit",
",",
"bv",
")",
"\n",
"}"
] | // WithGitInit returns a context with the value for the git init flag set. | [
"WithGitInit",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"the",
"git",
"init",
"flag",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L526-L528 |
29,105 | gopasspw/gopass | pkg/ctxutil/ctxutil.go | HasGitInit | func HasGitInit(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyGitInit).(bool)
return ok
} | go | func HasGitInit(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyGitInit).(bool)
return ok
} | [
"func",
"HasGitInit",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyGitInit",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasGitInit returns true if the git init flag was set. | [
"HasGitInit",
"returns",
"true",
"if",
"the",
"git",
"init",
"flag",
"was",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L531-L534 |
29,106 | gopasspw/gopass | pkg/ctxutil/ctxutil.go | IsGitInit | func IsGitInit(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyGitInit).(bool)
if !ok {
return true
}
return bv
} | go | func IsGitInit(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyGitInit).(bool)
if !ok {
return true
}
return bv
} | [
"func",
"IsGitInit",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"bv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyGitInit",
")",
".",
"(",
"bool",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"... | // IsGitInit returns the value of the git init flag or ture if none was set. | [
"IsGitInit",
"returns",
"the",
"value",
"of",
"the",
"git",
"init",
"flag",
"or",
"ture",
"if",
"none",
"was",
"set",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L537-L543 |
29,107 | gopasspw/gopass | pkg/completion/zsh/completion.go | GetCompletion | func GetCompletion(a *cli.App) (string, error) {
tplFuncs := template.FuncMap{
"formatFlag": formatFlagFunc(),
}
tpl, err := template.New("zsh").Funcs(tplFuncs).Parse(zshTemplate)
if err != nil {
return "", err
}
buf := &bytes.Buffer{}
if err := tpl.Execute(buf, a); err != nil {
return "", err
}
return b... | go | func GetCompletion(a *cli.App) (string, error) {
tplFuncs := template.FuncMap{
"formatFlag": formatFlagFunc(),
}
tpl, err := template.New("zsh").Funcs(tplFuncs).Parse(zshTemplate)
if err != nil {
return "", err
}
buf := &bytes.Buffer{}
if err := tpl.Execute(buf, a); err != nil {
return "", err
}
return b... | [
"func",
"GetCompletion",
"(",
"a",
"*",
"cli",
".",
"App",
")",
"(",
"string",
",",
"error",
")",
"{",
"tplFuncs",
":=",
"template",
".",
"FuncMap",
"{",
"\"",
"\"",
":",
"formatFlagFunc",
"(",
")",
",",
"}",
"\n",
"tpl",
",",
"err",
":=",
"templat... | // GetCompletion returns a zsh completion script | [
"GetCompletion",
"returns",
"a",
"zsh",
"completion",
"script"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/completion/zsh/completion.go#L56-L69 |
29,108 | gopasspw/gopass | pkg/action/binary/sum.go | Sum | func Sum(ctx context.Context, c *cli.Context, store storer) error {
name := c.Args().First()
if name == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "Usage: %s sha256 name", c.App.Name)
}
if !strings.HasSuffix(name, Suffix) {
name += Suffix
}
buf, err := binaryGet(ctx, name, store)
if err != ni... | go | func Sum(ctx context.Context, c *cli.Context, store storer) error {
name := c.Args().First()
if name == "" {
return action.ExitError(ctx, action.ExitUsage, nil, "Usage: %s sha256 name", c.App.Name)
}
if !strings.HasSuffix(name, Suffix) {
name += Suffix
}
buf, err := binaryGet(ctx, name, store)
if err != ni... | [
"func",
"Sum",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"store",
"storer",
")",
"error",
"{",
"name",
":=",
"c",
".",
"Args",
"(",
")",
".",
"First",
"(",
")",
"\n",
"if",
"name",
"==",
"\"",
"\"",
"{",
... | // Sum decodes binary content and computes the SHA256 checksum | [
"Sum",
"decodes",
"binary",
"content",
"and",
"computes",
"the",
"SHA256",
"checksum"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/binary/sum.go#L15-L35 |
29,109 | gopasspw/gopass | pkg/store/sub/read.go | Get | func (s *Store) Get(ctx context.Context, name string) (store.Secret, error) {
p := s.passfile(name)
ciphertext, err := s.storage.Get(ctx, p)
if err != nil {
out.Debug(ctx, "File %s not found: %s", p, err)
return nil, store.ErrNotFound
}
content, err := s.crypto.Decrypt(ctx, ciphertext)
if err != nil {
out... | go | func (s *Store) Get(ctx context.Context, name string) (store.Secret, error) {
p := s.passfile(name)
ciphertext, err := s.storage.Get(ctx, p)
if err != nil {
out.Debug(ctx, "File %s not found: %s", p, err)
return nil, store.ErrNotFound
}
content, err := s.crypto.Decrypt(ctx, ciphertext)
if err != nil {
out... | [
"func",
"(",
"s",
"*",
"Store",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"store",
".",
"Secret",
",",
"error",
")",
"{",
"p",
":=",
"s",
".",
"passfile",
"(",
"name",
")",
"\n\n",
"ciphertext",
",",
"err... | // Get returns the plaintext of a single key | [
"Get",
"returns",
"the",
"plaintext",
"of",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/read.go#L12-L32 |
29,110 | gopasspw/gopass | pkg/action/jsonapi.go | JSONAPI | func (s *Action) JSONAPI(ctx context.Context, c *cli.Context) error {
api := jsonapi.API{Store: s.Store, Reader: stdin, Writer: stdout, Version: s.version}
if err := api.ReadAndRespond(ctx); err != nil {
return api.RespondError(err)
}
return nil
} | go | func (s *Action) JSONAPI(ctx context.Context, c *cli.Context) error {
api := jsonapi.API{Store: s.Store, Reader: stdin, Writer: stdout, Version: s.version}
if err := api.ReadAndRespond(ctx); err != nil {
return api.RespondError(err)
}
return nil
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"JSONAPI",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"api",
":=",
"jsonapi",
".",
"API",
"{",
"Store",
":",
"s",
".",
"Store",
",",
"Reader",
":",
"stdin"... | // JSONAPI reads a json message on stdin and responds on stdout | [
"JSONAPI",
"reads",
"a",
"json",
"message",
"on",
"stdin",
"and",
"responds",
"on",
"stdout"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/jsonapi.go#L19-L25 |
29,111 | gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Get | func (m *InMem) Get(ctx context.Context, name string) ([]byte, error) {
m.Lock()
defer m.Unlock()
sec, found := m.data[name]
if !found {
return nil, fmt.Errorf("entry not found")
}
return sec, nil
} | go | func (m *InMem) Get(ctx context.Context, name string) ([]byte, error) {
m.Lock()
defer m.Unlock()
sec, found := m.data[name]
if !found {
return nil, fmt.Errorf("entry not found")
}
return sec, nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"se... | // Get retrieves a value | [
"Get",
"retrieves",
"a",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L27-L36 |
29,112 | gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Set | func (m *InMem) Set(ctx context.Context, name string, value []byte) error {
m.Lock()
defer m.Unlock()
m.data[name] = value
return nil
} | go | func (m *InMem) Set(ctx context.Context, name string, value []byte) error {
m.Lock()
defer m.Unlock()
m.data[name] = value
return nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Set",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"value",
"[",
"]",
"byte",
")",
"error",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"m",
... | // Set writes a value | [
"Set",
"writes",
"a",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L39-L45 |
29,113 | gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Delete | func (m *InMem) Delete(ctx context.Context, name string) error {
m.Lock()
defer m.Unlock()
delete(m.data, name)
return nil
} | go | func (m *InMem) Delete(ctx context.Context, name string) error {
m.Lock()
defer m.Unlock()
delete(m.data, name)
return nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"error",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"delete",
"(",
"m",
".",
"data",
",... | // Delete removes a value | [
"Delete",
"removes",
"a",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L48-L54 |
29,114 | gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Exists | func (m *InMem) Exists(ctx context.Context, name string) bool {
m.Lock()
defer m.Unlock()
_, found := m.data[name]
return found
} | go | func (m *InMem) Exists(ctx context.Context, name string) bool {
m.Lock()
defer m.Unlock()
_, found := m.data[name]
return found
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Exists",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"_",
",",
"found",
":=",
"m",
".",
... | // Exists checks is a value exists | [
"Exists",
"checks",
"is",
"a",
"value",
"exists"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L57-L63 |
29,115 | gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | List | func (m *InMem) List(ctx context.Context, prefix string) ([]string, error) {
m.Lock()
defer m.Unlock()
keys := make([]string, 0, len(m.data))
for k := range m.data {
keys = append(keys, k)
}
sort.Strings(keys)
return keys, nil
} | go | func (m *InMem) List(ctx context.Context, prefix string) ([]string, error) {
m.Lock()
defer m.Unlock()
keys := make([]string, 0, len(m.data))
for k := range m.data {
keys = append(keys, k)
}
sort.Strings(keys)
return keys, nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
... | // List shows all values | [
"List",
"shows",
"all",
"values"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L66-L76 |
29,116 | gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | IsDir | func (m *InMem) IsDir(ctx context.Context, name string) bool {
m.Lock()
defer m.Unlock()
for k := range m.data {
if strings.HasPrefix(k, name+"/") {
return true
}
}
return false
} | go | func (m *InMem) IsDir(ctx context.Context, name string) bool {
m.Lock()
defer m.Unlock()
for k := range m.data {
if strings.HasPrefix(k, name+"/") {
return true
}
}
return false
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"IsDir",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"k",
":=",
"range",
"m",
".",
... | // IsDir returns true if the entry is a directory | [
"IsDir",
"returns",
"true",
"if",
"the",
"entry",
"is",
"a",
"directory"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L79-L89 |
29,117 | gopasspw/gopass | pkg/backend/storage/kv/inmem/store.go | Prune | func (m *InMem) Prune(ctx context.Context, prefix string) error {
m.Lock()
defer m.Unlock()
deleted := 0
for k := range m.data {
if strings.HasPrefix(k, prefix+"/") {
delete(m.data, k)
deleted++
}
}
if deleted < 1 {
return fmt.Errorf("not found")
}
return nil
} | go | func (m *InMem) Prune(ctx context.Context, prefix string) error {
m.Lock()
defer m.Unlock()
deleted := 0
for k := range m.data {
if strings.HasPrefix(k, prefix+"/") {
delete(m.data, k)
deleted++
}
}
if deleted < 1 {
return fmt.Errorf("not found")
}
return nil
} | [
"func",
"(",
"m",
"*",
"InMem",
")",
"Prune",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"error",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"deleted",
":=",
"0",
"\n",
"for",
... | // Prune removes a directory | [
"Prune",
"removes",
"a",
"directory"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/inmem/store.go#L92-L107 |
29,118 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/private_key.go | GenerateKeypair | func GenerateKeypair(passphrase string) (*PrivateKey, error) {
pub, priv, err := box.GenerateKey(crypto_rand.Reader)
if err != nil {
return nil, err
}
k := &PrivateKey{
PublicKey: PublicKey{
CreationTime: time.Now(),
PubKeyAlgo: PubKeyNaCl,
PublicKey: *pub,
Identity: &xcpb.Identity{},
},
... | go | func GenerateKeypair(passphrase string) (*PrivateKey, error) {
pub, priv, err := box.GenerateKey(crypto_rand.Reader)
if err != nil {
return nil, err
}
k := &PrivateKey{
PublicKey: PublicKey{
CreationTime: time.Now(),
PubKeyAlgo: PubKeyNaCl,
PublicKey: *pub,
Identity: &xcpb.Identity{},
},
... | [
"func",
"GenerateKeypair",
"(",
"passphrase",
"string",
")",
"(",
"*",
"PrivateKey",
",",
"error",
")",
"{",
"pub",
",",
"priv",
",",
"err",
":=",
"box",
".",
"GenerateKey",
"(",
"crypto_rand",
".",
"Reader",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // GenerateKeypair generates a new keypair | [
"GenerateKeypair",
"generates",
"a",
"new",
"keypair"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/private_key.go#L41-L58 |
29,119 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/private_key.go | Encrypt | func (p *PrivateKey) Encrypt(passphrase string) error {
p.Salt = make([]byte, saltLength)
if n, err := crypto_rand.Read(p.Salt); err != nil || n < len(p.Salt) {
return err
}
secretKey := p.deriveKey(passphrase)
var nonce [nonceLength]byte
if _, err := io.ReadFull(crypto_rand.Reader, nonce[:]); err != nil {
r... | go | func (p *PrivateKey) Encrypt(passphrase string) error {
p.Salt = make([]byte, saltLength)
if n, err := crypto_rand.Read(p.Salt); err != nil || n < len(p.Salt) {
return err
}
secretKey := p.deriveKey(passphrase)
var nonce [nonceLength]byte
if _, err := io.ReadFull(crypto_rand.Reader, nonce[:]); err != nil {
r... | [
"func",
"(",
"p",
"*",
"PrivateKey",
")",
"Encrypt",
"(",
"passphrase",
"string",
")",
"error",
"{",
"p",
".",
"Salt",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"saltLength",
")",
"\n",
"if",
"n",
",",
"err",
":=",
"crypto_rand",
".",
"Read",
"(",
... | // Encrypt encrypts the private key material with the given passphrase | [
"Encrypt",
"encrypts",
"the",
"private",
"key",
"material",
"with",
"the",
"given",
"passphrase"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/private_key.go#L61-L76 |
29,120 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/private_key.go | Decrypt | func (p *PrivateKey) Decrypt(passphrase string) error {
if !p.Encrypted {
return nil
}
secretKey := p.deriveKey(passphrase)
decrypted, ok := secretbox.Open(nil, p.EncryptedData, &p.Nonce, &secretKey)
if !ok {
return fmt.Errorf("decryption error")
}
copy(p.privateKey[:], decrypted)
p.Encrypted = false
ret... | go | func (p *PrivateKey) Decrypt(passphrase string) error {
if !p.Encrypted {
return nil
}
secretKey := p.deriveKey(passphrase)
decrypted, ok := secretbox.Open(nil, p.EncryptedData, &p.Nonce, &secretKey)
if !ok {
return fmt.Errorf("decryption error")
}
copy(p.privateKey[:], decrypted)
p.Encrypted = false
ret... | [
"func",
"(",
"p",
"*",
"PrivateKey",
")",
"Decrypt",
"(",
"passphrase",
"string",
")",
"error",
"{",
"if",
"!",
"p",
".",
"Encrypted",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"secretKey",
":=",
"p",
".",
"deriveKey",
"(",
"passphrase",
")",
"\n\n",
"d... | // Decrypt decrypts the private key | [
"Decrypt",
"decrypts",
"the",
"private",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/private_key.go#L79-L93 |
29,121 | gopasspw/gopass | pkg/action/create/create.go | Create | func Create(ctx context.Context, c *cli.Context, store storer) error {
s := creator{store: store}
acts := make(cui.Actions, 0, 5)
acts = append(acts, cui.Action{Name: "Website Login", Fn: s.createWebsite})
acts = append(acts, cui.Action{Name: "PIN Code (numerical)", Fn: s.createPIN})
acts = append(acts, cui.Action... | go | func Create(ctx context.Context, c *cli.Context, store storer) error {
s := creator{store: store}
acts := make(cui.Actions, 0, 5)
acts = append(acts, cui.Action{Name: "Website Login", Fn: s.createWebsite})
acts = append(acts, cui.Action{Name: "PIN Code (numerical)", Fn: s.createPIN})
acts = append(acts, cui.Action... | [
"func",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"store",
"storer",
")",
"error",
"{",
"s",
":=",
"creator",
"{",
"store",
":",
"store",
"}",
"\n",
"acts",
":=",
"make",
"(",
"cui",
".",
"Actions",... | // Create displays the password creation wizard | [
"Create",
"displays",
"the",
"password",
"creation",
"wizard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L49-L66 |
29,122 | gopasspw/gopass | pkg/action/create/create.go | extractHostname | func extractHostname(in string) string {
if in == "" {
return ""
}
// help url.Parse by adding a scheme if one is missing. This should still
// allow for any scheme, but by default we assume http (only for parsing)
urlStr := in
if !strings.Contains(urlStr, "://") {
urlStr = "http://" + urlStr
}
u, err := ur... | go | func extractHostname(in string) string {
if in == "" {
return ""
}
// help url.Parse by adding a scheme if one is missing. This should still
// allow for any scheme, but by default we assume http (only for parsing)
urlStr := in
if !strings.Contains(urlStr, "://") {
urlStr = "http://" + urlStr
}
u, err := ur... | [
"func",
"extractHostname",
"(",
"in",
"string",
")",
"string",
"{",
"if",
"in",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"// help url.Parse by adding a scheme if one is missing. This should still",
"// allow for any scheme, but by default we assume http... | // extractHostname tries to extract the hostname from a URL in a filepath-safe
// way for use in the name of a secret | [
"extractHostname",
"tries",
"to",
"extract",
"the",
"hostname",
"from",
"a",
"URL",
"in",
"a",
"filepath",
"-",
"safe",
"way",
"for",
"use",
"in",
"the",
"name",
"of",
"a",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L70-L87 |
29,123 | gopasspw/gopass | pkg/action/create/create.go | createAWS | func (s *creator) createAWS(ctx context.Context, c *cli.Context) error {
var (
account = c.Args().Get(0)
username = c.Args().Get(1)
accesskey = c.Args().Get(2)
secretkey string
region string
store = c.String("store")
err error
)
out.Green(ctx, "=> Creating AWS credentials ...")
account... | go | func (s *creator) createAWS(ctx context.Context, c *cli.Context) error {
var (
account = c.Args().Get(0)
username = c.Args().Get(1)
accesskey = c.Args().Get(2)
secretkey string
region string
store = c.String("store")
err error
)
out.Green(ctx, "=> Creating AWS credentials ...")
account... | [
"func",
"(",
"s",
"*",
"creator",
")",
"createAWS",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"var",
"(",
"account",
"=",
"c",
".",
"Args",
"(",
")",
".",
"Get",
"(",
"0",
")",
"\n",
"userna... | // createAWS will walk through the AWS credential creation wizard | [
"createAWS",
"will",
"walk",
"through",
"the",
"AWS",
"credential",
"creation",
"wizard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L254-L314 |
29,124 | gopasspw/gopass | pkg/action/create/create.go | createGCP | func (s *creator) createGCP(ctx context.Context, c *cli.Context) error {
var (
project string
username string
svcaccfn = c.Args().Get(0)
store = c.String("store")
err error
)
out.Green(ctx, "=> Creating GCP credentials ...")
svcaccfn, err = termio.AskForString(ctx, fmtfn(2, "1", "Service Account ... | go | func (s *creator) createGCP(ctx context.Context, c *cli.Context) error {
var (
project string
username string
svcaccfn = c.Args().Get(0)
store = c.String("store")
err error
)
out.Green(ctx, "=> Creating GCP credentials ...")
svcaccfn, err = termio.AskForString(ctx, fmtfn(2, "1", "Service Account ... | [
"func",
"(",
"s",
"*",
"creator",
")",
"createGCP",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"var",
"(",
"project",
"string",
"\n",
"username",
"string",
"\n",
"svcaccfn",
"=",
"c",
".",
"Args",
... | // createGCP will walk through the GCP credential creation wizard | [
"createGCP",
"will",
"walk",
"through",
"the",
"GCP",
"credential",
"creation",
"wizard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L317-L378 |
29,125 | gopasspw/gopass | pkg/action/create/create.go | extractGCPInfo | func extractGCPInfo(buf []byte) (string, string, error) {
var m map[string]string
if err := json.Unmarshal(buf, &m); err != nil {
return "", "", err
}
p := strings.Split(m["client_email"], "@")
if len(p) < 2 {
return "", "", fmt.Errorf("client_email contains no email")
}
username := p[0]
p = strings.Split(p... | go | func extractGCPInfo(buf []byte) (string, string, error) {
var m map[string]string
if err := json.Unmarshal(buf, &m); err != nil {
return "", "", err
}
p := strings.Split(m["client_email"], "@")
if len(p) < 2 {
return "", "", fmt.Errorf("client_email contains no email")
}
username := p[0]
p = strings.Split(p... | [
"func",
"extractGCPInfo",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"var",
"m",
"map",
"[",
"string",
"]",
"string",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"buf",
",",
"&",
"m",
")",... | // extractGCPInfo will extract the GCP details from the given json blob | [
"extractGCPInfo",
"will",
"extract",
"the",
"GCP",
"details",
"from",
"the",
"given",
"json",
"blob"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L381-L396 |
29,126 | gopasspw/gopass | pkg/action/create/create.go | createGeneric | func (s *creator) createGeneric(ctx context.Context, c *cli.Context) error {
var (
shortname = c.Args().Get(0)
password string
store = c.String("store")
err error
genPw bool
)
out.Green(ctx, "=> Creating generic secret ...")
shortname, err = termio.AskForString(ctx, fmtfn(2, "1", "Name"), s... | go | func (s *creator) createGeneric(ctx context.Context, c *cli.Context) error {
var (
shortname = c.Args().Get(0)
password string
store = c.String("store")
err error
genPw bool
)
out.Green(ctx, "=> Creating generic secret ...")
shortname, err = termio.AskForString(ctx, fmtfn(2, "1", "Name"), s... | [
"func",
"(",
"s",
"*",
"creator",
")",
"createGeneric",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"var",
"(",
"shortname",
"=",
"c",
".",
"Args",
"(",
")",
".",
"Get",
"(",
"0",
")",
"\n",
"... | // createGeneric will walk through the generic secret wizard | [
"createGeneric",
"will",
"walk",
"through",
"the",
"generic",
"secret",
"wizard"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L399-L468 |
29,127 | gopasspw/gopass | pkg/action/create/create.go | createGeneratePassword | func (s *creator) createGeneratePassword(ctx context.Context) (string, error) {
noXkcd, err := termio.AskForBool(ctx, fmtfn(4, "a", "Cryptic Password?"), true)
if err != nil {
return "", err
}
if !noXkcd {
length, err := termio.AskForInt(ctx, fmtfn(4, "b", "How many words?"), 4)
if err != nil {
return "", ... | go | func (s *creator) createGeneratePassword(ctx context.Context) (string, error) {
noXkcd, err := termio.AskForBool(ctx, fmtfn(4, "a", "Cryptic Password?"), true)
if err != nil {
return "", err
}
if !noXkcd {
length, err := termio.AskForInt(ctx, fmtfn(4, "b", "How many words?"), 4)
if err != nil {
return "", ... | [
"func",
"(",
"s",
"*",
"creator",
")",
"createGeneratePassword",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"noXkcd",
",",
"err",
":=",
"termio",
".",
"AskForBool",
"(",
"ctx",
",",
"fmtfn",
"(",
"4",
",",
"\""... | // createGeneratePasssword will walk through the password generation steps | [
"createGeneratePasssword",
"will",
"walk",
"through",
"the",
"password",
"generation",
"steps"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L471-L504 |
29,128 | gopasspw/gopass | pkg/action/create/create.go | createGeneratePIN | func (s *creator) createGeneratePIN(ctx context.Context) (string, error) {
length, err := termio.AskForInt(ctx, fmtfn(4, "a", "How long?"), 4)
if err != nil {
return "", err
}
return pwgen.GeneratePasswordCharset(length, "0123456789"), nil
} | go | func (s *creator) createGeneratePIN(ctx context.Context) (string, error) {
length, err := termio.AskForInt(ctx, fmtfn(4, "a", "How long?"), 4)
if err != nil {
return "", err
}
return pwgen.GeneratePasswordCharset(length, "0123456789"), nil
} | [
"func",
"(",
"s",
"*",
"creator",
")",
"createGeneratePIN",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"length",
",",
"err",
":=",
"termio",
".",
"AskForInt",
"(",
"ctx",
",",
"fmtfn",
"(",
"4",
",",
"\"",
"\... | // createGeneratePIN will walk through the PIN generation steps | [
"createGeneratePIN",
"will",
"walk",
"through",
"the",
"PIN",
"generation",
"steps"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/create/create.go#L507-L513 |
29,129 | gopasspw/gopass | pkg/backend/context.go | WithCryptoBackendString | func WithCryptoBackendString(ctx context.Context, be string) context.Context {
if cb := cryptoBackendFromName(be); cb >= 0 {
ctx = WithCryptoBackend(ctx, cb)
}
return ctx
} | go | func WithCryptoBackendString(ctx context.Context, be string) context.Context {
if cb := cryptoBackendFromName(be); cb >= 0 {
ctx = WithCryptoBackend(ctx, cb)
}
return ctx
} | [
"func",
"WithCryptoBackendString",
"(",
"ctx",
"context",
".",
"Context",
",",
"be",
"string",
")",
"context",
".",
"Context",
"{",
"if",
"cb",
":=",
"cryptoBackendFromName",
"(",
"be",
")",
";",
"cb",
">=",
"0",
"{",
"ctx",
"=",
"WithCryptoBackend",
"(",
... | // WithCryptoBackendString returns a context with the given crypto backend set | [
"WithCryptoBackendString",
"returns",
"a",
"context",
"with",
"the",
"given",
"crypto",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L19-L24 |
29,130 | gopasspw/gopass | pkg/backend/context.go | WithCryptoBackend | func WithCryptoBackend(ctx context.Context, be CryptoBackend) context.Context {
return context.WithValue(ctx, ctxKeyCryptoBackend, be)
} | go | func WithCryptoBackend(ctx context.Context, be CryptoBackend) context.Context {
return context.WithValue(ctx, ctxKeyCryptoBackend, be)
} | [
"func",
"WithCryptoBackend",
"(",
"ctx",
"context",
".",
"Context",
",",
"be",
"CryptoBackend",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyCryptoBackend",
",",
"be",
")",
"\n",
"}"
] | // WithCryptoBackend returns a context with the given crypto backend set | [
"WithCryptoBackend",
"returns",
"a",
"context",
"with",
"the",
"given",
"crypto",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L27-L29 |
29,131 | gopasspw/gopass | pkg/backend/context.go | HasCryptoBackend | func HasCryptoBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyCryptoBackend).(CryptoBackend)
return ok
} | go | func HasCryptoBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyCryptoBackend).(CryptoBackend)
return ok
} | [
"func",
"HasCryptoBackend",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyCryptoBackend",
")",
".",
"(",
"CryptoBackend",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasCryptoBackend returns true if a value for crypto backend has been set in the context | [
"HasCryptoBackend",
"returns",
"true",
"if",
"a",
"value",
"for",
"crypto",
"backend",
"has",
"been",
"set",
"in",
"the",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L32-L35 |
29,132 | gopasspw/gopass | pkg/backend/context.go | WithRCSBackendString | func WithRCSBackendString(ctx context.Context, sb string) context.Context {
if be := rcsBackendFromName(sb); be >= 0 {
return WithRCSBackend(ctx, be)
}
return WithRCSBackend(ctx, Noop)
} | go | func WithRCSBackendString(ctx context.Context, sb string) context.Context {
if be := rcsBackendFromName(sb); be >= 0 {
return WithRCSBackend(ctx, be)
}
return WithRCSBackend(ctx, Noop)
} | [
"func",
"WithRCSBackendString",
"(",
"ctx",
"context",
".",
"Context",
",",
"sb",
"string",
")",
"context",
".",
"Context",
"{",
"if",
"be",
":=",
"rcsBackendFromName",
"(",
"sb",
")",
";",
"be",
">=",
"0",
"{",
"return",
"WithRCSBackend",
"(",
"ctx",
",... | // WithRCSBackendString returns a context with the given sync backend set | [
"WithRCSBackendString",
"returns",
"a",
"context",
"with",
"the",
"given",
"sync",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L52-L57 |
29,133 | gopasspw/gopass | pkg/backend/context.go | WithRCSBackend | func WithRCSBackend(ctx context.Context, sb RCSBackend) context.Context {
return context.WithValue(ctx, ctxKeyRCSBackend, sb)
} | go | func WithRCSBackend(ctx context.Context, sb RCSBackend) context.Context {
return context.WithValue(ctx, ctxKeyRCSBackend, sb)
} | [
"func",
"WithRCSBackend",
"(",
"ctx",
"context",
".",
"Context",
",",
"sb",
"RCSBackend",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyRCSBackend",
",",
"sb",
")",
"\n",
"}"
] | // WithRCSBackend returns a context with the given sync backend set | [
"WithRCSBackend",
"returns",
"a",
"context",
"with",
"the",
"given",
"sync",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L60-L62 |
29,134 | gopasspw/gopass | pkg/backend/context.go | HasRCSBackend | func HasRCSBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyRCSBackend).(RCSBackend)
return ok
} | go | func HasRCSBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyRCSBackend).(RCSBackend)
return ok
} | [
"func",
"HasRCSBackend",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyRCSBackend",
")",
".",
"(",
"RCSBackend",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasRCSBackend returns true if a value for sync backend has been set in the context | [
"HasRCSBackend",
"returns",
"true",
"if",
"a",
"value",
"for",
"sync",
"backend",
"has",
"been",
"set",
"in",
"the",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L65-L68 |
29,135 | gopasspw/gopass | pkg/backend/context.go | WithStorageBackendString | func WithStorageBackendString(ctx context.Context, sb string) context.Context {
return WithStorageBackend(ctx, storageBackendFromName(sb))
} | go | func WithStorageBackendString(ctx context.Context, sb string) context.Context {
return WithStorageBackend(ctx, storageBackendFromName(sb))
} | [
"func",
"WithStorageBackendString",
"(",
"ctx",
"context",
".",
"Context",
",",
"sb",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"WithStorageBackend",
"(",
"ctx",
",",
"storageBackendFromName",
"(",
"sb",
")",
")",
"\n",
"}"
] | // WithStorageBackendString returns a context with the given store backend set | [
"WithStorageBackendString",
"returns",
"a",
"context",
"with",
"the",
"given",
"store",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L80-L82 |
29,136 | gopasspw/gopass | pkg/backend/context.go | WithStorageBackend | func WithStorageBackend(ctx context.Context, sb StorageBackend) context.Context {
return context.WithValue(ctx, ctxKeyStorageBackend, sb)
} | go | func WithStorageBackend(ctx context.Context, sb StorageBackend) context.Context {
return context.WithValue(ctx, ctxKeyStorageBackend, sb)
} | [
"func",
"WithStorageBackend",
"(",
"ctx",
"context",
".",
"Context",
",",
"sb",
"StorageBackend",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyStorageBackend",
",",
"sb",
")",
"\n",
"}"
] | // WithStorageBackend returns a context with the given store backend set | [
"WithStorageBackend",
"returns",
"a",
"context",
"with",
"the",
"given",
"store",
"backend",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L85-L87 |
29,137 | gopasspw/gopass | pkg/backend/context.go | HasStorageBackend | func HasStorageBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyStorageBackend).(StorageBackend)
return ok
} | go | func HasStorageBackend(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyStorageBackend).(StorageBackend)
return ok
} | [
"func",
"HasStorageBackend",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyStorageBackend",
")",
".",
"(",
"StorageBackend",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasStorageBackend returns true if a value for store backend was set | [
"HasStorageBackend",
"returns",
"true",
"if",
"a",
"value",
"for",
"store",
"backend",
"was",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/context.go#L99-L102 |
29,138 | gopasspw/gopass | pkg/config/config.go | New | func New() *Config {
return &Config{
Path: configLocation(),
Root: &StoreConfig{
AskForMore: false,
AutoClip: true,
AutoImport: true,
AutoSync: true,
ClipTimeout: 45,
Concurrency: 1,
NoColor: false,
NoConfirm: false,
NoPager: false,
SafeContent: f... | go | func New() *Config {
return &Config{
Path: configLocation(),
Root: &StoreConfig{
AskForMore: false,
AutoClip: true,
AutoImport: true,
AutoSync: true,
ClipTimeout: 45,
Concurrency: 1,
NoColor: false,
NoConfirm: false,
NoPager: false,
SafeContent: f... | [
"func",
"New",
"(",
")",
"*",
"Config",
"{",
"return",
"&",
"Config",
"{",
"Path",
":",
"configLocation",
"(",
")",
",",
"Root",
":",
"&",
"StoreConfig",
"{",
"AskForMore",
":",
"false",
",",
"AutoClip",
":",
"true",
",",
"AutoImport",
":",
"true",
"... | // New creates a new config with sane default values | [
"New",
"creates",
"a",
"new",
"config",
"with",
"sane",
"default",
"values"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/config.go#L37-L56 |
29,139 | gopasspw/gopass | pkg/config/config.go | GetRecipientHash | func (c *Config) GetRecipientHash(alias, name string) string {
if alias == "" {
return c.Root.RecipientHash[name]
}
if sc, found := c.Mounts[alias]; found && sc != nil {
return sc.RecipientHash[name]
}
return ""
} | go | func (c *Config) GetRecipientHash(alias, name string) string {
if alias == "" {
return c.Root.RecipientHash[name]
}
if sc, found := c.Mounts[alias]; found && sc != nil {
return sc.RecipientHash[name]
}
return ""
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"GetRecipientHash",
"(",
"alias",
",",
"name",
"string",
")",
"string",
"{",
"if",
"alias",
"==",
"\"",
"\"",
"{",
"return",
"c",
".",
"Root",
".",
"RecipientHash",
"[",
"name",
"]",
"\n",
"}",
"\n",
"if",
"sc"... | // GetRecipientHash returns the recipients hash for the given store and file | [
"GetRecipientHash",
"returns",
"the",
"recipients",
"hash",
"for",
"the",
"given",
"store",
"and",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/config.go#L125-L133 |
29,140 | gopasspw/gopass | pkg/config/config.go | SetRecipientHash | func (c *Config) SetRecipientHash(alias, name, value string) error {
if alias == "" {
c.Root.setRecipientHash(name, value)
} else {
if sc, found := c.Mounts[alias]; found && sc != nil {
sc.setRecipientHash(name, value)
}
}
return c.Save()
} | go | func (c *Config) SetRecipientHash(alias, name, value string) error {
if alias == "" {
c.Root.setRecipientHash(name, value)
} else {
if sc, found := c.Mounts[alias]; found && sc != nil {
sc.setRecipientHash(name, value)
}
}
return c.Save()
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"SetRecipientHash",
"(",
"alias",
",",
"name",
",",
"value",
"string",
")",
"error",
"{",
"if",
"alias",
"==",
"\"",
"\"",
"{",
"c",
".",
"Root",
".",
"setRecipientHash",
"(",
"name",
",",
"value",
")",
"\n",
"... | // SetRecipientHash will set and save the recipient hash for the given store
// and file | [
"SetRecipientHash",
"will",
"set",
"and",
"save",
"the",
"recipient",
"hash",
"for",
"the",
"given",
"store",
"and",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/config.go#L137-L147 |
29,141 | gopasspw/gopass | pkg/store/sub/list.go | List | func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
if s.storage == nil || s.crypto == nil {
return nil, nil
}
lst, err := s.storage.List(ctx, prefix)
if err != nil {
return nil, err
}
out.Debug(ctx, "sub.List(%s): %+v\n", prefix, lst)
out := make([]string, 0, len(lst))
cExt := "."... | go | func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
if s.storage == nil || s.crypto == nil {
return nil, nil
}
lst, err := s.storage.List(ctx, prefix)
if err != nil {
return nil, err
}
out.Debug(ctx, "sub.List(%s): %+v\n", prefix, lst)
out := make([]string, 0, len(lst))
cExt := "."... | [
"func",
"(",
"s",
"*",
"Store",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"s",
".",
"storage",
"==",
"nil",
"||",
"s",
".",
"crypto",
"==",
"nil",
"{... | // List will list all entries in this store | [
"List",
"will",
"list",
"all",
"entries",
"in",
"this",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/list.go#L16-L39 |
29,142 | gopasspw/gopass | pkg/action/init.go | Initialized | func (s *Action) Initialized(ctx context.Context, c *cli.Context) error {
inited, err := s.Store.Initialized(ctx)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to initialize store: %s", err)
}
if inited {
out.Debug(ctx, "Store is already initialized")
return nil
}
out.Debug(ctx, "Store ne... | go | func (s *Action) Initialized(ctx context.Context, c *cli.Context) error {
inited, err := s.Store.Initialized(ctx)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to initialize store: %s", err)
}
if inited {
out.Debug(ctx, "Store is already initialized")
return nil
}
out.Debug(ctx, "Store ne... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Initialized",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"inited",
",",
"err",
":=",
"s",
".",
"Store",
".",
"Initialized",
"(",
"ctx",
")",
"\n",
"if",
"... | // Initialized returns an error if the store is not properly
// prepared. | [
"Initialized",
"returns",
"an",
"error",
"if",
"the",
"store",
"is",
"not",
"properly",
"prepared",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/init.go#L25-L46 |
29,143 | gopasspw/gopass | pkg/action/init.go | Init | func (s *Action) Init(ctx context.Context, c *cli.Context) error {
path := c.String("path")
alias := c.String("store")
ctx = initParseContext(ctx, c)
inited, err := s.Store.Initialized(ctx)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to initialized store: %s", err)
}
if inited {
out.Erro... | go | func (s *Action) Init(ctx context.Context, c *cli.Context) error {
path := c.String("path")
alias := c.String("store")
ctx = initParseContext(ctx, c)
inited, err := s.Store.Initialized(ctx)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to initialized store: %s", err)
}
if inited {
out.Erro... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Init",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"path",
":=",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"alias",
":=",
"c",
".",
"String",
"(",
... | // Init a new password store with a first gpg id | [
"Init",
"a",
"new",
"password",
"store",
"with",
"a",
"first",
"gpg",
"id"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/init.go#L49-L66 |
29,144 | gopasspw/gopass | pkg/action/init.go | initLocal | func (s *Action) initLocal(ctx context.Context, c *cli.Context) error {
ctx = out.AddPrefix(ctx, "[local] ")
path := ""
if s.Store != nil {
path = s.Store.URL()
}
out.Print(ctx, "Initializing your local store ...")
if err := s.init(out.WithHidden(ctx, true), "", path); err != nil {
return errors.Wrapf(err, ... | go | func (s *Action) initLocal(ctx context.Context, c *cli.Context) error {
ctx = out.AddPrefix(ctx, "[local] ")
path := ""
if s.Store != nil {
path = s.Store.URL()
}
out.Print(ctx, "Initializing your local store ...")
if err := s.init(out.WithHidden(ctx, true), "", path); err != nil {
return errors.Wrapf(err, ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"initLocal",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"ctx",
"=",
"out",
".",
"AddPrefix",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n\n",
"path",
":=",
"\"",
... | // initLocal will initialize a local store, useful for local-only setups or as
// part of team setups to create the root store | [
"initLocal",
"will",
"initialize",
"a",
"local",
"store",
"useful",
"for",
"local",
"-",
"only",
"setups",
"or",
"as",
"part",
"of",
"team",
"setups",
"to",
"create",
"the",
"root",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/init.go#L323-L364 |
29,145 | gopasspw/gopass | pkg/action/init.go | initCreateTeam | func (s *Action) initCreateTeam(ctx context.Context, c *cli.Context, team, remote string) error {
var err error
out.Print(ctx, "Creating a new team ...")
if err := s.initLocal(ctx, c); err != nil {
return errors.Wrapf(err, "failed to create local store")
}
// name of the new team
team, err = termio.AskForStri... | go | func (s *Action) initCreateTeam(ctx context.Context, c *cli.Context, team, remote string) error {
var err error
out.Print(ctx, "Creating a new team ...")
if err := s.initLocal(ctx, c); err != nil {
return errors.Wrapf(err, "failed to create local store")
}
// name of the new team
team, err = termio.AskForStri... | [
"func",
"(",
"s",
"*",
"Action",
")",
"initCreateTeam",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"team",
",",
"remote",
"string",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"out",
".",
"Print",
"(",
"... | // initCreateTeam will create a local root store and a shared team store | [
"initCreateTeam",
"will",
"create",
"a",
"local",
"root",
"store",
"and",
"a",
"shared",
"team",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/init.go#L367-L395 |
29,146 | gopasspw/gopass | pkg/notify/notify_dbus.go | Notify | func Notify(ctx context.Context, subj, msg string) error {
if os.Getenv("GOPASS_NO_NOTIFY") != "" || !ctxutil.IsNotifications(ctx) {
return nil
}
conn, err := dbus.SessionBus()
if err != nil {
return err
}
obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
call := obj.Call... | go | func Notify(ctx context.Context, subj, msg string) error {
if os.Getenv("GOPASS_NO_NOTIFY") != "" || !ctxutil.IsNotifications(ctx) {
return nil
}
conn, err := dbus.SessionBus()
if err != nil {
return err
}
obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
call := obj.Call... | [
"func",
"Notify",
"(",
"ctx",
"context",
".",
"Context",
",",
"subj",
",",
"msg",
"string",
")",
"error",
"{",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"!=",
"\"",
"\"",
"||",
"!",
"ctxutil",
".",
"IsNotifications",
"(",
"ctx",
")",
"{",
... | // Notify displays a desktop notification with dbus | [
"Notify",
"displays",
"a",
"desktop",
"notification",
"with",
"dbus"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/notify/notify_dbus.go#L15-L31 |
29,147 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/public_key.go | Fingerprint | func (p PublicKey) Fingerprint() string {
h := make([]byte, 20)
d := sha3.NewShake256()
_, _ = d.Write([]byte{0x42})
_ = binary.Write(d, binary.LittleEndian, p.PubKeyAlgo)
_, _ = d.Write(p.PublicKey[:])
_, _ = d.Read(h)
return fmt.Sprintf("%x", h)
} | go | func (p PublicKey) Fingerprint() string {
h := make([]byte, 20)
d := sha3.NewShake256()
_, _ = d.Write([]byte{0x42})
_ = binary.Write(d, binary.LittleEndian, p.PubKeyAlgo)
_, _ = d.Write(p.PublicKey[:])
_, _ = d.Read(h)
return fmt.Sprintf("%x", h)
} | [
"func",
"(",
"p",
"PublicKey",
")",
"Fingerprint",
"(",
")",
"string",
"{",
"h",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"20",
")",
"\n",
"d",
":=",
"sha3",
".",
"NewShake256",
"(",
")",
"\n",
"_",
",",
"_",
"=",
"d",
".",
"Write",
"(",
"["... | // Fingerprint calculates the unique ID of a public key | [
"Fingerprint",
"calculates",
"the",
"unique",
"ID",
"of",
"a",
"public",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/public_key.go#L30-L38 |
29,148 | gopasspw/gopass | pkg/action/completion.go | bashEscape | func bashEscape(s string) string {
return escapeRegExp.ReplaceAllStringFunc(s, func(c string) string {
if c == `\` {
return `\\\\`
}
return `\\` + c
})
} | go | func bashEscape(s string) string {
return escapeRegExp.ReplaceAllStringFunc(s, func(c string) string {
if c == `\` {
return `\\\\`
}
return `\\` + c
})
} | [
"func",
"bashEscape",
"(",
"s",
"string",
")",
"string",
"{",
"return",
"escapeRegExp",
".",
"ReplaceAllStringFunc",
"(",
"s",
",",
"func",
"(",
"c",
"string",
")",
"string",
"{",
"if",
"c",
"==",
"`\\`",
"{",
"return",
"`\\\\\\\\`",
"\n",
"}",
"\n",
"... | // bashEscape Escape special characters with `\` | [
"bashEscape",
"Escape",
"special",
"characters",
"with",
"\\"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L20-L27 |
29,149 | gopasspw/gopass | pkg/action/completion.go | Complete | func (s *Action) Complete(ctx context.Context, c *cli.Context) {
_, err := s.Store.Initialized(ctx) // important to make sure the structs are not nil
if err != nil {
out.Error(ctx, "Store not initialized: %s", err)
return
}
list, err := s.Store.List(ctx, 0)
if err != nil {
return
}
for _, v := range list ... | go | func (s *Action) Complete(ctx context.Context, c *cli.Context) {
_, err := s.Store.Initialized(ctx) // important to make sure the structs are not nil
if err != nil {
out.Error(ctx, "Store not initialized: %s", err)
return
}
list, err := s.Store.List(ctx, 0)
if err != nil {
return
}
for _, v := range list ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Complete",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"_",
",",
"err",
":=",
"s",
".",
"Store",
".",
"Initialized",
"(",
"ctx",
")",
"// important to make sure the struc... | // Complete prints a list of all password names to os.Stdout | [
"Complete",
"prints",
"a",
"list",
"of",
"all",
"password",
"names",
"to",
"os",
".",
"Stdout"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L30-L44 |
29,150 | gopasspw/gopass | pkg/action/completion.go | CompletionOpenBSDKsh | func (s *Action) CompletionOpenBSDKsh(c *cli.Context, a *cli.App) error {
out := `
PASS_LIST=$(gopass ls -f)
set -A complete_gopass -- $PASS_LIST %s
`
if a == nil {
return fmt.Errorf("can not parse command options")
}
var opts []string
for _, opt := range a.Commands {
opts = append(opts, opt.Name)
if len(o... | go | func (s *Action) CompletionOpenBSDKsh(c *cli.Context, a *cli.App) error {
out := `
PASS_LIST=$(gopass ls -f)
set -A complete_gopass -- $PASS_LIST %s
`
if a == nil {
return fmt.Errorf("can not parse command options")
}
var opts []string
for _, opt := range a.Commands {
opts = append(opts, opt.Name)
if len(o... | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompletionOpenBSDKsh",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"a",
"*",
"cli",
".",
"App",
")",
"error",
"{",
"out",
":=",
"`\nPASS_LIST=$(gopass ls -f)\nset -A complete_gopass -- $PASS_LIST %s\n`",
"\n\n",
"if",
"a",
... | // CompletionOpenBSDKsh returns an OpenBSD ksh script used for auto completion | [
"CompletionOpenBSDKsh",
"returns",
"an",
"OpenBSD",
"ksh",
"script",
"used",
"for",
"auto",
"completion"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L47-L67 |
29,151 | gopasspw/gopass | pkg/action/completion.go | CompletionBash | func (s *Action) CompletionBash(c *cli.Context) error {
out := `_gopass_bash_autocomplete() {
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
local IFS=$'\n'
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ... | go | func (s *Action) CompletionBash(c *cli.Context) error {
out := `_gopass_bash_autocomplete() {
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
local IFS=$'\n'
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompletionBash",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"out",
":=",
"`_gopass_bash_autocomplete() {\n local cur opts base\n COMPREPLY=()\n cur=\"${COMP_WORDS[COMP_CWORD]}\"\n opts=$( ${COMP_WORDS[@]:0:$COMP... | // CompletionBash returns a bash script used for auto completion | [
"CompletionBash",
"returns",
"a",
"bash",
"script",
"used",
"for",
"auto",
"completion"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L70-L89 |
29,152 | gopasspw/gopass | pkg/action/completion.go | CompletionFish | func (s *Action) CompletionFish(c *cli.Context, a *cli.App) error {
comp, err := fishcomp.GetCompletion(a)
if err != nil {
return err
}
fmt.Fprintln(stdout, comp)
return nil
} | go | func (s *Action) CompletionFish(c *cli.Context, a *cli.App) error {
comp, err := fishcomp.GetCompletion(a)
if err != nil {
return err
}
fmt.Fprintln(stdout, comp)
return nil
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompletionFish",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"a",
"*",
"cli",
".",
"App",
")",
"error",
"{",
"comp",
",",
"err",
":=",
"fishcomp",
".",
"GetCompletion",
"(",
"a",
")",
"\n",
"if",
"err",
"!=",... | // CompletionFish returns an autocompletion script for fish | [
"CompletionFish",
"returns",
"an",
"autocompletion",
"script",
"for",
"fish"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L92-L100 |
29,153 | gopasspw/gopass | pkg/action/completion.go | CompletionZSH | func (s *Action) CompletionZSH(c *cli.Context, a *cli.App) error {
comp, err := zshcomp.GetCompletion(a)
if err != nil {
return err
}
fmt.Fprintln(stdout, comp)
return nil
} | go | func (s *Action) CompletionZSH(c *cli.Context, a *cli.App) error {
comp, err := zshcomp.GetCompletion(a)
if err != nil {
return err
}
fmt.Fprintln(stdout, comp)
return nil
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompletionZSH",
"(",
"c",
"*",
"cli",
".",
"Context",
",",
"a",
"*",
"cli",
".",
"App",
")",
"error",
"{",
"comp",
",",
"err",
":=",
"zshcomp",
".",
"GetCompletion",
"(",
"a",
")",
"\n",
"if",
"err",
"!=",
... | // CompletionZSH returns a zsh completion script | [
"CompletionZSH",
"returns",
"a",
"zsh",
"completion",
"script"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/completion.go#L103-L111 |
29,154 | gopasspw/gopass | pkg/agent/client/client.go | New | func New(dir string) *Client {
socket := filepath.Join(dir, ".gopass-agent.sock")
return &Client{
http: &http.Client{
Transport: &http.Transport{
DialContext: func(context.Context, string, string) (net.Conn, error) {
return net.Dial("unix", socket)
},
},
Timeout: 10 * time.Minute,
},
}
} | go | func New(dir string) *Client {
socket := filepath.Join(dir, ".gopass-agent.sock")
return &Client{
http: &http.Client{
Transport: &http.Transport{
DialContext: func(context.Context, string, string) (net.Conn, error) {
return net.Dial("unix", socket)
},
},
Timeout: 10 * time.Minute,
},
}
} | [
"func",
"New",
"(",
"dir",
"string",
")",
"*",
"Client",
"{",
"socket",
":=",
"filepath",
".",
"Join",
"(",
"dir",
",",
"\"",
"\"",
")",
"\n",
"return",
"&",
"Client",
"{",
"http",
":",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"&",
"htt... | // New creates a new client | [
"New",
"creates",
"a",
"new",
"client"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/client/client.go#L24-L36 |
29,155 | gopasspw/gopass | pkg/agent/client/client.go | Ping | func (c *Client) Ping(ctx context.Context) error {
pc := &http.Client{
Transport: c.http.Transport,
Timeout: 5 * time.Second,
}
resp, err := pc.Get("http://unix/ping")
if err != nil {
return err
}
_ = resp.Body.Close()
return nil
} | go | func (c *Client) Ping(ctx context.Context) error {
pc := &http.Client{
Transport: c.http.Transport,
Timeout: 5 * time.Second,
}
resp, err := pc.Get("http://unix/ping")
if err != nil {
return err
}
_ = resp.Body.Close()
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Ping",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"pc",
":=",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"c",
".",
"http",
".",
"Transport",
",",
"Timeout",
":",
"5",
"*",
"time",
".",... | // Ping checks connectivity to the agent | [
"Ping",
"checks",
"connectivity",
"to",
"the",
"agent"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/client/client.go#L39-L50 |
29,156 | gopasspw/gopass | pkg/agent/client/client.go | Remove | func (c *Client) Remove(ctx context.Context, key string) error {
if err := c.checkAgent(ctx); err != nil {
return errors.Wrapf(err, "agent not available: %s", err)
}
u, err := url.Parse("http://unix/cache/remove")
if err != nil {
return errors.Wrapf(err, "failed to build request url")
}
values := u.Query()
... | go | func (c *Client) Remove(ctx context.Context, key string) error {
if err := c.checkAgent(ctx); err != nil {
return errors.Wrapf(err, "agent not available: %s", err)
}
u, err := url.Parse("http://unix/cache/remove")
if err != nil {
return errors.Wrapf(err, "failed to build request url")
}
values := u.Query()
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Remove",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"checkAgent",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wr... | // Remove un-caches a single key | [
"Remove",
"un",
"-",
"caches",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/client/client.go#L72-L97 |
29,157 | gopasspw/gopass | pkg/backend/crypto/xc/import.go | ImportPublicKey | func (x *XC) ImportPublicKey(ctx context.Context, buf []byte) error {
if err := x.pubring.Import(buf); err != nil {
return err
}
return x.pubring.Save()
} | go | func (x *XC) ImportPublicKey(ctx context.Context, buf []byte) error {
if err := x.pubring.Import(buf); err != nil {
return err
}
return x.pubring.Save()
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ImportPublicKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"err",
":=",
"x",
".",
"pubring",
".",
"Import",
"(",
"buf",
")",
";",
"err",
"!=",
"nil",
"{",
"... | // ImportPublicKey imports a given public key into the keyring | [
"ImportPublicKey",
"imports",
"a",
"given",
"public",
"key",
"into",
"the",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/import.go#L6-L11 |
29,158 | gopasspw/gopass | pkg/backend/crypto/xc/import.go | ImportPrivateKey | func (x *XC) ImportPrivateKey(ctx context.Context, buf []byte) error {
if err := x.secring.Import(buf); err != nil {
return err
}
return x.secring.Save()
} | go | func (x *XC) ImportPrivateKey(ctx context.Context, buf []byte) error {
if err := x.secring.Import(buf); err != nil {
return err
}
return x.secring.Save()
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ImportPrivateKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"err",
":=",
"x",
".",
"secring",
".",
"Import",
"(",
"buf",
")",
";",
"err",
"!=",
"nil",
"{",
... | // ImportPrivateKey imports a given private key into the keyring | [
"ImportPrivateKey",
"imports",
"a",
"given",
"private",
"key",
"into",
"the",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/import.go#L14-L19 |
29,159 | gopasspw/gopass | pkg/backend/crypto/xc/xc.go | New | func New(dir string, client agentClient) (*XC, error) {
skr, _ := keyring.LoadSecring(filepath.Join(dir, secringFilename))
pkr, _ := keyring.LoadPubring(filepath.Join(dir, pubringFilename), skr)
return &XC{
dir: dir,
pubring: pkr,
secring: skr,
client: client,
}, nil
} | go | func New(dir string, client agentClient) (*XC, error) {
skr, _ := keyring.LoadSecring(filepath.Join(dir, secringFilename))
pkr, _ := keyring.LoadPubring(filepath.Join(dir, pubringFilename), skr)
return &XC{
dir: dir,
pubring: pkr,
secring: skr,
client: client,
}, nil
} | [
"func",
"New",
"(",
"dir",
"string",
",",
"client",
"agentClient",
")",
"(",
"*",
"XC",
",",
"error",
")",
"{",
"skr",
",",
"_",
":=",
"keyring",
".",
"LoadSecring",
"(",
"filepath",
".",
"Join",
"(",
"dir",
",",
"secringFilename",
")",
")",
"\n",
... | // New creates a new XC backend | [
"New",
"creates",
"a",
"new",
"XC",
"backend"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/xc.go#L37-L46 |
29,160 | gopasspw/gopass | pkg/backend/crypto/xc/xc.go | RemoveKey | func (x *XC) RemoveKey(id string) error {
if x.secring.Contains(id) {
if err := x.secring.Remove(id); err != nil {
return err
}
return x.secring.Save()
}
if x.pubring.Contains(id) {
if err := x.pubring.Remove(id); err != nil {
return err
}
return x.pubring.Save()
}
return fmt.Errorf("not found")
... | go | func (x *XC) RemoveKey(id string) error {
if x.secring.Contains(id) {
if err := x.secring.Remove(id); err != nil {
return err
}
return x.secring.Save()
}
if x.pubring.Contains(id) {
if err := x.pubring.Remove(id); err != nil {
return err
}
return x.pubring.Save()
}
return fmt.Errorf("not found")
... | [
"func",
"(",
"x",
"*",
"XC",
")",
"RemoveKey",
"(",
"id",
"string",
")",
"error",
"{",
"if",
"x",
".",
"secring",
".",
"Contains",
"(",
"id",
")",
"{",
"if",
"err",
":=",
"x",
".",
"secring",
".",
"Remove",
"(",
"id",
")",
";",
"err",
"!=",
"... | // RemoveKey removes a single key from the keyring | [
"RemoveKey",
"removes",
"a",
"single",
"key",
"from",
"the",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/xc.go#L49-L63 |
29,161 | gopasspw/gopass | pkg/backend/crypto/xc/xc.go | Initialized | func (x *XC) Initialized(ctx context.Context) error {
if x == nil {
return fmt.Errorf("XC not initialized")
}
if x.pubring == nil {
return fmt.Errorf("pubring not initialized")
}
if x.secring == nil {
return fmt.Errorf("secring not initialized")
}
if x.client == nil {
return fmt.Errorf("client not initia... | go | func (x *XC) Initialized(ctx context.Context) error {
if x == nil {
return fmt.Errorf("XC not initialized")
}
if x.pubring == nil {
return fmt.Errorf("pubring not initialized")
}
if x.secring == nil {
return fmt.Errorf("secring not initialized")
}
if x.client == nil {
return fmt.Errorf("client not initia... | [
"func",
"(",
"x",
"*",
"XC",
")",
"Initialized",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"x",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"x",
".",
"pubring",
"==",
"nil... | // Initialized returns an error if this backend is not properly initialized | [
"Initialized",
"returns",
"an",
"error",
"if",
"this",
"backend",
"is",
"not",
"properly",
"initialized"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/xc.go#L66-L83 |
29,162 | gopasspw/gopass | pkg/backend/crypto/xc/xc.go | Version | func (x *XC) Version(ctx context.Context) semver.Version {
return semver.Version{
Patch: 1,
}
} | go | func (x *XC) Version(ctx context.Context) semver.Version {
return semver.Version{
Patch: 1,
}
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"Version",
"(",
"ctx",
"context",
".",
"Context",
")",
"semver",
".",
"Version",
"{",
"return",
"semver",
".",
"Version",
"{",
"Patch",
":",
"1",
",",
"}",
"\n",
"}"
] | // Version returns 0.0.1 | [
"Version",
"returns",
"0",
".",
"0",
".",
"1"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/xc.go#L91-L95 |
29,163 | gopasspw/gopass | pkg/backend/crypto/gpg/cli/binary.go | Binary | func Binary(ctx context.Context, bin string) (string, error) {
bins, err := detectBinaryCandidates(bin)
if err != nil {
return "", err
}
bv := make(byVersion, 0, len(bins))
for _, b := range bins {
//out.Debug(ctx, "gpg.detectBinary - Looking for '%s' ...", b)
if p, err := exec.LookPath(b); err == nil {
g... | go | func Binary(ctx context.Context, bin string) (string, error) {
bins, err := detectBinaryCandidates(bin)
if err != nil {
return "", err
}
bv := make(byVersion, 0, len(bins))
for _, b := range bins {
//out.Debug(ctx, "gpg.detectBinary - Looking for '%s' ...", b)
if p, err := exec.LookPath(b); err == nil {
g... | [
"func",
"Binary",
"(",
"ctx",
"context",
".",
"Context",
",",
"bin",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"bins",
",",
"err",
":=",
"detectBinaryCandidates",
"(",
"bin",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",... | // Binary reutrns the GGP binary location | [
"Binary",
"reutrns",
"the",
"GGP",
"binary",
"location"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/binary.go#L19-L43 |
29,164 | gopasspw/gopass | pkg/out/context.go | WithPrefix | func WithPrefix(ctx context.Context, prefix string) context.Context {
return context.WithValue(ctx, ctxKeyPrefix, prefix)
} | go | func WithPrefix(ctx context.Context, prefix string) context.Context {
return context.WithValue(ctx, ctxKeyPrefix, prefix)
} | [
"func",
"WithPrefix",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyPrefix",
",",
"prefix",
")",
"\n",
"}"
] | // WithPrefix returns a context with the given prefix set | [
"WithPrefix",
"returns",
"a",
"context",
"with",
"the",
"given",
"prefix",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L14-L16 |
29,165 | gopasspw/gopass | pkg/out/context.go | AddPrefix | func AddPrefix(ctx context.Context, prefix string) context.Context {
if prefix == "" {
return ctx
}
pfx := Prefix(ctx)
if pfx == "" {
return WithPrefix(ctx, prefix)
}
return WithPrefix(ctx, pfx+prefix)
} | go | func AddPrefix(ctx context.Context, prefix string) context.Context {
if prefix == "" {
return ctx
}
pfx := Prefix(ctx)
if pfx == "" {
return WithPrefix(ctx, prefix)
}
return WithPrefix(ctx, pfx+prefix)
} | [
"func",
"AddPrefix",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"context",
".",
"Context",
"{",
"if",
"prefix",
"==",
"\"",
"\"",
"{",
"return",
"ctx",
"\n",
"}",
"\n",
"pfx",
":=",
"Prefix",
"(",
"ctx",
")",
"\n",
"if",
"... | // AddPrefix returns a context with the given prefix added to end of the
// existing prefix | [
"AddPrefix",
"returns",
"a",
"context",
"with",
"the",
"given",
"prefix",
"added",
"to",
"end",
"of",
"the",
"existing",
"prefix"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L20-L29 |
29,166 | gopasspw/gopass | pkg/out/context.go | Prefix | func Prefix(ctx context.Context) string {
sv, ok := ctx.Value(ctxKeyPrefix).(string)
if !ok {
return ""
}
return sv
} | go | func Prefix(ctx context.Context) string {
sv, ok := ctx.Value(ctxKeyPrefix).(string)
if !ok {
return ""
}
return sv
} | [
"func",
"Prefix",
"(",
"ctx",
"context",
".",
"Context",
")",
"string",
"{",
"sv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyPrefix",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return... | // Prefix returns the prefix or an empty string | [
"Prefix",
"returns",
"the",
"prefix",
"or",
"an",
"empty",
"string"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L32-L38 |
29,167 | gopasspw/gopass | pkg/out/context.go | WithHidden | func WithHidden(ctx context.Context, hidden bool) context.Context {
return context.WithValue(ctx, ctxKeyHidden, hidden)
} | go | func WithHidden(ctx context.Context, hidden bool) context.Context {
return context.WithValue(ctx, ctxKeyHidden, hidden)
} | [
"func",
"WithHidden",
"(",
"ctx",
"context",
".",
"Context",
",",
"hidden",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyHidden",
",",
"hidden",
")",
"\n",
"}"
] | // WithHidden returns a context with the flag value for hidden set | [
"WithHidden",
"returns",
"a",
"context",
"with",
"the",
"flag",
"value",
"for",
"hidden",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L41-L43 |
29,168 | gopasspw/gopass | pkg/out/context.go | IsHidden | func IsHidden(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyHidden).(bool)
if !ok {
return false
}
return bv
} | go | func IsHidden(ctx context.Context) bool {
bv, ok := ctx.Value(ctxKeyHidden).(bool)
if !ok {
return false
}
return bv
} | [
"func",
"IsHidden",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"bv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyHidden",
")",
".",
"(",
"bool",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"b... | // IsHidden returns true if any output should be hidden in this context | [
"IsHidden",
"returns",
"true",
"if",
"any",
"output",
"should",
"be",
"hidden",
"in",
"this",
"context"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L46-L52 |
29,169 | gopasspw/gopass | pkg/out/context.go | WithNewline | func WithNewline(ctx context.Context, nl bool) context.Context {
return context.WithValue(ctx, ctxKeyNewline, nl)
} | go | func WithNewline(ctx context.Context, nl bool) context.Context {
return context.WithValue(ctx, ctxKeyNewline, nl)
} | [
"func",
"WithNewline",
"(",
"ctx",
"context",
".",
"Context",
",",
"nl",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyNewline",
",",
"nl",
")",
"\n",
"}"
] | // WithNewline returns a context with the flag value for newline set | [
"WithNewline",
"returns",
"a",
"context",
"with",
"the",
"flag",
"value",
"for",
"newline",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/context.go#L55-L57 |
29,170 | gopasspw/gopass | pkg/action/move.go | Move | func (s *Action) Move(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
if len(c.Args()) != 2 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s mv old-path new-path", s.Name)
}
from := c.Args()[0]
to := c.Args()[1]
if !force {
if s.Store.Exists(ctx, to) && !termio.AskForConfirmation(ct... | go | func (s *Action) Move(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
if len(c.Args()) != 2 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s mv old-path new-path", s.Name)
}
from := c.Args()[0]
to := c.Args()[1]
if !force {
if s.Store.Exists(ctx, to) && !termio.AskForConfirmation(ct... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Move",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"force",
":=",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"len",
"(",
"c",
".",
"Args",
"... | // Move the content from one secret to another | [
"Move",
"the",
"content",
"from",
"one",
"secret",
"to",
"another"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/move.go#L13-L34 |
29,171 | gopasspw/gopass | pkg/config/secrets/config.go | New | func New(dir, passphrase string) (*Config, error) {
if dir == "" || dir == "." {
return nil, fmt.Errorf("dir must not be empty")
}
fn := filepath.Join(dir, filename)
c := &Config{
filename: fn,
passphrase: passphrase,
}
if !fsutil.IsFile(fn) {
err := save(c.filename, c.passphrase, map[string]string{})... | go | func New(dir, passphrase string) (*Config, error) {
if dir == "" || dir == "." {
return nil, fmt.Errorf("dir must not be empty")
}
fn := filepath.Join(dir, filename)
c := &Config{
filename: fn,
passphrase: passphrase,
}
if !fsutil.IsFile(fn) {
err := save(c.filename, c.passphrase, map[string]string{})... | [
"func",
"New",
"(",
"dir",
",",
"passphrase",
"string",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"if",
"dir",
"==",
"\"",
"\"",
"||",
"dir",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
... | // New will load the given file from disk and try to unseal it | [
"New",
"will",
"load",
"the",
"given",
"file",
"from",
"disk",
"and",
"try",
"to",
"unseal",
"it"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L33-L54 |
29,172 | gopasspw/gopass | pkg/config/secrets/config.go | Get | func (c *Config) Get(key string) (string, error) {
data, err := load(c.filename, c.passphrase)
return data[key], err
} | go | func (c *Config) Get(key string) (string, error) {
data, err := load(c.filename, c.passphrase)
return data[key], err
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"load",
"(",
"c",
".",
"filename",
",",
"c",
".",
"passphrase",
")",
"\n",
"return",
"data",
"[",
"key",
"]... | // Get loads the requested key from disk | [
"Get",
"loads",
"the",
"requested",
"key",
"from",
"disk"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L57-L60 |
29,173 | gopasspw/gopass | pkg/config/secrets/config.go | Set | func (c *Config) Set(key, value string) error {
data, err := load(c.filename, c.passphrase)
if err != nil {
return errors.Wrapf(err, "failed to read secrects config %s: %s", c.filename, err)
}
old := data[key]
if value == old {
return nil
}
data[key] = value
return save(c.filename, c.passphrase, data)
} | go | func (c *Config) Set(key, value string) error {
data, err := load(c.filename, c.passphrase)
if err != nil {
return errors.Wrapf(err, "failed to read secrects config %s: %s", c.filename, err)
}
old := data[key]
if value == old {
return nil
}
data[key] = value
return save(c.filename, c.passphrase, data)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Set",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"data",
",",
"err",
":=",
"load",
"(",
"c",
".",
"filename",
",",
"c",
".",
"passphrase",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"e... | // Set writes the requested key to disk | [
"Set",
"writes",
"the",
"requested",
"key",
"to",
"disk"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L63-L76 |
29,174 | gopasspw/gopass | pkg/config/secrets/config.go | Unset | func (c *Config) Unset(key string) error {
data, err := load(c.filename, c.passphrase)
if err != nil {
return errors.Wrapf(err, "failed to read secrects config %s: %s", c.filename, err)
}
_, found := data[key]
if !found {
return nil
}
delete(data, key)
return save(c.filename, c.passphrase, data)
} | go | func (c *Config) Unset(key string) error {
data, err := load(c.filename, c.passphrase)
if err != nil {
return errors.Wrapf(err, "failed to read secrects config %s: %s", c.filename, err)
}
_, found := data[key]
if !found {
return nil
}
delete(data, key)
return save(c.filename, c.passphrase, data)
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Unset",
"(",
"key",
"string",
")",
"error",
"{",
"data",
",",
"err",
":=",
"load",
"(",
"c",
".",
"filename",
",",
"c",
".",
"passphrase",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
... | // Unset removes the key from the storage | [
"Unset",
"removes",
"the",
"key",
"from",
"the",
"storage"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L79-L92 |
29,175 | gopasspw/gopass | pkg/config/secrets/config.go | open | func open(buf []byte, passphrase string) (map[string]string, error) {
salt := make([]byte, saltLength)
copy(salt, buf[:saltLength])
var nonce [nonceLength]byte
copy(nonce[:], buf[saltLength:nonceLength+saltLength])
secretKey := deriveKey(passphrase, salt)
decrypted, ok := secretbox.Open(nil, buf[nonceLength+saltL... | go | func open(buf []byte, passphrase string) (map[string]string, error) {
salt := make([]byte, saltLength)
copy(salt, buf[:saltLength])
var nonce [nonceLength]byte
copy(nonce[:], buf[saltLength:nonceLength+saltLength])
secretKey := deriveKey(passphrase, salt)
decrypted, ok := secretbox.Open(nil, buf[nonceLength+saltL... | [
"func",
"open",
"(",
"buf",
"[",
"]",
"byte",
",",
"passphrase",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"salt",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"saltLength",
")",
"\n",
"copy",
"(",
"salt",
",",... | // open will try to unseal the given buffer | [
"open",
"will",
"try",
"to",
"unseal",
"the",
"given",
"buffer"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L103-L118 |
29,176 | gopasspw/gopass | pkg/config/secrets/config.go | save | func save(filename, passphrase string, data map[string]string) error {
buf, err := seal(data, passphrase)
if err != nil {
return err
}
return ioutil.WriteFile(filename, buf, 0600)
} | go | func save(filename, passphrase string, data map[string]string) error {
buf, err := seal(data, passphrase)
if err != nil {
return err
}
return ioutil.WriteFile(filename, buf, 0600)
} | [
"func",
"save",
"(",
"filename",
",",
"passphrase",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"buf",
",",
"err",
":=",
"seal",
"(",
"data",
",",
"passphrase",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // save will try to marshal, seal and write to disk | [
"save",
"will",
"try",
"to",
"marshal",
"seal",
"and",
"write",
"to",
"disk"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L121-L127 |
29,177 | gopasspw/gopass | pkg/config/secrets/config.go | seal | func seal(data map[string]string, passphrase string) ([]byte, error) {
jstr, err := json.Marshal(data)
if err != nil {
return nil, err
}
var nonce [nonceLength]byte
if _, err := io.ReadFull(crypto_rand.Reader, nonce[:]); err != nil {
return nil, err
}
salt := make([]byte, saltLength)
if _, err := crypto_ran... | go | func seal(data map[string]string, passphrase string) ([]byte, error) {
jstr, err := json.Marshal(data)
if err != nil {
return nil, err
}
var nonce [nonceLength]byte
if _, err := io.ReadFull(crypto_rand.Reader, nonce[:]); err != nil {
return nil, err
}
salt := make([]byte, saltLength)
if _, err := crypto_ran... | [
"func",
"seal",
"(",
"data",
"map",
"[",
"string",
"]",
"string",
",",
"passphrase",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"jstr",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // seal will try to marshal and seal the given data | [
"seal",
"will",
"try",
"to",
"marshal",
"and",
"seal",
"the",
"given",
"data"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/secrets/config.go#L130-L146 |
29,178 | gopasspw/gopass | pkg/cui/recipients.go | AskForPrivateKey | func AskForPrivateKey(ctx context.Context, crypto backend.Crypto, name, prompt string) (string, error) {
if !ctxutil.IsInteractive(ctx) {
return "", errors.New("can not select private key without terminal")
}
if crypto == nil {
return "", errors.New("can not select private key without valid crypto backend")
}
... | go | func AskForPrivateKey(ctx context.Context, crypto backend.Crypto, name, prompt string) (string, error) {
if !ctxutil.IsInteractive(ctx) {
return "", errors.New("can not select private key without terminal")
}
if crypto == nil {
return "", errors.New("can not select private key without valid crypto backend")
}
... | [
"func",
"AskForPrivateKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"crypto",
"backend",
".",
"Crypto",
",",
"name",
",",
"prompt",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"!",
"ctxutil",
".",
"IsInteractive",
"(",
"ctx",
")",
"... | // AskForPrivateKey promts the user to select from a list of private keys | [
"AskForPrivateKey",
"promts",
"the",
"user",
"to",
"select",
"from",
"a",
"list",
"of",
"private",
"keys"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/cui/recipients.go#L184-L228 |
29,179 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/secring.go | NewSecring | func NewSecring() *Secring {
return &Secring{
data: &xcpb.Secring{
PrivateKeys: make([]*xcpb.PrivateKey, 0, 10),
},
}
} | go | func NewSecring() *Secring {
return &Secring{
data: &xcpb.Secring{
PrivateKeys: make([]*xcpb.PrivateKey, 0, 10),
},
}
} | [
"func",
"NewSecring",
"(",
")",
"*",
"Secring",
"{",
"return",
"&",
"Secring",
"{",
"data",
":",
"&",
"xcpb",
".",
"Secring",
"{",
"PrivateKeys",
":",
"make",
"(",
"[",
"]",
"*",
"xcpb",
".",
"PrivateKey",
",",
"0",
",",
"10",
")",
",",
"}",
",",... | // NewSecring initializes and a new secring | [
"NewSecring",
"initializes",
"and",
"a",
"new",
"secring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/secring.go#L26-L32 |
29,180 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/secring.go | LoadSecring | func LoadSecring(file string) (*Secring, error) {
pr := NewSecring()
pr.File = file
buf, err := ioutil.ReadFile(file)
if os.IsNotExist(err) {
return pr, nil
}
if err != nil {
return nil, err
}
if err := proto.Unmarshal(buf, pr.data); err != nil {
return nil, err
}
return pr, nil
} | go | func LoadSecring(file string) (*Secring, error) {
pr := NewSecring()
pr.File = file
buf, err := ioutil.ReadFile(file)
if os.IsNotExist(err) {
return pr, nil
}
if err != nil {
return nil, err
}
if err := proto.Unmarshal(buf, pr.data); err != nil {
return nil, err
}
return pr, nil
} | [
"func",
"LoadSecring",
"(",
"file",
"string",
")",
"(",
"*",
"Secring",
",",
"error",
")",
"{",
"pr",
":=",
"NewSecring",
"(",
")",
"\n",
"pr",
".",
"File",
"=",
"file",
"\n\n",
"buf",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"file",
")",
... | // LoadSecring loads an existing secring from disk. If the file is not found
// an empty keyring is returned | [
"LoadSecring",
"loads",
"an",
"existing",
"secring",
"from",
"disk",
".",
"If",
"the",
"file",
"is",
"not",
"found",
"an",
"empty",
"keyring",
"is",
"returned"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/secring.go#L36-L53 |
29,181 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/secring.go | Contains | func (p *Secring) Contains(fp string) bool {
p.Lock()
defer p.Unlock()
for _, pk := range p.data.PrivateKeys {
if pk.PublicKey.Fingerprint == fp {
return true
}
}
return false
} | go | func (p *Secring) Contains(fp string) bool {
p.Lock()
defer p.Unlock()
for _, pk := range p.data.PrivateKeys {
if pk.PublicKey.Fingerprint == fp {
return true
}
}
return false
} | [
"func",
"(",
"p",
"*",
"Secring",
")",
"Contains",
"(",
"fp",
"string",
")",
"bool",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"_",
",",
"pk",
":=",
"range",
"p",
".",
"data",
".",
"PrivateKeys... | // Contains returns true if the given key is found in the keyring | [
"Contains",
"returns",
"true",
"if",
"the",
"given",
"key",
"is",
"found",
"in",
"the",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/secring.go#L68-L78 |
29,182 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/secring.go | KeyIDs | func (p *Secring) KeyIDs() []string {
p.Lock()
defer p.Unlock()
ids := make([]string, 0, len(p.data.PrivateKeys))
for _, pk := range p.data.PrivateKeys {
ids = append(ids, pk.PublicKey.Fingerprint)
}
sort.Strings(ids)
return ids
} | go | func (p *Secring) KeyIDs() []string {
p.Lock()
defer p.Unlock()
ids := make([]string, 0, len(p.data.PrivateKeys))
for _, pk := range p.data.PrivateKeys {
ids = append(ids, pk.PublicKey.Fingerprint)
}
sort.Strings(ids)
return ids
} | [
"func",
"(",
"p",
"*",
"Secring",
")",
"KeyIDs",
"(",
")",
"[",
"]",
"string",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"ids",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"p... | // KeyIDs returns a list of key IDs | [
"KeyIDs",
"returns",
"a",
"list",
"of",
"key",
"IDs"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/secring.go#L81-L91 |
29,183 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/secring.go | Export | func (p *Secring) Export(id string, withPrivate bool) ([]byte, error) {
p.Lock()
defer p.Unlock()
xpk := p.fetch(id)
if xpk == nil {
return nil, fmt.Errorf("key not found")
}
if withPrivate {
return proto.Marshal(xpk)
}
return proto.Marshal(xpk.PublicKey)
} | go | func (p *Secring) Export(id string, withPrivate bool) ([]byte, error) {
p.Lock()
defer p.Unlock()
xpk := p.fetch(id)
if xpk == nil {
return nil, fmt.Errorf("key not found")
}
if withPrivate {
return proto.Marshal(xpk)
}
return proto.Marshal(xpk.PublicKey)
} | [
"func",
"(",
"p",
"*",
"Secring",
")",
"Export",
"(",
"id",
"string",
",",
"withPrivate",
"bool",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"xpk",
":=",
... | // Export marshals a single private key | [
"Export",
"marshals",
"a",
"single",
"private",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/secring.go#L94-L107 |
29,184 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/secring.go | Import | func (p *Secring) Import(buf []byte) error {
pk := &xcpb.PrivateKey{}
if err := proto.Unmarshal(buf, pk); err != nil {
return err
}
p.insert(pk)
return nil
} | go | func (p *Secring) Import(buf []byte) error {
pk := &xcpb.PrivateKey{}
if err := proto.Unmarshal(buf, pk); err != nil {
return err
}
p.insert(pk)
return nil
} | [
"func",
"(",
"p",
"*",
"Secring",
")",
"Import",
"(",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"pk",
":=",
"&",
"xcpb",
".",
"PrivateKey",
"{",
"}",
"\n",
"if",
"err",
":=",
"proto",
".",
"Unmarshal",
"(",
"buf",
",",
"pk",
")",
";",
"err",
... | // Import unmarshals and imports a previously exported key | [
"Import",
"unmarshals",
"and",
"imports",
"a",
"previously",
"exported",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/secring.go#L132-L140 |
29,185 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/secring.go | Set | func (p *Secring) Set(pk *PrivateKey) error {
if !pk.Encrypted {
return fmt.Errorf("private key must be encrypted")
}
p.Lock()
defer p.Unlock()
p.insert(secKRToPB(pk))
return nil
} | go | func (p *Secring) Set(pk *PrivateKey) error {
if !pk.Encrypted {
return fmt.Errorf("private key must be encrypted")
}
p.Lock()
defer p.Unlock()
p.insert(secKRToPB(pk))
return nil
} | [
"func",
"(",
"p",
"*",
"Secring",
")",
"Set",
"(",
"pk",
"*",
"PrivateKey",
")",
"error",
"{",
"if",
"!",
"pk",
".",
"Encrypted",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"p",
".",
"Lock",
"(",
")",
"\n",
... | // Set inserts a single key | [
"Set",
"inserts",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/secring.go#L143-L153 |
29,186 | gopasspw/gopass | pkg/backend/crypto/xc/keyring/secring.go | Remove | func (p *Secring) Remove(id string) error {
p.Lock()
defer p.Unlock()
match := -1
for i, pk := range p.data.PrivateKeys {
if pk.PublicKey.Fingerprint == id {
match = i
break
}
}
if match < 0 || match > len(p.data.PrivateKeys) {
return fmt.Errorf("not found")
}
p.data.PrivateKeys = append(p.data.Pri... | go | func (p *Secring) Remove(id string) error {
p.Lock()
defer p.Unlock()
match := -1
for i, pk := range p.data.PrivateKeys {
if pk.PublicKey.Fingerprint == id {
match = i
break
}
}
if match < 0 || match > len(p.data.PrivateKeys) {
return fmt.Errorf("not found")
}
p.data.PrivateKeys = append(p.data.Pri... | [
"func",
"(",
"p",
"*",
"Secring",
")",
"Remove",
"(",
"id",
"string",
")",
"error",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"match",
":=",
"-",
"1",
"\n",
"for",
"i",
",",
"pk",
":=",
"range",
"p"... | // Remove deletes the given key | [
"Remove",
"deletes",
"the",
"given",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/secring.go#L166-L182 |
29,187 | gopasspw/gopass | pkg/action/sync.go | Sync | func (s *Action) Sync(ctx context.Context, c *cli.Context) error {
store := c.String("store")
return s.sync(ctx, c, store)
} | go | func (s *Action) Sync(ctx context.Context, c *cli.Context) error {
store := c.String("store")
return s.sync(ctx, c, store)
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"Sync",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"store",
":=",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"return",
"s",
".",
"sync",
"(",
"ctx",... | // Sync all stores with their remotes | [
"Sync",
"all",
"stores",
"with",
"their",
"remotes"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/sync.go#L18-L21 |
29,188 | gopasspw/gopass | pkg/backend/rcs/git/cli/git.go | Open | func Open(path, gpg string) (*Git, error) {
if !fsutil.IsDir(filepath.Join(path, ".git")) {
return nil, fmt.Errorf("git repo does not exist")
}
return &Git{
path: path,
}, nil
} | go | func Open(path, gpg string) (*Git, error) {
if !fsutil.IsDir(filepath.Join(path, ".git")) {
return nil, fmt.Errorf("git repo does not exist")
}
return &Git{
path: path,
}, nil
} | [
"func",
"Open",
"(",
"path",
",",
"gpg",
"string",
")",
"(",
"*",
"Git",
",",
"error",
")",
"{",
"if",
"!",
"fsutil",
".",
"IsDir",
"(",
"filepath",
".",
"Join",
"(",
"path",
",",
"\"",
"\"",
")",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"... | // Open creates a new git cli based git backend | [
"Open",
"creates",
"a",
"new",
"git",
"cli",
"based",
"git",
"backend"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/git.go#L31-L38 |
29,189 | gopasspw/gopass | pkg/backend/rcs/git/cli/git.go | Clone | func Clone(ctx context.Context, repo, path string) (*Git, error) {
g := &Git{
path: filepath.Dir(path),
}
if err := g.Cmd(ctx, "Clone", "clone", repo, path); err != nil {
return nil, err
}
g.path = path
return g, nil
} | go | func Clone(ctx context.Context, repo, path string) (*Git, error) {
g := &Git{
path: filepath.Dir(path),
}
if err := g.Cmd(ctx, "Clone", "clone", repo, path); err != nil {
return nil, err
}
g.path = path
return g, nil
} | [
"func",
"Clone",
"(",
"ctx",
"context",
".",
"Context",
",",
"repo",
",",
"path",
"string",
")",
"(",
"*",
"Git",
",",
"error",
")",
"{",
"g",
":=",
"&",
"Git",
"{",
"path",
":",
"filepath",
".",
"Dir",
"(",
"path",
")",
",",
"}",
"\n",
"if",
... | // Clone clones an existing git repo and returns a new cli based git backend
// configured for this clone repo | [
"Clone",
"clones",
"an",
"existing",
"git",
"repo",
"and",
"returns",
"a",
"new",
"cli",
"based",
"git",
"backend",
"configured",
"for",
"this",
"clone",
"repo"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/git.go#L42-L51 |
29,190 | gopasspw/gopass | pkg/backend/rcs/git/cli/git.go | Init | func Init(ctx context.Context, path, userName, userEmail string) (*Git, error) {
g := &Git{
path: path,
}
// the git repo may be empty (i.e. no branches, cloned from a fresh remote)
// or already initialized. Only run git init if the folder is completely empty
if !g.IsInitialized() {
if err := g.Cmd(ctx, "Init... | go | func Init(ctx context.Context, path, userName, userEmail string) (*Git, error) {
g := &Git{
path: path,
}
// the git repo may be empty (i.e. no branches, cloned from a fresh remote)
// or already initialized. Only run git init if the folder is completely empty
if !g.IsInitialized() {
if err := g.Cmd(ctx, "Init... | [
"func",
"Init",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
",",
"userName",
",",
"userEmail",
"string",
")",
"(",
"*",
"Git",
",",
"error",
")",
"{",
"g",
":=",
"&",
"Git",
"{",
"path",
":",
"path",
",",
"}",
"\n",
"// the git repo may be em... | // Init initializes this store's git repo | [
"Init",
"initializes",
"this",
"store",
"s",
"git",
"repo"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/git.go#L54-L93 |
29,191 | gopasspw/gopass | pkg/backend/rcs/git/cli/git.go | Cmd | func (g *Git) Cmd(ctx context.Context, name string, args ...string) error {
stdout, stderr, err := g.captureCmd(ctx, name, args...)
if err != nil {
out.Debug(ctx, "Output:\n Stdout: '%s'\n Stderr: '%s'", string(stdout), string(stderr))
return err
}
return nil
} | go | func (g *Git) Cmd(ctx context.Context, name string, args ...string) error {
stdout, stderr, err := g.captureCmd(ctx, name, args...)
if err != nil {
out.Debug(ctx, "Output:\n Stdout: '%s'\n Stderr: '%s'", string(stdout), string(stderr))
return err
}
return nil
} | [
"func",
"(",
"g",
"*",
"Git",
")",
"Cmd",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"args",
"...",
"string",
")",
"error",
"{",
"stdout",
",",
"stderr",
",",
"err",
":=",
"g",
".",
"captureCmd",
"(",
"ctx",
",",
"name",
"... | // Cmd runs an git command | [
"Cmd",
"runs",
"an",
"git",
"command"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/git.go#L115-L123 |
29,192 | gopasspw/gopass | pkg/backend/rcs/git/cli/git.go | Version | func (g *Git) Version(ctx context.Context) semver.Version {
v := semver.Version{}
cmd := exec.CommandContext(ctx, "git", "version")
cmdout, err := cmd.Output()
if err != nil {
out.Debug(ctx, "Failed to run 'git version': %s", err)
return v
}
svStr := strings.TrimPrefix(string(cmdout), "git version ")
if p ... | go | func (g *Git) Version(ctx context.Context) semver.Version {
v := semver.Version{}
cmd := exec.CommandContext(ctx, "git", "version")
cmdout, err := cmd.Output()
if err != nil {
out.Debug(ctx, "Failed to run 'git version': %s", err)
return v
}
svStr := strings.TrimPrefix(string(cmdout), "git version ")
if p ... | [
"func",
"(",
"g",
"*",
"Git",
")",
"Version",
"(",
"ctx",
"context",
".",
"Context",
")",
"semver",
".",
"Version",
"{",
"v",
":=",
"semver",
".",
"Version",
"{",
"}",
"\n\n",
"cmd",
":=",
"exec",
".",
"CommandContext",
"(",
"ctx",
",",
"\"",
"\"",... | // Version returns the git version as major, minor and patch level | [
"Version",
"returns",
"the",
"git",
"version",
"as",
"major",
"minor",
"and",
"patch",
"level"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/git.go#L131-L152 |
29,193 | gopasspw/gopass | pkg/backend/rcs/git/cli/git.go | Add | func (g *Git) Add(ctx context.Context, files ...string) error {
if !g.IsInitialized() {
return store.ErrGitNotInit
}
for i := range files {
files[i] = strings.TrimPrefix(files[i], g.path+"/")
}
args := []string{"add", "--all", "--force"}
args = append(args, files...)
return g.Cmd(ctx, "gitAdd", args...)
} | go | func (g *Git) Add(ctx context.Context, files ...string) error {
if !g.IsInitialized() {
return store.ErrGitNotInit
}
for i := range files {
files[i] = strings.TrimPrefix(files[i], g.path+"/")
}
args := []string{"add", "--all", "--force"}
args = append(args, files...)
return g.Cmd(ctx, "gitAdd", args...)
} | [
"func",
"(",
"g",
"*",
"Git",
")",
"Add",
"(",
"ctx",
"context",
".",
"Context",
",",
"files",
"...",
"string",
")",
"error",
"{",
"if",
"!",
"g",
".",
"IsInitialized",
"(",
")",
"{",
"return",
"store",
".",
"ErrGitNotInit",
"\n",
"}",
"\n\n",
"for... | // Add adds the listed files to the git index | [
"Add",
"adds",
"the",
"listed",
"files",
"to",
"the",
"git",
"index"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/git.go#L160-L173 |
29,194 | gopasspw/gopass | pkg/backend/rcs/git/cli/git.go | HasStagedChanges | func (g *Git) HasStagedChanges(ctx context.Context) bool {
if err := g.Cmd(ctx, "gitDiffIndex", "diff-index", "--quiet", "HEAD"); err != nil {
return true
}
return false
} | go | func (g *Git) HasStagedChanges(ctx context.Context) bool {
if err := g.Cmd(ctx, "gitDiffIndex", "diff-index", "--quiet", "HEAD"); err != nil {
return true
}
return false
} | [
"func",
"(",
"g",
"*",
"Git",
")",
"HasStagedChanges",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"if",
"err",
":=",
"g",
".",
"Cmd",
"(",
"ctx",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
";",
"err... | // HasStagedChanges returns true if there are any staged changes which can be committed | [
"HasStagedChanges",
"returns",
"true",
"if",
"there",
"are",
"any",
"staged",
"changes",
"which",
"can",
"be",
"committed"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/git.go#L176-L181 |
29,195 | gopasspw/gopass | pkg/backend/rcs/git/cli/git.go | Commit | func (g *Git) Commit(ctx context.Context, msg string) error {
if !g.IsInitialized() {
return store.ErrGitNotInit
}
if !g.HasStagedChanges(ctx) {
return store.ErrGitNothingToCommit
}
return g.Cmd(ctx, "gitCommit", "commit", "-m", msg)
} | go | func (g *Git) Commit(ctx context.Context, msg string) error {
if !g.IsInitialized() {
return store.ErrGitNotInit
}
if !g.HasStagedChanges(ctx) {
return store.ErrGitNothingToCommit
}
return g.Cmd(ctx, "gitCommit", "commit", "-m", msg)
} | [
"func",
"(",
"g",
"*",
"Git",
")",
"Commit",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"string",
")",
"error",
"{",
"if",
"!",
"g",
".",
"IsInitialized",
"(",
")",
"{",
"return",
"store",
".",
"ErrGitNotInit",
"\n",
"}",
"\n\n",
"if",
"!",... | // Commit creates a new git commit with the given commit message | [
"Commit",
"creates",
"a",
"new",
"git",
"commit",
"with",
"the",
"given",
"commit",
"message"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/git.go#L184-L194 |
29,196 | gopasspw/gopass | pkg/backend/rcs/git/cli/git.go | Push | func (g *Git) Push(ctx context.Context, remote, branch string) error {
return g.PushPull(ctx, "push", remote, branch)
} | go | func (g *Git) Push(ctx context.Context, remote, branch string) error {
return g.PushPull(ctx, "push", remote, branch)
} | [
"func",
"(",
"g",
"*",
"Git",
")",
"Push",
"(",
"ctx",
"context",
".",
"Context",
",",
"remote",
",",
"branch",
"string",
")",
"error",
"{",
"return",
"g",
".",
"PushPull",
"(",
"ctx",
",",
"\"",
"\"",
",",
"remote",
",",
"branch",
")",
"\n",
"}"... | // Push pushes to the git remote | [
"Push",
"pushes",
"to",
"the",
"git",
"remote"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/rcs/git/cli/git.go#L256-L258 |
29,197 | gopasspw/gopass | pkg/store/sub/gpg.go | exportPublicKey | func (s *Store) exportPublicKey(ctx context.Context, r string) (string, error) {
filename := filepath.Join(keyDir, r)
// do not overwrite existing keys
if s.storage.Exists(ctx, filename) {
return "", nil
}
pk, err := s.crypto.ExportPublicKey(ctx, r)
if err != nil {
return "", errors.Wrapf(err, "failed to ex... | go | func (s *Store) exportPublicKey(ctx context.Context, r string) (string, error) {
filename := filepath.Join(keyDir, r)
// do not overwrite existing keys
if s.storage.Exists(ctx, filename) {
return "", nil
}
pk, err := s.crypto.ExportPublicKey(ctx, r)
if err != nil {
return "", errors.Wrapf(err, "failed to ex... | [
"func",
"(",
"s",
"*",
"Store",
")",
"exportPublicKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"filename",
":=",
"filepath",
".",
"Join",
"(",
"keyDir",
",",
"r",
")",
"\n\n",
"// do not... | // export an ASCII armored public key | [
"export",
"an",
"ASCII",
"armored",
"public",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/gpg.go#L85-L108 |
29,198 | gopasspw/gopass | pkg/store/sub/gpg.go | importPublicKey | func (s *Store) importPublicKey(ctx context.Context, r string) error {
for _, kd := range []string{keyDir, oldKeyDir} {
filename := filepath.Join(kd, r)
if !s.storage.Exists(ctx, filename) {
out.Debug(ctx, "Public Key %s not found at %s", r, filename)
continue
}
pk, err := s.storage.Get(ctx, filename)
... | go | func (s *Store) importPublicKey(ctx context.Context, r string) error {
for _, kd := range []string{keyDir, oldKeyDir} {
filename := filepath.Join(kd, r)
if !s.storage.Exists(ctx, filename) {
out.Debug(ctx, "Public Key %s not found at %s", r, filename)
continue
}
pk, err := s.storage.Get(ctx, filename)
... | [
"func",
"(",
"s",
"*",
"Store",
")",
"importPublicKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"string",
")",
"error",
"{",
"for",
"_",
",",
"kd",
":=",
"range",
"[",
"]",
"string",
"{",
"keyDir",
",",
"oldKeyDir",
"}",
"{",
"filename",
"... | // import an public key into the default keyring | [
"import",
"an",
"public",
"key",
"into",
"the",
"default",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/gpg.go#L111-L125 |
29,199 | gopasspw/gopass | pkg/action/list.go | List | func (s *Action) List(ctx context.Context, c *cli.Context) error {
filter := c.Args().First()
flat := c.Bool("flat")
stripPrefix := c.Bool("strip-prefix")
limit := c.Int("limit")
folders := c.Bool("folders")
// we only support listing folders in flat mode currently
if folders {
flat = true
}
ctx = s.Store.W... | go | func (s *Action) List(ctx context.Context, c *cli.Context) error {
filter := c.Args().First()
flat := c.Bool("flat")
stripPrefix := c.Bool("strip-prefix")
limit := c.Int("limit")
folders := c.Bool("folders")
// we only support listing folders in flat mode currently
if folders {
flat = true
}
ctx = s.Store.W... | [
"func",
"(",
"s",
"*",
"Action",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"filter",
":=",
"c",
".",
"Args",
"(",
")",
".",
"First",
"(",
")",
"\n",
"flat",
":=",
"c",
".",
"B... | // List all secrets as a tree. If the filter argument is non-empty
// display only those that have this prefix | [
"List",
"all",
"secrets",
"as",
"a",
"tree",
".",
"If",
"the",
"filter",
"argument",
"is",
"non",
"-",
"empty",
"display",
"only",
"those",
"that",
"have",
"this",
"prefix"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/list.go#L24-L46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.