mirror of
https://github.com/containers/podman.git
synced 2025-11-14 10:09:20 +08:00
Vendor in containers/(storage,image, common, buildah)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
14
vendor/github.com/containers/common/pkg/secrets/passdriver/passdriver.go
generated
vendored
14
vendor/github.com/containers/common/pkg/secrets/passdriver/passdriver.go
generated
vendored
@@ -3,6 +3,8 @@ package passdriver
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -10,8 +12,6 @@ import (
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -108,7 +108,7 @@ func NewDriver(opts map[string]string) (*Driver, error) {
|
||||
func (d *Driver) List() (secrets []string, err error) {
|
||||
files, err := ioutil.ReadDir(d.Root)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to read secret directory")
|
||||
return nil, fmt.Errorf("failed to read secret directory: %w", err)
|
||||
}
|
||||
for _, f := range files {
|
||||
fileName := f.Name()
|
||||
@@ -127,10 +127,10 @@ func (d *Driver) Lookup(id string) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
if err := d.gpg(context.TODO(), nil, out, "--decrypt", key); err != nil {
|
||||
return nil, errors.Wrapf(errNoSecretData, id)
|
||||
return nil, fmt.Errorf("%s: %w", id, errNoSecretData)
|
||||
}
|
||||
if out.Len() == 0 {
|
||||
return nil, errors.Wrapf(errNoSecretData, id)
|
||||
return nil, fmt.Errorf("%s: %w", id, errNoSecretData)
|
||||
}
|
||||
return out.Bytes(), nil
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func (d *Driver) Lookup(id string) ([]byte, error) {
|
||||
// Store saves the bytes associated with an ID. An error is returned if the ID already exists
|
||||
func (d *Driver) Store(id string, data []byte) error {
|
||||
if _, err := d.Lookup(id); err == nil {
|
||||
return errors.Wrap(errSecretIDExists, id)
|
||||
return fmt.Errorf("%s: %w", id, errSecretIDExists)
|
||||
}
|
||||
in := bytes.NewReader(data)
|
||||
key, err := d.getPath(id)
|
||||
@@ -155,7 +155,7 @@ func (d *Driver) Delete(id string) error {
|
||||
return err
|
||||
}
|
||||
if err := os.Remove(key); err != nil {
|
||||
return errors.Wrap(errNoSecretData, id)
|
||||
return fmt.Errorf("%s: %w", id, errNoSecretData)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user