const ( // ProviderName is the name this credentials provider will label any // returned credentials Value with. ProviderName = `ProcessProvider` // DefaultTimeout default limit on time a process can run. DefaultTimeout = time.Duration(1) * time.Minute )
A CredentialProcessResponse is the AWS credentials format that must be returned when executing an external credential_process.
type CredentialProcessResponse struct { // As of this writing, the Version key must be set to 1. This might // increment over time as the structure evolves. Version int // The access key ID that identifies the temporary security credentials. AccessKeyID string `json:"AccessKeyId"` // The secret access key that can be used to sign requests. SecretAccessKey string // The token that users must pass to the service API to use the temporary credentials. SessionToken string // The date on which the current credentials expire. Expiration *time.Time }
DefaultNewCommandBuilder provides the default NewCommandBuilder implementation used by the provider. It takes a command and arguments to invoke. The command will also be initialized with the current process environment variables, stderr, and stdin pipes.
type DefaultNewCommandBuilder struct { Args []string }
func (b DefaultNewCommandBuilder) NewCommand(ctx context.Context) (*exec.Cmd, error)
NewCommand returns an initialized exec.Cmd with the builder's initialized Args. The command is also initialized current process environment variables, stderr, and stdin pipes.
NewCommandBuilder provides the interface for specifying how command will be created that the Provider will use to retrieve credentials with.
type NewCommandBuilder interface { NewCommand(context.Context) (*exec.Cmd, error) }
NewCommandBuilderFunc provides a wrapper type around a function pointer to satisfy the NewCommandBuilder interface.
type NewCommandBuilderFunc func(context.Context) (*exec.Cmd, error)
func (fn NewCommandBuilderFunc) NewCommand(ctx context.Context) (*exec.Cmd, error)
NewCommand calls the underlying function pointer the builder was initialized with.
Options is the configuration options for configuring the Provider.
type Options struct { // Timeout limits the time a process can run. Timeout time.Duration }
Provider satisfies the credentials.Provider interface, and is a client to retrieve credentials from a process.
type Provider struct {
// contains filtered or unexported fields
}
func NewProvider(command string, options ...func(*Options)) *Provider
NewProvider returns a pointer to a new Credentials object wrapping the Provider.
The provider defaults to the DefaultNewCommandBuilder for creating command the Provider will use to retrieve credentials with.
func NewProviderCommand(builder NewCommandBuilder, options ...func(*Options)) *Provider
NewProviderCommand returns a pointer to a new Credentials object with the specified command, and default timeout duration. Use this to provide custom creation of exec.Cmd for options like environment variables, or other configuration.
func (p *Provider) Retrieve(ctx context.Context) (aws.Credentials, error)
Retrieve executes the credential process command and returns the credentials, or error if the command fails.
ProviderError is an error indicating failure initializing or executing the process credentials provider
type ProviderError struct { Err error }
func (e *ProviderError) Error() string
Error returns the error message.
func (e *ProviderError) Unwrap() error
Unwrap returns the underlying error the provider error wraps.