filecache

package
v0.6.28 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func V1CredentialToV2Provider

func V1CredentialToV2Provider(c *credentials.Credentials) aws.CredentialsProvider

V1CredentialToV2Provider converts a v1 credentials.Credential to a v2 aws.CredentialProvider

func V1ProviderToV2Provider

func V1ProviderToV2Provider(p credentials.Provider) aws.CredentialsProvider

V1ProviderToV2Provider converts a v1 credentials.Provider to a v2 aws.CredentialsProvider

func V2CredentialToV1Value

func V2CredentialToV1Value(cred aws.Credentials) credentials.Value

V2CredentialToV1Value converts a v2 aws.Credentials to a v1 credentials.Value

Types

type FileCacheOpt

type FileCacheOpt func(*FileCacheProvider)

func WithFileLockerCreator

func WithFileLockerCreator(f func(string) FileLocker) FileCacheOpt

WithFileLockCreator returns a FileCacheOpt that sets the cache's FileLocker creation function

func WithFilename

func WithFilename(filename string) FileCacheOpt

WithFilename returns a FileCacheOpt that sets the cache's file

func WithFs

func WithFs(fs afero.Fs) FileCacheOpt

WithFs returns a FileCacheOpt that sets the cache's filesystem

type FileCacheProvider

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

FileCacheProvider is a credentials.Provider implementation that wraps an underlying Provider (contained in Credentials) and provides caching support for credentials for the specified clusterID, profile, and roleARN (contained in cacheKey)

func NewFileCacheProvider

func NewFileCacheProvider(clusterID, profile, roleARN string, provider aws.CredentialsProvider, opts ...FileCacheOpt) (*FileCacheProvider, error)

NewFileCacheProvider creates a new Provider implementation that wraps a provided Credentials, and works with an on disk cache to speed up credential usage when the cached copy is not expired. If there are any problems accessing or initializing the cache, an error will be returned, and callers should just use the existing credentials provider.

func (*FileCacheProvider) ExpiresAt

func (f *FileCacheProvider) ExpiresAt() time.Time

ExpiresAt implements the Expirer interface, and gives access to the expiration time of the credential

func (*FileCacheProvider) IsExpired

func (f *FileCacheProvider) IsExpired() bool

IsExpired() implements the Provider interface, deferring to the cached credential first, but fall back to the underlying Provider if it is expired.

func (*FileCacheProvider) Retrieve

func (f *FileCacheProvider) Retrieve() (credentials.Value, error)

Retrieve() implements the Provider interface, returning the cached credential if is not expired, otherwise fetching the credential from the underlying Provider and caching the results on disk with an expiration time.

func (*FileCacheProvider) RetrieveWithContext

func (f *FileCacheProvider) RetrieveWithContext(ctx context.Context) (credentials.Value, error)

Retrieve() implements the Provider interface, returning the cached credential if is not expired, otherwise fetching the credential from the underlying Provider and caching the results on disk with an expiration time.

type FileLocker

type FileLocker interface {
	Unlock() error
	TryLockContext(ctx context.Context, retryDelay time.Duration) (bool, error)
	TryRLockContext(ctx context.Context, retryDelay time.Duration) (bool, error)
}

FileLocker is a subset of the methods exposed by *flock.Flock

func NewFileLocker

func NewFileLocker(filename string) FileLocker

NewFileLocker returns a *flock.Flock that satisfies FileLocker

Jump to

Keyboard shortcuts

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