Documentation ¶
Index ¶
- Variables
- func ContextWithToken(ctx context.Context, name string, token *T) context.Context
- func ContextWithTokens(ctx context.Context, name string, tokens []byte) context.Contextdeprecated
- func ParseTokensJSON(ctx context.Context, name string, cfg any) (bool, error)deprecated
- func ParseTokensYAML(ctx context.Context, name string, cfg any) (bool, error)deprecated
- func TokensFromContext(ctx context.Context, name string) ([]byte, bool)deprecated
- type EnvVarReader
- type LiteralReader
- type Reader
- type Readers
- type T
Constants ¶
This section is empty.
Variables ¶
var DefaultReaders = &Readers{}
DefaultReaders is the default registry of readers, it includes readers for local files, literal values and environment variables.
Functions ¶
func ContextWithToken ¶
ContextWithToken returns a new context that contains the provided named token in addition to any existing tokens.
func ContextWithTokens
deprecated
func ParseTokensJSON
deprecated
ParseTokensJSON parses the tokens stored in the context for the specified name as JSON. It will return false if there are no tokens stored, true otherwise and an error if the unmarshal fails.
Deprecated: use TokenFromContext instead.
func ParseTokensYAML
deprecated
ParseTokensYAML parses the tokens stored in the context for the specified name as YAML. It will return false if there are no tokens stored, true otherwise and an error if the unmarshal fails.
Deprecated: use TokenFromContext instead.
Types ¶
type EnvVarReader ¶
type EnvVarReader struct{}
EnvVarReader implements a Reader for environment variables. The text should be 'env://<env-var-name>'.
func (*EnvVarReader) ReadFileCtx ¶
type LiteralReader ¶
type LiteralReader struct{}
LiteralReader implements a Reader for a literal token. The text should be 'literal://<token>'. ReadFile will return the text string it is called with.
func (*LiteralReader) ReadFileCtx ¶
type Reader ¶
Reader is the interface that must be implemented by any token reader. ReadFileCtx is called with the path of the token and should return the value of the token, that is, the scheme (eg. file://) should be stripped from the path before calling ReadFileCtx.
type Readers ¶
type Readers struct {
// contains filtered or unexported fields
}
Readers is a registry of token readers.
func CloneReaders ¶
CloneReaders returns a copy of the supplied readers.
type T ¶
T represents a token that can be used to authenticate with an API. Tokens are typically of the form scheme://value where scheme is used to identify the reader that should be used to read the value.
func New ¶
New creates a token from the supplied text. If the text does not contain a scheme, the entire text is used as the value of the token and the scheme is the empty string. It is left to the caller to determine the appropriate interpretation of the value.
func TokenFromContext ¶
TokenFromContext returns the token for the specified name, if any, that are stored in the context.