Documentation ¶
Overview ¶
Example ¶
package main import ( "context" "fmt" "github.com/gopasspw/gopass/pkg/gopass/api" "github.com/gopasspw/gopass/pkg/gopass/secrets" ) func main() { //nolint:testableexamples ctx := context.Background() gp, err := api.New(ctx) if err != nil { panic(err) } // Listing secrets ls, err := gp.List(ctx) if err != nil { panic(err) } for _, s := range ls { fmt.Printf("Secret: %s", s) } // Writing secrets sec := secrets.New() sec.SetPassword("foobar") if err := gp.Set(ctx, "my/new/secret", sec); err != nil { panic(err) } // Reading secrets sec, err = gp.Get(ctx, "my/new/secret", "latest") if err != nil { panic(err) } fmt.Printf("content of %s: %s\n", "my/new/secret", string(sec.Bytes())) // Removing a secret if err := gp.Remove(ctx, "my/new/secret"); err != nil { panic(err) } // Cleaning up if err := gp.Close(ctx); err != nil { panic(err) } }
Output:
Index ¶
- Variables
- func ConfigDir() string
- type Gopass
- func (g *Gopass) Close(ctx context.Context) error
- func (g *Gopass) Get(ctx context.Context, name, revision string) (gopass.Secret, error)
- func (g *Gopass) List(ctx context.Context) ([]string, error)
- func (g *Gopass) Remove(ctx context.Context, name string) error
- func (g *Gopass) RemoveAll(ctx context.Context, prefix string) error
- func (g *Gopass) Rename(ctx context.Context, src, dest string) error
- func (g *Gopass) Revisions(ctx context.Context, name string) ([]string, error)
- func (g *Gopass) Set(ctx context.Context, name string, sec gopass.Byter) error
- func (g *Gopass) String() string
- func (g *Gopass) Sync(ctx context.Context) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = fmt.Errorf("not yet implemented")
ErrNotImplemented is returned when a method is not implemented.
var ErrNotInitialized = fmt.Errorf("password store not initialized. run 'gopass setup' first")
ErrNotInitialized is returned when the store is not initialized.
Functions ¶
Types ¶
type Gopass ¶
type Gopass struct {
// contains filtered or unexported fields
}
Gopass is a secret store implementation.
func New ¶
New initializes an existing password store. It will attempt to load an existing configuration or use the built-in defaults. If no password store is found and the user will need to initialize it with the gopass CLI (`gopass setup`) first.
WARNING: This will need to change to accommodate for runtime configuration.
func (*Gopass) Close ¶
Close shuts down all background processes.
MUST be called before existing to make sure any background processing (e.g. pending commits or pushes) are complete. Failing to do so might result in an invalid password store state.
func (*Gopass) Get ¶
Get returns a single, encrypted secret. It must be unwrapped before use. Use "latest" to get the latest revision.