configdir

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package configdir provides simple functions to manage the SecretHub configuration directory.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCredentialNotFound is returned when a credential file does not exist but CredentialFile.Read() is called.
	ErrCredentialNotFound = errors.New("credential not found")
)

Functions

This section is empty.

Types

type CredentialFile

type CredentialFile struct {
	// contains filtered or unexported fields
}

CredentialFile represents the file that contains the SecretHub API credential. By default, it's a file named "credential" in the configuration directory.

func (*CredentialFile) Exists

func (f *CredentialFile) Exists() bool

Exists returns true when a file exists at the path this credential points to.

func (*CredentialFile) Path

func (f *CredentialFile) Path() string

Path returns the path on the filesystem at which the credential file is located.

func (*CredentialFile) Read

func (f *CredentialFile) Read() ([]byte, error)

Read reads from the filesystem and returns the contents of the credential file.

func (*CredentialFile) Source added in v0.32.0

func (f *CredentialFile) Source() string

Source returns the path to the credential file.

func (*CredentialFile) Write

func (f *CredentialFile) Write(data []byte) error

Write writes the given bytes to the credential file.

type Dir

type Dir struct {
	// contains filtered or unexported fields
}

Dir represents the configuration directory located at some path on the file system.

func Default

func Default() (*Dir, error)

Default is the default way to get the location of the SecretHub configuration directory, sourcing it from the environment variable SECRETHUB_CONFIG_DIR or falling back to the ~/.secrethub directory.

func New

func New(path string) Dir

New a new Dir which represents a configuration directory at the given location.

func (Dir) Credential

func (c Dir) Credential() *CredentialFile

Credential returns the file that contains the SecretHub API credential.

func (Dir) Path

func (c Dir) Path() string

Path returns the path on the filesystem at which the config directory is located.

func (Dir) String

func (c Dir) String() string

Jump to

Keyboard shortcuts

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