human

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const ConfigType = "human"

ConfigType is the type name for the human secrets keeper.

Variables

This section is empty.

Functions

func Builder

func Builder(_ context.Context, c any) (secrets.Keeper, error)

Builder creates a new human secrets keeper from the given configuration.

func RemoveQuestion

func RemoveQuestion(kc config.KeeperConfig, id string)

RemoveQuestion removes a question from the given keeper configuration. This is used by the command-line interface to help remove configuration incrementally.

func SetQuestion

func SetQuestion(
	kc config.KeeperConfig,
	id string,
	presets map[string]any,
	askFor []string,
)

SetQuestion adds or updates a question in the given keeper configuration. This is used by the command-line interface to help build up the configuration incrementally.

func Validator

func Validator(_ context.Context, c any) error

Validator checks that the configuration is correct for the human secrets keeper. It will check that every question has at least one field to ask for and that no question has a preset that is already being asked for.

Types

type Config

type Config struct {
	// Questions is the list of questions that will be asked of the user.
	Questions []QuestionConfig `mapstructure:"questions" yaml:"questions"`
}

Config is the configuration of the human secrets keeper.

type Human

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

Human is a secret keeper that asks the user for the secrets.

func New

func New() *Human

New creates a new human secrets keeper.

func (*Human) AddQuestion

func (h *Human) AddQuestion(
	id string,
	askFor []string,
	preset map[string]string,
)

AddQuestion adds a question to the human secrets keeper.

func (*Human) CopySecret

func (h *Human) CopySecret(_ context.Context, id, location string) (secrets.Secret, error)

CopySecret fails with an error.

func (*Human) DeleteSecret

func (h *Human) DeleteSecret(_ context.Context, id string) error

DeleteSecret fails with an error.

func (*Human) GetSecret

func (h *Human) GetSecret(_ context.Context, id string) (secrets.Secret, error)

GetSecret retrieves the secret with the given ID by asking the user for the secret information as defined by the identified question configuration.

func (*Human) GetSecretsByName

func (h *Human) GetSecretsByName(ctx context.Context, name string) ([]secrets.Secret, error)

GetSecretsByName retrieves the secret with the given name by asking the user for the secret information as defined by the identified question configuration. As ID and name are treated the same by the human secret keeper, this is essentially identical to GetSecret.

func (*Human) ListLocations

func (h *Human) ListLocations(_ context.Context) ([]string, error)

ListLocations returns the list of locations from the human secrets keeper. This always just returns "". As of this writing, you should only use an empty location with the human secret keeper.

func (*Human) ListSecrets

func (h *Human) ListSecrets(_ context.Context, _ string) ([]string, error)

ListSecrets returns an empty list.

func (*Human) MoveSecret

func (h *Human) MoveSecret(_ context.Context, id, location string) (secrets.Secret, error)

MoveSecret fails with an error.

func (*Human) SetSecret

func (h *Human) SetSecret(_ context.Context, secret secrets.Secret) (secrets.Secret, error)

SetSecret fails with an error.

type Question

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

Question defines the questions to ask for a secret as well as the preset values to use to fill in the rest.

type QuestionConfig

type QuestionConfig struct {
	// ID is the unique identifier for the question. It is used to reference
	// the question in the configuration.
	ID string `mapstructure:"id" yaml:"id"`

	// Presets are the values that will be used to populate the parts of the
	// secret that are not queried directly from the user via pinentry.
	Presets map[string]string `mapstructure:"presets" yaml:"presets"`

	// AskFor is the list of fields that will be queried from the user via
	// pinentry.
	AskFor []string `mapstructure:"ask_for" yaml:"ask_for"`
}

QuestionConfig is the configuration for a single question. Each question behaves as a secret. The contents of the secret are determined by this configuration and user input.

Jump to

Keyboard shortcuts

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