azure

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 19 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
	// DefaultSecretsRefreshInterval is the default value for SecretsRefreshInterval.
	// It should not be too high so as to retrieve secrets regularly.
	DefaultSecretsRefreshInterval = 15 * time.Second
)

Azure blob implementation examples can be found here: https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/storage/azblob/examples_test.go

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"`

	// Path to the file containing the account key as an alternative to
	// AccountKey, e.g. /run/secrets/simpleblob-azure-account-key.
	AccountKeyFile string `yaml:"account_key_file"`

	// Time between each secrets retrieval. Minimum is 1s, lower values are
	// considered an error. It defaults to DefaultSecretsRefreshInterval, which
	// is currently 15s.
	SecretsRefreshInterval time.Duration `yaml:"secrets_refresh_interval"`

	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:10000" for Azurite
	EndpointURL string `yaml:"endpoint_url"`

	// 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"`

	// IdleConnTimeout is the maximum amount of time an idle
	// (keep-alive) connection will remain idle before closing
	// itself. Default if unset: 90s
	IdleConnTimeout time.Duration `yaml:"idle_conn_timeout"`

	// MaxIdleConns controls the maximum number of idle (keep-alive)
	// connections. Default if unset: 100
	MaxIdleConns int `yaml:"max_idle_conns"`

	// DialTimeout is the maximum amount of time a dial will wait for
	// a connect to complete. Default if unset: 10s
	DialTimeout time.Duration `yaml:"dial_timeout"`

	// DialKeepAlive specifies the interval between keep-alive
	// probes for an active network connection. Default if unset: 10s
	DialKeepAlive time.Duration `yaml:"dial_keep_alive"`

	// TLSHandshakeTimeout specifies the maximum amount of time to
	// wait for a TLS handshake. Default if unset: 10s
	TLSHandshakeTimeout time.Duration `yaml:"tls_handshake_timeout"`

	// ClientTimeout specifies a time limit for requests made by this
	// HTTP Client. The timeout includes connection time, any
	// redirects, and reading the response body. The timer remains
	// running after Get, Head, Post, or Do return and will
	// interrupt reading of the Response.Body.
	// Default if unset: 15m
	ClientTimeout time.Duration `yaml:"client_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 as defined in
	// azblob.UploadStreamOptions. The default value there is one.
	// https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob#UploadStreamOptions.Concurrency
	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