vaultcli

package
v1.40.6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFileNotFound = errors.New("configuration file not found")

Functions

func DeleteConfigFile

func DeleteConfigFile(path string) error

func EditData

func EditData(data []byte, saveFunc SaveFunc, startErr *errors.ApiError, retry bool) (edited []byte, runErr *errors.ApiError)

func GetFilenameFromArgs

func GetFilenameFromArgs(args []string) string

GetFilenameFromArgs tries to extract a filename from args. If args has a --data or -d flag and its value starts with an '@' followed by a filename, the function tries to capture that filename.

func GetFlagVal

func GetFlagVal(flag string, args []string) string

func LookupConfigPath

func LookupConfigPath(dir string) string

func SurveyOptionalCIDR

func SurveyOptionalCIDR(ans interface{}) error

SurveyOptionalCIDR verifies that the answer is either empty or a valid CIDR.

func SurveyOptionalJSON

func SurveyOptionalJSON(ans interface{}) error

SurveyOptionalJSON verifies that the answer is either empty or a valid JSON.

func SurveyRequired

func SurveyRequired(ans interface{}) error

SurveyRequired verifies that there is some answer. Built-in function "survey.Required()" does not trim spaces.

func SurveyRequiredFile

func SurveyRequiredFile(ans interface{}) error

SurveyRequiredFile verifies that the answer is a valid path to a file.

func SurveyRequiredInt

func SurveyRequiredInt(ans interface{}) error

SurveyRequiredInt verifies that the answer is a valid integer number.

func SurveyRequiredName

func SurveyRequiredName(ans interface{}) error

SurveyRequiredName checks name.

func SurveyRequiredPath

func SurveyRequiredPath(ans interface{}) error

SurveyRequiredPath checks path.

func SurveyRequiredPortNumber

func SurveyRequiredPortNumber(ans interface{}) error

SurveyRequiredPortNumber verifies that the answer is a valid port number.

func SurveyRequiredProfileName

func SurveyRequiredProfileName(existingProfiles []string) func(ans interface{}) error

SurveyRequiredProfileName checks profile name.

func SurveySelectAtLeastOne

func SurveySelectAtLeastOne(ans interface{}) error

SurveySelectAtLeastOne requires the answer is a list with at least one item.

func SurveyTrimSpace

func SurveyTrimSpace(ans interface{}) (newAns interface{})

SurveyTrimSpace trims spaces.

func ToFlagName

func ToFlagName(flag string) string

func ValidateName

func ValidateName(name string) error

func ValidatePath

func ValidatePath(resource string) error

func ValidateProfile

func ValidateProfile(profile string) error

func ValidateUsername

func ValidateUsername(username string) error

func ViperInit

func ViperInit() error

Types

type CLI

type CLI interface {
	HTTPClient() requests.Client
	GraphQLClient() requests.GraphClient
	Out() format.OutClient
	Edit(data []byte, saveFunc SaveFunc) (edited []byte, err *errors.ApiError)
	Authenticator() auth.Authenticator
	Store(t string) (store.Store, error)
}

func New

func New() CLI

func NewWithOpts

func NewWithOpts(opts ...VaultCLIOption) (CLI, error)

type ConfigFile

type ConfigFile struct {
	DefaultProfile string
	// contains filtered or unexported fields
}

func NewConfigFile

func NewConfigFile(path string) (*ConfigFile, error)

func ReadConfigFile

func ReadConfigFile(path string) (*ConfigFile, error)

func (*ConfigFile) Bytes

func (cf *ConfigFile) Bytes() []byte

func (*ConfigFile) Delete

func (cf *ConfigFile) Delete() error

func (*ConfigFile) GetPath

func (cf *ConfigFile) GetPath() string

func (*ConfigFile) GetProfile

func (cf *ConfigFile) GetProfile(p string) (*Profile, bool)

func (*ConfigFile) ListProfiles

func (cf *ConfigFile) ListProfiles() []*Profile

func (*ConfigFile) ListProfilesNames

func (cf *ConfigFile) ListProfilesNames() []string

func (*ConfigFile) RawUpdate

func (cf *ConfigFile) RawUpdate(b []byte) error

func (*ConfigFile) Read

func (cf *ConfigFile) Read() error

func (*ConfigFile) Save

func (cf *ConfigFile) Save() error

func (*ConfigFile) SetProfile

func (cf *ConfigFile) SetProfile(p *Profile)

type Profile

type Profile struct {
	Name string
	// contains filtered or unexported fields
}

func NewProfile

func NewProfile(name string) *Profile

func (*Profile) Del

func (p *Profile) Del(path ...string)

func (*Profile) Get

func (p *Profile) Get(path ...string) string

func (*Profile) Set

func (p *Profile) Set(val string, path ...string)

type SaveFunc

type SaveFunc func(data []byte) (resp []byte, err *errors.ApiError)

type VaultCLIOption

type VaultCLIOption func(vcli CLI) error

func WithAuthenticator

func WithAuthenticator(a auth.Authenticator) VaultCLIOption

func WithEditFunc

func WithEditFunc(f func(data []byte, save SaveFunc) (edited []byte, err *errors.ApiError)) VaultCLIOption

func WithGraphQLClient

func WithGraphQLClient(c requests.GraphClient) VaultCLIOption

func WithHTTPClient

func WithHTTPClient(c requests.Client) VaultCLIOption

func WithOutClient

func WithOutClient(c format.OutClient) VaultCLIOption

func WithStore

func WithStore(s store.Store) VaultCLIOption

Jump to

Keyboard shortcuts

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