Help us shape the future of Go! Take the 2026 Go Developer Survey

azurefile

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 34 Imported by: 0

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 38 (33 ok, 5 partial)
Feature families 5 (4 ok, 1 partial)
Known gaps 11
Deferred items 0
Resource leaks clean
Known gaps
  • NFS shares: hard links, symbolic links, x-ms-owner/-group/-mode and NFS file types are not modelled (the routes answer 400 InvalidUri); NFS only changes the stored protocol and root squash.
  • SMB handles are never modelled, so List Handles is empty and Force Close Handles is a no-op.
  • CORS rules are stored but not enforced and OPTIONS preflight is unsupported; metrics and logging settings are stored only.
  • SAS permissions (sp), stored access policy references (si), account SAS signatures, IP/protocol restrictions and Bearer tokens are not enforced; Get User Delegation Key is unsupported; verification is off by default and limited to the development account.
  • Share quota is not enforced (no ShareSizeLimitReached), access tier changes are instant, provisioned/bursting options are echoed without validation.
  • Lease error codes for share operations (LeaseIdMismatchWithLeaseOperation, LeaseNotPresentWithLeaseOperation as 412) and the code for an unknown permission key follow the file-operation names and are not verified against the live service.
  • Metadata keys sent as headers come back in Go's canonical case (Foo) rather than the exact case sent; list XML returns them as stored.
  • Copy File is synchronous and only reads emulator file and blob URLs; x-ms-copy-source-authorization and CRC64 source checks are ignored, so Abort Copy never finds a pending copy.
  • LastAccessTime is reported as LastWriteTime and ChangeTime is only set explicitly or on mutation; trailing-dot handling (x-ms-allow-trailing-dot) and structured-body/CRC64 transactional validation are ignored.
  • Share soft delete follows ARM PUT/PATCH/GET storageAccounts/{a}/fileServices/default (shareDeleteRetentionPolicy only; cors and protocolSettings sent through ARM are accepted but not applied, and the default is disabled rather than 7 days). ARM fileServices/shares resources and the dashboard UI do not exist yet.
  • Share snapshots are full in-memory deep copies (metadata and tree), so large trees cost memory 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 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
	// 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 {
	// 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) ExportShare

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

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

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) 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 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 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 ShareTree

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

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

Jump to

Keyboard shortcuts

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