objaws

package
v9.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package objaws provides an implementation of 'objstore.Client' for use with AWS S3.

Index

Constants

View Source
const (
	// PageSize is the default page size used by AWS.
	PageSize = 1_000

	// MaxUploadParts is the maximum number of parts for a multipart upload in AWS.
	MaxUploadParts = 10_000

	// MinUploadSize is the minimum size for a multipart upload in AWS.
	MinUploadSize = 5 * 1024 * 1024
)

Variables

View Source
var (
	// ErrStaticCredentialsRequired - Returned if the user has disabled shared config loading but they haven't provided
	// static credentials.
	ErrStaticCredentialsRequired = errors.New("when shared config and instance metadata " +
		"are both disabled, static credentials must be provided")

	// ErrRegionRequiredWhenStaticConfigDisabled - Returned if the user has disabled shared config loading but they
	// haven't provided the '--obj-region' flag.
	ErrRegionRequiredWhenStaticConfigDisabled = errors.New("when shared config is disabled, a region must be provided")
)

Functions

func AddSchemeIfMissing

func AddSchemeIfMissing(endpoint string, provider objval.Provider) string

AddSchemeIfMissing - Returns the endpoint with "https://" prepended if it doesn't already have a scheme. If the endpoint is empty, a scheme is present, or the provider is not AWS, the endpoint is returned as is.

Types

type AWSLogger

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

AWSLogger - Implementation of the logger interface for AWS which redirects logging using 'log'.

func AWSNewConfig

func AWSNewConfig(ctx context.Context, options AWSOptions) (aws.Config, *AWSLogger, error)

func NewAWSLogger

func NewAWSLogger() *AWSLogger

NewAWSLogger - Create a new AWS logger which by default is disabled meaning all logging is ignored.

func (*AWSLogger) GetEnabled

func (a *AWSLogger) GetEnabled() bool

GetEnabled - Get whether logging is enabled/disabled.

func (*AWSLogger) Logf

func (a *AWSLogger) Logf(_ logging.Classification, format string, v ...any)

Log - Implement the logger interface for the AWS SDK; this function simply redirects logging using 'log'.

func (*AWSLogger) SetEnabled

func (a *AWSLogger) SetEnabled(enabled bool)

SetEnabled - Set logging to enabled/disabled.

type AWSOptions

type AWSOptions struct {
	TLSConfig              *tls.Config
	Region                 string
	AccessKeyID            string
	SecretAccessKey        string
	RefreshToken           string
	AuthByInstanceMetaData bool
	LogLevel               string
}

AWSOptions contains the options used by AWSNewConfig. It mirrors the fields of CloudContainerOptions that are used when building an AWS config.

type AWSRetryer

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

AWSRetryer - Extends the 'DefaultRetryer' provided by the AWS SDK to retry some additional errors which users are expected to hit in 'cbbackupmgr'.

func NewAWSRetryer

func NewAWSRetryer() *AWSRetryer

NewAWSRetryer - Returns a new AWS retryer with a user configurable number of retries.

func (*AWSRetryer) GetInitialToken

func (a *AWSRetryer) GetInitialToken() (releaseToken func(error) error)

GetInitialToken returns the initial attempt token that can increment the retry token pool if the attempt is successful.

func (*AWSRetryer) GetRetryToken

func (a *AWSRetryer) GetRetryToken(ctx context.Context, opErr error) (releaseToken func(error) error, err error)

GetRetryToken attempts to deduct the retry cost from the retry token pool. Returning the token release function, or error.

func (*AWSRetryer) IsErrorRetryable

func (a *AWSRetryer) IsErrorRetryable(err error) bool

func (*AWSRetryer) MaxAttempts

func (a *AWSRetryer) MaxAttempts() int

MaxAttempts returns the maximum number of attempts that can be made for an attempt before failing. A value of 0 implies that the attempt should be retried until it succeeds if the errors are retryable.

func (*AWSRetryer) RetryDelay

func (a *AWSRetryer) RetryDelay(attempt int, opErr error) (time.Duration, error)

RetryDelay returns the delay that should be used before retrying the attempt. Will return error if the delay could not be determined.

type Client

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

Client implements the 'objcli.Client' interface allowing the creation/management of objects stored in AWS S3.

func NewClient

func NewClient(options ClientOptions) *Client

NewClient returns a new client which uses the given 'serviceAPI', in general this should be the one created using the 's3.New' function exposed by the SDK.

func (*Client) AbortMultipartUpload

func (c *Client) AbortMultipartUpload(ctx context.Context, opts objcli.AbortMultipartUploadOptions) error

func (*Client) AppendToObject

func (c *Client) AppendToObject(ctx context.Context, opts objcli.AppendToObjectOptions) (*objval.ObjectAttrs, error)

func (*Client) Close

func (c *Client) Close() error

Close is a no-op for AWS as this won't result in a memory leak.

func (*Client) CompleteMultipartUpload

func (c *Client) CompleteMultipartUpload(
	ctx context.Context, opts objcli.CompleteMultipartUploadOptions,
) (*objval.ObjectAttrs, error)

func (*Client) CopyObject

func (c *Client) CopyObject(ctx context.Context, opts objcli.CopyObjectOptions) (*objval.ObjectAttrs, error)

func (*Client) CreateMultipartUpload

func (c *Client) CreateMultipartUpload(ctx context.Context, opts objcli.CreateMultipartUploadOptions) (string, error)

func (*Client) DeleteDirectory

func (c *Client) DeleteDirectory(ctx context.Context, opts objcli.DeleteDirectoryOptions) error

DeleteDirectory deletes all objects in a specific directory of a bucket. This does not delete old versions of objects if any.

func (*Client) DeleteObjectVersions

func (c *Client) DeleteObjectVersions(ctx context.Context, opts objcli.DeleteObjectVersionsOptions) error

func (*Client) DeleteObjects

func (c *Client) DeleteObjects(ctx context.Context, opts objcli.DeleteObjectsOptions) error

func (*Client) GetBucketLockingStatus

func (c *Client) GetBucketLockingStatus(
	ctx context.Context,
	opts objcli.GetBucketLockingStatusOptions,
) (*objval.BucketLockingStatus, error)

func (*Client) GetBucketVersioningStatus

func (c *Client) GetBucketVersioningStatus(
	ctx context.Context,
	opts objcli.GetBucketLockingStatusOptions,
) (*objval.BucketVersioningStatus, error)

func (*Client) GetObject

func (c *Client) GetObject(ctx context.Context, opts objcli.GetObjectOptions) (*objval.Object, error)

func (*Client) GetObjectAttrs

func (c *Client) GetObjectAttrs(ctx context.Context, opts objcli.GetObjectAttrsOptions) (*objval.ObjectAttrs, error)

func (*Client) GetObjectLock

func (c *Client) GetObjectLock(ctx context.Context, opts objcli.GetObjectLockOptions) (*objval.ObjectAttrs, error)

func (*Client) IterateObjects

func (c *Client) IterateObjects(ctx context.Context, opts objcli.IterateObjectsOptions) error

func (*Client) ListParts

func (c *Client) ListParts(ctx context.Context, opts objcli.ListPartsOptions) ([]objval.Part, error)

func (*Client) Provider

func (c *Client) Provider() objval.Provider

func (*Client) PutObject

func (c *Client) PutObject(ctx context.Context, opts objcli.PutObjectOptions) (*objval.ObjectAttrs, error)

func (*Client) SetObjectLock

func (c *Client) SetObjectLock(ctx context.Context, opts objcli.SetObjectLockOptions) error

func (*Client) UploadPart

func (c *Client) UploadPart(ctx context.Context, opts objcli.UploadPartOptions) (objval.Part, error)

func (*Client) UploadPartCopy

func (c *Client) UploadPartCopy(ctx context.Context, opts objcli.UploadPartCopyOptions) (objval.Part, error)

type ClientOptions

type ClientOptions struct {
	// ServiceAPI is the is the minimal subset of functions that we use from the AWS SDK, this allows for a greatly
	// reduce surface area for mock generation.
	//
	// NOTE: Required
	ServiceAPI serviceAPI

	// Logger is the passed logger which implements a custom Log method
	Logger *slog.Logger
	// contains filtered or unexported fields
}

ClientOptions encapsulates the options for creating a new AWS Client.

Jump to

Keyboard shortcuts

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