azure

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultInitTimeout is the time we allow for initialisation, like credential
	// checking and bucket creation. We define this here, because we do not
	// pass a context when initialising a plugin.
	DefaultInitTimeout = 20 * time.Second
	// UpdateMarkerFilename is the filename used for the update marker functionality
	UpdateMarkerFilename = "update-marker"
	// DefaultUpdateMarkerForceListInterval is the default value for
	// UpdateMarkerForceListInterval.
	DefaultUpdateMarkerForceListInterval = 5 * time.Minute
	// DefaultDisableContentMd5 : disable sending the Content-MD5 header
	DefaultDisableContentMd5 = false
	// Max number of concurrent uploads to be performed to upload the file
	DefaultConcurrency = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

func New

func New(ctx context.Context, opt Options) (*Backend, error)

New creates a new backend instance. The lifetime of the context passed in must span the lifetime of the whole backend instance, not just the init time, so do not set any timeout on it!

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, name string) error

Delete removes the object identified by name from the Azure Container configured in b.

func (*Backend) List

func (b *Backend) List(ctx context.Context, prefix string) (blobList simpleblob.BlobList, err error)

func (*Backend) Load

func (b *Backend) Load(ctx context.Context, name string) ([]byte, error)

Load retrieves the content of the object identified by name from the Azure container configured in b.

func (*Backend) NewReader

func (b *Backend) NewReader(ctx context.Context, name string) (io.ReadCloser, error)

NewReader satisfies StreamReader and provides a read streaming interface to a blob located on an Azure Storage container.

func (*Backend) NewWriter

func (b *Backend) NewWriter(ctx context.Context, name string) (io.WriteCloser, error)

NewWriter satisfies StreamWriter and provides a write streaming interface to a blob located on an Azure Storage container.

func (*Backend) Store

func (b *Backend) Store(ctx context.Context, name string, data []byte) error

Store sets the content of the object identified by name to the content of data, in the Azure container configured in b.

type Options

type Options struct {

	// AccountName and AccountKey are statically defined here.
	AccountName string `yaml:"account_name"`
	AccountKey  string `yaml:"account_key"`

	UseSharedKey bool `yaml:"use_shared_key"`

	// Azure blob container name. If it doesn't exist it will be automatically created if `CreateContainer` is true.
	Container string `yaml:"container"`

	// CreateBucket tells us to try to create the bucket
	CreateContainer bool `yaml:"create_container"`

	// GlobalPrefix is a prefix applied to all operations, allowing work within a prefix
	// seamlessly
	GlobalPrefix string `yaml:"global_prefix"`

	// EndpointURL can be set to something like "http://localhost:9000" for local testing
	EndpointURL string `yaml:"endpoint_url"`

	// DisableContentMd5 defines whether to disable sending the Content-MD5 header
	DisableContentMd5 bool `yaml:"disable_send_content_md5"`

	// TLS allows customising the TLS configuration
	// See https://github.com/PowerDNS/go-tlsconfig for the available options
	TLS tlsconfig.Config `yaml:"tls"`

	// InitTimeout is the time we allow for initialisation, like credential
	// checking and bucket creation. It defaults to DefaultInitTimeout, which
	// is currently 20s.
	InitTimeout time.Duration `yaml:"init_timeout"`

	// UseUpdateMarker makes the backend write and read a file to determine if
	// it can cache the last List command. The file contains the name of the
	// last file stored or deleted.
	// This can reduce the number of LIST commands sent to Azure, replacing them
	// with GET commands that are about 12x cheaper.
	// If enabled, it MUST be enabled on all instances!
	// CAVEAT: This will NOT work correctly if the bucket itself is replicated
	//         in an active-active fashion between data centers! In that case
	//         do not enable this option.
	UseUpdateMarker bool `yaml:"use_update_marker"`
	// UpdateMarkerForceListInterval is used when UseUpdateMarker is enabled.
	// A LIST command will be sent when this interval has passed without a
	// change in marker, to ensure a full sync even if the marker would for
	// some reason get out of sync.
	UpdateMarkerForceListInterval time.Duration `yaml:"update_marker_force_list_interval"`

	// Concurrency defines the max number of concurrent uploads to be performed to upload the file.
	// Each concurrent upload will create a buffer of size BlockSize.  The default value is one.
	// https://github.com/Azure/azure-sdk-for-go/blob/e5c902ce7aca5aa0f4c7bb7e46c18c8fc91ad458/sdk/storage/azblob/blockblob/models.go#L264
	Concurrency int `yaml:"concurrency"`

	// Not loaded from YAML
	Logger logr.Logger `yaml:"-"`
}

func (Options) Check

func (o Options) Check() error

Jump to

Keyboard shortcuts

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