secret

package
v1.6.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Secret

type Secret struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Secret is a decoded secret

func New

func New(password, body string) *Secret

New creates a new secret

func Parse

func Parse(buf []byte) (*Secret, error)

Parse decodes an secret. It will always return a valid secret. If decoding the body to YAML is may return an error which can be ignored.

func (*Secret) Body

func (s *Secret) Body() string

Body returns the body of a secret. If the body was valid YAML it returns an empty string

func (*Secret) Bytes

func (s *Secret) Bytes() ([]byte, error)

Bytes encodes an secret

func (*Secret) Data added in v1.5.0

func (s *Secret) Data() map[string]interface{}

Data returns the data of a secret. Unless the body was valid YAML, it returns an map

func (*Secret) DeleteKey

func (s *Secret) DeleteKey(key string) error

DeleteKey key will delete a single key from an decoded map

func (*Secret) Equal

func (s *Secret) Equal(other *Secret) bool

Equal returns true if two secrets are equal

func (*Secret) Password

func (s *Secret) Password() string

Password returns the first line from a secret

func (*Secret) SetBody

func (s *Secret) SetBody(b string) error

SetBody sets a new body possibly erasing an decoded YAML map

func (*Secret) SetPassword

func (s *Secret) SetPassword(pw string)

SetPassword sets a new password (i.e. the first line)

func (*Secret) SetValue

func (s *Secret) SetValue(key, value string) error

SetValue sets a key to a given value. Will fail if an non-empty body exists

func (*Secret) String

func (s *Secret) String() string

String encodes and returns a string representation of a secret

func (*Secret) Value

func (s *Secret) Value(key string) (string, error)

Value returns the value of the given key if the body contained valid YAML

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL