azurefile

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 39 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Azure Files

Parity grade: B · SDK azure-sdk-for-go/sdk/storage/azfile@v1.5.4 · last audited 2026-10-25 (770f2a6d6)

Coverage

Metric Value
PARITY entries audited 42 (42 ok)
Feature families 8 (8 ok)
Known gaps 2
Deferred items 0
Resource leaks clean
Known gaps
  • ARM fileServices/shares: not implemented are the shares lease action, $filter on List, nextAllowed*DowngradeTime, accessTierStatus and the dashboard UI. The ARM HTTP handler and the property mapping live in services/azurearm (rp_storage_fileshares.go; FileShareView there has no such fields), which this work may not edit; azurefile.ShareView (arm_shares.go) would need the fields first.
  • Share snapshots copy the node tree (names, metadata, SMB/NFS properties, extent lists) per snapshot while file bytes are already shared copy-on-write; at roughly 0.5 KiB per node, a 100,000-node share with the 200-snapshot cap can cost about 10 GB. Removing it needs a persistent (path-copying) tree, because every handler mutates nodes in place. Persistence still writes the bytes once per snapshot.

More

Documentation

Index

Constants

View Source
const DefaultPort = 10009

DefaultPort is Azure Files' fixed listener port; Azurite has no Files service, so this is the first free slot after the Azure data-plane block.

Variables

View Source
var ErrNilAppContext = errors.New("azurefile: nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

View Source
var ErrShareNotFound = errors.New("azurefile: share not found")

ErrShareNotFound is returned when a share named by ExportShare or ApplyShare does not exist.

View Source
var ErrSnapshotNull = errors.New("azurefile: restore snapshot: null entry")

ErrSnapshotNull is returned by Restore when a snapshot holds a null entry.

Functions

This section is empty.

Types

type BlobReader

type BlobReader interface {
	ReadBlob(container, blob, snapshot string) ([]byte, string, error)
}

BlobReader reads blobs from the emulator's own Azure Blob service, for Copy File and Put Range From URL sources.

type CORSSetting

type CORSSetting struct {
	AllowedOrigins  string
	AllowedMethods  string
	AllowedHeaders  string
	ExposedHeaders  string
	MaxAgeInSeconds int32
}

CORSSetting is one CORS rule as the management plane sees it (list values comma separated).

type ConfigProvider

type ConfigProvider interface {
	GetAzureFileSettings() Settings
}

ConfigProvider extracts Azure Files configuration from the AppContext Config.

type Handler

type Handler struct {
	Backend *InMemoryBackend
	// Blobs resolves blob copy sources; nil rejects them.
	Blobs BlobReader
	// ValidateToken checks Bearer tokens when VerifyAuth is on and returns their oid and tid; nil accepts any token.
	ValidateToken func(token string) (oid, tid string, err error)
	// Metrics receives Storage Analytics rows for enabled hour/minute metrics; nil disables them.
	Metrics MetricsSink
	// Now is the clock; nil means time.Now.
	Now func() time.Time

	// Port is the fixed TCP port StartWorker binds.
	Port int
	// BlobPort is the Blob listener port, used to recognise blob source URLs.
	BlobPort int
	// VerifyAuth makes requests signed with the development account's key
	// (Shared Key or SAS) fail when the signature is wrong or expired.
	VerifyAuth bool
	// contains filtered or unexported fields
}

Handler serves the Azure Files REST API on a dedicated listener.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a Handler on DefaultPort.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation names the operation for metrics.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the share name for metrics.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists the supported operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler for Azure Files requests.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority is irrelevant because RouteMatcher never matches.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: Azure Files runs on its own listener.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown stops the listener.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the dedicated listener; a taken port fails startup.

type InMemoryBackend

type InMemoryBackend struct {

	// AccountSKU resolves a storage account's SKU name (for example Premium_LRS); nil leaves the media unknown.
	AccountSKU func(account string) (string, bool)
	// contains filtered or unexported fields
}

InMemoryBackend holds every account's shares behind one coarse lock.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) Accounts

func (b *InMemoryBackend) Accounts() []string

Accounts lists the storage accounts that currently hold at least one share.

func (*InMemoryBackend) ApplyShare

func (b *InMemoryBackend) ApplyShare(accountName, shareName string, tree ShareTree) error

ApplyShare makes the share's contents match tree: new files are created, changed files rewritten, and files and directories absent from tree removed. Unchanged files keep their properties.

func (*InMemoryBackend) CORS

func (b *InMemoryBackend) CORS(account string) []CORSSetting

CORS returns the account's CORS rules.

func (*InMemoryBackend) DeleteShare

func (b *InMemoryBackend) DeleteShare(account, name, snapshot string, mode ShareDeleteMode) (bool, error)

DeleteShare removes a share (or the named snapshot); it reports false when nothing existed.

func (*InMemoryBackend) ExportShare

func (b *InMemoryBackend) ExportShare(accountName, shareName string) (ShareTree, error)

ExportShare returns a copy of the share's files and directories.

func (*InMemoryBackend) GetShare

func (b *InMemoryBackend) GetShare(account, name, snapshot string) (ShareView, error)

GetShare returns a live share, or one of its snapshots when snapshot is set.

func (*InMemoryBackend) ListShares

func (b *InMemoryBackend) ListShares(account string, snapshots, deleted bool) []ShareView

ListShares returns the account's shares sorted by name; snapshots and soft-deleted shares are included on request.

func (*InMemoryBackend) PutShare

func (b *InMemoryBackend) PutShare(account, name string, in ShareInput, create bool) (ShareView, bool, error)

PutShare creates the share or updates it in place, reporting whether it was created. create=false refuses a missing share (PATCH).

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset drops all state.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads backend state from a snapshot. It implements persistence.Persistable.

func (*InMemoryBackend) RestoreShare

func (b *InMemoryBackend) RestoreShare(account, target, deletedName, deletedVersion string) (ShareView, error)

RestoreShare revives a soft-deleted share under the given name.

func (*InMemoryBackend) SMB

func (b *InMemoryBackend) SMB(account string) SMBSetting

SMB returns the account's SMB protocol settings.

func (*InMemoryBackend) SetCORS

func (b *InMemoryBackend) SetCORS(account string, rules []CORSSetting) error

SetCORS replaces the account's CORS rules; invalid rules are refused.

func (*InMemoryBackend) SetSMB

func (b *InMemoryBackend) SetSMB(account string, s SMBSetting)

SetSMB replaces the account's SMB protocol settings, keeping the encryption-in-transit element.

func (*InMemoryBackend) SetShareRetention

func (b *InMemoryBackend) SetShareRetention(account string, enabled bool, days int32)

SetShareRetention sets the account's share soft-delete policy (the management-plane shareDeleteRetentionPolicy).

func (*InMemoryBackend) ShareRetention

func (b *InMemoryBackend) ShareRetention(account string) (bool, int32)

ShareRetention returns the account's share soft-delete policy.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state. It implements persistence.Persistable.

type MetricsSink

type MetricsSink interface {
	PutMetricRow(table, partitionKey, rowKey string, props map[string]any) error
}

MetricsSink stores one Storage Analytics transactions row; the row replaces any earlier row with the same keys.

type Provider

type Provider struct{}

Provider implements service.Provider for Azure Files. Like the other Azure data-plane services it never joins the shared AWS router: the Handler runs its own listener (see Handler.StartWorker).

func (*Provider) Init

Init builds the backend and handler; the port is bound later in StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type SMBSetting

type SMBSetting struct {
	Versions                 string
	AuthenticationMethods    string
	KerberosTicketEncryption string
	ChannelEncryption        string
	MultichannelEnabled      bool
}

SMBSetting is the SMB protocol settings of the file service (list values semicolon separated).

type Settings

type Settings struct {
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 197-byte string literal not displayed */
	VerifyAuth bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 188-byte string literal not displayed */
}

Settings holds Azure Files configuration, embedded in the root CLI.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the default Settings.

type ShareACL

type ShareACL struct {
	ID         string
	Start      string
	Expiry     string
	Permission string
}

ShareACL is one stored access policy.

type ShareDeleteMode

type ShareDeleteMode string

ShareDeleteMode is the $include value of the management-plane delete.

const (
	ShareDeleteSnapshots       ShareDeleteMode = "snapshots"
	ShareDeleteLeasedSnapshots ShareDeleteMode = "leased-snapshots"
	ShareDeleteNone            ShareDeleteMode = "none"
)

Delete modes of the Microsoft.Storage fileServices/shares DELETE.

type ShareError

type ShareError struct {
	Code    string
	Message string
	Status  int
}

ShareError is a data-plane refusal surfaced to the management plane.

func (*ShareError) Error

func (e *ShareError) Error() string

type ShareInput

type ShareInput struct {
	Metadata       map[string]string
	Quota          *int64
	Iops           *int64
	Bandwidth      *int64
	BurstIops      *int64
	BurstBandwidth *int64
	PaidBursting   *bool
	Tier           string
	Protocols      string
	RootSquash     string
	ACL            []ShareACL
	HasMetadata    bool
	HasACL         bool
}

ShareInput is the settable part of a share as the management plane writes it.

type ShareTree

type ShareTree struct {
	Files map[string][]byte
	Dirs  []string
}

ShareTree is a share's files (slash paths to contents) and directories.

type ShareView

type ShareView struct {
	Created        time.Time
	LastModified   time.Time
	TierChanged    time.Time
	DeletedAt      time.Time
	Metadata       map[string]string
	Iops           *int64
	Bandwidth      *int64
	BurstIops      *int64
	BurstBandwidth *int64
	IncludedBurst  *int64
	BurstCredits   *int64
	PaidBursting   *bool
	SnapshotVDir   *bool
	Name           string
	ETag           string
	Tier           string
	Protocols      string
	RootSquash     string
	Version        string
	Snapshot       string
	LeaseStatus    string
	LeaseState     string
	LeaseDuration  string
	ACL            []ShareACL
	Usage          int64
	RemainingDays  int32
	Quota          int32
	Deleted        bool
}

ShareView is a share, snapshot or soft-deleted share as the management plane reads it.

Jump to

Keyboard shortcuts

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