credential

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProtocolHmac will hold access key and secret key credential.
	//
	// HMAC means hash-based message authentication code, it may be inaccurate to represent credential
	// protocol ak/sk(access key + secret key with hmac), but it's simple and no confuse with other
	// protocol, so just keep this.
	//
	// value = [Access Key, Secret Key]
	ProtocolHmac = "hmac"
	// ProtocolAPIKey will hold api key credential.
	//
	// value = [API Key]
	ProtocolAPIKey = "apikey"
	// ProtocolFile will hold file credential.
	//
	// value = [File Path], service decide how to use this file
	ProtocolFile = "file"
	// ProtocolEnv will represent credential from env.
	//
	// value = [], service retrieves credential value from env.
	ProtocolEnv = "env"
)

Variables

View Source
var (
	// ErrInvalidConfig will return if config string invalid.
	ErrInvalidConfig = errors.New("invalid config")
	// ErrUnsupportedProtocol will return if protocol is unsupported.
	ErrUnsupportedProtocol = errors.New("unsupported protocol")
)

Functions

This section is empty.

Types

type Provider

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

Provider will provide credential protocol and values.

func MustNewAPIKey added in v0.5.0

func MustNewAPIKey(value ...string) *Provider

MustNewAPIKey make sure Provider must be created if no panic happened.

func MustNewEnv added in v0.5.0

func MustNewEnv(value ...string) *Provider

MustNewEnv make sure Provider must be created if no panic happened.

func MustNewFile added in v0.5.0

func MustNewFile(value ...string) *Provider

MustNewFile make sure Provider must be created if no panic happened.

func MustNewHmac added in v0.5.0

func MustNewHmac(value ...string) *Provider

MustNewHmac make sure Provider must be created if no panic happened.

func NewAPIKey added in v0.5.0

func NewAPIKey(value ...string) (*Provider, error)

NewAPIKey create a api key provider.

func NewEnv added in v0.5.0

func NewEnv(_ ...string) (*Provider, error)

NewEnv create a env provider.

func NewFile added in v0.5.0

func NewFile(value ...string) (*Provider, error)

NewFile create a file provider.

func NewHmac added in v0.5.0

func NewHmac(value ...string) (*Provider, error)

NewHmac create a hmac provider.

func Parse

func Parse(cfg string) (*Provider, error)

Parse will parse config string to create a credential Provider.

func (*Provider) Protocol added in v0.5.0

func (p *Provider) Protocol() string

Protocol provides current credential's protocol.

func (*Provider) Value

func (p *Provider) Value() []string

Value provides current credential's value in string array.

Jump to

Keyboard shortcuts

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