repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gopasspw/gopass | pkg/action/generate.go | generateSetPassword | func (s *Action) generateSetPassword(ctx context.Context, name, key, password string, kvps map[string]string) (context.Context, error) {
// set a single key in a yaml doc
if key != "" {
sec, ctx, err := s.Store.GetContext(ctx, name)
if err != nil {
return ctx, ExitError(ctx, ExitEncrypt, err, "failed to set ke... | go | func (s *Action) generateSetPassword(ctx context.Context, name, key, password string, kvps map[string]string) (context.Context, error) {
// set a single key in a yaml doc
if key != "" {
sec, ctx, err := s.Store.GetContext(ctx, name)
if err != nil {
return ctx, ExitError(ctx, ExitEncrypt, err, "failed to set ke... | [
"func",
"(",
"s",
"*",
"Action",
")",
"generateSetPassword",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
",",
"key",
",",
"password",
"string",
",",
"kvps",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"context",
".",
"Context",
",",
"error",... | // generateSetPassword will update or create a secret | [
"generateSetPassword",
"will",
"update",
"or",
"create",
"a",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/generate.go#L209-L256 | train |
gopasspw/gopass | pkg/action/generate.go | CompleteGenerate | func (s *Action) CompleteGenerate(ctx context.Context, c *cli.Context) {
args := c.Args()
if len(args) < 1 {
return
}
needle := args[0]
_, 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 ... | go | func (s *Action) CompleteGenerate(ctx context.Context, c *cli.Context) {
args := c.Args()
if len(args) < 1 {
return
}
needle := args[0]
_, 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 ... | [
"func",
"(",
"s",
"*",
"Action",
")",
"CompleteGenerate",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"args",
":=",
"c",
".",
"Args",
"(",
")",
"\n",
"if",
"len",
"(",
"args",
")",
"<",
"1",
"{",
"retu... | // CompleteGenerate implements the completion heuristic for the generate command | [
"CompleteGenerate",
"implements",
"the",
"completion",
"heuristic",
"for",
"the",
"generate",
"command"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/generate.go#L265-L291 | train |
gopasspw/gopass | pkg/editor/editor.go | Invoke | func Invoke(ctx context.Context, editor string, content []byte) ([]byte, error) {
if !ctxutil.IsTerminal(ctx) {
return nil, errors.New("need terminal")
}
tmpfile, err := tempfile.New(ctx, "gopass-edit")
if err != nil {
return []byte{}, errors.Errorf("failed to create tmpfile %s: %s", editor, err)
}
defer fun... | go | func Invoke(ctx context.Context, editor string, content []byte) ([]byte, error) {
if !ctxutil.IsTerminal(ctx) {
return nil, errors.New("need terminal")
}
tmpfile, err := tempfile.New(ctx, "gopass-edit")
if err != nil {
return []byte{}, errors.Errorf("failed to create tmpfile %s: %s", editor, err)
}
defer fun... | [
"func",
"Invoke",
"(",
"ctx",
"context",
".",
"Context",
",",
"editor",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"!",
"ctxutil",
".",
"IsTerminal",
"(",
"ctx",
")",
"{",
"return",
"nil",
... | // Invoke will start the given editor and return the content | [
"Invoke",
"will",
"start",
"the",
"given",
"editor",
"and",
"return",
"the",
"content"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/editor/editor.go#L30-L80 | train |
gopasspw/gopass | pkg/audit/audit.go | Batch | func Batch(ctx context.Context, secrets []string, secStore secretGetter) error {
out.Print(ctx, "Checking %d secrets. This may take some time ...\n", len(secrets))
// Secrets that still need auditing.
pending := make(chan string, 100)
// Secrets that have been audited.
checked := make(chan auditedSecret, 100)
... | go | func Batch(ctx context.Context, secrets []string, secStore secretGetter) error {
out.Print(ctx, "Checking %d secrets. This may take some time ...\n", len(secrets))
// Secrets that still need auditing.
pending := make(chan string, 100)
// Secrets that have been audited.
checked := make(chan auditedSecret, 100)
... | [
"func",
"Batch",
"(",
"ctx",
"context",
".",
"Context",
",",
"secrets",
"[",
"]",
"string",
",",
"secStore",
"secretGetter",
")",
"error",
"{",
"out",
".",
"Print",
"(",
"ctx",
",",
"\"",
"\\n",
"\"",
",",
"len",
"(",
"secrets",
")",
")",
"\n\n",
"... | // Batch runs a password strength audit on multiple secrets | [
"Batch",
"runs",
"a",
"password",
"strength",
"audit",
"on",
"multiple",
"secrets"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/audit/audit.go#L39-L108 | train |
gopasspw/gopass | pkg/audit/audit.go | Single | func Single(ctx context.Context, password string) {
validator := crunchy.NewValidator()
if err := validator.Check(password); err != nil {
out.Cyan(ctx, fmt.Sprintf("Warning: %s", err))
}
} | go | func Single(ctx context.Context, password string) {
validator := crunchy.NewValidator()
if err := validator.Check(password); err != nil {
out.Cyan(ctx, fmt.Sprintf("Warning: %s", err))
}
} | [
"func",
"Single",
"(",
"ctx",
"context",
".",
"Context",
",",
"password",
"string",
")",
"{",
"validator",
":=",
"crunchy",
".",
"NewValidator",
"(",
")",
"\n",
"if",
"err",
":=",
"validator",
".",
"Check",
"(",
"password",
")",
";",
"err",
"!=",
"nil"... | // Single runs a password strength audit on a single password | [
"Single",
"runs",
"a",
"password",
"strength",
"audit",
"on",
"a",
"single",
"password"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/audit/audit.go#L155-L160 | train |
gopasspw/gopass | pkg/store/vault/secret.go | Bytes | func (s *Secret) Bytes() ([]byte, error) {
if s.d == nil {
return []byte{}, nil
}
buf := &bytes.Buffer{}
if pw, found := s.d[passwordKey]; found {
if sv, ok := pw.(string); ok {
_, _ = buf.WriteString(sv)
}
}
_, _ = buf.WriteString("\n")
keys := make([]string, 0, len(s.d))
for k := range s.d {
keys ... | go | func (s *Secret) Bytes() ([]byte, error) {
if s.d == nil {
return []byte{}, nil
}
buf := &bytes.Buffer{}
if pw, found := s.d[passwordKey]; found {
if sv, ok := pw.(string); ok {
_, _ = buf.WriteString(sv)
}
}
_, _ = buf.WriteString("\n")
keys := make([]string, 0, len(s.d))
for k := range s.d {
keys ... | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Bytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"s",
".",
"d",
"==",
"nil",
"{",
"return",
"[",
"]",
"byte",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n\n",
"buf",
":=",
"&",
"bytes",
... | // Bytes returns a list serialized copy of this secret | [
"Bytes",
"returns",
"a",
"list",
"serialized",
"copy",
"of",
"this",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L23-L53 | train |
gopasspw/gopass | pkg/store/vault/secret.go | Data | func (s *Secret) Data() map[string]interface{} {
if s.d == nil {
s.d = make(map[string]interface{})
}
return s.d
} | go | func (s *Secret) Data() map[string]interface{} {
if s.d == nil {
s.d = make(map[string]interface{})
}
return s.d
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Data",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"if",
"s",
".",
"d",
"==",
"nil",
"{",
"s",
".",
"d",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\... | // Data returns the data map. Will never be nil | [
"Data",
"returns",
"the",
"data",
"map",
".",
"Will",
"never",
"be",
"nil"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L56-L61 | train |
gopasspw/gopass | pkg/store/vault/secret.go | DeleteKey | func (s *Secret) DeleteKey(key string) error {
if s.d == nil {
return nil
}
delete(s.d, key)
return nil
} | go | func (s *Secret) DeleteKey(key string) error {
if s.d == nil {
return nil
}
delete(s.d, key)
return nil
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"DeleteKey",
"(",
"key",
"string",
")",
"error",
"{",
"if",
"s",
".",
"d",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"delete",
"(",
"s",
".",
"d",
",",
"key",
")",
"\n",
"return",
"nil",
"\n",
"... | // DeleteKey removes a single key | [
"DeleteKey",
"removes",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L64-L70 | train |
gopasspw/gopass | pkg/store/vault/secret.go | Equal | func (s *Secret) Equal(other store.Secret) bool {
b1, err := s.Bytes()
if err != nil {
return false
}
b2, err := other.Bytes()
if err != nil {
return false
}
return string(b1) == string(b2)
} | go | func (s *Secret) Equal(other store.Secret) bool {
b1, err := s.Bytes()
if err != nil {
return false
}
b2, err := other.Bytes()
if err != nil {
return false
}
return string(b1) == string(b2)
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Equal",
"(",
"other",
"store",
".",
"Secret",
")",
"bool",
"{",
"b1",
",",
"err",
":=",
"s",
".",
"Bytes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"b2",
",",
"e... | // Equal returns true if two secrets match | [
"Equal",
"returns",
"true",
"if",
"two",
"secrets",
"match"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L73-L83 | train |
gopasspw/gopass | pkg/store/vault/secret.go | Password | func (s *Secret) Password() string {
v := s.d[passwordKey]
if sv, ok := v.(string); ok {
return sv
}
return ""
} | go | func (s *Secret) Password() string {
v := s.d[passwordKey]
if sv, ok := v.(string); ok {
return sv
}
return ""
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Password",
"(",
")",
"string",
"{",
"v",
":=",
"s",
".",
"d",
"[",
"passwordKey",
"]",
"\n",
"if",
"sv",
",",
"ok",
":=",
"v",
".",
"(",
"string",
")",
";",
"ok",
"{",
"return",
"sv",
"\n",
"}",
"\n",
... | // Password returns the password | [
"Password",
"returns",
"the",
"password"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L86-L92 | train |
gopasspw/gopass | pkg/store/vault/secret.go | SetValue | func (s *Secret) SetValue(key string, value string) error {
s.d[key] = value
return nil
} | go | func (s *Secret) SetValue(key string, value string) error {
s.d[key] = value
return nil
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"SetValue",
"(",
"key",
"string",
",",
"value",
"string",
")",
"error",
"{",
"s",
".",
"d",
"[",
"key",
"]",
"=",
"value",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetValue sets a single key | [
"SetValue",
"sets",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L105-L108 | train |
gopasspw/gopass | pkg/store/vault/secret.go | Value | func (s *Secret) Value(key string) (string, error) {
v := s.d[key]
if sv, ok := v.(string); ok {
return sv, nil
}
return "", nil
} | go | func (s *Secret) Value(key string) (string, error) {
v := s.d[key]
if sv, ok := v.(string); ok {
return sv, nil
}
return "", nil
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Value",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"v",
":=",
"s",
".",
"d",
"[",
"key",
"]",
"\n",
"if",
"sv",
",",
"ok",
":=",
"v",
".",
"(",
"string",
")",
";",
"ok",
"{",
"... | // Value returns a single value | [
"Value",
"returns",
"a",
"single",
"value"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/secret.go#L137-L143 | train |
gopasspw/gopass | pkg/store/sub/init.go | Initialized | func (s *Store) Initialized(ctx context.Context) bool {
if s == nil || s.storage == nil {
return false
}
return s.storage.Exists(ctx, s.idFile(ctx, ""))
} | go | func (s *Store) Initialized(ctx context.Context) bool {
if s == nil || s.storage == nil {
return false
}
return s.storage.Exists(ctx, s.idFile(ctx, ""))
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Initialized",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"if",
"s",
"==",
"nil",
"||",
"s",
".",
"storage",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"s",
".",
"storage",
"... | // Initialized returns true if the store is properly initialized | [
"Initialized",
"returns",
"true",
"if",
"the",
"store",
"is",
"properly",
"initialized"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/init.go#L13-L18 | train |
gopasspw/gopass | pkg/store/root/list.go | List | func (r *Store) List(ctx context.Context, maxDepth int) ([]string, error) {
t, err := r.Tree(ctx)
if err != nil {
return []string{}, err
}
return t.List(maxDepth), nil
} | go | func (r *Store) List(ctx context.Context, maxDepth int) ([]string, error) {
t, err := r.Tree(ctx)
if err != nil {
return []string{}, err
}
return t.List(maxDepth), nil
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"maxDepth",
"int",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"t",
",",
"err",
":=",
"r",
".",
"Tree",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=... | // List will return a flattened list of all tree entries | [
"List",
"will",
"return",
"a",
"flattened",
"list",
"of",
"all",
"tree",
"entries"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/list.go#L17-L23 | train |
gopasspw/gopass | pkg/store/root/list.go | Tree | func (r *Store) Tree(ctx context.Context) (tree.Tree, error) {
root := simple.New("gopass")
addFileFunc := func(in ...string) {
for _, f := range in {
var ct string
switch {
case strings.HasSuffix(f, ".b64"):
ct = "application/octet-stream"
case strings.HasSuffix(f, ".yml"):
ct = "text/yaml"
... | go | func (r *Store) Tree(ctx context.Context) (tree.Tree, error) {
root := simple.New("gopass")
addFileFunc := func(in ...string) {
for _, f := range in {
var ct string
switch {
case strings.HasSuffix(f, ".b64"):
ct = "application/octet-stream"
case strings.HasSuffix(f, ".yml"):
ct = "text/yaml"
... | [
"func",
"(",
"r",
"*",
"Store",
")",
"Tree",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"tree",
".",
"Tree",
",",
"error",
")",
"{",
"root",
":=",
"simple",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"addFileFunc",
":=",
"func",
"(",
"in",
"... | // Tree returns the tree representation of the entries | [
"Tree",
"returns",
"the",
"tree",
"representation",
"of",
"the",
"entries"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/list.go#L26-L82 | train |
gopasspw/gopass | pkg/action/hibp.go | HIBP | func (s *Action) HIBP(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
api := c.Bool("api")
if api {
return s.hibpAPI(ctx, force)
}
out.Yellow(ctx, "WARNING: Using the HIBPv2 dumps is very expensive. If you can condone leaking a few bits of entropy per secret you should probably use the '-... | go | func (s *Action) HIBP(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
api := c.Bool("api")
if api {
return s.hibpAPI(ctx, force)
}
out.Yellow(ctx, "WARNING: Using the HIBPv2 dumps is very expensive. If you can condone leaking a few bits of entropy per secret you should probably use the '-... | [
"func",
"(",
"s",
"*",
"Action",
")",
"HIBP",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"force",
":=",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n",
"api",
":=",
"c",
".",
"Bool",
"(",
"\"... | // HIBP compares all entries from the store against the provided SHA1 sum dumps | [
"HIBP",
"compares",
"all",
"entries",
"from",
"the",
"store",
"against",
"the",
"provided",
"SHA1",
"sum",
"dumps"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/hibp.go#L22-L34 | train |
gopasspw/gopass | pkg/backend/crypto/xc/utils.go | RecipientIDs | func (x *XC) RecipientIDs(ctx context.Context, ciphertext []byte) ([]string, error) {
msg := &xcpb.Message{}
if err := proto.Unmarshal(ciphertext, msg); err != nil {
return nil, err
}
ids := make([]string, 0, len(msg.Header.Recipients))
for k := range msg.Header.Recipients {
ids = append(ids, k)
}
sort.Stri... | go | func (x *XC) RecipientIDs(ctx context.Context, ciphertext []byte) ([]string, error) {
msg := &xcpb.Message{}
if err := proto.Unmarshal(ciphertext, msg); err != nil {
return nil, err
}
ids := make([]string, 0, len(msg.Header.Recipients))
for k := range msg.Header.Recipients {
ids = append(ids, k)
}
sort.Stri... | [
"func",
"(",
"x",
"*",
"XC",
")",
"RecipientIDs",
"(",
"ctx",
"context",
".",
"Context",
",",
"ciphertext",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"msg",
":=",
"&",
"xcpb",
".",
"Message",
"{",
"}",
"\n",
"if",
... | // RecipientIDs reads the header of the given file and extracts the
// recipients IDs | [
"RecipientIDs",
"reads",
"the",
"header",
"of",
"the",
"given",
"file",
"and",
"extracts",
"the",
"recipients",
"IDs"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L18-L30 | train |
gopasspw/gopass | pkg/backend/crypto/xc/utils.go | ReadNamesFromKey | func (x *XC) ReadNamesFromKey(ctx context.Context, buf []byte) ([]string, error) {
pk := &xcpb.PublicKey{}
if err := proto.Unmarshal(buf, pk); err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal public key: %s", err)
}
return []string{pk.Identity.Name}, nil
} | go | func (x *XC) ReadNamesFromKey(ctx context.Context, buf []byte) ([]string, error) {
pk := &xcpb.PublicKey{}
if err := proto.Unmarshal(buf, pk); err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal public key: %s", err)
}
return []string{pk.Identity.Name}, nil
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ReadNamesFromKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"buf",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"pk",
":=",
"&",
"xcpb",
".",
"PublicKey",
"{",
"}",
"\n",
"if",
"e... | // ReadNamesFromKey unmarshals the given public key and returns the identities name | [
"ReadNamesFromKey",
"unmarshals",
"the",
"given",
"public",
"key",
"and",
"returns",
"the",
"identities",
"name"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L33-L40 | train |
gopasspw/gopass | pkg/backend/crypto/xc/utils.go | ListPublicKeyIDs | func (x *XC) ListPublicKeyIDs(ctx context.Context) ([]string, error) {
return x.pubring.KeyIDs(), nil
} | go | func (x *XC) ListPublicKeyIDs(ctx context.Context) ([]string, error) {
return x.pubring.KeyIDs(), nil
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ListPublicKeyIDs",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"x",
".",
"pubring",
".",
"KeyIDs",
"(",
")",
",",
"nil",
"\n",
"}"
] | // ListPublicKeyIDs lists all public key IDs | [
"ListPublicKeyIDs",
"lists",
"all",
"public",
"key",
"IDs"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L43-L45 | train |
gopasspw/gopass | pkg/backend/crypto/xc/utils.go | ListPrivateKeyIDs | func (x *XC) ListPrivateKeyIDs(ctx context.Context) ([]string, error) {
return x.secring.KeyIDs(), nil
} | go | func (x *XC) ListPrivateKeyIDs(ctx context.Context) ([]string, error) {
return x.secring.KeyIDs(), nil
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"ListPrivateKeyIDs",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"x",
".",
"secring",
".",
"KeyIDs",
"(",
")",
",",
"nil",
"\n",
"}"
] | // ListPrivateKeyIDs lists all private key IDs | [
"ListPrivateKeyIDs",
"lists",
"all",
"private",
"key",
"IDs"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L48-L50 | train |
gopasspw/gopass | pkg/backend/crypto/xc/utils.go | FindPublicKeys | func (x *XC) FindPublicKeys(ctx context.Context, search ...string) ([]string, error) {
ids := make([]string, 0, 1)
candidates, _ := x.ListPublicKeyIDs(ctx)
for _, needle := range search {
for _, fp := range candidates {
if strings.HasSuffix(fp, needle) {
ids = append(ids, fp)
}
}
}
sort.Strings(ids)
... | go | func (x *XC) FindPublicKeys(ctx context.Context, search ...string) ([]string, error) {
ids := make([]string, 0, 1)
candidates, _ := x.ListPublicKeyIDs(ctx)
for _, needle := range search {
for _, fp := range candidates {
if strings.HasSuffix(fp, needle) {
ids = append(ids, fp)
}
}
}
sort.Strings(ids)
... | [
"func",
"(",
"x",
"*",
"XC",
")",
"FindPublicKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"search",
"...",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"ids",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"1",
"... | // FindPublicKeys finds all matching public keys | [
"FindPublicKeys",
"finds",
"all",
"matching",
"public",
"keys"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L53-L65 | train |
gopasspw/gopass | pkg/backend/crypto/xc/utils.go | FormatKey | func (x *XC) FormatKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return id + " - " + key.Identity.ID()
}
if key := x.secring.Get(id); key != nil {
return id + " - " + key.PublicKey.Identity.ID()
}
return id
} | go | func (x *XC) FormatKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return id + " - " + key.Identity.ID()
}
if key := x.secring.Get(id); key != nil {
return id + " - " + key.PublicKey.Identity.ID()
}
return id
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"FormatKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"string",
"{",
"if",
"key",
":=",
"x",
".",
"pubring",
".",
"Get",
"(",
"id",
")",
";",
"key",
"!=",
"nil",
"{",
"return",
"id",
"+"... | // FormatKey formats a key | [
"FormatKey",
"formats",
"a",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L83-L91 | train |
gopasspw/gopass | pkg/backend/crypto/xc/utils.go | NameFromKey | func (x *XC) NameFromKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return key.Identity.Name
}
if key := x.secring.Get(id); key != nil {
return key.PublicKey.Identity.Name
}
return id
} | go | func (x *XC) NameFromKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return key.Identity.Name
}
if key := x.secring.Get(id); key != nil {
return key.PublicKey.Identity.Name
}
return id
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"NameFromKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"string",
"{",
"if",
"key",
":=",
"x",
".",
"pubring",
".",
"Get",
"(",
"id",
")",
";",
"key",
"!=",
"nil",
"{",
"return",
"key",
... | // NameFromKey extracts the name from a key | [
"NameFromKey",
"extracts",
"the",
"name",
"from",
"a",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L94-L102 | train |
gopasspw/gopass | pkg/backend/crypto/xc/utils.go | EmailFromKey | func (x *XC) EmailFromKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return key.Identity.Email
}
if key := x.secring.Get(id); key != nil {
return key.PublicKey.Identity.Email
}
return id
} | go | func (x *XC) EmailFromKey(ctx context.Context, id string) string {
if key := x.pubring.Get(id); key != nil {
return key.Identity.Email
}
if key := x.secring.Get(id); key != nil {
return key.PublicKey.Identity.Email
}
return id
} | [
"func",
"(",
"x",
"*",
"XC",
")",
"EmailFromKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"string",
"{",
"if",
"key",
":=",
"x",
".",
"pubring",
".",
"Get",
"(",
"id",
")",
";",
"key",
"!=",
"nil",
"{",
"return",
"key",
... | // EmailFromKey extracts the email from a key | [
"EmailFromKey",
"extracts",
"the",
"email",
"from",
"a",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L105-L113 | train |
gopasspw/gopass | pkg/backend/crypto/xc/utils.go | CreatePrivateKeyBatch | func (x *XC) CreatePrivateKeyBatch(ctx context.Context, name, email, passphrase string) error {
k, err := keyring.GenerateKeypair(passphrase)
if err != nil {
return errors.Wrapf(err, "failed to generate keypair: %s", err)
}
k.Identity.Name = name
k.Identity.Email = email
if err := x.secring.Set(k); err != nil {... | go | func (x *XC) CreatePrivateKeyBatch(ctx context.Context, name, email, passphrase string) error {
k, err := keyring.GenerateKeypair(passphrase)
if err != nil {
return errors.Wrapf(err, "failed to generate keypair: %s", err)
}
k.Identity.Name = name
k.Identity.Email = email
if err := x.secring.Set(k); err != nil {... | [
"func",
"(",
"x",
"*",
"XC",
")",
"CreatePrivateKeyBatch",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
",",
"email",
",",
"passphrase",
"string",
")",
"error",
"{",
"k",
",",
"err",
":=",
"keyring",
".",
"GenerateKeypair",
"(",
"passphrase",
")",... | // CreatePrivateKeyBatch creates a new keypair | [
"CreatePrivateKeyBatch",
"creates",
"a",
"new",
"keypair"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/utils.go#L121-L132 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/context.go | WithAlwaysTrust | func WithAlwaysTrust(ctx context.Context, at bool) context.Context {
return context.WithValue(ctx, ctxKeyAlwaysTrust, at)
} | go | func WithAlwaysTrust(ctx context.Context, at bool) context.Context {
return context.WithValue(ctx, ctxKeyAlwaysTrust, at)
} | [
"func",
"WithAlwaysTrust",
"(",
"ctx",
"context",
".",
"Context",
",",
"at",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyAlwaysTrust",
",",
"at",
")",
"\n",
"}"
] | // WithAlwaysTrust will return a context with the flag for always trust set | [
"WithAlwaysTrust",
"will",
"return",
"a",
"context",
"with",
"the",
"flag",
"for",
"always",
"trust",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/context.go#L12-L14 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/pubring.go | NewPubring | func NewPubring(sec *Secring) *Pubring {
return &Pubring{
data: &xcpb.Pubring{
PublicKeys: make([]*xcpb.PublicKey, 0, 10),
},
secring: sec,
}
} | go | func NewPubring(sec *Secring) *Pubring {
return &Pubring{
data: &xcpb.Pubring{
PublicKeys: make([]*xcpb.PublicKey, 0, 10),
},
secring: sec,
}
} | [
"func",
"NewPubring",
"(",
"sec",
"*",
"Secring",
")",
"*",
"Pubring",
"{",
"return",
"&",
"Pubring",
"{",
"data",
":",
"&",
"xcpb",
".",
"Pubring",
"{",
"PublicKeys",
":",
"make",
"(",
"[",
"]",
"*",
"xcpb",
".",
"PublicKey",
",",
"0",
",",
"10",
... | // NewPubring initializes a new public key ring | [
"NewPubring",
"initializes",
"a",
"new",
"public",
"key",
"ring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/pubring.go#L27-L34 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/pubring.go | LoadPubring | func LoadPubring(file string, sec *Secring) (*Pubring, error) {
pr := NewPubring(sec)
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 LoadPubring(file string, sec *Secring) (*Pubring, error) {
pr := NewPubring(sec)
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",
"LoadPubring",
"(",
"file",
"string",
",",
"sec",
"*",
"Secring",
")",
"(",
"*",
"Pubring",
",",
"error",
")",
"{",
"pr",
":=",
"NewPubring",
"(",
"sec",
")",
"\n",
"pr",
".",
"File",
"=",
"file",
"\n\n",
"buf",
",",
"err",
":=",
"ioutil",
... | // LoadPubring loads an existing keyring from disk. If the file is not
// found an empty keyring is returned. | [
"LoadPubring",
"loads",
"an",
"existing",
"keyring",
"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/pubring.go#L38-L55 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/pubring.go | Contains | func (p *Pubring) Contains(fp string) bool {
p.Lock()
defer p.Unlock()
for _, pk := range p.data.PublicKeys {
if pk.Fingerprint == fp {
return true
}
}
if p.secring == nil {
return false
}
return p.secring.Contains(fp)
} | go | func (p *Pubring) Contains(fp string) bool {
p.Lock()
defer p.Unlock()
for _, pk := range p.data.PublicKeys {
if pk.Fingerprint == fp {
return true
}
}
if p.secring == nil {
return false
}
return p.secring.Contains(fp)
} | [
"func",
"(",
"p",
"*",
"Pubring",
")",
"Contains",
"(",
"fp",
"string",
")",
"bool",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"_",
",",
"pk",
":=",
"range",
"p",
".",
"data",
".",
"PublicKeys"... | // Contains checks if a given key is in the keyring | [
"Contains",
"checks",
"if",
"a",
"given",
"key",
"is",
"in",
"the",
"keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/pubring.go#L67-L82 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/pubring.go | KeyIDs | func (p *Pubring) KeyIDs() []string {
p.Lock()
defer p.Unlock()
ids := make([]string, 0, len(p.data.PublicKeys))
for _, pk := range p.data.PublicKeys {
ids = append(ids, pk.Fingerprint)
}
if p.secring != nil {
ids = append(ids, p.secring.KeyIDs()...)
}
sort.Strings(ids)
return ids
} | go | func (p *Pubring) KeyIDs() []string {
p.Lock()
defer p.Unlock()
ids := make([]string, 0, len(p.data.PublicKeys))
for _, pk := range p.data.PublicKeys {
ids = append(ids, pk.Fingerprint)
}
if p.secring != nil {
ids = append(ids, p.secring.KeyIDs()...)
}
sort.Strings(ids)
return ids
} | [
"func",
"(",
"p",
"*",
"Pubring",
")",
"KeyIDs",
"(",
")",
"[",
"]",
"string",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"ids",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"p... | // KeyIDs returns a list of all key IDs | [
"KeyIDs",
"returns",
"a",
"list",
"of",
"all",
"key",
"IDs"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/pubring.go#L85-L98 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/pubring.go | Export | func (p *Pubring) Export(id string) ([]byte, error) {
p.Lock()
defer p.Unlock()
xpk := p.fetch(id)
if xpk == nil {
if p.secring != nil {
return p.secring.Export(id, false)
}
return nil, fmt.Errorf("key not found")
}
return proto.Marshal(xpk)
} | go | func (p *Pubring) Export(id string) ([]byte, error) {
p.Lock()
defer p.Unlock()
xpk := p.fetch(id)
if xpk == nil {
if p.secring != nil {
return p.secring.Export(id, false)
}
return nil, fmt.Errorf("key not found")
}
return proto.Marshal(xpk)
} | [
"func",
"(",
"p",
"*",
"Pubring",
")",
"Export",
"(",
"id",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"xpk",
":=",
"p",
".",
"fetch",
"(",
... | // Export marshals a single key | [
"Export",
"marshals",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/pubring.go#L101-L114 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/pubring.go | Import | func (p *Pubring) Import(buf []byte) error {
pk := &xcpb.PublicKey{}
if err := proto.Unmarshal(buf, pk); err != nil {
return err
}
p.insert(pk)
return nil
} | go | func (p *Pubring) Import(buf []byte) error {
pk := &xcpb.PublicKey{}
if err := proto.Unmarshal(buf, pk); err != nil {
return err
}
p.insert(pk)
return nil
} | [
"func",
"(",
"p",
"*",
"Pubring",
")",
"Import",
"(",
"buf",
"[",
"]",
"byte",
")",
"error",
"{",
"pk",
":=",
"&",
"xcpb",
".",
"PublicKey",
"{",
"}",
"\n",
"if",
"err",
":=",
"proto",
".",
"Unmarshal",
"(",
"buf",
",",
"pk",
")",
";",
"err",
... | // Import unmarshals and inserts and previously exported key | [
"Import",
"unmarshals",
"and",
"inserts",
"and",
"previously",
"exported",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/pubring.go#L144-L152 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/pubring.go | Set | func (p *Pubring) Set(pk *PublicKey) error {
p.Lock()
defer p.Unlock()
p.insert(pubKRToPB(pk))
return nil
} | go | func (p *Pubring) Set(pk *PublicKey) error {
p.Lock()
defer p.Unlock()
p.insert(pubKRToPB(pk))
return nil
} | [
"func",
"(",
"p",
"*",
"Pubring",
")",
"Set",
"(",
"pk",
"*",
"PublicKey",
")",
"error",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"p",
".",
"insert",
"(",
"pubKRToPB",
"(",
"pk",
")",
")",
"\n",
"r... | // Set inserts a key, possibly overwriting and existing entry | [
"Set",
"inserts",
"a",
"key",
"possibly",
"overwriting",
"and",
"existing",
"entry"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/pubring.go#L155-L161 | train |
gopasspw/gopass | pkg/backend/crypto/xc/keyring/pubring.go | Remove | func (p *Pubring) Remove(id string) error {
p.Lock()
defer p.Unlock()
match := -1
for i, pk := range p.data.PublicKeys {
if pk.Fingerprint == id {
match = i
break
}
}
if match < 0 || match > len(p.data.PublicKeys) {
return fmt.Errorf("not found")
}
p.data.PublicKeys = append(p.data.PublicKeys[:matc... | go | func (p *Pubring) Remove(id string) error {
p.Lock()
defer p.Unlock()
match := -1
for i, pk := range p.data.PublicKeys {
if pk.Fingerprint == id {
match = i
break
}
}
if match < 0 || match > len(p.data.PublicKeys) {
return fmt.Errorf("not found")
}
p.data.PublicKeys = append(p.data.PublicKeys[:matc... | [
"func",
"(",
"p",
"*",
"Pubring",
")",
"Remove",
"(",
"id",
"string",
")",
"error",
"{",
"p",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"Unlock",
"(",
")",
"\n\n",
"match",
":=",
"-",
"1",
"\n",
"for",
"i",
",",
"pk",
":=",
"range",
"p"... | // Remove deletes a single key | [
"Remove",
"deletes",
"a",
"single",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/keyring/pubring.go#L175-L191 | train |
gopasspw/gopass | pkg/config/store_config.go | ConfigMap | func (c *StoreConfig) ConfigMap() map[string]string {
m := make(map[string]string, 20)
o := reflect.ValueOf(c).Elem()
for i := 0; i < o.NumField(); i++ {
jsonArg := o.Type().Field(i).Tag.Get("yaml")
if jsonArg == "" || jsonArg == "-" {
continue
}
f := o.Field(i)
var strVal string
switch f.Kind() {
c... | go | func (c *StoreConfig) ConfigMap() map[string]string {
m := make(map[string]string, 20)
o := reflect.ValueOf(c).Elem()
for i := 0; i < o.NumField(); i++ {
jsonArg := o.Type().Field(i).Tag.Get("yaml")
if jsonArg == "" || jsonArg == "-" {
continue
}
f := o.Field(i)
var strVal string
switch f.Kind() {
c... | [
"func",
"(",
"c",
"*",
"StoreConfig",
")",
"ConfigMap",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"20",
")",
"\n",
"o",
":=",
"reflect",
".",
"ValueOf",
"(",
"c",
")",
... | // ConfigMap returns a map of stringified config values for easy printing | [
"ConfigMap",
"returns",
"a",
"map",
"of",
"stringified",
"config",
"values",
"for",
"easy",
"printing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/store_config.go#L52-L83 | train |
gopasspw/gopass | pkg/store/root/mount.go | RemoveMount | func (r *Store) RemoveMount(ctx context.Context, alias string) error {
if _, found := r.mounts[alias]; !found {
return errors.Errorf("%s is not mounted", alias)
}
if _, found := r.mounts[alias]; !found {
out.Yellow(ctx, "%s is not initialized", alias)
}
delete(r.mounts, alias)
delete(r.cfg.Mounts, alias)
ret... | go | func (r *Store) RemoveMount(ctx context.Context, alias string) error {
if _, found := r.mounts[alias]; !found {
return errors.Errorf("%s is not mounted", alias)
}
if _, found := r.mounts[alias]; !found {
out.Yellow(ctx, "%s is not initialized", alias)
}
delete(r.mounts, alias)
delete(r.cfg.Mounts, alias)
ret... | [
"func",
"(",
"r",
"*",
"Store",
")",
"RemoveMount",
"(",
"ctx",
"context",
".",
"Context",
",",
"alias",
"string",
")",
"error",
"{",
"if",
"_",
",",
"found",
":=",
"r",
".",
"mounts",
"[",
"alias",
"]",
";",
"!",
"found",
"{",
"return",
"errors",
... | // RemoveMount removes and existing mount | [
"RemoveMount",
"removes",
"and",
"existing",
"mount"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/mount.go#L128-L138 | train |
gopasspw/gopass | pkg/store/root/mount.go | Mounts | func (r *Store) Mounts() map[string]string {
m := make(map[string]string, len(r.mounts))
for alias, sub := range r.mounts {
m[alias] = sub.Path()
}
return m
} | go | func (r *Store) Mounts() map[string]string {
m := make(map[string]string, len(r.mounts))
for alias, sub := range r.mounts {
m[alias] = sub.Path()
}
return m
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"Mounts",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"len",
"(",
"r",
".",
"mounts",
")",
")",
"\n",
"for",
"alias",
",",
"sub",
"... | // Mounts returns a map of mounts with their paths | [
"Mounts",
"returns",
"a",
"map",
"of",
"mounts",
"with",
"their",
"paths"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/mount.go#L141-L147 | train |
gopasspw/gopass | pkg/store/root/mount.go | MountPoints | func (r *Store) MountPoints() []string {
mps := make([]string, 0, len(r.mounts))
for k := range r.mounts {
mps = append(mps, k)
}
sort.Sort(sort.Reverse(store.ByPathLen(mps)))
return mps
} | go | func (r *Store) MountPoints() []string {
mps := make([]string, 0, len(r.mounts))
for k := range r.mounts {
mps = append(mps, k)
}
sort.Sort(sort.Reverse(store.ByPathLen(mps)))
return mps
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"MountPoints",
"(",
")",
"[",
"]",
"string",
"{",
"mps",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"r",
".",
"mounts",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"r",
".",
"mounts",... | // MountPoints returns a sorted list of mount points. It encodes the logic that
// the longer a mount point the more specific it is. This allows to "shadow" a
// shorter mount point by a longer one. | [
"MountPoints",
"returns",
"a",
"sorted",
"list",
"of",
"mount",
"points",
".",
"It",
"encodes",
"the",
"logic",
"that",
"the",
"longer",
"a",
"mount",
"point",
"the",
"more",
"specific",
"it",
"is",
".",
"This",
"allows",
"to",
"shadow",
"a",
"shorter",
... | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/mount.go#L152-L159 | train |
gopasspw/gopass | pkg/store/root/mount.go | MountPoint | func (r *Store) MountPoint(name string) string {
for _, mp := range r.MountPoints() {
if strings.HasPrefix(name+"/", mp+"/") {
return mp
}
}
return ""
} | go | func (r *Store) MountPoint(name string) string {
for _, mp := range r.MountPoints() {
if strings.HasPrefix(name+"/", mp+"/") {
return mp
}
}
return ""
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"MountPoint",
"(",
"name",
"string",
")",
"string",
"{",
"for",
"_",
",",
"mp",
":=",
"range",
"r",
".",
"MountPoints",
"(",
")",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"name",
"+",
"\"",
"\"",
",",
"mp"... | // MountPoint returns the most-specific mount point for the given key | [
"MountPoint",
"returns",
"the",
"most",
"-",
"specific",
"mount",
"point",
"for",
"the",
"given",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/mount.go#L162-L169 | train |
gopasspw/gopass | pkg/store/root/mount.go | getStore | func (r *Store) getStore(ctx context.Context, name string) (context.Context, store.Store, string) {
name = strings.TrimSuffix(name, "/")
mp := r.MountPoint(name)
if sub, found := r.mounts[mp]; found {
return r.cfg.Mounts[mp].WithContext(ctx), sub, strings.TrimPrefix(name, sub.Alias())
}
return r.cfg.Root.WithCon... | go | func (r *Store) getStore(ctx context.Context, name string) (context.Context, store.Store, string) {
name = strings.TrimSuffix(name, "/")
mp := r.MountPoint(name)
if sub, found := r.mounts[mp]; found {
return r.cfg.Mounts[mp].WithContext(ctx), sub, strings.TrimPrefix(name, sub.Alias())
}
return r.cfg.Root.WithCon... | [
"func",
"(",
"r",
"*",
"Store",
")",
"getStore",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"context",
".",
"Context",
",",
"store",
".",
"Store",
",",
"string",
")",
"{",
"name",
"=",
"strings",
".",
"TrimSuffix",
"(",
... | // getStore returns the Store object at the most-specific mount point for the
// given key
// context with sub store options set, sub store reference, truncated path to secret | [
"getStore",
"returns",
"the",
"Store",
"object",
"at",
"the",
"most",
"-",
"specific",
"mount",
"point",
"for",
"the",
"given",
"key",
"context",
"with",
"sub",
"store",
"options",
"set",
"sub",
"store",
"reference",
"truncated",
"path",
"to",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/mount.go#L174-L181 | train |
gopasspw/gopass | pkg/store/root/mount.go | WithConfig | func (r *Store) WithConfig(ctx context.Context, name string) context.Context {
name = strings.TrimSuffix(name, "/")
mp := r.MountPoint(name)
if _, found := r.mounts[mp]; found {
return r.cfg.Mounts[mp].WithContext(ctx)
}
return r.cfg.Root.WithContext(ctx)
} | go | func (r *Store) WithConfig(ctx context.Context, name string) context.Context {
name = strings.TrimSuffix(name, "/")
mp := r.MountPoint(name)
if _, found := r.mounts[mp]; found {
return r.cfg.Mounts[mp].WithContext(ctx)
}
return r.cfg.Root.WithContext(ctx)
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"WithConfig",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"context",
".",
"Context",
"{",
"name",
"=",
"strings",
".",
"TrimSuffix",
"(",
"name",
",",
"\"",
"\"",
")",
"\n",
"mp",
":=",
"r... | // WithConfig populates the context with the substore config | [
"WithConfig",
"populates",
"the",
"context",
"with",
"the",
"substore",
"config"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/mount.go#L184-L191 | train |
gopasspw/gopass | pkg/store/root/mount.go | GetSubStore | func (r *Store) GetSubStore(name string) (store.Store, error) {
if name == "" {
return r.store, nil
}
if sub, found := r.mounts[name]; found {
return sub, nil
}
return nil, errors.Errorf("no such mount point '%s'", name)
} | go | func (r *Store) GetSubStore(name string) (store.Store, error) {
if name == "" {
return r.store, nil
}
if sub, found := r.mounts[name]; found {
return sub, nil
}
return nil, errors.Errorf("no such mount point '%s'", name)
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"GetSubStore",
"(",
"name",
"string",
")",
"(",
"store",
".",
"Store",
",",
"error",
")",
"{",
"if",
"name",
"==",
"\"",
"\"",
"{",
"return",
"r",
".",
"store",
",",
"nil",
"\n",
"}",
"\n",
"if",
"sub",
",",... | // GetSubStore returns an exact match for a mount point or an error if this
// mount point does not exist | [
"GetSubStore",
"returns",
"an",
"exact",
"match",
"for",
"a",
"mount",
"point",
"or",
"an",
"error",
"if",
"this",
"mount",
"point",
"does",
"not",
"exist"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/mount.go#L195-L203 | train |
gopasspw/gopass | pkg/store/root/mount.go | checkMounts | func (r *Store) checkMounts() error {
paths := make(map[string]string, len(r.mounts))
for k, v := range r.mounts {
if _, found := paths[v.Path()]; found {
return errors.Errorf("Doubly mounted path at %s: %s", v.Path(), k)
}
paths[v.Path()] = k
}
return nil
} | go | func (r *Store) checkMounts() error {
paths := make(map[string]string, len(r.mounts))
for k, v := range r.mounts {
if _, found := paths[v.Path()]; found {
return errors.Errorf("Doubly mounted path at %s: %s", v.Path(), k)
}
paths[v.Path()] = k
}
return nil
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"checkMounts",
"(",
")",
"error",
"{",
"paths",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"len",
"(",
"r",
".",
"mounts",
")",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"r",
".",
"... | // checkMounts performs some sanity checks on our mounts. At the moment it
// only checks if some path is mounted twice. | [
"checkMounts",
"performs",
"some",
"sanity",
"checks",
"on",
"our",
"mounts",
".",
"At",
"the",
"moment",
"it",
"only",
"checks",
"if",
"some",
"path",
"is",
"mounted",
"twice",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/mount.go#L207-L216 | train |
gopasspw/gopass | pkg/action/version.go | Version | func (s *Action) Version(ctx context.Context, c *cli.Context) error {
version := make(chan string, 1)
go s.checkVersion(ctx, version)
_ = s.Initialized(ctx, c)
cli.VersionPrinter(c)
cryptoVer := versionInfo(ctx, s.Store.Crypto(ctx, ""))
rcsVer := versionInfo(ctx, s.Store.RCS(ctx, ""))
storageVer := versionInf... | go | func (s *Action) Version(ctx context.Context, c *cli.Context) error {
version := make(chan string, 1)
go s.checkVersion(ctx, version)
_ = s.Initialized(ctx, c)
cli.VersionPrinter(c)
cryptoVer := versionInfo(ctx, s.Store.Crypto(ctx, ""))
rcsVer := versionInfo(ctx, s.Store.RCS(ctx, ""))
storageVer := versionInf... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Version",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"version",
":=",
"make",
"(",
"chan",
"string",
",",
"1",
")",
"\n",
"go",
"s",
".",
"checkVersion",
... | // Version prints the gopass version | [
"Version",
"prints",
"the",
"gopass",
"version"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/version.go#L21-L63 | train |
gopasspw/gopass | pkg/clipboard/kill_ps.go | killPrecedessors | func killPrecedessors() error {
procs, err := ps.Processes()
if err != nil {
return err
}
for _, proc := range procs {
walkFn(proc.Pid(), killProc)
}
return nil
} | go | func killPrecedessors() error {
procs, err := ps.Processes()
if err != nil {
return err
}
for _, proc := range procs {
walkFn(proc.Pid(), killProc)
}
return nil
} | [
"func",
"killPrecedessors",
"(",
")",
"error",
"{",
"procs",
",",
"err",
":=",
"ps",
".",
"Processes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"for",
"_",
",",
"proc",
":=",
"range",
"procs",
"{",
"walkFn",
... | // killPrecedessors will kill any previous "gopass unclip" invokations to avoid
// erasing the clipboard prematurely in case the the same content is copied to
// the clipboard repeatedly | [
"killPrecedessors",
"will",
"kill",
"any",
"previous",
"gopass",
"unclip",
"invokations",
"to",
"avoid",
"erasing",
"the",
"clipboard",
"prematurely",
"in",
"case",
"the",
"the",
"same",
"content",
"is",
"copied",
"to",
"the",
"clipboard",
"repeatedly"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/clipboard/kill_ps.go#L12-L21 | train |
gopasspw/gopass | pkg/tpl/template.go | Execute | func Execute(ctx context.Context, tpl, name string, content []byte, s kvstore) ([]byte, error) {
funcs := funcMap(ctx, s)
pl := payload{
Dir: filepath.Dir(name),
Path: name,
Name: filepath.Base(name),
Content: string(content),
}
tmpl, err := template.New(tpl).Funcs(funcs).Parse(tpl)
if err != ni... | go | func Execute(ctx context.Context, tpl, name string, content []byte, s kvstore) ([]byte, error) {
funcs := funcMap(ctx, s)
pl := payload{
Dir: filepath.Dir(name),
Path: name,
Name: filepath.Base(name),
Content: string(content),
}
tmpl, err := template.New(tpl).Funcs(funcs).Parse(tpl)
if err != ni... | [
"func",
"Execute",
"(",
"ctx",
"context",
".",
"Context",
",",
"tpl",
",",
"name",
"string",
",",
"content",
"[",
"]",
"byte",
",",
"s",
"kvstore",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"funcs",
":=",
"funcMap",
"(",
"ctx",
",",
"s"... | // Execute executes the given template | [
"Execute",
"executes",
"the",
"given",
"template"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tpl/template.go#L24-L44 | train |
gopasspw/gopass | pkg/store/secret/yaml.go | Value | func (s *Secret) Value(key string) (string, error) {
s.Lock()
defer s.Unlock()
if s.data == nil {
if !strings.HasPrefix(s.body, "---\n") {
return "", store.ErrYAMLNoMark
}
if err := s.decode(); err != nil {
return "", err
}
}
if v, found := s.data[key]; found {
return fmt.Sprintf("%v", v), nil
}
... | go | func (s *Secret) Value(key string) (string, error) {
s.Lock()
defer s.Unlock()
if s.data == nil {
if !strings.HasPrefix(s.body, "---\n") {
return "", store.ErrYAMLNoMark
}
if err := s.decode(); err != nil {
return "", err
}
}
if v, found := s.data[key]; found {
return fmt.Sprintf("%v", v), nil
}
... | [
"func",
"(",
"s",
"*",
"Secret",
")",
"Value",
"(",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"data",
"==",
"nil",
"{",
"if",
... | // Value returns the value of the given key if the body contained valid
// YAML | [
"Value",
"returns",
"the",
"value",
"of",
"the",
"given",
"key",
"if",
"the",
"body",
"contained",
"valid",
"YAML"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/yaml.go#L14-L30 | train |
gopasspw/gopass | pkg/store/secret/yaml.go | SetValue | func (s *Secret) SetValue(key, value string) error {
s.Lock()
defer s.Unlock()
if s.body == "" && s.data == nil {
s.data = make(map[string]interface{}, 1)
}
if s.data == nil {
return store.ErrYAMLNoMark
}
s.data[key] = value
return s.encode()
} | go | func (s *Secret) SetValue(key, value string) error {
s.Lock()
defer s.Unlock()
if s.body == "" && s.data == nil {
s.data = make(map[string]interface{}, 1)
}
if s.data == nil {
return store.ErrYAMLNoMark
}
s.data[key] = value
return s.encode()
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"SetValue",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"body",
"==",
"\"",
"\"",
"&&",
"s",
"."... | // SetValue sets a key to a given value. Will fail if an non-empty body exists | [
"SetValue",
"sets",
"a",
"key",
"to",
"a",
"given",
"value",
".",
"Will",
"fail",
"if",
"an",
"non",
"-",
"empty",
"body",
"exists"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/yaml.go#L33-L45 | train |
gopasspw/gopass | pkg/store/secret/yaml.go | DeleteKey | func (s *Secret) DeleteKey(key string) error {
s.Lock()
defer s.Unlock()
if s.data == nil {
return store.ErrYAMLNoMark
}
delete(s.data, key)
return s.encode()
} | go | func (s *Secret) DeleteKey(key string) error {
s.Lock()
defer s.Unlock()
if s.data == nil {
return store.ErrYAMLNoMark
}
delete(s.data, key)
return s.encode()
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"DeleteKey",
"(",
"key",
"string",
")",
"error",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"data",
"==",
"nil",
"{",
"return",
"store",
".",
"ErrY... | // DeleteKey key will delete a single key from an decoded map | [
"DeleteKey",
"key",
"will",
"delete",
"a",
"single",
"key",
"from",
"an",
"decoded",
"map"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/yaml.go#L48-L57 | train |
gopasspw/gopass | pkg/store/secret/yaml.go | decodeYAML | func (s *Secret) decodeYAML() (bool, error) {
if !strings.HasPrefix(s.body, "---\n") && s.password != "---" {
return false, nil
}
d := make(map[string]interface{})
err := yaml.Unmarshal([]byte(s.body), &d)
if err != nil {
return true, err
}
s.data = d
return true, nil
} | go | func (s *Secret) decodeYAML() (bool, error) {
if !strings.HasPrefix(s.body, "---\n") && s.password != "---" {
return false, nil
}
d := make(map[string]interface{})
err := yaml.Unmarshal([]byte(s.body), &d)
if err != nil {
return true, err
}
s.data = d
return true, nil
} | [
"func",
"(",
"s",
"*",
"Secret",
")",
"decodeYAML",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"s",
".",
"body",
",",
"\"",
"\\n",
"\"",
")",
"&&",
"s",
".",
"password",
"!=",
"\"",
"\"",
"{",
... | // decodeYAML attempts to decode an optional YAML part of a secret | [
"decodeYAML",
"attempts",
"to",
"decode",
"an",
"optional",
"YAML",
"part",
"of",
"a",
"secret"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/yaml.go#L60-L71 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/openpgp/keyring.go | ListPublicKeyIDs | func (g *GPG) ListPublicKeyIDs(context.Context) ([]string, error) {
if g.pubring == nil {
return nil, fmt.Errorf("pubring is not initialized")
}
ids := listKeyIDs(g.pubring)
if g.secring != nil {
ids = append(ids, listKeyIDs(g.secring)...)
}
return ids, nil
} | go | func (g *GPG) ListPublicKeyIDs(context.Context) ([]string, error) {
if g.pubring == nil {
return nil, fmt.Errorf("pubring is not initialized")
}
ids := listKeyIDs(g.pubring)
if g.secring != nil {
ids = append(ids, listKeyIDs(g.secring)...)
}
return ids, nil
} | [
"func",
"(",
"g",
"*",
"GPG",
")",
"ListPublicKeyIDs",
"(",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"g",
".",
"pubring",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",... | // ListPublicKeyIDs does nothing | [
"ListPublicKeyIDs",
"does",
"nothing"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/openpgp/keyring.go#L15-L24 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/openpgp/keyring.go | KeysByIdUsage | func (g *GPG) KeysByIdUsage(id uint64, requiredUsage byte) []openpgp.Key {
return append(g.secring.KeysByIdUsage(id, requiredUsage), g.pubring.KeysByIdUsage(id, requiredUsage)...)
} | go | func (g *GPG) KeysByIdUsage(id uint64, requiredUsage byte) []openpgp.Key {
return append(g.secring.KeysByIdUsage(id, requiredUsage), g.pubring.KeysByIdUsage(id, requiredUsage)...)
} | [
"func",
"(",
"g",
"*",
"GPG",
")",
"KeysByIdUsage",
"(",
"id",
"uint64",
",",
"requiredUsage",
"byte",
")",
"[",
"]",
"openpgp",
".",
"Key",
"{",
"return",
"append",
"(",
"g",
".",
"secring",
".",
"KeysByIdUsage",
"(",
"id",
",",
"requiredUsage",
")",
... | // KeysByIdUsage implements openpgp.Keyring | [
"KeysByIdUsage",
"implements",
"openpgp",
".",
"Keyring"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/openpgp/keyring.go#L137-L139 | train |
gopasspw/gopass | pkg/backend/crypto/gpg/openpgp/keyring.go | SigningKeys | func (g *GPG) SigningKeys() []openpgp.Key {
keys := []openpgp.Key{}
for _, e := range g.secring {
for _, subKey := range e.Subkeys {
if subKey.PrivateKey != nil && (!subKey.Sig.FlagsValid || subKey.Sig.FlagSign) {
keys = append(keys, openpgp.Key{
Entity: e,
PublicKey: subKey.PublicKey,
... | go | func (g *GPG) SigningKeys() []openpgp.Key {
keys := []openpgp.Key{}
for _, e := range g.secring {
for _, subKey := range e.Subkeys {
if subKey.PrivateKey != nil && (!subKey.Sig.FlagsValid || subKey.Sig.FlagSign) {
keys = append(keys, openpgp.Key{
Entity: e,
PublicKey: subKey.PublicKey,
... | [
"func",
"(",
"g",
"*",
"GPG",
")",
"SigningKeys",
"(",
")",
"[",
"]",
"openpgp",
".",
"Key",
"{",
"keys",
":=",
"[",
"]",
"openpgp",
".",
"Key",
"{",
"}",
"\n",
"for",
"_",
",",
"e",
":=",
"range",
"g",
".",
"secring",
"{",
"for",
"_",
",",
... | // SigningKeys returns a list of signing keys | [
"SigningKeys",
"returns",
"a",
"list",
"of",
"signing",
"keys"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/openpgp/keyring.go#L149-L164 | train |
gopasspw/gopass | pkg/jsonapi/helpers.go | isPublicSuffix | func isPublicSuffix(host string) bool {
suffix, _ := publicsuffix.PublicSuffix(host)
return host == suffix
} | go | func isPublicSuffix(host string) bool {
suffix, _ := publicsuffix.PublicSuffix(host)
return host == suffix
} | [
"func",
"isPublicSuffix",
"(",
"host",
"string",
")",
"bool",
"{",
"suffix",
",",
"_",
":=",
"publicsuffix",
".",
"PublicSuffix",
"(",
"host",
")",
"\n",
"return",
"host",
"==",
"suffix",
"\n",
"}"
] | // isPublicSuffix returns true if this host is one users can or could directly
// register names | [
"isPublicSuffix",
"returns",
"true",
"if",
"this",
"host",
"is",
"one",
"users",
"can",
"or",
"could",
"directly",
"register",
"names"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/jsonapi/helpers.go#L12-L15 | train |
gopasspw/gopass | pkg/store/sub/recipients.go | Recipients | func (s *Store) Recipients(ctx context.Context) []string {
rs, err := s.GetRecipients(ctx, "")
if err != nil {
out.Error(ctx, "failed to read recipient list: %s", err)
}
return rs
} | go | func (s *Store) Recipients(ctx context.Context) []string {
rs, err := s.GetRecipients(ctx, "")
if err != nil {
out.Error(ctx, "failed to read recipient list: %s", err)
}
return rs
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Recipients",
"(",
"ctx",
"context",
".",
"Context",
")",
"[",
"]",
"string",
"{",
"rs",
",",
"err",
":=",
"s",
".",
"GetRecipients",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"o... | // Recipients returns the list of recipients of this store | [
"Recipients",
"returns",
"the",
"list",
"of",
"recipients",
"of",
"this",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/recipients.go#L30-L36 | train |
gopasspw/gopass | pkg/store/sub/recipients.go | AddRecipient | func (s *Store) AddRecipient(ctx context.Context, id string) error {
rs, err := s.GetRecipients(ctx, "")
if err != nil {
return errors.Wrapf(err, "failed to read recipient list")
}
for _, k := range rs {
if k == id {
return errors.Errorf("Recipient already in store")
}
}
rs = append(rs, id)
if err :=... | go | func (s *Store) AddRecipient(ctx context.Context, id string) error {
rs, err := s.GetRecipients(ctx, "")
if err != nil {
return errors.Wrapf(err, "failed to read recipient list")
}
for _, k := range rs {
if k == id {
return errors.Errorf("Recipient already in store")
}
}
rs = append(rs, id)
if err :=... | [
"func",
"(",
"s",
"*",
"Store",
")",
"AddRecipient",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"error",
"{",
"rs",
",",
"err",
":=",
"s",
".",
"GetRecipients",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil... | // AddRecipient adds a new recipient to the list | [
"AddRecipient",
"adds",
"a",
"new",
"recipient",
"to",
"the",
"list"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/recipients.go#L39-L59 | train |
gopasspw/gopass | pkg/store/sub/recipients.go | SaveRecipients | func (s *Store) SaveRecipients(ctx context.Context) error {
rs, err := s.GetRecipients(ctx, "")
if err != nil {
return errors.Wrapf(err, "failed to get recipients")
}
return s.saveRecipients(ctx, rs, "Save Recipients", true)
} | go | func (s *Store) SaveRecipients(ctx context.Context) error {
rs, err := s.GetRecipients(ctx, "")
if err != nil {
return errors.Wrapf(err, "failed to get recipients")
}
return s.saveRecipients(ctx, rs, "Save Recipients", true)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"SaveRecipients",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"rs",
",",
"err",
":=",
"s",
".",
"GetRecipients",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"... | // SaveRecipients persists the current recipients on disk | [
"SaveRecipients",
"persists",
"the",
"current",
"recipients",
"on",
"disk"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/recipients.go#L62-L68 | train |
gopasspw/gopass | pkg/store/sub/recipients.go | SetRecipients | func (s *Store) SetRecipients(ctx context.Context, rs []string) error {
return s.saveRecipients(ctx, rs, "Set Recipients", true)
} | go | func (s *Store) SetRecipients(ctx context.Context, rs []string) error {
return s.saveRecipients(ctx, rs, "Set Recipients", true)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"SetRecipients",
"(",
"ctx",
"context",
".",
"Context",
",",
"rs",
"[",
"]",
"string",
")",
"error",
"{",
"return",
"s",
".",
"saveRecipients",
"(",
"ctx",
",",
"rs",
",",
"\"",
"\"",
",",
"true",
")",
"\n",
"... | // SetRecipients will update the stored recipients and the associated checksum | [
"SetRecipients",
"will",
"update",
"the",
"stored",
"recipients",
"and",
"the",
"associated",
"checksum"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/recipients.go#L71-L73 | train |
gopasspw/gopass | pkg/store/sub/recipients.go | RemoveRecipient | func (s *Store) RemoveRecipient(ctx context.Context, id string) error {
keys, err := s.crypto.FindPublicKeys(ctx, id)
if err != nil {
out.Cyan(ctx, "Warning: Failed to get GPG Key Info for %s: %s", id, err)
}
rs, err := s.GetRecipients(ctx, "")
if err != nil {
return errors.Wrapf(err, "failed to read recipien... | go | func (s *Store) RemoveRecipient(ctx context.Context, id string) error {
keys, err := s.crypto.FindPublicKeys(ctx, id)
if err != nil {
out.Cyan(ctx, "Warning: Failed to get GPG Key Info for %s: %s", id, err)
}
rs, err := s.GetRecipients(ctx, "")
if err != nil {
return errors.Wrapf(err, "failed to read recipien... | [
"func",
"(",
"s",
"*",
"Store",
")",
"RemoveRecipient",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"error",
"{",
"keys",
",",
"err",
":=",
"s",
".",
"crypto",
".",
"FindPublicKeys",
"(",
"ctx",
",",
"id",
")",
"\n",
"if",
"err... | // RemoveRecipient will remove the given recipient from the store
// but if this key is not available on this machine we
// just try to remove it literally | [
"RemoveRecipient",
"will",
"remove",
"the",
"given",
"recipient",
"from",
"the",
"store",
"but",
"if",
"this",
"key",
"is",
"not",
"available",
"on",
"this",
"machine",
"we",
"just",
"try",
"to",
"remove",
"it",
"literally"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/recipients.go#L78-L114 | train |
gopasspw/gopass | pkg/store/sub/recipients.go | ExportMissingPublicKeys | func (s *Store) ExportMissingPublicKeys(ctx context.Context, rs []string) (bool, error) {
ok := true
exported := false
for _, r := range rs {
if r == "" {
continue
}
path, err := s.exportPublicKey(ctx, r)
if err != nil {
ok = false
out.Error(ctx, "failed to export public key for '%s': %s", r, err)
... | go | func (s *Store) ExportMissingPublicKeys(ctx context.Context, rs []string) (bool, error) {
ok := true
exported := false
for _, r := range rs {
if r == "" {
continue
}
path, err := s.exportPublicKey(ctx, r)
if err != nil {
ok = false
out.Error(ctx, "failed to export public key for '%s': %s", r, err)
... | [
"func",
"(",
"s",
"*",
"Store",
")",
"ExportMissingPublicKeys",
"(",
"ctx",
"context",
".",
"Context",
",",
"rs",
"[",
"]",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"ok",
":=",
"true",
"\n",
"exported",
":=",
"false",
"\n",
"for",
"_",
"... | // ExportMissingPublicKeys will export any possibly missing public keys to the
// stores .public-keys directory | [
"ExportMissingPublicKeys",
"will",
"export",
"any",
"possibly",
"missing",
"public",
"keys",
"to",
"the",
"stores",
".",
"public",
"-",
"keys",
"directory"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/recipients.go#L179-L215 | train |
gopasspw/gopass | pkg/store/sub/recipients.go | unmarshalRecipients | func unmarshalRecipients(buf []byte) []string {
m := make(map[string]struct{}, 5)
scanner := bufio.NewScanner(bytes.NewReader(buf))
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line != "" {
// deduplicate
m[line] = struct{}{}
}
}
lst := make([]string, 0, len(m))
for k := range m... | go | func unmarshalRecipients(buf []byte) []string {
m := make(map[string]struct{}, 5)
scanner := bufio.NewScanner(bytes.NewReader(buf))
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line != "" {
// deduplicate
m[line] = struct{}{}
}
}
lst := make([]string, 0, len(m))
for k := range m... | [
"func",
"unmarshalRecipients",
"(",
"buf",
"[",
"]",
"byte",
")",
"[",
"]",
"string",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"5",
")",
"\n",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"bytes",
".",
... | // unmarshal Recipients line by line from a io.Reader. | [
"unmarshal",
"Recipients",
"line",
"by",
"line",
"from",
"a",
"io",
".",
"Reader",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/recipients.go#L302-L322 | train |
gopasspw/gopass | pkg/out/print.go | Print | func Print(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprintf(Stdout, Prefix(ctx)+format+newline(ctx), args...)
} | go | func Print(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprintf(Stdout, Prefix(ctx)+format+newline(ctx), args...)
} | [
"func",
"Print",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}"... | // Print formats and prints the given string | [
"Print",
"formats",
"and",
"prints",
"the",
"given",
"string"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L31-L36 | train |
gopasspw/gopass | pkg/out/print.go | Debug | func Debug(ctx context.Context, format string, args ...interface{}) {
if !ctxutil.IsDebug(ctx) {
return
}
var loc string
if _, file, line, ok := runtime.Caller(1); ok {
file = file[strings.Index(file, "pkg/"):]
file = strings.TrimPrefix(file, "pkg/")
loc = fmt.Sprintf("%s:%d ", file, line)
}
fmt.Fprintf... | go | func Debug(ctx context.Context, format string, args ...interface{}) {
if !ctxutil.IsDebug(ctx) {
return
}
var loc string
if _, file, line, ok := runtime.Caller(1); ok {
file = file[strings.Index(file, "pkg/"):]
file = strings.TrimPrefix(file, "pkg/")
loc = fmt.Sprintf("%s:%d ", file, line)
}
fmt.Fprintf... | [
"func",
"Debug",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"var",
"loc",
"string",
"... | // Debug prints the given string if the debug flag is set | [
"Debug",
"prints",
"the",
"given",
"string",
"if",
"the",
"debug",
"flag",
"is",
"set"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L39-L52 | train |
gopasspw/gopass | pkg/out/print.go | Black | func Black(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.BlackString(Prefix(ctx)+format+newline(ctx), args...))
} | go | func Black(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.BlackString(Prefix(ctx)+format+newline(ctx), args...))
} | [
"func",
"Black",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}"... | // Black prints the string in black | [
"Black",
"prints",
"the",
"string",
"in",
"black"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L55-L60 | train |
gopasspw/gopass | pkg/out/print.go | Blue | func Blue(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.BlueString(Prefix(ctx)+format+newline(ctx), args...))
} | go | func Blue(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.BlueString(Prefix(ctx)+format+newline(ctx), args...))
} | [
"func",
"Blue",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}",... | // Blue prints the string in blue | [
"Blue",
"prints",
"the",
"string",
"in",
"blue"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L63-L68 | train |
gopasspw/gopass | pkg/out/print.go | Cyan | func Cyan(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.CyanString(Prefix(ctx)+format+newline(ctx), args...))
} | go | func Cyan(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.CyanString(Prefix(ctx)+format+newline(ctx), args...))
} | [
"func",
"Cyan",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}",... | // Cyan prints the string in cyan | [
"Cyan",
"prints",
"the",
"string",
"in",
"cyan"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L71-L76 | train |
gopasspw/gopass | pkg/out/print.go | Green | func Green(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.GreenString(Prefix(ctx)+format+newline(ctx), args...))
} | go | func Green(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.GreenString(Prefix(ctx)+format+newline(ctx), args...))
} | [
"func",
"Green",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}"... | // Green prints the string in green | [
"Green",
"prints",
"the",
"string",
"in",
"green"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L79-L84 | train |
gopasspw/gopass | pkg/out/print.go | Magenta | func Magenta(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.MagentaString(Prefix(ctx)+format+newline(ctx), args...))
} | go | func Magenta(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.MagentaString(Prefix(ctx)+format+newline(ctx), args...))
} | [
"func",
"Magenta",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"... | // Magenta prints the string in magenta | [
"Magenta",
"prints",
"the",
"string",
"in",
"magenta"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L87-L92 | train |
gopasspw/gopass | pkg/out/print.go | Red | func Red(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.RedString(Prefix(ctx)+format+newline(ctx), args...))
} | go | func Red(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.RedString(Prefix(ctx)+format+newline(ctx), args...))
} | [
"func",
"Red",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}",
... | // Red prints the string in red | [
"Red",
"prints",
"the",
"string",
"in",
"red"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L95-L100 | train |
gopasspw/gopass | pkg/out/print.go | Error | func Error(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stderr, color.RedString(Prefix(ctx)+format+newline(ctx), args...))
} | go | func Error(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stderr, color.RedString(Prefix(ctx)+format+newline(ctx), args...))
} | [
"func",
"Error",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}"... | // Error prints the string in red to stderr | [
"Error",
"prints",
"the",
"string",
"in",
"red",
"to",
"stderr"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L103-L108 | train |
gopasspw/gopass | pkg/out/print.go | White | func White(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.WhiteString(Prefix(ctx)+format+newline(ctx), args...))
} | go | func White(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.WhiteString(Prefix(ctx)+format+newline(ctx), args...))
} | [
"func",
"White",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}"... | // White prints the string in white | [
"White",
"prints",
"the",
"string",
"in",
"white"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L111-L116 | train |
gopasspw/gopass | pkg/out/print.go | Yellow | func Yellow(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.YellowString(Prefix(ctx)+format+newline(ctx), args...))
} | go | func Yellow(ctx context.Context, format string, args ...interface{}) {
if IsHidden(ctx) && !ctxutil.IsDebug(ctx) {
return
}
fmt.Fprint(Stdout, color.YellowString(Prefix(ctx)+format+newline(ctx), args...))
} | [
"func",
"Yellow",
"(",
"ctx",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"IsHidden",
"(",
"ctx",
")",
"&&",
"!",
"ctxutil",
".",
"IsDebug",
"(",
"ctx",
")",
"{",
"return",
"\n",
"}... | // Yellow prints the string in yellow | [
"Yellow",
"prints",
"the",
"string",
"in",
"yellow"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/out/print.go#L119-L124 | train |
gopasspw/gopass | pkg/tree/simple/folder.go | Len | func (f *Folder) Len() int {
l := len(f.Files)
for _, f := range f.Folders {
l += f.Len()
}
return l
} | go | func (f *Folder) Len() int {
l := len(f.Files)
for _, f := range f.Folders {
l += f.Len()
}
return l
} | [
"func",
"(",
"f",
"*",
"Folder",
")",
"Len",
"(",
")",
"int",
"{",
"l",
":=",
"len",
"(",
"f",
".",
"Files",
")",
"\n",
"for",
"_",
",",
"f",
":=",
"range",
"f",
".",
"Folders",
"{",
"l",
"+=",
"f",
".",
"Len",
"(",
")",
"\n",
"}",
"\n",
... | // Len returns the number of entries in this folder and all subfolder including
// this folder itself | [
"Len",
"returns",
"the",
"number",
"of",
"entries",
"in",
"this",
"folder",
"and",
"all",
"subfolder",
"including",
"this",
"folder",
"itself"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/folder.go#L26-L32 | train |
gopasspw/gopass | pkg/tree/simple/folder.go | Format | func (f *Folder) Format(maxDepth int) string {
return f.format("", true, maxDepth, 0)
} | go | func (f *Folder) Format(maxDepth int) string {
return f.format("", true, maxDepth, 0)
} | [
"func",
"(",
"f",
"*",
"Folder",
")",
"Format",
"(",
"maxDepth",
"int",
")",
"string",
"{",
"return",
"f",
".",
"format",
"(",
"\"",
"\"",
",",
"true",
",",
"maxDepth",
",",
"0",
")",
"\n",
"}"
] | // Format returns a pretty printed tree | [
"Format",
"returns",
"a",
"pretty",
"printed",
"tree"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/folder.go#L48-L50 | train |
gopasspw/gopass | pkg/tree/simple/folder.go | AddFile | func (f *Folder) AddFile(name string, contentType string) error {
return f.addFile(strings.Split(name, sep), contentType)
} | go | func (f *Folder) AddFile(name string, contentType string) error {
return f.addFile(strings.Split(name, sep), contentType)
} | [
"func",
"(",
"f",
"*",
"Folder",
")",
"AddFile",
"(",
"name",
"string",
",",
"contentType",
"string",
")",
"error",
"{",
"return",
"f",
".",
"addFile",
"(",
"strings",
".",
"Split",
"(",
"name",
",",
"sep",
")",
",",
"contentType",
")",
"\n",
"}"
] | // AddFile adds a new file | [
"AddFile",
"adds",
"a",
"new",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/folder.go#L58-L60 | train |
gopasspw/gopass | pkg/tree/simple/folder.go | AddTemplate | func (f *Folder) AddTemplate(name string) error {
return f.addTemplate(strings.Split(name, sep))
} | go | func (f *Folder) AddTemplate(name string) error {
return f.addTemplate(strings.Split(name, sep))
} | [
"func",
"(",
"f",
"*",
"Folder",
")",
"AddTemplate",
"(",
"name",
"string",
")",
"error",
"{",
"return",
"f",
".",
"addTemplate",
"(",
"strings",
".",
"Split",
"(",
"name",
",",
"sep",
")",
")",
"\n",
"}"
] | // AddTemplate adds a new template | [
"AddTemplate",
"adds",
"a",
"new",
"template"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/folder.go#L68-L70 | train |
gopasspw/gopass | pkg/tree/simple/folder.go | newFolder | func newFolder(name string) *Folder {
return &Folder{
Name: name,
Path: "",
Folders: make(map[string]*Folder, 10),
Files: make(map[string]*File, 10),
}
} | go | func newFolder(name string) *Folder {
return &Folder{
Name: name,
Path: "",
Folders: make(map[string]*Folder, 10),
Files: make(map[string]*File, 10),
}
} | [
"func",
"newFolder",
"(",
"name",
"string",
")",
"*",
"Folder",
"{",
"return",
"&",
"Folder",
"{",
"Name",
":",
"name",
",",
"Path",
":",
"\"",
"\"",
",",
"Folders",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Folder",
",",
"10",
")",
",",... | // newFolder creates a new, initialized folder | [
"newFolder",
"creates",
"a",
"new",
"initialized",
"folder"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/folder.go#L73-L80 | train |
gopasspw/gopass | pkg/tree/simple/folder.go | getFolder | func (f *Folder) getFolder(name string) *Folder {
if next, found := f.Folders[name]; found {
return next
}
next := newFolder(name)
f.Folders[name] = next
return next
} | go | func (f *Folder) getFolder(name string) *Folder {
if next, found := f.Folders[name]; found {
return next
}
next := newFolder(name)
f.Folders[name] = next
return next
} | [
"func",
"(",
"f",
"*",
"Folder",
")",
"getFolder",
"(",
"name",
"string",
")",
"*",
"Folder",
"{",
"if",
"next",
",",
"found",
":=",
"f",
".",
"Folders",
"[",
"name",
"]",
";",
"found",
"{",
"return",
"next",
"\n",
"}",
"\n",
"next",
":=",
"newFo... | // getFolder returns a direct sub-folder within this folder.
// name MUST NOT include filepath separators. If there is no
// such folder a new one is created with that name. | [
"getFolder",
"returns",
"a",
"direct",
"sub",
"-",
"folder",
"within",
"this",
"folder",
".",
"name",
"MUST",
"NOT",
"include",
"filepath",
"separators",
".",
"If",
"there",
"is",
"no",
"such",
"folder",
"a",
"new",
"one",
"is",
"created",
"with",
"that",
... | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/folder.go#L193-L200 | train |
gopasspw/gopass | pkg/tree/simple/folder.go | FindFolder | func (f *Folder) FindFolder(name string) (tree.Tree, error) {
sub := f.findFolder(strings.Split(strings.TrimSuffix(name, sep), sep))
if sub == nil {
return nil, errors.Errorf("Entry not found")
}
return sub, nil
} | go | func (f *Folder) FindFolder(name string) (tree.Tree, error) {
sub := f.findFolder(strings.Split(strings.TrimSuffix(name, sep), sep))
if sub == nil {
return nil, errors.Errorf("Entry not found")
}
return sub, nil
} | [
"func",
"(",
"f",
"*",
"Folder",
")",
"FindFolder",
"(",
"name",
"string",
")",
"(",
"tree",
".",
"Tree",
",",
"error",
")",
"{",
"sub",
":=",
"f",
".",
"findFolder",
"(",
"strings",
".",
"Split",
"(",
"strings",
".",
"TrimSuffix",
"(",
"name",
","... | // FindFolder returns a sub-tree or nil, if the subtree does not exist | [
"FindFolder",
"returns",
"a",
"sub",
"-",
"tree",
"or",
"nil",
"if",
"the",
"subtree",
"does",
"not",
"exist"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/folder.go#L203-L209 | train |
gopasspw/gopass | pkg/tree/simple/folder.go | findFolder | func (f *Folder) findFolder(path []string) *Folder {
if len(path) < 1 {
return f
}
name := path[0]
if next, found := f.Folders[name]; found {
return next.findFolder(path[1:])
}
return nil
} | go | func (f *Folder) findFolder(path []string) *Folder {
if len(path) < 1 {
return f
}
name := path[0]
if next, found := f.Folders[name]; found {
return next.findFolder(path[1:])
}
return nil
} | [
"func",
"(",
"f",
"*",
"Folder",
")",
"findFolder",
"(",
"path",
"[",
"]",
"string",
")",
"*",
"Folder",
"{",
"if",
"len",
"(",
"path",
")",
"<",
"1",
"{",
"return",
"f",
"\n",
"}",
"\n",
"name",
":=",
"path",
"[",
"0",
"]",
"\n",
"if",
"next... | // findFolder recursively tries to find the named sub-folder | [
"findFolder",
"recursively",
"tries",
"to",
"find",
"the",
"named",
"sub",
"-",
"folder"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/folder.go#L212-L221 | train |
gopasspw/gopass | pkg/tree/simple/folder.go | addFile | func (f *Folder) addFile(path []string, contentType string) error {
if len(path) < 1 {
return errors.Errorf("Path must not be empty")
}
name := path[0]
if len(path) == 1 {
if _, found := f.Files[name]; found {
return errors.Errorf("File %s exists", name)
}
f.Files[name] = &File{
Name: name,
Metadat... | go | func (f *Folder) addFile(path []string, contentType string) error {
if len(path) < 1 {
return errors.Errorf("Path must not be empty")
}
name := path[0]
if len(path) == 1 {
if _, found := f.Files[name]; found {
return errors.Errorf("File %s exists", name)
}
f.Files[name] = &File{
Name: name,
Metadat... | [
"func",
"(",
"f",
"*",
"Folder",
")",
"addFile",
"(",
"path",
"[",
"]",
"string",
",",
"contentType",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"path",
")",
"<",
"1",
"{",
"return",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
... | // addFile adds new file | [
"addFile",
"adds",
"new",
"file"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/tree/simple/folder.go#L224-L243 | train |
gopasspw/gopass | pkg/jsonapi/api.go | ReadAndRespond | func (api *API) ReadAndRespond(ctx context.Context) error {
silentCtx := out.WithHidden(ctx, true)
message, err := readMessage(api.Reader)
if message == nil || err != nil {
return err
}
return api.respondMessage(silentCtx, message)
} | go | func (api *API) ReadAndRespond(ctx context.Context) error {
silentCtx := out.WithHidden(ctx, true)
message, err := readMessage(api.Reader)
if message == nil || err != nil {
return err
}
return api.respondMessage(silentCtx, message)
} | [
"func",
"(",
"api",
"*",
"API",
")",
"ReadAndRespond",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"silentCtx",
":=",
"out",
".",
"WithHidden",
"(",
"ctx",
",",
"true",
")",
"\n",
"message",
",",
"err",
":=",
"readMessage",
"(",
"api",
... | // ReadAndRespond a single message | [
"ReadAndRespond",
"a",
"single",
"message"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/jsonapi/api.go#L21-L29 | train |
gopasspw/gopass | pkg/jsonapi/api.go | RespondError | func (api *API) RespondError(err error) error {
var response errorResponse
response.Error = err.Error()
return sendSerializedJSONMessage(response, api.Writer)
} | go | func (api *API) RespondError(err error) error {
var response errorResponse
response.Error = err.Error()
return sendSerializedJSONMessage(response, api.Writer)
} | [
"func",
"(",
"api",
"*",
"API",
")",
"RespondError",
"(",
"err",
"error",
")",
"error",
"{",
"var",
"response",
"errorResponse",
"\n",
"response",
".",
"Error",
"=",
"err",
".",
"Error",
"(",
")",
"\n\n",
"return",
"sendSerializedJSONMessage",
"(",
"respon... | // RespondError sends err as JSON response | [
"RespondError",
"sends",
"err",
"as",
"JSON",
"response"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/jsonapi/api.go#L32-L37 | train |
gopasspw/gopass | pkg/pinentry/pinentry.go | New | func New() (*Client, error) {
cmd := exec.Command(GetBinary())
stdin, err := cmd.StdinPipe()
if err != nil {
return nil, err
}
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, err
}
br := bufio.NewReader(stdout)
if err := cmd.Start(); err != nil {
return nil, err
}
// check welcome messag... | go | func New() (*Client, error) {
cmd := exec.Command(GetBinary())
stdin, err := cmd.StdinPipe()
if err != nil {
return nil, err
}
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, err
}
br := bufio.NewReader(stdout)
if err := cmd.Start(); err != nil {
return nil, err
}
// check welcome messag... | [
"func",
"New",
"(",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"GetBinary",
"(",
")",
")",
"\n",
"stdin",
",",
"err",
":=",
"cmd",
".",
"StdinPipe",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // New creates a new pinentry client | [
"New",
"creates",
"a",
"new",
"pinentry",
"client"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/pinentry/pinentry.go#L22-L55 | train |
gopasspw/gopass | pkg/pinentry/pinentry.go | Confirm | func (c *Client) Confirm() bool {
if err := c.Set("confirm", ""); err == nil {
return true
}
return false
} | go | func (c *Client) Confirm() bool {
if err := c.Set("confirm", ""); err == nil {
return true
}
return false
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Confirm",
"(",
")",
"bool",
"{",
"if",
"err",
":=",
"c",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // Confirm sends the confirm message | [
"Confirm",
"sends",
"the",
"confirm",
"message"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/pinentry/pinentry.go#L63-L68 | train |
gopasspw/gopass | pkg/pinentry/pinentry.go | Set | func (c *Client) Set(key, value string) error {
key = strings.ToUpper(key)
if value != "" {
value = " " + value
}
val := "SET" + key + value + "\n"
if _, err := c.in.Write([]byte(val)); err != nil {
return err
}
line, _, _ := c.out.ReadLine()
if string(line) != "OK" {
return errors.Errorf("error: %s", lin... | go | func (c *Client) Set(key, value string) error {
key = strings.ToUpper(key)
if value != "" {
value = " " + value
}
val := "SET" + key + value + "\n"
if _, err := c.in.Write([]byte(val)); err != nil {
return err
}
line, _, _ := c.out.ReadLine()
if string(line) != "OK" {
return errors.Errorf("error: %s", lin... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Set",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"key",
"=",
"strings",
".",
"ToUpper",
"(",
"key",
")",
"\n",
"if",
"value",
"!=",
"\"",
"\"",
"{",
"value",
"=",
"\"",
"\"",
"+",
"value",
"\n"... | // Set sets a key | [
"Set",
"sets",
"a",
"key"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/pinentry/pinentry.go#L71-L85 | train |
gopasspw/gopass | pkg/pinentry/pinentry.go | GetPin | func (c *Client) GetPin() ([]byte, error) {
if _, err := c.in.Write([]byte("GETPIN\n")); err != nil {
return nil, err
}
pin, _, err := c.out.ReadLine()
if err != nil {
return nil, err
}
if bytes.HasPrefix(pin, []byte("OK")) {
return nil, nil
}
if !bytes.HasPrefix(pin, []byte("D ")) {
return nil, fmt.Err... | go | func (c *Client) GetPin() ([]byte, error) {
if _, err := c.in.Write([]byte("GETPIN\n")); err != nil {
return nil, err
}
pin, _, err := c.out.ReadLine()
if err != nil {
return nil, err
}
if bytes.HasPrefix(pin, []byte("OK")) {
return nil, nil
}
if !bytes.HasPrefix(pin, []byte("D ")) {
return nil, fmt.Err... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetPin",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"_",
",",
"err",
":=",
"c",
".",
"in",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"err",
"!=",... | // GetPin asks for the pin | [
"GetPin",
"asks",
"for",
"the",
"pin"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/pinentry/pinentry.go#L88-L111 | train |
gopasspw/gopass | pkg/action/config.go | Config | func (s *Action) Config(ctx context.Context, c *cli.Context) error {
if len(c.Args()) < 1 {
s.printConfigValues(ctx, "")
return nil
}
if len(c.Args()) == 1 {
s.printConfigValues(ctx, "", c.Args()[0])
return nil
}
if len(c.Args()) > 2 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s config key value",... | go | func (s *Action) Config(ctx context.Context, c *cli.Context) error {
if len(c.Args()) < 1 {
s.printConfigValues(ctx, "")
return nil
}
if len(c.Args()) == 1 {
s.printConfigValues(ctx, "", c.Args()[0])
return nil
}
if len(c.Args()) > 2 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s config key value",... | [
"func",
"(",
"s",
"*",
"Action",
")",
"Config",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"if",
"len",
"(",
"c",
".",
"Args",
"(",
")",
")",
"<",
"1",
"{",
"s",
".",
"printConfigValues",
"("... | // Config handles changes to the gopass configuration | [
"Config",
"handles",
"changes",
"to",
"the",
"gopass",
"configuration"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/config.go#L15-L34 | train |
gopasspw/gopass | pkg/action/config.go | ConfigComplete | func (s *Action) ConfigComplete(c *cli.Context) {
cm := s.cfg.Root.ConfigMap()
keys := make([]string, 0, len(cm))
for k := range cm {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
fmt.Fprintln(stdout, k)
}
} | go | func (s *Action) ConfigComplete(c *cli.Context) {
cm := s.cfg.Root.ConfigMap()
keys := make([]string, 0, len(cm))
for k := range cm {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
fmt.Fprintln(stdout, k)
}
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"ConfigComplete",
"(",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"cm",
":=",
"s",
".",
"cfg",
".",
"Root",
".",
"ConfigMap",
"(",
")",
"\n",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
... | // ConfigComplete will print the list of valid config keys | [
"ConfigComplete",
"will",
"print",
"the",
"list",
"of",
"valid",
"config",
"keys"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/config.go#L101-L111 | train |
gopasspw/gopass | pkg/fsutil/umask.go | Umask | func Umask() int {
for _, en := range []string{"GOPASS_UMASK", "PASSWORD_STORE_UMASK"} {
if um := os.Getenv(en); um != "" {
if iv, err := strconv.ParseInt(um, 8, 32); err == nil && iv >= 0 && iv <= 0777 {
return int(iv)
}
}
}
return 077
} | go | func Umask() int {
for _, en := range []string{"GOPASS_UMASK", "PASSWORD_STORE_UMASK"} {
if um := os.Getenv(en); um != "" {
if iv, err := strconv.ParseInt(um, 8, 32); err == nil && iv >= 0 && iv <= 0777 {
return int(iv)
}
}
}
return 077
} | [
"func",
"Umask",
"(",
")",
"int",
"{",
"for",
"_",
",",
"en",
":=",
"range",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"{",
"if",
"um",
":=",
"os",
".",
"Getenv",
"(",
"en",
")",
";",
"um",
"!=",
"\"",
"\"",
"{",
"if",
"i... | // Umask extracts the umask from env | [
"Umask",
"extracts",
"the",
"umask",
"from",
"env"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/fsutil/umask.go#L9-L18 | train |
gopasspw/gopass | pkg/store/root/init.go | Initialized | func (r *Store) Initialized(ctx context.Context) (bool, error) {
if r.store == nil {
out.Debug(ctx, "initializing store and possible sub-stores")
if err := r.initialize(ctx); err != nil {
return false, errors.Wrapf(err, "failed to initialized stores: %s", err)
}
}
return r.store.Initialized(ctx), nil
} | go | func (r *Store) Initialized(ctx context.Context) (bool, error) {
if r.store == nil {
out.Debug(ctx, "initializing store and possible sub-stores")
if err := r.initialize(ctx); err != nil {
return false, errors.Wrapf(err, "failed to initialized stores: %s", err)
}
}
return r.store.Initialized(ctx), nil
} | [
"func",
"(",
"r",
"*",
"Store",
")",
"Initialized",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"r",
".",
"store",
"==",
"nil",
"{",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"if",
... | // Initialized checks on disk if .gpg-id was generated and thus returns true. | [
"Initialized",
"checks",
"on",
"disk",
"if",
".",
"gpg",
"-",
"id",
"was",
"generated",
"and",
"thus",
"returns",
"true",
"."
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/init.go#L16-L24 | train |
gopasspw/gopass | pkg/hibp/api/client.go | Lookup | func Lookup(ctx context.Context, shaSum string) (uint64, error) {
if len(shaSum) != 40 {
return 0, errors.Errorf("invalid shasum")
}
shaSum = strings.ToUpper(shaSum)
prefix := shaSum[:5]
suffix := shaSum[5:]
var count uint64
url := fmt.Sprintf("%s/range/%s", URL, prefix)
op := func() error {
out.Debug(ct... | go | func Lookup(ctx context.Context, shaSum string) (uint64, error) {
if len(shaSum) != 40 {
return 0, errors.Errorf("invalid shasum")
}
shaSum = strings.ToUpper(shaSum)
prefix := shaSum[:5]
suffix := shaSum[5:]
var count uint64
url := fmt.Sprintf("%s/range/%s", URL, prefix)
op := func() error {
out.Debug(ct... | [
"func",
"Lookup",
"(",
"ctx",
"context",
".",
"Context",
",",
"shaSum",
"string",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"if",
"len",
"(",
"shaSum",
")",
"!=",
"40",
"{",
"return",
"0",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n... | // Lookup performs a lookup against the HIBP v2 API | [
"Lookup",
"performs",
"a",
"lookup",
"against",
"the",
"HIBP",
"v2",
"API"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/hibp/api/client.go#L22-L78 | train |
gopasspw/gopass | pkg/action/git.go | GitInit | func (s *Action) GitInit(ctx context.Context, c *cli.Context) error {
store := c.String("store")
un := c.String("username")
ue := c.String("useremail")
ctx = backend.WithRCSBackendString(ctx, c.String("rcs"))
// default to git
if !backend.HasRCSBackend(ctx) {
ctx = backend.WithRCSBackend(ctx, backend.GitCLI)
... | go | func (s *Action) GitInit(ctx context.Context, c *cli.Context) error {
store := c.String("store")
un := c.String("username")
ue := c.String("useremail")
ctx = backend.WithRCSBackendString(ctx, c.String("rcs"))
// default to git
if !backend.HasRCSBackend(ctx) {
ctx = backend.WithRCSBackend(ctx, backend.GitCLI)
... | [
"func",
"(",
"s",
"*",
"Action",
")",
"GitInit",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"store",
":=",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"un",
":=",
"c",
".",
"String",
"(",... | // GitInit initializes a git repo including basic configuration | [
"GitInit",
"initializes",
"a",
"git",
"repo",
"including",
"basic",
"configuration"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git.go#L18-L33 | train |
gopasspw/gopass | pkg/action/git.go | GitAddRemote | func (s *Action) GitAddRemote(ctx context.Context, c *cli.Context) error {
store := c.String("store")
remote := c.Args().Get(0)
url := c.Args().Get(1)
if remote == "" || url == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s git remote add <REMOTE> <URL>", s.Name)
}
return s.Store.GitAddRemote(ctx, stor... | go | func (s *Action) GitAddRemote(ctx context.Context, c *cli.Context) error {
store := c.String("store")
remote := c.Args().Get(0)
url := c.Args().Get(1)
if remote == "" || url == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s git remote add <REMOTE> <URL>", s.Name)
}
return s.Store.GitAddRemote(ctx, stor... | [
"func",
"(",
"s",
"*",
"Action",
")",
"GitAddRemote",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"store",
":=",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"remote",
":=",
"c",
".",
"Args",... | // GitAddRemote adds a new git remote | [
"GitAddRemote",
"adds",
"a",
"new",
"git",
"remote"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git.go#L79-L89 | train |
gopasspw/gopass | pkg/action/git.go | GitPull | func (s *Action) GitPull(ctx context.Context, c *cli.Context) error {
store := c.String("store")
origin := c.Args().Get(0)
branch := c.Args().Get(1)
if origin == "" {
origin = "origin"
}
if branch == "" {
branch = "master"
}
return s.Store.GitPull(ctx, store, origin, branch)
} | go | func (s *Action) GitPull(ctx context.Context, c *cli.Context) error {
store := c.String("store")
origin := c.Args().Get(0)
branch := c.Args().Get(1)
if origin == "" {
origin = "origin"
}
if branch == "" {
branch = "master"
}
return s.Store.GitPull(ctx, store, origin, branch)
} | [
"func",
"(",
"s",
"*",
"Action",
")",
"GitPull",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"store",
":=",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"origin",
":=",
"c",
".",
"Args",
"(... | // GitPull pulls from a git remote | [
"GitPull",
"pulls",
"from",
"a",
"git",
"remote"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git.go#L104-L116 | train |
gopasspw/gopass | pkg/action/git.go | GitPush | func (s *Action) GitPush(ctx context.Context, c *cli.Context) error {
store := c.String("store")
origin := c.Args().Get(0)
branch := c.Args().Get(1)
if origin == "" || branch == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s git push <ORIGIN> <BRANCH>", s.Name)
}
return s.Store.GitPush(ctx, store, origi... | go | func (s *Action) GitPush(ctx context.Context, c *cli.Context) error {
store := c.String("store")
origin := c.Args().Get(0)
branch := c.Args().Get(1)
if origin == "" || branch == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s git push <ORIGIN> <BRANCH>", s.Name)
}
return s.Store.GitPush(ctx, store, origi... | [
"func",
"(",
"s",
"*",
"Action",
")",
"GitPush",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"store",
":=",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"origin",
":=",
"c",
".",
"Args",
"(... | // GitPush pushes to a git remote | [
"GitPush",
"pushes",
"to",
"a",
"git",
"remote"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/git.go#L119-L128 | train |
gopasspw/gopass | pkg/store/sub/store.go | New | func New(ctx context.Context, sc recipientHashStorer, alias string, u *backend.URL, cfgdir string, agent *client.Client) (*Store, error) {
out.Debug(ctx, "sub.New - URL: %s", u.String())
s := &Store{
alias: alias,
url: u,
rcs: noop.New(),
cfgdir: cfgdir,
agent: agent,
sc: sc,
}
// init sto... | go | func New(ctx context.Context, sc recipientHashStorer, alias string, u *backend.URL, cfgdir string, agent *client.Client) (*Store, error) {
out.Debug(ctx, "sub.New - URL: %s", u.String())
s := &Store{
alias: alias,
url: u,
rcs: noop.New(),
cfgdir: cfgdir,
agent: agent,
sc: sc,
}
// init sto... | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"sc",
"recipientHashStorer",
",",
"alias",
"string",
",",
"u",
"*",
"backend",
".",
"URL",
",",
"cfgdir",
"string",
",",
"agent",
"*",
"client",
".",
"Client",
")",
"(",
"*",
"Store",
",",
"e... | // New creates a new store, copying settings from the given root store | [
"New",
"creates",
"a",
"new",
"store",
"copying",
"settings",
"from",
"the",
"given",
"root",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/store.go#L42-L83 | train |
gopasspw/gopass | pkg/store/sub/store.go | idFile | func (s *Store) idFile(ctx context.Context, name string) string {
fn := name
var cnt uint8
for {
cnt++
if cnt > 100 {
break
}
if fn == "" || fn == sep {
break
}
gfn := filepath.Join(fn, s.crypto.IDFile())
if s.storage.Exists(ctx, gfn) {
return gfn
}
fn = filepath.Dir(fn)
}
return s.crypt... | go | func (s *Store) idFile(ctx context.Context, name string) string {
fn := name
var cnt uint8
for {
cnt++
if cnt > 100 {
break
}
if fn == "" || fn == sep {
break
}
gfn := filepath.Join(fn, s.crypto.IDFile())
if s.storage.Exists(ctx, gfn) {
return gfn
}
fn = filepath.Dir(fn)
}
return s.crypt... | [
"func",
"(",
"s",
"*",
"Store",
")",
"idFile",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"string",
"{",
"fn",
":=",
"name",
"\n",
"var",
"cnt",
"uint8",
"\n",
"for",
"{",
"cnt",
"++",
"\n",
"if",
"cnt",
">",
"100",
"{",
... | // idFile returns the path to the recipient list for this.storage
// it walks up from the given filename until it finds a directory containing
// a gpg id file or it leaves the scope of this.storage. | [
"idFile",
"returns",
"the",
"path",
"to",
"the",
"recipient",
"list",
"for",
"this",
".",
"storage",
"it",
"walks",
"up",
"from",
"the",
"given",
"filename",
"until",
"it",
"finds",
"a",
"directory",
"containing",
"a",
"gpg",
"id",
"file",
"or",
"it",
"l... | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/store.go#L88-L106 | train |
gopasspw/gopass | pkg/store/sub/store.go | Equals | func (s *Store) Equals(other store.Store) bool {
if other == nil {
return false
}
return s.URL() == other.URL()
} | go | func (s *Store) Equals(other store.Store) bool {
if other == nil {
return false
}
return s.URL() == other.URL()
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Equals",
"(",
"other",
"store",
".",
"Store",
")",
"bool",
"{",
"if",
"other",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"s",
".",
"URL",
"(",
")",
"==",
"other",
".",
"URL",
"(",
")",... | // Equals returns true if this.storage has the same on-disk path as the other | [
"Equals",
"returns",
"true",
"if",
"this",
".",
"storage",
"has",
"the",
"same",
"on",
"-",
"disk",
"path",
"as",
"the",
"other"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/store.go#L109-L114 | train |
gopasspw/gopass | pkg/store/sub/store.go | IsDir | func (s *Store) IsDir(ctx context.Context, name string) bool {
return s.storage.IsDir(ctx, name)
} | go | func (s *Store) IsDir(ctx context.Context, name string) bool {
return s.storage.IsDir(ctx, name)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"IsDir",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"return",
"s",
".",
"storage",
".",
"IsDir",
"(",
"ctx",
",",
"name",
")",
"\n",
"}"
] | // IsDir returns true if the entry is folder inside the store | [
"IsDir",
"returns",
"true",
"if",
"the",
"entry",
"is",
"folder",
"inside",
"the",
"store"
] | fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4 | https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/sub/store.go#L117-L119 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.