Documentation
¶
Index ¶
- Constants
- Variables
- type BlobReader
- type CORSSetting
- type ConfigProvider
- type Handler
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) Accounts() []string
- func (b *InMemoryBackend) ApplyShare(accountName, shareName string, tree ShareTree) error
- func (b *InMemoryBackend) CORS(account string) []CORSSetting
- func (b *InMemoryBackend) DeleteShare(account, name, snapshot string, mode ShareDeleteMode) (bool, error)
- func (b *InMemoryBackend) ExportShare(accountName, shareName string) (ShareTree, error)
- func (b *InMemoryBackend) GetShare(account, name, snapshot string) (ShareView, error)
- func (b *InMemoryBackend) ListShares(account string, snapshots, deleted bool) []ShareView
- func (b *InMemoryBackend) PutShare(account, name string, in ShareInput, create bool) (ShareView, bool, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RestoreShare(account, target, deletedName, deletedVersion string) (ShareView, error)
- func (b *InMemoryBackend) SMB(account string) SMBSetting
- func (b *InMemoryBackend) SetCORS(account string, rules []CORSSetting) error
- func (b *InMemoryBackend) SetSMB(account string, s SMBSetting)
- func (b *InMemoryBackend) SetShareRetention(account string, enabled bool, days int32)
- func (b *InMemoryBackend) ShareRetention(account string) (bool, int32)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- type MetricsSink
- type Provider
- type SMBSetting
- type Settings
- type ShareACL
- type ShareDeleteMode
- type ShareError
- type ShareInput
- type ShareTree
- type ShareView
Constants ¶
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 ¶
var ErrNilAppContext = errors.New("azurefile: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
ErrShareNotFound is returned when a share named by ExportShare or ApplyShare does not exist.
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 ¶
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 ¶
ExtractOperation names the operation for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns the share name for metrics.
func (*Handler) GetSupportedOperations ¶
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 ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Azure Files runs on its own listener.
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) 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.
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 ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler; the port is bound later in StartWorker.
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 ShareDeleteMode ¶
type ShareDeleteMode string
ShareDeleteMode is the $include value of the management-plane delete.
const ( )
Delete modes of the Microsoft.Storage fileServices/shares DELETE.
type ShareError ¶
type ShareError struct {
}
ShareError is a data-plane refusal surfaced to the management plane.
func (*ShareError) Error ¶
func (e *ShareError) Error() string
type ShareInput ¶
type ShareInput struct {
}
ShareInput is the settable part of a share as the management plane writes it.