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

azurearm

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: 45 Imported by: 0

README

Azurearm

Parity grade: B · SDK hashicorp/terraform-provider-azurerm@v4.81.0 · last audited 2026-09-12 (f973f0c90)

Coverage

Metric Value
PARITY entries audited 20 (15 ok, 2 partial, 3 gap)
Feature families 6 (6 ok)
Known gaps 14
Deferred items 3
Resource leaks clean
Known gaps
  • Storage RP account state (StorageProvider.accounts) does not survive a snapshot/restore cycle -- only InMemoryBackend's resource-group/generic-resource/provider-registration state is persisted (see ops.StorageAccountCRUD). Fix is additive: give StorageProvider its own Snapshot/Restore and wire it into Handler.Snapshot/Restore alongside the backend's.
  • ServiceBus RP state (ServiceBusProvider's namespaces/queues/topics/subscriptions maps) does not survive a snapshot/restore cycle either, the same known gap as StorageAccountCRUD above and for the same reason -- no ResourceProvider's own state is currently wired into Handler.Snapshot/Restore.
  • TestTerraform_Azure_ServiceBus (M9) could not be confirmed against a live tofu apply on this milestone's local macOS development sandbox, due to the same pre-existing host-OS-specific TLS-trust gap documented for M7/M8 (AZURE.md section 10.10) -- apply fails at ARM's own metadata-discovery call, before reaching any ServiceBus-specific code. Compensating verification: test/integration/azurearm_test.go's TestIntegration_AzureARM_ServiceBusLifecycleAndCrossServiceWiring exercises the identical ARM CRUD + cross-service-wiring path over plain HTTP and passed; wire-shape questions were answered by reading the pinned terraform-provider-azurerm/go-azure-sdk source directly. Should be re-confirmed against a green CI run (expected to work on Linux).
  • Token endpoint accepts any (or a missing) client_id/grant_type without validation and always issues a token; a malformed client_credentials request should arguably 400 with invalid_request/unsupported_grant_type per RFC 6749, matching AAD's own error shape more closely.
  • Direct-data-plane storage resources (azurerm_storage_container/_blob/_queue/_table) are covered as of M8 via the new services/azurestoragevhost virtual-hosted-style listener (AZURE.md section 10.8 finding (9)); azurerm_storage_share (File Share) remains out of scope -- no gopherstack file-share service exists.
  • Multi-account namespace isolation: all ARM-created storage accounts alias one shared Blob/Queue/Table container/queue/table namespace (services/azureblob/azurequeue/azuretable discard the account-name path segment entirely). Two ARM storage accounts see each other's containers. Deferred to M10 per AZURE.md section 10.4's original note; StorageAccounts.RegisterAccount/DeleteAccount (interfaces.go) is the forward-compat seam for that fix.
  • ARM error codes are a small hand-picked table (errors.go's errorDetails), not audited against ARM's full published error-code catalog the way services/sqs's errorDetails table has been over multiple audit passes.
  • management locks, Azure Policy, RBAC/Microsoft.Authorization, ARM template deployments (Microsoft.Resources/deployments), PATCH-merge semantics beyond full-replace, $filter/$expand and nextLink pagination on list operations, cross-subscription/cross-tenant, resource moves, What-If, and LRO polling are all explicitly out of MVP scope per AZURE.md section 10.1/10.3 -- not bugs, deliberate scope boundaries for this milestone.
  • Container Instances: interactive exec and attach need a websocket terminal session; both answer 501 NotImplemented.
  • Container Instances: not supported and rejected with 400 InvalidRequestContent: Windows containers, gitRepo volumes, GPUs, liveness/readiness probes, init containers, identity, zones, subnet and DNS configuration, diagnostics, confidential/dedicated SKUs, spot priority, encryption, extensions, UDP ports.
  • Container Instances: azureFile volumes are copied from the Azure Files share when the containers start and written back when a container exits and when the group stops or is deleted, not synchronized live; the storage account key is accepted without being checked.
  • Container Instances: the group address is 127.0.0.1 and ports are published on pool-assigned host ports (reported in a PortPublished event), not on the declared port numbers; Private addresses behave the same.
  • Container Instances: restarting a failed container under Never is not done (the platform may restart it); the restart back-off starts at 10s and caps at 5 minutes. Resource requests are validated but only limits are enforced, and per-group CPU/memory maxima are not checked.
  • Container Instances: sibling endpoints (locations/{loc}/usages, cachedImages, capabilities, the operations list, outboundNetworkDependenciesEndpoints, container group profiles) are not implemented; a restored snapshot brings groups back Stopped.
Deferred
  • M7 initial implementation. No prior audit passes to report.
  • M9 added the Microsoft.ServiceBus RP (ServiceBusNamespaceCRUD/ServiceBusQueueTopicSubscriptionCRUD/ServiceBusAuthorizationRuleListKeys). QC pass over the pre-existing implementation found and fixed two real bugs before any Terraform run (List not filtering by resource group for queues/topics/subscriptions; DeleteResourcesInGroup's cascade delete never matching due to a double-pipe key-prefix bug) -- see AZURE.md section 10.10's M9 entry for full detail.
  • M9's first real-CI run (PR #2466, terraform-tests (6) job on Linux, past the macOS TLS-trust gap) surfaced a third real bug: classifyServiceBusPath had no case for namespaces/{ns}/networkRuleSets/default, which terraform-provider-azurerm's namespace Read calls unconditionally on every namespace regardless of SKU or config -- see ops.ServiceBusNamespaceNetworkRuleSet above and AZURE.md section 10.10's M9 entry for full detail. Checked queue/topic/subscription/authorizationRule Read functions in the same pinned source for the same class of unconditional sub-resource probe; none exists (each Read function only calls its own client.Get).

More

Documentation

Index

Constants

View Source
const (
	FunctionHostKeyTypeFunction = "functionKeys"
	FunctionHostKeyTypeSystem   = "systemKeys"
)

Host key collections ARM addresses as host/default/{keyType}.

View Source
const (
	ACIEngineAuto = "auto"
	ACIEngineNone = "none"
)

ACIEngineAuto runs container groups in the container runtime; ACIEngineNone fails them to provision.

View Source
const (
	DefaultEventHubPort     = 10005
	DefaultEventHubAMQPPort = 5673
)

DefaultEventHubPort and DefaultEventHubAMQPPort are the Event Hubs REST and AMQP ports ARM advertises; they must equal services/azureeventhubs's defaults.

View Source
const DefaultAppConfigPort = 10008

DefaultAppConfigPort is the App Configuration data plane's HTTPS port ARM advertises; it must equal services/azureappconfig.DefaultPort.

View Source
const DefaultClientID = "00000000-0000-0000-0000-000000000000"

DefaultClientID is the fixed dev client (application) ID.

View Source
const DefaultClientSecret = "gopherstack"

DefaultClientSecret is the fixed dev client secret accepted by the token endpoint when validation is off (the default).

View Source
const DefaultContainerRegistryPort = 10011

DefaultContainerRegistryPort is the Container Registry data plane's port ARM advertises in loginServer; it must equal services/azurecontainerregistry.DefaultPort.

View Source
const DefaultCosmosDBPort = 8081

DefaultCosmosDBPort is the Cosmos DB data plane's default port, used for documentEndpoint when no data-plane adapter is wired; it must equal services/cosmosdb.DefaultPort.

View Source
const DefaultEnvironmentName = "gopherstack"

DefaultEnvironmentName is the environment name advertised by the metadata document; must equal the Terraform provider's own `environment` setting.

View Source
const DefaultEventGridPort = 10007

DefaultEventGridPort is the Event Grid data plane's HTTPS port ARM advertises; it must equal services/azureeventgrid.DefaultPort.

View Source
const DefaultKeyVaultPort = 10004

DefaultKeyVaultPort is the default port ARM's Microsoft.KeyVault RP advertises in vaultUri; it must equal services/azurekeyvault.DefaultPort.

View Source
const DefaultLocation = "local"

DefaultLocation is the default Azure "location" value used when a request doesn't specify one.

View Source
const DefaultPort = 10006

DefaultPort is the fixed TCP port for the dedicated ARM listener. It sits inside --port-range-start/--port-range-end's default range (10000-10100) and leaves Key Vault (10004, M11) and App Configuration (10005, M12) untouched -- see AZURE.md section 10.7.

View Source
const DefaultServiceBusPort = 10003

DefaultServiceBusPort is the default port ARM's Microsoft.ServiceBus RP advertises as serviceBusEndpoint (AZURE.md section 10.10's M9 entry). Mirrors DefaultStorageVHostPort's rationale for duplicating rather than importing services/azureservicebus.DefaultPort: this package has no other reason to depend on that package (rp_servicebus.go delegates through the narrow ServiceBusEntities interface, not a direct import), and importing it just for one int constant would be a needless coupling.

View Source
const DefaultStorageVHostPort = 10010

DefaultStorageVHostPort is the default port ARM's Microsoft.Storage RP advertises in primaryEndpoints (AZURE.md section 10.4/10.8). This intentionally duplicates services/azurestoragevhost.DefaultPort as a literal constant rather than importing that package: services/azurearm has no other reason to depend on it (no delegation happens here, see rp_storage.go), and importing a package just for one int constant would be a needless coupling for a documented, stable port number. Unlike the three separate per-service ports this replaced, there is only one port now: terraform-provider-azurerm's data-plane SDK requires Blob/Queue/Table to share a single domain suffix, which (since Go's url.URL.Host always includes the port) forces them onto a single shared port too -- see services/azurestoragevhost's package doc comment for the full derivation.

View Source
const DefaultSubscriptionID = "00000000-0000-0000-0000-000000000000"

DefaultSubscriptionID is the fixed dev subscription ID.

View Source
const DefaultTenantID = "00000000-0000-0000-0000-000000000000"

DefaultTenantID is the fixed dev AAD tenant ID. It, DefaultSubscriptionID, and DefaultClientID are all-zeros GUIDs, matching LocalStack's own Azure emulator convention: valid GUIDs (azurerm parses subscription_id/tenant_id as GUIDs) that are obviously not real Azure identifiers. See AZURE.md section 10.5.

Variables

View Source
var (
	ErrACIGroupNotFound     = errors.New("azurearm: container group not found")
	ErrACIContainerNotFound = errors.New("azurearm: container not found in the group")
	ErrACINotRunning        = errors.New("azurearm: container has no logs: never started, or the group is stopped")
)

Sentinel errors returned by the engine.

View Source
var (
	ErrInvalidResourceID      = errors.New("azurearm: invalid resource ID")
	ErrResourceGroupNotFound  = errors.New("azurearm: resource group not found")
	ErrResourceNotFound       = errors.New("azurearm: resource not found")
	ErrSubscriptionNotFound   = errors.New("azurearm: subscription not found")
	ErrProviderNotFound       = errors.New("azurearm: resource provider not found")
	ErrInvalidRequestBody     = errors.New("azurearm: invalid request body")
	ErrStorageAccountNotFound = errors.New("azurearm: storage account not found")

	ErrServiceBusNamespaceNotFound    = errors.New("azurearm: service bus namespace not found")
	ErrServiceBusQueueNotFound        = errors.New("azurearm: service bus queue not found")
	ErrServiceBusTopicNotFound        = errors.New("azurearm: service bus topic not found")
	ErrServiceBusSubscriptionNotFound = errors.New("azurearm: service bus subscription not found")

	ErrKeyVaultNotFound = errors.New("azurearm: key vault not found")

	ErrEventHubNamespaceNotFound     = errors.New("azurearm: event hubs namespace not found")
	ErrEventHubNotFound              = errors.New("azurearm: event hub not found")
	ErrEventHubConsumerGroupNotFound = errors.New("azurearm: event hubs consumer group not found")
	ErrEventHubRuleNotFound          = errors.New("azurearm: event hubs authorization rule not found")

	ErrEventGridTopicNotFound          = errors.New("azurearm: event grid topic not found")
	ErrEventGridSubscriptionNotFound   = errors.New("azurearm: event subscription not found")
	ErrEventGridNamespaceNotFound      = errors.New("azurearm: event grid namespace not found")
	ErrEventGridNamespaceTopicNotFound = errors.New("azurearm: event grid namespace topic not found")
	ErrEventGridDomainNotFound         = errors.New("azurearm: event grid domain not found")
	ErrEventGridDomainTopicNotFound    = errors.New("azurearm: event grid domain topic not found")
	ErrEventGridUnavailable            = errors.New("azurearm: event grid data plane is not available")

	ErrAppConfigStoreNotFound    = errors.New("azurearm: app configuration store not found")
	ErrAppConfigKeyValueNotFound = errors.New("azurearm: app configuration key-value not found")
	ErrAppConfigReplicaNotFound  = errors.New("azurearm: app configuration replica not found")
	ErrAppConfigDeletedNotFound  = errors.New("azurearm: deleted app configuration store not found")
	ErrAppConfigKeyLocked        = errors.New("azurearm: app configuration key-value is read-only")
	ErrAppConfigNameTaken        = errors.New("azurearm: app configuration store name is already in use")
	ErrAppConfigSoftDeleted      = errors.New("azurearm: app configuration store name is soft-deleted")
	ErrAppConfigPurgeProtected   = errors.New("azurearm: app configuration store has purge protection enabled")
	ErrAppConfigUnavailable      = errors.New("azurearm: app configuration data plane is not available")

	ErrWebSiteNotFound         = errors.New("azurearm: web site not found")
	ErrWebPlanNotFound         = errors.New("azurearm: app service plan not found")
	ErrWebFunctionNotFound     = errors.New("azurearm: function not found")
	ErrWebKeyNotFound          = errors.New("azurearm: function key not found")
	ErrWebConfigNotFound       = errors.New("azurearm: site configuration not found")
	ErrWebNameTaken            = errors.New("azurearm: site name is already in use")
	ErrWebPlanInUse            = errors.New("azurearm: app service plan still has sites")
	ErrWebUnsupportedKind      = errors.New("azurearm: only Linux web apps and function apps are supported")
	ErrWebInvalidSiteConfig    = errors.New("azurearm: invalid site configuration")
	ErrWebPlanNotLinux         = errors.New("azurearm: Linux app needs a Linux (reserved) plan")
	ErrWebNotFunctionApp       = errors.New("azurearm: operation is only valid for function apps")
	ErrWebInvalidKeyType       = errors.New("azurearm: key type must be functionKeys or systemKeys")
	ErrWebFunctionsUnavailable = errors.New("azurearm: azure functions data plane is not available")

	ErrACRRegistryNotFound    = errors.New("azurearm: container registry not found")
	ErrACRReplicationNotFound = errors.New("azurearm: container registry replication not found")
	ErrACRWebhookNotFound     = errors.New("azurearm: container registry webhook not found")
	ErrACRNameTaken           = errors.New("azurearm: container registry name is already in use")
	ErrACRAdminDisabled       = errors.New("azurearm: container registry admin user is not enabled")
	ErrACRInvalidSKU          = errors.New("azurearm: container registry sku name must be Basic, Standard or Premium")
	ErrACRPremiumRequired     = errors.New("azurearm: georeplication requires a Premium registry")
	ErrACRInvalidCredential   = errors.New("azurearm: credential name must be password or password2")
	ErrACRUnavailable         = errors.New("azurearm: container registry data plane is not available")

	ErrCosmosAccountNotFound    = errors.New("azurearm: cosmos db account not found")
	ErrCosmosDatabaseNotFound   = errors.New("azurearm: cosmos db database not found")
	ErrCosmosContainerNotFound  = errors.New("azurearm: cosmos db container not found")
	ErrCosmosThroughputNotFound = errors.New("azurearm: cosmos db throughput settings not found")
	ErrCosmosConflict           = errors.New("azurearm: cosmos db resource conflict")
	ErrCosmosBadRequest         = errors.New("azurearm: cosmos db invalid request")
	ErrCosmosUnavailable        = errors.New("azurearm: cosmos db data plane unavailable")

	ErrDeletedVaultNotFound = errors.New("azurearm: deleted key vault not found")
	ErrVaultPurgeProtected  = errors.New("azurearm: key vault has purge protection enabled")

	// ErrSnapshotResourceGroupNull/ErrSnapshotResourceNull are returned by
	// Restore when a persisted snapshot's map holds a JSON null entry, which
	// decodes to a nil pointer that would panic on first dereference if
	// stored as-is (same class of bug services/cosmosdb's persistence.go
	// guards against).
	ErrSnapshotResourceGroupNull = errors.New("azurearm: restore snapshot: resource group is null")
	ErrSnapshotResourceNull      = errors.New("azurearm: restore snapshot: resource is null")
)

Sentinel errors for Azure Resource Manager (ARM) emulation. Mapped to ARM error codes/HTTP statuses in the errorDetails table (handler.go), modeled on services/sqs's errorDetails pattern.

View Source
var (
	ErrRedisNotFound         = errors.New("azurearm: redis cache not found")
	ErrRedisFirewallNotFound = errors.New("azurearm: redis firewall rule not found")
	ErrRedisPatchNotFound    = errors.New("azurearm: redis patch schedule not found")
	ErrRedisLinkedNotFound   = errors.New("azurearm: redis linked server not found")
	ErrRedisNameTaken        = errors.New("azurearm: redis cache name is already in use")
	ErrRedisInvalid          = errors.New("azurearm: invalid redis request")
	ErrRedisUnavailable      = errors.New("azurearm: redis data plane is not available")
)

Sentinel errors of the Microsoft.Cache provider.

View Source
var (
	ErrSQLServerNotFound   = errors.New("azurearm: sql server not found")
	ErrSQLChildNotFound    = errors.New("azurearm: sql resource not found")
	ErrSQLNameTaken        = errors.New("azurearm: sql server name is already in use")
	ErrSQLInvalid          = errors.New("azurearm: invalid sql request")
	ErrSQLPasswordNotValid = errors.New("azurearm: sql password does not meet the policy")
	ErrSQLEngine           = errors.New("azurearm: sql engine failure")
	ErrSQLConflict         = errors.New("azurearm: sql resource is in use")
)

Sentinel errors of the Microsoft.Sql provider.

View Source
var ErrKeyVaultPortMismatch = errors.New(
	"azurearm: --azure-arm-keyvault-port must match --azure-keyvault-port",
)

ErrKeyVaultPortMismatch is returned when Settings.KeyVaultPort (what ARM advertises in vaultUri) disagrees with the Key Vault listener's own port.

View Source
var ErrMonitorUnavailable = &MonitorError{
	Code: redisCodeUnavailable, Message: "The Azure Monitor Logs data plane is not available.",
	Status: http.StatusServiceUnavailable,
}

ErrMonitorUnavailable is returned when no Azure Monitor Logs data plane is wired.

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

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

View Source
var ErrServiceBusPortMismatch = errors.New(
	"azurearm: --azure-arm-servicebus-port must match --azure-servicebus-port",
)

ErrServiceBusPortMismatch is returned when Settings.ServiceBusPort (what ARM advertises as serviceBusEndpoint) disagrees with the actual services/azureservicebus listener's own configured port -- the same fail-fast rationale as ErrStorageVHostPortMismatch.

View Source
var ErrStorageVHostPortMismatch = errors.New(
	"azurearm: --azure-arm-storage-vhost-port must match --azure-storage-vhost-port",
)

ErrStorageVHostPortMismatch is returned when Settings.StorageVHostPort (what ARM advertises in primaryEndpoints) disagrees with the actual services/azurestoragevhost listener's own configured port. Failing fast here, rather than letting the two silently diverge, avoids repeating the exact "advertised a port nothing answers on" bug class already found and fixed twice in this milestone (AZURE.md section 10.10, M8 bugs (1)/(5)).

Functions

func ProviderBody

func ProviderBody(subscriptionID, namespace, registrationState string, types []ResourceTypeDef) map[string]any

ProviderBody returns the wire response body for GET /subscriptions/{sub}/providers/{ns} and each entry of the GET /subscriptions/{sub}/providers list.

func RequestHostFromContext

func RequestHostFromContext(ctx context.Context) string

RequestHostFromContext returns the host stashed by WithRequestHost, or "" if none was set (e.g. a unit test calling a ResourceProvider directly).

func SubscriptionBody

func SubscriptionBody(subscriptionID, tenantID, displayName string) map[string]any

SubscriptionBody returns the wire response body for GET /subscriptions/{sub} and as the single entry of GET /subscriptions' "value" array. tenantID is a separate value from subscriptionID -- both default to the same fixed all-zeros GUID (AZURE.md section 10.5), but Settings allows overriding either independently, so this must not assume they're equal.

func TenantBody

func TenantBody(tenantID string) map[string]any

TenantBody returns the wire response body for one entry of GET /tenants' "value" array.

func WithRequestHost

func WithRequestHost(ctx context.Context, host string) context.Context

WithRequestHost returns a copy of ctx carrying host (the ARM request's own Host header, hostname only, no port).

Types

type ACIContainerView

type ACIContainerView struct {
	Prev     *ACIState
	Cur      ACIState
	Name     string
	Events   []ACIEvent
	Restarts int
}

ACIContainerView is a container's instanceView.

type ACICredential

type ACICredential struct {
	Server   string
	Username string
	Password string
}

ACICredential is an imageRegistryCredentials entry.

type ACIEngine

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

ACIEngine runs container groups in the container runtime.

func NewACIEngine

func NewACIEngine(runtime func() (ACIRuntime, error), disabledReason string) *ACIEngine

NewACIEngine creates an engine; runtime nil makes every group fail with disabledReason (or a default reason).

func (*ACIEngine) Active

func (e *ACIEngine) Active(key string) bool

Active reports whether the group has a live (not stopped, not failed) run.

func (*ACIEngine) Close

func (e *ACIEngine) Close()

Close stops every group and the engine.

func (*ACIEngine) Deploy

func (e *ACIEngine) Deploy(cfg aciConfig)

Deploy (re)creates the group's containers and returns once each has started or failed. Failures are recorded on the group's view, not returned.

func (*ACIEngine) Logs

func (e *ACIEngine) Logs(ctx context.Context, key, name string, tail int) (string, error)

Logs returns the container's logs, limited to the last tail lines when tail is positive.

func (*ACIEngine) Remove

func (e *ACIEngine) Remove(key string)

Remove stops the group and forgets it.

func (*ACIEngine) RemoveAll

func (e *ACIEngine) RemoveAll()

RemoveAll stops and forgets every group.

func (*ACIEngine) SetFileShares

func (e *ACIEngine) SetFileShares(s ACIFileShares)

SetFileShares wires the Azure Files seam used by azureFile volumes.

func (*ACIEngine) SetOnClose

func (e *ACIEngine) SetOnClose(fn func())

SetOnClose registers a hook run by Close after every group is stopped.

func (*ACIEngine) SetPortPool

func (e *ACIEngine) SetPortPool(p ACIPortPool)

SetPortPool wires the host port source for published ports.

func (*ACIEngine) SetRuntime

func (e *ACIEngine) SetRuntime(fn func() (ACIRuntime, error))

SetRuntime replaces the container runtime source; nil disables the engine.

func (*ACIEngine) SetTiming

func (e *ACIEngine) SetTiming(backoff func(int) time.Duration, startup time.Duration)

SetTiming overrides the restart backoff and the startup bound; for tests and tuning.

func (*ACIEngine) Stop

func (e *ACIEngine) Stop(key string)

Stop tears the group's containers down but keeps its record; later reads report Stopped.

func (*ACIEngine) View

func (e *ACIEngine) View(key string) (ACIView, bool)

View returns the live state of the group.

type ACIEvent

type ACIEvent struct {
	First   time.Time
	Last    time.Time
	Name    string
	Type    string
	Message string
	Count   int
}

ACIEvent is one entry of an instanceView events list.

type ACIFileShares

type ACIFileShares interface {
	ExportShare(account, share string) (ACIShareTree, error)
	ApplyShare(account, share string, tree ACIShareTree) error
}

ACIFileShares is the seam azureFile volumes use to reach the Azure Files service. ExportShare must fail when the share does not exist.

type ACIPortPool

type ACIPortPool = gcpserve.PortPool

ACIPortPool hands out host ports for published container ports.

type ACIRuntime

type ACIRuntime interface {
	// Pull fetches ref when it is absent or when cred is set; it reports whether a pull happened.
	Pull(ctx context.Context, ref string, cred *ACICredential) (bool, error)
	Start(ctx context.Context, spec container.Spec) (string, error)
	// Wait blocks until the container exits and returns its exit code.
	Wait(ctx context.Context, id string) (int, error)
	Logs(ctx context.Context, id, tail string) (string, error)
	Remove(ctx context.Context, id string) error
}

ACIRuntime is the slice of the container runtime that container groups need.

func NewDockerACIRuntime

func NewDockerACIRuntime(r gcpserve.Runner) ACIRuntime

NewDockerACIRuntime wraps a pkgs/container runner.

type ACIShareTree

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

ACIShareTree is the content of an Azure Files share: slash paths to file bytes, and directory paths.

type ACIState

type ACIState struct {
	StartTime  *time.Time
	FinishTime *time.Time
	ExitCode   *int
	State      string
	Detail     string
}

ACIState is a container's currentState or previousState.

type ACIView

type ACIView struct {
	HostPorts  map[int]int
	State      string
	Failure    string
	Events     []ACIEvent
	Containers []ACIContainerView
}

ACIView is the live state of one container group.

type AppConfig

type AppConfig interface {
	PutStore(name string) (time.Time, error)
	StoreCreated(name string) (time.Time, bool)
	DeleteStore(name string) error
	StoreKeys(name string) ([]AppConfigKey, error)
	RegenerateStoreKey(name, keyID string) (AppConfigKey, error)

	PutKeyValue(store string, kv AppConfigKV) (AppConfigKV, error)
	GetKeyValue(store, key, label string) (AppConfigKV, bool)
	DeleteKeyValue(store, key, label string) error
	ListKeyValues(store string) ([]AppConfigKV, error)
}

AppConfig is the seam the Microsoft.AppConfiguration resource provider uses to keep the App Configuration data plane in step with ARM, so stores, access keys and key-values are shared between both planes.

type AppConfigEndpointConfig

type AppConfigEndpointConfig struct {
	Override string
	Port     int
}

AppConfigEndpointConfig configures the endpoints the provider advertises.

type AppConfigKV

type AppConfigKV struct {
	LastModified time.Time
	Value        *string
	ContentType  *string
	Tags         map[string]string
	Key          string
	Label        string
	ETag         string
	Locked       bool
}

AppConfigKV is a key-value as the ARM keyValues resources see it.

type AppConfigKey

type AppConfigKey struct {
	LastModified time.Time
	ID           string
	Name         string
	Value        string
	ReadOnly     bool
}

AppConfigKey is one of a configuration store's access keys.

type AppConfigProvider

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

AppConfigProvider implements ResourceProvider for Microsoft.AppConfiguration. ARM keeps location, tags, SKU and unmodelled properties; stores, access keys and key-values live in the data plane.

func NewAppConfigProvider

func NewAppConfigProvider(cfg AppConfigEndpointConfig, dataPlane AppConfig) *AppConfigProvider

NewAppConfigProvider creates an AppConfigProvider; dataPlane may be nil.

func (*AppConfigProvider) CheckName

func (p *AppConfigProvider) CheckName(_ context.Context, name string) map[string]any

CheckName reports whether a store name is available.

func (*AppConfigProvider) Delete

Delete implements ResourceProvider.

func (*AppConfigProvider) DeleteResourcesInGroup

func (p *AppConfigProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*AppConfigProvider) DeletedStore

func (p *AppConfigProvider) DeletedStore(_ context.Context, location, name string) (map[string]any, error)

DeletedStore returns a soft-deleted store.

func (*AppConfigProvider) Get

Get implements ResourceProvider.

func (*AppConfigProvider) KeyValue

func (p *AppConfigProvider) KeyValue(_ context.Context, storeID ResourceID, key, label string) (map[string]any, error)

KeyValue serves POST .../listKeyValue: the key-value for the requested key and label.

func (*AppConfigProvider) List

func (p *AppConfigProvider) List(_ context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider; only stores are listable here.

func (*AppConfigProvider) ListDeletedStores

func (p *AppConfigProvider) ListDeletedStores(_ context.Context, subscription string) []map[string]any

ListDeletedStores lists the soft-deleted stores of a subscription.

func (*AppConfigProvider) ListKeyValues

func (p *AppConfigProvider) ListKeyValues(_ context.Context, storeID ResourceID) ([]map[string]any, error)

ListKeyValues lists the key-values of the store addressed by storeID.

func (*AppConfigProvider) ListKeys

func (p *AppConfigProvider) ListKeys(_ context.Context, id ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider for .../configurationStores/{name}/listKeys.

func (*AppConfigProvider) ListReplicas

func (p *AppConfigProvider) ListReplicas(_ context.Context, storeID ResourceID) ([]map[string]any, error)

ListReplicas lists the replicas of the store addressed by storeID.

func (*AppConfigProvider) Namespace

func (p *AppConfigProvider) Namespace() string

Namespace implements ResourceProvider.

func (*AppConfigProvider) PurgeDeletedStore

func (p *AppConfigProvider) PurgeDeletedStore(_ context.Context, location, name string) error

PurgeDeletedStore permanently removes a soft-deleted store.

func (*AppConfigProvider) Put

func (p *AppConfigProvider) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*AppConfigProvider) RegenerateKey

func (p *AppConfigProvider) RegenerateKey(_ context.Context, id ResourceID, keyID string) (map[string]any, error)

RegenerateKey replaces the access key with the given id and returns it.

func (*AppConfigProvider) Reset

func (p *AppConfigProvider) Reset()

Reset implements ResourceProvider.

func (*AppConfigProvider) ResourceTypes

func (p *AppConfigProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type ConfigProvider

type ConfigProvider interface {
	GetAzureARMSettings() Settings
}

ConfigProvider is a private interface to extract ARM configuration from the abstract AppContext Config, mirroring services/cosmosdb.ConfigProvider.

type ContainerInstanceProvider

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

ContainerInstanceProvider implements ResourceProvider for Microsoft.ContainerInstance container groups. ARM keeps the configuration; the ACIEngine runs the containers.

func NewContainerInstanceProvider

func NewContainerInstanceProvider(engine *ACIEngine) *ContainerInstanceProvider

NewContainerInstanceProvider creates a provider over engine.

func (*ContainerInstanceProvider) Action

Action runs start, stop or restart on a group.

func (*ContainerInstanceProvider) Close

func (p *ContainerInstanceProvider) Close()

Close stops every running group.

func (*ContainerInstanceProvider) Delete

Delete implements ResourceProvider.

func (*ContainerInstanceProvider) DeleteResourcesInGroup

func (p *ContainerInstanceProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*ContainerInstanceProvider) Engine

func (p *ContainerInstanceProvider) Engine() *ACIEngine

Engine returns the execution engine.

func (*ContainerInstanceProvider) Get

Get implements ResourceProvider.

func (*ContainerInstanceProvider) List

List implements ResourceProvider.

func (*ContainerInstanceProvider) ListKeys

ListKeys implements ResourceProvider.

func (*ContainerInstanceProvider) Logs

func (p *ContainerInstanceProvider) Logs(
	ctx context.Context,
	id ResourceID,
	container string,
	tail int,
) (string, error)

Logs returns a container's logs.

func (*ContainerInstanceProvider) Namespace

func (p *ContainerInstanceProvider) Namespace() string

Namespace implements ResourceProvider.

func (*ContainerInstanceProvider) Patch

func (p *ContainerInstanceProvider) Patch(
	_ context.Context,
	id ResourceID,
	body map[string]any,
) (map[string]any, error)

Patch replaces the group's tags.

func (*ContainerInstanceProvider) Put

func (p *ContainerInstanceProvider) Put(_ context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider. It answers once the containers have started or failed to.

func (*ContainerInstanceProvider) Reset

func (p *ContainerInstanceProvider) Reset()

Reset implements ResourceProvider.

func (*ContainerInstanceProvider) ResourceTypes

func (p *ContainerInstanceProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type ContainerRegistries

type ContainerRegistries interface {
	PutRegistry(name string, adminEnabled bool) (ContainerRegistryInfo, error)
	RegistryInfo(name string) (ContainerRegistryInfo, bool)
	DeleteRegistry(name string) error
	Credentials(name string) (ContainerRegistryCredentials, error)
	RegenerateCredential(name, which string) (ContainerRegistryCredentials, error)
	SetWebhook(registry string, w ContainerRegistryWebhook) error
	DeleteWebhook(registry, name string) error
	PingWebhook(registry, name string) (string, error)
	WebhookEvents(registry, name string) ([]map[string]any, error)
}

ContainerRegistries is the seam the Microsoft.ContainerRegistry resource provider uses to keep the registry data plane in step with ARM. Primitive types only, so this package never imports the data-plane service.

type ContainerRegistryCredentials

type ContainerRegistryCredentials struct {
	Username  string
	Password  string
	Password2 string
}

ContainerRegistryCredentials are a registry's admin-user credentials.

type ContainerRegistryEndpointConfig

type ContainerRegistryEndpointConfig struct {
	Override string
	Port     int
}

ContainerRegistryEndpointConfig configures the login server the provider advertises.

type ContainerRegistryInfo

type ContainerRegistryInfo struct {
	CreatedAt    time.Time
	AdminEnabled bool
}

ContainerRegistryInfo is the data plane's view of a registry.

type ContainerRegistryProvider

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

ContainerRegistryProvider implements ResourceProvider for Microsoft.ContainerRegistry. ARM keeps location, tags, SKU, child resources and unmodelled properties; the registry, its admin flag and credentials live in the data plane.

func NewContainerRegistryProvider

func NewContainerRegistryProvider(
	cfg ContainerRegistryEndpointConfig, dataPlane ContainerRegistries,
) *ContainerRegistryProvider

NewContainerRegistryProvider creates a ContainerRegistryProvider; dataPlane may be nil.

func (*ContainerRegistryProvider) CallbackConfig

func (p *ContainerRegistryProvider) CallbackConfig(_ context.Context, id ResourceID) (map[string]any, error)

CallbackConfig answers POST .../webhooks/{name}/getCallbackConfig.

func (*ContainerRegistryProvider) CheckName

func (p *ContainerRegistryProvider) CheckName(name string) map[string]any

CheckName answers POST .../checkNameAvailability.

func (*ContainerRegistryProvider) Delete

Delete implements ResourceProvider.

func (*ContainerRegistryProvider) DeleteResourcesInGroup

func (p *ContainerRegistryProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*ContainerRegistryProvider) Get

Get implements ResourceProvider.

func (*ContainerRegistryProvider) List

List implements ResourceProvider; registries are listable at subscription and group scope.

func (*ContainerRegistryProvider) ListChildren

func (p *ContainerRegistryProvider) ListChildren(id ResourceID, kind acrKind) ([]map[string]any, error)

ListChildren lists a registry's replications or webhooks.

func (*ContainerRegistryProvider) ListCredentials

func (p *ContainerRegistryProvider) ListCredentials(_ context.Context, id ResourceID) (map[string]any, error)

ListCredentials answers POST .../listCredentials.

func (*ContainerRegistryProvider) ListKeys

ListKeys is not applicable to registries; credentials come from ListCredentials.

func (*ContainerRegistryProvider) Namespace

func (p *ContainerRegistryProvider) Namespace() string

Namespace implements ResourceProvider.

func (*ContainerRegistryProvider) Patch

func (p *ContainerRegistryProvider) Patch(
	_ context.Context,
	id ResourceID,
	body map[string]any,
) (map[string]any, error)

Patch updates tags, SKU, identity and properties of a registry in place (ARM PATCH).

func (*ContainerRegistryProvider) PingWebhook

func (p *ContainerRegistryProvider) PingWebhook(_ context.Context, id ResourceID) (map[string]any, error)

PingWebhook answers POST .../webhooks/{name}/ping with the id of the ping event it delivers.

func (*ContainerRegistryProvider) Put

func (p *ContainerRegistryProvider) Put(
	ctx context.Context, id ResourceID, body map[string]any,
) (map[string]any, error)

Put implements ResourceProvider.

func (*ContainerRegistryProvider) RegenerateCredential

func (p *ContainerRegistryProvider) RegenerateCredential(
	_ context.Context, id ResourceID, which string,
) (map[string]any, error)

RegenerateCredential answers POST .../regenerateCredential.

func (*ContainerRegistryProvider) Reset

func (p *ContainerRegistryProvider) Reset()

Reset implements ResourceProvider.

func (*ContainerRegistryProvider) ResourceTypes

func (p *ContainerRegistryProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

func (*ContainerRegistryProvider) WebhookEvents

func (p *ContainerRegistryProvider) WebhookEvents(_ context.Context, id ResourceID) (map[string]any, error)

WebhookEvents answers POST .../webhooks/{name}/listEvents.

type ContainerRegistryWebhook

type ContainerRegistryWebhook struct {
	Headers    map[string]string
	Name       string
	ServiceURI string
	Scope      string
	Status     string
	Actions    []string
}

ContainerRegistryWebhook is a registry webhook the data plane fires on image and chart pushes and deletes.

type CosmosContainer

type CosmosContainer struct {
	Modified                 time.Time
	DefaultTTL               *int
	ID                       string
	RID                      string
	PartitionKeyPaths        []string
	IndexingPolicy           []byte
	UniqueKeyPolicy          []byte
	ConflictResolutionPolicy []byte
}

CosmosContainer is a Cosmos DB container as the data plane reports it; the policy fields are raw JSON.

type CosmosDatabase

type CosmosDatabase struct {
	Modified time.Time
	ID       string
	RID      string
}

CosmosDatabase is a Cosmos DB database as the data plane reports it.

type CosmosEndpointConfig

type CosmosEndpointConfig struct {
	Override string
}

CosmosEndpointConfig configures how the DocumentDB provider advertises documentEndpoint.

type CosmosProvider

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

CosmosProvider implements ResourceProvider for Microsoft.DocumentDB. Databases and containers live in the Cosmos DB data plane behind the CosmosResources seam; this provider keeps account metadata, ownership and the legacy throughput entries of snapshots written before offers moved to the data plane.

func NewCosmosProvider

func NewCosmosProvider(cfg CosmosEndpointConfig, dataPlane CosmosResources) *CosmosProvider

NewCosmosProvider creates a CosmosProvider; dataPlane may be nil.

func (*CosmosProvider) ConnectionStrings

func (p *CosmosProvider) ConnectionStrings(ctx context.Context, id ResourceID) (map[string]any, error)

ConnectionStrings serves the listConnectionStrings action.

func (*CosmosProvider) Delete

func (p *CosmosProvider) Delete(_ context.Context, id ResourceID) error

Delete implements ResourceProvider.

func (*CosmosProvider) DeleteResourcesInGroup

func (p *CosmosProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*CosmosProvider) FailoverPriorityChange

func (p *CosmosProvider) FailoverPriorityChange(_ context.Context, id ResourceID, body map[string]any) error

FailoverPriorityChange applies a manual failover: the body must give every location exactly one unique priority, and the location with priority 0 becomes the write region.

func (*CosmosProvider) Get

func (p *CosmosProvider) Get(ctx context.Context, id ResourceID) (map[string]any, error)

Get implements ResourceProvider.

func (*CosmosProvider) List

func (p *CosmosProvider) List(ctx context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider; id's Names holds the parent chain for child lists.

func (*CosmosProvider) ListKeys

func (p *CosmosProvider) ListKeys(_ context.Context, id ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider.

func (*CosmosProvider) Namespace

func (p *CosmosProvider) Namespace() string

Namespace implements ResourceProvider.

func (*CosmosProvider) Patch

func (p *CosmosProvider) Patch(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Patch merges tags, identity and properties into an existing account.

func (*CosmosProvider) Put

func (p *CosmosProvider) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*CosmosProvider) ReadonlyKeys

func (p *CosmosProvider) ReadonlyKeys(_ context.Context, id ResourceID) (map[string]any, error)

ReadonlyKeys serves the readonlykeys action.

func (*CosmosProvider) RegenerateKey

func (p *CosmosProvider) RegenerateKey(_ context.Context, id ResourceID, kind string) error

RegenerateKey replaces one of the account's keys with a fresh random one the data plane authorizes.

func (*CosmosProvider) Reset

func (p *CosmosProvider) Reset()

Reset implements ResourceProvider.

func (*CosmosProvider) ResourceTypes

func (p *CosmosProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type CosmosRegion

type CosmosRegion struct {
	Name     string
	Priority int
}

CosmosRegion is one account location and its failover priority.

type CosmosResources

type CosmosResources interface {
	// Endpoint reports the data-plane listener's port and whether it serves TLS.
	Endpoint() (port int, tls bool)
	// MasterKey is the data plane's configured master key.
	MasterKey() string
	// AcceptKey and RevokeKey manage extra keys the data plane authorizes.
	AcceptKey(key string)
	RevokeKey(key string)

	CreateDatabase(id string) (CosmosDatabase, error)
	GetDatabase(id string) (CosmosDatabase, error)
	ListDatabases() []CosmosDatabase
	DeleteDatabase(id string) error

	// PutContainer creates the container, or replaces its mutable settings when it already exists.
	PutContainer(db string, c CosmosContainer) (CosmosContainer, error)
	GetContainer(db, id string) (CosmosContainer, error)
	ListContainers(db string) ([]CosmosContainer, error)
	DeleteContainer(db, id string) error

	// GetThroughput reads the offer of a database (container == "") or container; ErrCosmosThroughputNotFound
	// when none is provisioned.
	GetThroughput(db, container string) (CosmosThroughput, error)
	// PutThroughput creates or replaces that offer.
	PutThroughput(db, container string, t CosmosThroughput) error

	// SetRegions publishes the account's regional topology (the lowest priority is the write region).
	SetRegions(regions []CosmosRegion, multiWrite bool)
}

CosmosResources is the seam the Microsoft.DocumentDB resource provider uses to reach the Cosmos DB data plane. Errors are the package's ErrCosmos* sentinels.

type CosmosThroughput

type CosmosThroughput = cosmosThroughput

CosmosThroughput is a provisioned-throughput setting: manual RU/s or an autoscale maximum.

type EnvironmentAuth

type EnvironmentAuth struct {
	LoginEndpoint    string   `json:"loginEndpoint"`
	IdentityProvider string   `json:"identityProvider"`
	Tenant           string   `json:"tenant"`
	Audiences        []string `json:"audiences"`
}

EnvironmentAuth is EnvironmentDescriptor's "authentication" field.

Tenant must be the literal string "common", and IdentityProvider must be "AAD" -- not gopherstack's fixed tenant GUID. hashicorp/go-azure-sdk's Environment.IsAzureStack() (sdk/environments/azure_stack.go) treats any other combination as an Azure Stack environment, which terraform-provider-azurerm explicitly refuses to run against (internal/clients/builder.go: "does not support Azure Stack"). Real Azure's own AzurePublic() environment (sdk/environments/azure_public.go) hardcodes exactly these two values even though it obviously isn't single-tenant -- this is a control field for auth flow selection, not a place to plug in a real tenant ID.

type EnvironmentDescriptor

type EnvironmentDescriptor struct {
	Suffixes                 EnvironmentSuffixes `json:"suffixes"`
	Gallery                  string              `json:"gallery"`
	Media                    string              `json:"media,omitempty"`
	Graph                    string              `json:"graph"`
	GraphAudience            string              `json:"graphAudience"`
	Name                     string              `json:"name"`
	ResourceManager          string              `json:"resourceManager"`
	ResourceManagerEndpoint  string              `json:"resourceManagerEndpoint"`
	ActiveDirectoryDataLake  string              `json:"activeDirectoryDataLake,omitempty"`
	SQLManagement            string              `json:"sqlManagement,omitempty"`
	Batch                    string              `json:"batch,omitempty"`
	Portal                   string              `json:"portal"`
	MicrosoftGraphResourceID string              `json:"microsoftGraphResourceId"`
	Authentication           EnvironmentAuth     `json:"authentication"`
}

EnvironmentDescriptor is the GET /metadata/endpoints response body: a SINGLE JSON object, not an array (see BuildMetadataEndpoints's doc comment for why this is non-obvious and easy to get backwards). Field set and semantics verified against hashicorp/go-azure-sdk's environments.FromEndpoint, which hard-fails on a document missing Name, ResourceManagerEndpoint, or MicrosoftGraphResourceID (AZURE.md section 10.8) -- every one of those three, plus every other field FromEndpoint reads, is populated below.

MicrosoftGraphResourceID is a TOP-LEVEL field ("microsoftGraphResourceId"), not nested under a "resourceIdentifiers" object -- verified against go-azure-sdk's sdk/internal/metadata/client.go's unexported metaDataResponse wire struct, which has no ResourceIdentifiers field at all. Nesting it silently zero-values the field on unmarshal (FromEndpoint then fails with "no `microsoftGraphResourceId` was returned").

func BuildMetadataEndpoints

func BuildMetadataEndpoints(baseURL string, settings Settings) EnvironmentDescriptor

BuildMetadataEndpoints builds the GET /metadata/endpoints response body for settings.Environment, with every URL pointing back at baseURL (the ARM listener's own scheme://host:port, e.g. "https://host:10006").

Returns a SINGLE EnvironmentDescriptor, not a slice -- deliberately, and non-obviously so. Real Azure's public /metadata/endpoints does return a JSON array (the multi-cloud discovery list: public/US Gov/China/etc), and that public shape is what most docs and examples show. But terraform-provider-azurerm's metadata_host custom-environment path never hits that public endpoint or its array-shaped client: it goes through hashicorp/go-azure-sdk's environments.FromEndpoint -> sdk/internal/metadata/client.go's GetMetaData, which does `json.Unmarshal(respBody, &metadata)` into a single `*metaDataResponse` struct. An array response there fails with "json: cannot unmarshal array into Go value of type metadata.metaDataResponse" -- a real bug M7 shipped with, undetected because no `terraform apply` had ever reached this endpoint until M8's CI-discovery-glob fix let the Terraform suite actually run (AZURE.md section 10.8 records this). Do not "fix" this back to an array without re-reading that section first.

type EnvironmentSuffixes

type EnvironmentSuffixes struct {
	Storage            string `json:"storage"`
	KeyVaultDNS        string `json:"keyVaultDns"`
	SQLServerHostname  string `json:"sqlServerHostname"`
	ACRLoginServer     string `json:"acrLoginServer"`
	AzureDatalakeStore string `json:"azureDataLakeStoreFileSystem,omitempty"`
}

EnvironmentSuffixes is EnvironmentDescriptor's "suffixes" field.

type EventGrid

type EventGrid interface {
	PutTopic(name, resourceID, inputSchema string) (EventGridTopic, error)
	TopicInfo(name string) (EventGridTopic, bool)
	DeleteTopic(name string) error
	TopicKeys(name string) (key1, key2 string, err error)
	RegenerateTopicKey(name, keyName string) (key1, key2 string, err error)

	PutSubscription(ctx context.Context, topic, name string, props map[string]any) (map[string]any, error)
	GetSubscription(topic, name string) (map[string]any, bool)
	DeleteSubscription(topic, name string) error
	SubscriptionFullURL(topic, name string) (string, error)

	PutNamespace(name string) error
	DeleteNamespace(name string) error
	NamespaceKeys(name string) (key1, key2 string, err error)
	RegenerateNamespaceKey(name, keyName string) (key1, key2 string, err error)
	PutNamespaceTopic(ns, name string) (time.Time, error)
	NamespaceTopicCreated(ns, name string) (time.Time, bool)
	DeleteNamespaceTopic(ns, name string) error

	PutPullSubscription(ns, topic, name string, props map[string]any) (map[string]any, error)
	GetPullSubscription(ns, topic, name string) (map[string]any, bool)
	DeletePullSubscription(ns, topic, name string) error

	PutDomain(name, resourceID, inputSchema string, autoCreate, autoDelete *bool) (EventGridDomain, error)
	DomainInfo(name string) (EventGridDomain, bool)
	DeleteDomain(name string) error
	DomainKeys(name string) (key1, key2 string, err error)
	RegenerateDomainKey(name, keyName string) (key1, key2 string, err error)
	PutDomainTopic(domain, name string) (time.Time, error)
	DomainTopic(domain, name string) (EventGridDomainTopic, bool)
	DomainTopics(domain string) ([]EventGridDomainTopic, error)
	DeleteDomainTopic(domain, name string) error

	// The scoped calls address a custom topic (domain empty), a domain (topic empty) or a domain topic.
	PutScopedSubscription(ctx context.Context, domain, topic, name string, props map[string]any) (map[string]any, error)
	GetScopedSubscription(domain, topic, name string) (map[string]any, bool)
	DeleteScopedSubscription(domain, topic, name string) error
	ScopedSubscriptionFullURL(domain, topic, name string) (string, error)
	DeliveryAttributes(domain, topic, name string) ([]map[string]any, error)
	// PatchScopedSubscription merges an EventSubscriptionUpdateParameters body into an existing subscription.
	PatchScopedSubscription(
		ctx context.Context,
		domain, topic, name string,
		patch map[string]any,
	) (map[string]any, error)

	// The resource calls address event subscriptions of an ARM scope: a subscription, resource group or resource.
	PutResourceSubscription(ctx context.Context, scopeID, name string, props map[string]any) (map[string]any, error)
	GetResourceSubscription(scopeID, name string) (map[string]any, bool)
	DeleteResourceSubscription(scopeID, name string) error
	ResourceSubscriptionFullURL(scopeID, name string) (string, error)
	ResourceDeliveryAttributes(scopeID, name string) ([]map[string]any, error)
	PatchResourceSubscription(ctx context.Context, scopeID, name string, patch map[string]any) (map[string]any, error)
}

EventGrid is the seam the Microsoft.EventGrid resource provider uses to keep the Event Grid data plane in step with ARM. Subscription and namespace-topic subscription properties cross as ARM property maps, so this package never imports services/azureeventgrid.

type EventGridDomain

type EventGridDomain struct {
	CreatedAt   time.Time
	InputSchema string
	AutoCreate  bool
	AutoDelete  bool
}

EventGridDomain is the data plane's view of a domain.

type EventGridDomainTopic

type EventGridDomainTopic struct {
	CreatedAt time.Time
	Name      string
}

EventGridDomainTopic is the data plane's view of a domain topic.

type EventGridEndpointConfig

type EventGridEndpointConfig struct {
	Override string
	Port     int
}

EventGridEndpointConfig configures the endpoints the provider advertises.

type EventGridProvider

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

EventGridProvider implements ResourceProvider for Microsoft.EventGrid. ARM keeps only ARM-side metadata; topics, keys, subscriptions and queued events live in the data plane.

func NewEventGridProvider

func NewEventGridProvider(cfg EventGridEndpointConfig, dataPlane EventGrid) *EventGridProvider

NewEventGridProvider creates an EventGridProvider; dataPlane may be nil.

func (*EventGridProvider) Delete

Delete implements ResourceProvider.

func (*EventGridProvider) DeleteResourcesInGroup

func (p *EventGridProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*EventGridProvider) DeleteScopeSubscription

func (p *EventGridProvider) DeleteScopeSubscription(scope EventSubscriptionScope, name string) error

DeleteScopeSubscription removes an event subscription of an ARM scope.

func (*EventGridProvider) DeliveryAttributes

func (p *EventGridProvider) DeliveryAttributes(_ context.Context, id ResourceID) (map[string]any, error)

DeliveryAttributes returns a subscription's delivery attribute mappings with secret values (POST .../getDeliveryAttributes).

func (*EventGridProvider) FullURL

func (p *EventGridProvider) FullURL(_ context.Context, id ResourceID) (map[string]any, error)

FullURL returns a WebHook subscription's complete endpoint URL (POST .../getFullUrl).

func (*EventGridProvider) Get

Get implements ResourceProvider.

func (*EventGridProvider) List

func (p *EventGridProvider) List(_ context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider; only topics and namespaces are listable.

func (*EventGridProvider) ListDomainTopics

func (p *EventGridProvider) ListDomainTopics(_ context.Context, id ResourceID) ([]map[string]any, error)

ListDomainTopics lists the topics of the domain identified by id.

func (*EventGridProvider) ListEventSubscriptions

func (p *EventGridProvider) ListEventSubscriptions(q EventSubscriptionQuery) ([]map[string]any, string, error)

ListEventSubscriptions lists event subscriptions per q and returns the page and the next token.

func (*EventGridProvider) ListKeys

func (p *EventGridProvider) ListKeys(_ context.Context, id ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider for topics and namespaces.

func (*EventGridProvider) Namespace

func (p *EventGridProvider) Namespace() string

Namespace implements ResourceProvider.

func (*EventGridProvider) PatchScopeSubscription

func (p *EventGridProvider) PatchScopeSubscription(
	ctx context.Context, scope EventSubscriptionScope, name string, body map[string]any,
) (map[string]any, error)

PatchScopeSubscription applies an EventSubscriptionUpdateParameters body to an existing event subscription of an ARM scope.

func (*EventGridProvider) PatchSubscription

func (p *EventGridProvider) PatchSubscription(
	ctx context.Context, id ResourceID, body map[string]any,
) (map[string]any, error)

PatchSubscription applies an EventSubscriptionUpdateParameters body to an existing topic, domain or domain topic event subscription and returns the updated resource.

func (*EventGridProvider) Put

func (p *EventGridProvider) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*EventGridProvider) PutScopeSubscription

func (p *EventGridProvider) PutScopeSubscription(
	ctx context.Context, scope EventSubscriptionScope, name string, body map[string]any,
) (map[string]any, error)

PutScopeSubscription creates or updates an event subscription on an ARM scope.

func (*EventGridProvider) RegenerateKey

func (p *EventGridProvider) RegenerateKey(_ context.Context, id ResourceID, keyName string) (map[string]any, error)

RegenerateKey replaces key1 or key2 and returns both keys.

func (*EventGridProvider) Reset

func (p *EventGridProvider) Reset()

Reset implements ResourceProvider.

func (*EventGridProvider) ResourceTypes

func (p *EventGridProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

func (*EventGridProvider) ScopeDeliveryAttributes

func (p *EventGridProvider) ScopeDeliveryAttributes(
	scope EventSubscriptionScope, name string,
) (map[string]any, error)

ScopeDeliveryAttributes returns a subscription's delivery attribute mappings with secret values.

func (*EventGridProvider) ScopeSubscription

func (p *EventGridProvider) ScopeSubscription(scope EventSubscriptionScope, name string) (map[string]any, error)

ScopeSubscription returns an event subscription of an ARM scope.

func (*EventGridProvider) ScopeSubscriptionFullURL

func (p *EventGridProvider) ScopeSubscriptionFullURL(
	scope EventSubscriptionScope, name string,
) (map[string]any, error)

ScopeSubscriptionFullURL returns a WebHook subscription's complete endpoint URL.

type EventGridTopic

type EventGridTopic struct {
	CreatedAt   time.Time
	InputSchema string
}

EventGridTopic is the data plane's view of a custom topic.

type EventHubEndpointConfig

type EventHubEndpointConfig struct {
	Override string
	Port     int
	AMQPPort int
}

EventHubEndpointConfig configures the endpoints the provider advertises.

type EventHubInfo

type EventHubInfo struct {
	CreatedAt    time.Time
	PartitionIDs []string
	Retention    time.Duration
}

EventHubInfo is the data plane's view of an event hub.

type EventHubProvider

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

EventHubProvider implements ResourceProvider for Microsoft.EventHub. ARM keeps only ARM-side metadata; hubs, consumer groups, rules and their keys live in the data plane.

func NewEventHubProvider

func NewEventHubProvider(cfg EventHubEndpointConfig, dataPlane EventHubs) *EventHubProvider

NewEventHubProvider creates an EventHubProvider; dataPlane may be nil.

func (*EventHubProvider) Delete

func (p *EventHubProvider) Delete(_ context.Context, id ResourceID) error

Delete implements ResourceProvider.

func (*EventHubProvider) DeleteResourcesInGroup

func (p *EventHubProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*EventHubProvider) Get

func (p *EventHubProvider) Get(_ context.Context, id ResourceID) (map[string]any, error)

Get implements ResourceProvider.

func (*EventHubProvider) List

func (p *EventHubProvider) List(_ context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider.

func (*EventHubProvider) ListKeys

func (p *EventHubProvider) ListKeys(_ context.Context, id ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider for .../authorizationRules/{rule}/listKeys.

func (*EventHubProvider) Namespace

func (p *EventHubProvider) Namespace() string

Namespace implements ResourceProvider.

func (*EventHubProvider) Put

func (p *EventHubProvider) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*EventHubProvider) Reset

func (p *EventHubProvider) Reset()

Reset implements ResourceProvider.

func (*EventHubProvider) ResourceTypes

func (p *EventHubProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type EventHubRule

type EventHubRule struct {
	PrimaryKey   string
	SecondaryKey string
	Rights       []string
}

EventHubRule is the data plane's view of an authorization rule.

type EventHubs

type EventHubs interface {
	EnsureNamespace(name string) error
	DeleteNamespace(name string) error
	CreateHub(ns, name string, partitionCount int, retention time.Duration) (EventHubInfo, error)
	HubInfo(ns, name string) (EventHubInfo, bool)
	DeleteHub(ns, name string) error
	CreateConsumerGroup(ns, hub, name string) error
	DeleteConsumerGroup(ns, hub, name string) error
	PutRule(ns, hub, name string, rights []string) (EventHubRule, error)
	GetRule(ns, hub, name string) (EventHubRule, bool)
	DeleteRule(ns, hub, name string) error
}

EventHubs is the seam the Microsoft.EventHub resource provider uses to keep the Event Hubs data plane in step with ARM. Primitive types only, so this package never imports services/azureeventhubs. hub is empty for namespace-scoped rules.

type EventSubscriptionQuery

type EventSubscriptionQuery struct {
	// OwnerID, when set, restricts the list to subscriptions owned by that resource.
	OwnerID        string
	SubscriptionID string
	ResourceGroup  string
	Location       string
	TopicType      string
	Filter         string
	SkipToken      string
	// Regional selects subscriptions of Event Grid topics and domains (by location);
	// otherwise subscriptions of subscriptions, resource groups and other resources.
	Regional bool
	Top      int
}

EventSubscriptionQuery selects the event subscriptions a list operation returns.

type EventSubscriptionScope

type EventSubscriptionScope struct {
	ID             string
	SubscriptionID string
	ResourceGroup  string
}

EventSubscriptionScope identifies the owner of an event subscription that is not an Event Grid resource: a subscription, a resource group or a resource.

type FileServices

type FileServices interface {
	SetShareRetention(account string, enabled bool, days int32)
	ShareRetention(account string) (bool, int32)
}

FileServices is the seam through which the file service's share soft-delete policy reaches the Azure Files data plane.

type FunctionAppConfig

type FunctionAppConfig struct {
	Kind            string
	LinuxFx         string
	AppCommandLine  string
	HealthCheckPath string
}

FunctionAppConfig is what ARM tells the data plane about a function app's stack.

type FunctionAppFunction

type FunctionAppFunction struct {
	Config     map[string]any
	Name       string
	Language   string
	InvokeURL  string
	IsDisabled bool
}

FunctionAppFunction is one function of an app.

type FunctionAppInfo

type FunctionAppInfo struct {
	Created    time.Time
	LastDeploy time.Time
	HostName   string
	SCMHost    string
	Image      string
	Worker     string
	Failure    string
	Stopped    bool
	Deployed   bool
}

FunctionAppInfo is the data plane's view of a function app.

type FunctionApps

type FunctionApps interface {
	PutApp(name string, cfg FunctionAppConfig) (FunctionAppInfo, error)
	DeleteApp(name string) error
	AppInfo(name string) (FunctionAppInfo, bool)
	Settings(name string) (map[string]string, error)
	SetSettings(name string, settings map[string]string) error
	SetStopped(name string, stopped bool) error
	Restart(name string) error
	Functions(ctx context.Context, name string) ([]FunctionAppFunction, error)
	HostKeys(name string) (FunctionHostKeys, error)
	SetHostKey(name, keyType, keyName, value string) (string, error)
	DeleteHostKey(name, keyType, keyName string) error
	FunctionKeys(name, fn string) (map[string]string, error)
	SetFunctionKey(name, fn, keyName, value string) (string, error)
	DeleteFunctionKey(name, fn, keyName string) error
	PublishingCredentials(name string) (user, password, scmURI string, err error)
}

FunctionApps is the seam the Microsoft.Web resource provider uses to keep function apps and Linux web apps in step with the Azure Functions data plane. Primitive types only, so this package never imports the data-plane service. Implementations return ErrWebSiteNotFound, ErrWebFunctionNotFound, ErrWebKeyNotFound or ErrWebInvalidKeyType.

type FunctionHostKeys

type FunctionHostKeys struct {
	FunctionKeys map[string]string
	SystemKeys   map[string]string
	MasterKey    string
}

FunctionHostKeys are an app's host-level keys.

type Handler

type Handler struct {
	Backend  *InMemoryBackend
	Registry *Registry
	Issuer   *aadauth.Issuer

	Settings Settings
	Port     int
	// contains filtered or unexported fields
}

Handler is the Echo HTTP handler for the ARM emulation's dedicated listener.

func NewHandler

func NewHandler(backend *InMemoryBackend, registry *Registry, issuer *aadauth.Issuer, settings Settings) *Handler

NewHandler creates a new ARM Handler.

func (*Handler) ExtractOperation

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

ExtractOperation extracts the ARM operation name from the request, for metrics labeling.

func (*Handler) ExtractResource

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

ExtractResource extracts a resource identifier from the request path, for metrics labeling.

func (*Handler) GetSupportedOperations

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

GetSupportedOperations returns the list of supported ARM operations.

func (*Handler) Handler

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

Handler returns the Echo handler function for ARM operations.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority for the AzureARM handler. Irrelevant in practice since RouteMatcher never matches; 0 is the safe default.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all in-memory ARM state.

func (*Handler) Restore

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

Restore implements persistence.Persistable.

func (*Handler) RouteMatcher

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

RouteMatcher exists only to satisfy service.Registerable's interface contract: AzureARM deliberately never matches on the shared AWS single-port Router, exactly like services/azureblob/azurequeue/azuretable/ cosmosdb -- it runs on its own dedicated HTTPS listener started by StartWorker. Only RouteMatcher itself is inert.

func (*Handler) SetResourceObserver

func (h *Handler) SetResourceObserver(o ResourceObserver)

SetResourceObserver registers the observer; call it before the handler serves requests.

func (*Handler) Shutdown

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

Shutdown stops the dedicated ARM listener, mirroring services/azureblob.Handler.Shutdown's graceful-then-forced-close shape.

func (*Handler) Snapshot

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

Snapshot implements persistence.Persistable: backend state plus the Microsoft.KeyVault provider's ARM-side vaults and deleted vaults.

func (*Handler) StartWorker

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

StartWorker binds AzureARM's dedicated fixed port and serves HTTPS -- either with a stable caller-supplied certificate or a freshly generated self-signed one (see loadOrGenerateCert) -- synchronously, failing fast if the port is unavailable rather than falling back into the shared PortAlloc pool -- exactly like services/azureblob/azurequeue/azuretable/cosmosdb's StartWorker (see AZURE.md section 10.7). Unlike those, ARM serves HTTPS unconditionally: azurerm's metadata_host handling hardcodes "https://" (AZURE.md section 10.8), so a plain-HTTP listener here would make provider initialization fail outright, not merely warn.

type InMemoryBackend

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

InMemoryBackend owns the ARM resource graph: one subscription's resource groups, its generic resource-provider-registration state, and the flat map of every resource not owned by a dedicated ResourceProvider's own internal state (e.g. rp_storage.go keeps its own storage-account map -- see registry.go for how the two interact). This is ARM-side metadata ONLY, never a second copy of any data-plane service's state (AZURE.md section 10.9).

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates an empty InMemoryBackend.

func (*InMemoryBackend) DeleteResourceGroup

func (b *InMemoryBackend) DeleteResourceGroup(name string) error

DeleteResourceGroup deletes the resource group named name, along with every generic resource whose ResourceGroup matches (case-insensitively). Resources owned by a dedicated ResourceProvider's own internal state (e.g. storage accounts) are NOT cascaded here -- see registry.go's DeleteResourcesInGroup, which handler.go calls across every registered provider before calling this.

func (*InMemoryBackend) GetResourceGroup

func (b *InMemoryBackend) GetResourceGroup(name string) (ResourceGroup, error)

GetResourceGroup returns the resource group named name.

func (*InMemoryBackend) IsProviderRegistered

func (b *InMemoryBackend) IsProviderRegistered(subscriptionID, namespace string) bool

IsProviderRegistered reports whether namespace has been registered for subscriptionID.

func (*InMemoryBackend) ListResourceGroups

func (b *InMemoryBackend) ListResourceGroups() []ResourceGroup

ListResourceGroups returns every resource group, sorted by name.

func (*InMemoryBackend) ProviderRegistrationState

func (b *InMemoryBackend) ProviderRegistrationState(subscriptionID, namespace string) string

ProviderRegistrationState returns "Registered" or "NotRegistered" for namespace under subscriptionID, the value ARM's /providers/{ns} response carries in its "registrationState" field.

func (*InMemoryBackend) PutResourceGroup

func (b *InMemoryBackend) PutResourceGroup(name, location string, tags map[string]string) (ResourceGroup, bool)

PutResourceGroup creates or updates the resource group named name. Always synchronous (AZURE.md section 10.3): the caller determines 200 vs 201 from the returned created bool.

func (*InMemoryBackend) RegisterProvider

func (b *InMemoryBackend) RegisterProvider(subscriptionID, namespace string)

RegisterProvider marks namespace as registered for subscriptionID.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all in-memory ARM state. Used by the POST /_gopherstack/reset endpoint. Never touches any data-plane service's own state (AZURE.md section 10.9).

func (*InMemoryBackend) ResourceGroupExists

func (b *InMemoryBackend) ResourceGroupExists(name string) bool

ResourceGroupExists reports whether a resource group named name exists.

func (*InMemoryBackend) Restore

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

Restore loads backend state from a JSON snapshot. It implements persistence.Persistable. Restore must be idempotent against the data plane (AZURE.md section 10.9): this method only ever restores ARM's own metadata, never re-creates or otherwise touches any data-plane service's state.

func (*InMemoryBackend) Snapshot

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

Snapshot serializes the backend state to JSON. It implements persistence.Persistable.

type KeyVaultEndpointConfig

type KeyVaultEndpointConfig struct {
	Override string
	Port     int
}

KeyVaultEndpointConfig configures how the KeyVault resource provider advertises properties.vaultUri.

type KeyVaultPortProvider

type KeyVaultPortProvider interface {
	GetAzureKeyVaultPort() int
}

KeyVaultPortProvider is a private interface AppContext.Config may implement to expose the Key Vault listener's configured port.

type KeyVaultProvider

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

KeyVaultProvider implements ResourceProvider for Microsoft.KeyVault/vaults. Vault lifecycle is delegated to the data plane through the KeyVaults seam.

func NewKeyVaultProvider

func NewKeyVaultProvider(cfg KeyVaultEndpointConfig, dataPlane KeyVaults) *KeyVaultProvider

NewKeyVaultProvider creates a KeyVaultProvider; dataPlane may be nil.

func (*KeyVaultProvider) CheckNameAvailability

func (p *KeyVaultProvider) CheckNameAvailability(name string) map[string]any

CheckNameAvailability implements the checkNameAvailability action.

func (*KeyVaultProvider) Delete

func (p *KeyVaultProvider) Delete(_ context.Context, id ResourceID) error

Delete implements ResourceProvider.

func (*KeyVaultProvider) DeleteResourcesInGroup

func (p *KeyVaultProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*KeyVaultProvider) Get

func (p *KeyVaultProvider) Get(_ context.Context, id ResourceID) (map[string]any, error)

Get implements ResourceProvider.

func (*KeyVaultProvider) GetDeleted

func (p *KeyVaultProvider) GetDeleted(sub, location, name string) (map[string]any, error)

GetDeleted returns the wire body of a soft-deleted vault.

func (*KeyVaultProvider) List

func (p *KeyVaultProvider) List(_ context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider.

func (*KeyVaultProvider) ListKeys

func (p *KeyVaultProvider) ListKeys(context.Context, ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider; vaults have no listKeys action.

func (*KeyVaultProvider) Namespace

func (p *KeyVaultProvider) Namespace() string

Namespace implements ResourceProvider.

func (*KeyVaultProvider) PurgeDeleted

func (p *KeyVaultProvider) PurgeDeleted(sub, location, name string) error

PurgeDeleted permanently removes a soft-deleted vault, unless purge protection is enabled.

func (*KeyVaultProvider) Put

func (p *KeyVaultProvider) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*KeyVaultProvider) Reset

func (p *KeyVaultProvider) Reset()

Reset implements ResourceProvider.

func (*KeyVaultProvider) ResourceTypes

func (p *KeyVaultProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type KeyVaults

type KeyVaults interface {
	CreateVault(name string, retentionDays int, purgeProtection bool)
	DeleteVault(name string)
	// SoftDeleteVault retires the vault, keeping its contents for RecoverVault.
	SoftDeleteVault(name string)
	// RecoverVault restores a soft-deleted vault with its contents.
	RecoverVault(name string)
	// PurgeVault permanently discards a soft-deleted vault's contents.
	PurgeVault(name string)
}

KeyVaults is the seam the Microsoft.KeyVault resource provider uses to register and remove vaults in the Key Vault data plane. Primitive types only, so this package never imports services/azurekeyvault.

type MonitorError

type MonitorError struct {
	Code    string
	Message string
	Status  int
}

MonitorError is a data-plane failure carried to the ARM error envelope unchanged.

func (*MonitorError) Error

func (e *MonitorError) Error() string

type MonitorLogs

type MonitorLogs interface {
	Put(req MonitorRequest, body map[string]any) (map[string]any, error)
	Get(req MonitorRequest) (map[string]any, error)
	Patch(req MonitorRequest, body map[string]any) (map[string]any, error)
	Delete(req MonitorRequest) error
	List(req MonitorRequest) ([]map[string]any, error)
	Action(req MonitorRequest, action string, body map[string]any) (map[string]any, error)
	DeleteInGroup(rg string)
	Reset()
}

MonitorLogs is the seam the Microsoft.OperationalInsights and Microsoft.Insights providers use to keep workspaces, tables, data collection endpoints and rules in the Azure Monitor Logs data plane. Errors wrap ErrResourceNotFound or are *MonitorError values.

type MonitorProvider

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

MonitorProvider implements ResourceProvider for Microsoft.OperationalInsights (workspaces, tables) and Microsoft.Insights (data collection endpoints and rules). Every other type under those namespaces keeps the generic metadata-only store.

func NewMonitorProvider

func NewMonitorProvider(namespace string, backend *InMemoryBackend, dataPlane MonitorLogs) *MonitorProvider

NewMonitorProvider creates the provider for one namespace; dataPlane may be nil.

func (*MonitorProvider) Action

func (p *MonitorProvider) Action(
	ctx context.Context, id ResourceID, action string, body map[string]any,
) (map[string]any, error)

Action runs a POST action on a workspace.

func (*MonitorProvider) Delete

func (p *MonitorProvider) Delete(ctx context.Context, id ResourceID) error

Delete implements ResourceProvider.

func (*MonitorProvider) DeleteResourcesInGroup

func (p *MonitorProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*MonitorProvider) Get

func (p *MonitorProvider) Get(ctx context.Context, id ResourceID) (map[string]any, error)

Get implements ResourceProvider.

func (*MonitorProvider) List

func (p *MonitorProvider) List(ctx context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider.

func (*MonitorProvider) ListKeys

func (p *MonitorProvider) ListKeys(ctx context.Context, id ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider; only workspaces have keys.

func (*MonitorProvider) Namespace

func (p *MonitorProvider) Namespace() string

Namespace implements ResourceProvider.

func (*MonitorProvider) Patch

func (p *MonitorProvider) Patch(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Patch updates tags and mutable properties.

func (*MonitorProvider) Put

func (p *MonitorProvider) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*MonitorProvider) Reset

func (p *MonitorProvider) Reset()

Reset implements ResourceProvider.

func (*MonitorProvider) ResourceTypes

func (p *MonitorProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type MonitorRequest

type MonitorRequest struct {
	Host      string
	Sub       string
	RG        string
	Namespace string
	Types     []string
	Names     []string
}

MonitorRequest addresses a Microsoft.OperationalInsights or Microsoft.Insights resource.

type Provider

type Provider struct{}

Provider implements service.Provider for the ARM emulation.

Like services/azureblob/azurequeue/azuretable/cosmosdb/azureservicebus, AzureARM does not register a RouteMatcher into the shared AWS single-port Router -- see handler.go's RouteMatcher doc comment. It is registered in cli.go's getMostRecentServiceProviders like every other provider; only its RouteMatcher (which always returns false) is inert.

func (*Provider) Init

Init initializes the ARM backend, registry (with the Storage RP registered), AAD token issuer, and handler. The configured port (Settings.Port, default DefaultPort) is only recorded here; the actual TCP bind happens synchronously in Handler.StartWorker, so a port-in-use failure is returned to the caller directly instead of being discovered later from a background goroutine.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type Redis

type Redis interface {
	Ensure(id string, spec RedisSpec) (RedisEndpoint, error)
	Endpoint(id string) (RedisEndpoint, bool)
	Delete(id string) error
	Keys(id string) (RedisKeys, error)
	RegenerateKey(id, keyType string) (RedisKeys, error)
	Reboot(id, rebootType string) error
	Import(id, format string, files []string) error
	Export(id, format, prefix, container string) error
}

Redis is the seam the Microsoft.Cache resource provider uses to run real Redis servers for its caches. id is the lower-cased ARM resource ID. Primitive types only, so this package never imports services/azureredis.

type RedisEndpoint

type RedisEndpoint struct {
	Host    string
	Port    int
	SSLPort int
}

RedisEndpoint is where a cache's servers listen; Port is 0 while the plaintext port is disabled.

type RedisKeys

type RedisKeys struct {
	Primary   string
	Secondary string
}

RedisKeys are a cache's access keys.

type RedisProvider

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

RedisProvider implements ResourceProvider for Microsoft.Cache/redis. ARM keeps the resource metadata, firewall rules, patch schedule and linked servers; the Redis servers, access keys and data live behind the Redis seam.

func NewRedisProvider

func NewRedisProvider(dataPlane Redis) *RedisProvider

NewRedisProvider creates a RedisProvider; dataPlane may be nil.

func (*RedisProvider) CreateOperation

func (p *RedisProvider) CreateOperation(readyAt time.Time) string

CreateOperation registers an async operation that completes at readyAt and returns its ID.

func (*RedisProvider) Delete

func (p *RedisProvider) Delete(_ context.Context, id ResourceID) error

Delete implements ResourceProvider.

func (*RedisProvider) DeleteResourcesInGroup

func (p *RedisProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*RedisProvider) ExportData

func (p *RedisProvider) ExportData(id ResourceID, body map[string]any) error

ExportData writes the cache's data to a blob container as an RDB file.

func (*RedisProvider) ForceReboot

func (p *RedisProvider) ForceReboot(id ResourceID, body map[string]any) (map[string]any, error)

ForceReboot reboots the selected nodes; see azureredis.Reboot for what survives.

func (*RedisProvider) Get

func (p *RedisProvider) Get(_ context.Context, id ResourceID) (map[string]any, error)

Get implements ResourceProvider.

func (*RedisProvider) ImportData

func (p *RedisProvider) ImportData(id ResourceID, body map[string]any) error

ImportData loads an RDB blob into the cache.

func (*RedisProvider) List

func (p *RedisProvider) List(_ context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider; only caches are listable here.

func (*RedisProvider) ListChildren

func (p *RedisProvider) ListChildren(parent ResourceID, childType string) ([]map[string]any, error)

ListChildren lists a cache's firewall rules, patch schedules or linked servers.

func (*RedisProvider) ListKeys

func (p *RedisProvider) ListKeys(_ context.Context, id ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider.

func (*RedisProvider) Namespace

func (p *RedisProvider) Namespace() string

Namespace implements ResourceProvider.

func (*RedisProvider) OperationDone

func (p *RedisProvider) OperationDone(id string) bool

OperationDone reports whether an operation has completed; unknown (aged-out) operations are complete.

func (*RedisProvider) Patch

func (p *RedisProvider) Patch(id ResourceID, body map[string]any) (map[string]any, error)

Patch merges an Update request into an existing cache.

func (*RedisProvider) Put

func (p *RedisProvider) Put(_ context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*RedisProvider) ReadyAt

func (p *RedisProvider) ReadyAt(id ResourceID) time.Time

ReadyAt is when the cache's current provisioning completes.

func (*RedisProvider) RegenerateKey

func (p *RedisProvider) RegenerateKey(id ResourceID, keyType string) (map[string]any, error)

RegenerateKey replaces the Primary or Secondary access key.

func (*RedisProvider) Reset

func (p *RedisProvider) Reset()

Reset implements ResourceProvider.

func (*RedisProvider) ResourceTypes

func (p *RedisProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type RedisSpec

type RedisSpec struct {
	SKU              string
	MinTLS           string
	EnableNonSSLPort bool
	Persistence      bool
	AuthNotRequired  bool
}

RedisSpec is the part of a cache's configuration the Redis servers act on.

type Registry

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

Registry dispatches generic-resource operations to the ResourceProvider registered for a namespace, falling back to InMemoryBackend's own generic (metadata-only) resource storage for any namespace with no dedicated provider -- so PUT/GET/DELETE of an arbitrary Microsoft.SomeFutureThing/whatever resource still round-trips instead of 404ing, per AZURE.md section 10.1's generic-resource-plane requirement.

func NewRegistry

func NewRegistry(backend *InMemoryBackend) *Registry

NewRegistry creates a Registry backed by backend, with no providers registered yet (use Register).

func (*Registry) CloseAll

func (r *Registry) CloseAll()

CloseAll stops the workloads of every provider that runs any.

func (*Registry) Delete

func (r *Registry) Delete(ctx context.Context, id ResourceID) error

Delete removes the resource identified by id.

func (*Registry) DeleteResourcesInGroup

func (r *Registry) DeleteResourcesInGroup(ctx context.Context, resourceGroup string)

DeleteResourcesInGroup cascades a resource-group delete into every registered dedicated provider, so a provider's own resources in that group (e.g. StorageProvider's accounts) don't survive as orphans reachable by their own resource ID after the owning group is gone.

func (*Registry) Get

func (r *Registry) Get(ctx context.Context, id ResourceID) (map[string]any, error)

Get returns the resource identified by id.

func (*Registry) List

func (r *Registry) List(ctx context.Context, id ResourceID) ([]map[string]any, error)

List returns every resource of id's LeafType, scoped per id.ResourceGroup.

func (*Registry) ListKeys

func (r *Registry) ListKeys(ctx context.Context, id ResourceID) (map[string]any, error)

ListKeys returns the listKeys response body for id.

func (*Registry) ProviderNamed

func (r *Registry) ProviderNamed(ns string) (ResourceProvider, bool)

ProviderNamed returns the dedicated ResourceProvider registered for ns (matched case-insensitively, AZURE.md section 10.1), and whether one was found. Used by the /providers/{ns} and /providers/{ns}/register handlers, which take ns directly from the URL path rather than a parsed ResourceID.

func (*Registry) Providers

func (r *Registry) Providers() []string

Providers returns the namespaces of every registered dedicated ResourceProvider, sorted, for the provider-list endpoint.

func (*Registry) Put

func (r *Registry) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, bool, error)

Put creates or updates the resource identified by id.

func (*Registry) Register

func (r *Registry) Register(p ResourceProvider)

Register adds a ResourceProvider to the registry, keyed by its lowercased Namespace() -- ARM namespaces are matched case-insensitively (AZURE.md section 10.1: "Microsoft.storage" and "microsoft.STORAGE" must both reach the same dedicated provider, not fall through to the generic pass-through).

func (*Registry) ResetAll

func (r *Registry) ResetAll()

ResetAll clears every registered dedicated provider's own state. Called by Handler.Reset alongside InMemoryBackend.Reset -- the generic pass-through resources and dedicated-provider resources (e.g. StorageProvider.accounts) are two separate stores, and the /_gopherstack/reset endpoint must clear both.

func (*Registry) SetACIFileShares

func (r *Registry) SetACIFileShares(s ACIFileShares)

SetACIFileShares gives the registered Microsoft.ContainerInstance provider (if any) the Azure Files seam that azureFile volumes use.

func (*Registry) SetAppConfig

func (r *Registry) SetAppConfig(a AppConfig)

SetAppConfig gives the registered Microsoft.AppConfiguration provider (if any) a real data-plane adapter, replacing its no-op default.

func (*Registry) SetContainerRegistries

func (r *Registry) SetContainerRegistries(c ContainerRegistries)

SetContainerRegistries gives the registered Microsoft.ContainerRegistry provider (if any) a real data-plane adapter, replacing its no-op default.

func (*Registry) SetCosmosResources

func (r *Registry) SetCosmosResources(c CosmosResources)

SetCosmosResources gives the registered Microsoft.DocumentDB provider (if any) a real data-plane adapter, replacing its no-op default.

func (*Registry) SetEventGrid

func (r *Registry) SetEventGrid(e EventGrid)

SetEventGrid gives the registered Microsoft.EventGrid provider (if any) a real data-plane adapter, replacing its no-op default.

func (*Registry) SetEventHubs

func (r *Registry) SetEventHubs(e EventHubs)

SetEventHubs gives the registered Microsoft.EventHub provider (if any) a real data-plane adapter, replacing its no-op default.

func (*Registry) SetFileServices

func (r *Registry) SetFileServices(fs FileServices)

SetFileServices gives the Microsoft.Storage provider (if any) a data-plane adapter for file service properties.

func (*Registry) SetFunctionApps

func (r *Registry) SetFunctionApps(f FunctionApps)

SetFunctionApps gives the registered Microsoft.Web provider (if any) a real Azure Functions data-plane adapter, replacing its no-op default.

func (*Registry) SetKeyVaults

func (r *Registry) SetKeyVaults(k KeyVaults)

SetKeyVaults gives the registered Microsoft.KeyVault provider (if any) a real KeyVaults adapter, replacing its no-op default.

func (*Registry) SetMonitorLogs

func (r *Registry) SetMonitorLogs(m MonitorLogs)

SetMonitorLogs gives the registered Microsoft.OperationalInsights and Microsoft.Insights providers (if any) a real data-plane adapter, replacing their no-op default.

func (*Registry) SetRedis

func (r *Registry) SetRedis(rd Redis)

SetRedis gives the registered Microsoft.Cache provider (if any) a real data-plane adapter, replacing its no-op default.

func (*Registry) SetSQL

func (r *Registry) SetSQL(s SQL)

SetSQL gives the registered Microsoft.Sql provider (if any) a real data-plane adapter, replacing its no-op default.

func (*Registry) SetServiceBusEntities

func (r *Registry) SetServiceBusEntities(e ServiceBusEntities)

SetServiceBusEntities gives the registered Microsoft.ServiceBus provider (if any) a real ServiceBusEntities adapter, replacing its no-op default -- called post-construction by cli.go's wireAzureARMResourceProviders once services/azureservicebus's own Handler exists, mirroring M8's wireAzureStorageVHost pattern (this can't be wired at azurearm.Provider.Init time the way StorageAccountsProvider is, since it needs a live reference to a sibling service's already-constructed runtime handler). A no-op if Microsoft.ServiceBus isn't registered or isn't a *ServiceBusProvider.

type Resource

type Resource struct {
	Tags       map[string]string
	Properties map[string]any
	SKU        map[string]any
	Location   string
	Kind       string
	ID         ResourceID
}

Resource is the generic stored representation of an ARM resource (any namespace/type not owned by a specific ResourceProvider -- see registry.go's fallback behavior). ResourceProvider implementations (e.g. rp_storage.go) may keep their own richer internal representation and build the wire body directly instead of using this type; Resource exists for the generic pass-through path every namespace gets even without a dedicated RP.

func (Resource) Body

func (r Resource) Body() map[string]any

Body returns the ARM wire response body for r.

type ResourceChange

type ResourceChange struct {
	Time            time.Time
	Claims          map[string]any
	SubscriptionID  string
	ResourceGroup   string
	ResourceURI     string
	Provider        string
	OperationName   string
	CorrelationID   string
	TenantID        string
	HTTPMethod      string
	HTTPURL         string
	ClientRequestID string
	ClientIP        string
	Kind            ResourceChangeKind
}

ResourceChange describes a successful ARM write, delete or action.

type ResourceChangeKind

type ResourceChangeKind int

ResourceChangeKind is the kind of a successful ARM operation.

const (
	ResourceWritten ResourceChangeKind = iota
	ResourceDeleted
	ResourceActionRun
)

Kinds of ResourceChange.

type ResourceGroup

type ResourceGroup struct {
	Tags     map[string]string `json:"tags,omitempty"`
	Name     string            `json:"name"`
	Location string            `json:"location"`
}

ResourceGroup is the stored representation of an ARM resource group.

func (ResourceGroup) Body

func (g ResourceGroup) Body(subscriptionID string) map[string]any

Body returns the ARM wire response body for g, scoped to subscriptionID.

type ResourceID

type ResourceID struct {
	SubscriptionID string
	ResourceGroup  string
	Namespace      string
	Types          []string
	Names          []string
}

ResourceID is a parsed ARM resource identifier of the generic shape /subscriptions/{sub}/resourceGroups/{rg}/providers/{namespace}/{type1}/{name1}[/{type2}/{name2}...].

Types/Names are parallel slices so nested child resources (e.g. Microsoft.ServiceBus/namespaces/{ns}/queues/{q}, two type/name pairs) are represented without a separate "parent" concept -- exactly the single generic path walker AZURE.md section 10.1 requires instead of per-type route registration.

func ParseGenericResourceListPath

func ParseGenericResourceListPath(path string) (ResourceID, bool, error)

ParseGenericResourceListPath parses a resource-type LIST path, either scoped to a resource group:

/subscriptions/{sub}/resourceGroups/{rg}/providers/{ns}/{type}

or across the whole subscription:

/subscriptions/{sub}/providers/{ns}/{type}

Returns the parsed (partial) ResourceID -- Names is empty -- and whether a resource group scope was present.

func ParseGenericResourcePath

func ParseGenericResourcePath(path string) (ResourceID, error)

ParseGenericResourcePath parses a full generic-resource ARM path:

/subscriptions/{sub}/resourceGroups/{rg}/providers/{ns}/{type}/{name}[/{type}/{name}...]

The "resourcegroups"/"resourceGroups" segment is matched case-insensitively per AZURE.md section 10.1 -- real ARM accepts both and azurerm emits both depending on code path.

func (ResourceID) ARMID

func (id ResourceID) ARMID() string

ARMID renders the canonical ARM resource ID string for id, always using the canonical "resourceGroups" casing regardless of what was parsed.

func (ResourceID) LeafName

func (id ResourceID) LeafName() string

LeafName returns the last (innermost) resource name segment -- the name of the resource this ID actually identifies.

func (ResourceID) LeafType

func (id ResourceID) LeafType() string

LeafType returns the last (innermost) resource type segment.

func (ResourceID) ResourceType

func (id ResourceID) ResourceType() string

ResourceType returns the ARM resource type string, e.g. "Microsoft.Storage/storageAccounts" or "Microsoft.ServiceBus/namespaces/queues".

type ResourceObserver

type ResourceObserver interface {
	ResourceChanged(ResourceChange)
}

ResourceObserver is told about every successful ARM write, delete and action.

type ResourceProvider

type ResourceProvider interface {
	// Namespace returns the ARM provider namespace this implementation
	// serves, e.g. "Microsoft.Storage".
	Namespace() string
	// ResourceTypes returns the resource types this provider serves, for
	// the /providers/{ns} registration-status response.
	ResourceTypes() []ResourceTypeDef
	// Put creates or updates the resource identified by id from body,
	// returning the full wire response body.
	Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)
	// Get returns the full wire response body for id.
	Get(ctx context.Context, id ResourceID) (map[string]any, error)
	// Delete removes the resource identified by id.
	Delete(ctx context.Context, id ResourceID) error
	// List returns every resource of id's LeafType, scoped to id's
	// ResourceGroup if set, else the whole subscription.
	List(ctx context.Context, id ResourceID) ([]map[string]any, error)
	// ListKeys returns the POST .../listKeys response body for id.
	ListKeys(ctx context.Context, id ResourceID) (map[string]any, error)
	// Reset clears all of this provider's own state, called by
	// Handler.Reset via Registry.ResetAll (the /_gopherstack/reset
	// endpoint) -- without this, a dedicated provider's resources survive
	// a reset that's supposed to wipe every service's state.
	Reset()
	// DeleteResourcesInGroup deletes every resource this provider owns in
	// resourceGroup, called by Registry.DeleteResourcesInGroup when a
	// resource group is deleted -- without this, a dedicated provider's
	// resources in that group are orphaned (InMemoryBackend's own generic
	// resources are cascaded directly by DeleteResourceGroup, but a
	// dedicated provider's internal state is opaque to InMemoryBackend).
	DeleteResourcesInGroup(ctx context.Context, resourceGroup string)
}

ResourceProvider is the small interface a resource-provider namespace (Microsoft.Storage today; Microsoft.ServiceBus/Microsoft.DocumentDB in M8/M9, Microsoft.KeyVault/Microsoft.AppConfiguration in M11/M12) plugs into the registry with. Deliberately narrow (AZURE.md section 10.6) so each future milestone adds one file and one registry entry.

Put/Get/Delete/ListKeys all return the full ARM wire response body (or nil for Delete's 204 case) -- the ResourceProvider owns its own response shape entirely, including the common id/name/type/location/tags/ properties.provisioningState envelope (Resource.Body / a hand-built equivalent), rather than the registry re-wrapping it.

type ResourceTypeDef

type ResourceTypeDef struct {
	Type        string
	APIVersions []string
	HasChildren bool
}

ResourceTypeDef describes one resource type a ResourceProvider serves -- its type name, supported API versions, and whether it has child resource types nested beneath it (informational only in this MVP; see registry.go).

type SQL

type SQL interface {
	EnsureServer(id string, spec SQLSpec) (SQLEndpoint, error)
	Endpoint(id string) (SQLEndpoint, bool)
	DeleteServer(id string) error
	EnsureDatabase(serverID, name, collation string) error
	DropDatabase(serverID, name string) error
}

SQL is the seam the Microsoft.Sql resource provider uses to run real SQL Server engines for its logical servers. id is the lower-cased ARM resource ID of the server. Primitive types only, so this package never imports services/azuresql.

type SQLEndpoint

type SQLEndpoint struct {
	Host string
	Port int
}

SQLEndpoint is where a server's TDS port listens; Port is 0 while the server is state-only.

type SQLProvider

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

SQLProvider implements ResourceProvider for Microsoft.Sql. ARM keeps the resource metadata and child resources; the SQL Server engines and their databases live behind the SQL seam.

func NewSQLProvider

func NewSQLProvider(dataPlane SQL) *SQLProvider

NewSQLProvider creates a SQLProvider; dataPlane may be nil.

func (*SQLProvider) CreateOperation

func (p *SQLProvider) CreateOperation() string

CreateOperation registers an async operation and returns its ID.

func (*SQLProvider) Delete

func (p *SQLProvider) Delete(_ context.Context, id ResourceID) error

Delete implements ResourceProvider.

func (*SQLProvider) DeleteResourcesInGroup

func (p *SQLProvider) DeleteResourcesInGroup(ctx context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*SQLProvider) Get

func (p *SQLProvider) Get(_ context.Context, id ResourceID) (map[string]any, error)

Get implements ResourceProvider.

func (*SQLProvider) List

func (p *SQLProvider) List(_ context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider; only servers are listable here, children use ListChildren.

func (*SQLProvider) ListChildren

func (p *SQLProvider) ListChildren(parent ResourceID, childType string) ([]map[string]any, error)

ListChildren lists the children of type childType under a server or database.

func (*SQLProvider) ListKeys

func (p *SQLProvider) ListKeys(context.Context, ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider; SQL servers have no keys.

func (*SQLProvider) Namespace

func (p *SQLProvider) Namespace() string

Namespace implements ResourceProvider.

func (*SQLProvider) OperationKnown

func (p *SQLProvider) OperationKnown(id string) bool

OperationKnown reports whether id was issued by CreateOperation and has not aged out.

func (*SQLProvider) Patch

func (p *SQLProvider) Patch(id ResourceID, body map[string]any) (map[string]any, error)

Patch merges an Update request into an existing server.

func (*SQLProvider) PatchDatabase

func (p *SQLProvider) PatchDatabase(id ResourceID, body map[string]any) (map[string]any, error)

PatchDatabase merges an Update request into an existing database.

func (*SQLProvider) Put

func (p *SQLProvider) Put(_ context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*SQLProvider) Reset

func (p *SQLProvider) Reset()

Reset implements ResourceProvider.

func (*SQLProvider) ResourceTypes

func (p *SQLProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type SQLSpec

type SQLSpec struct {
	AdminLogin    string
	AdminPassword string
}

SQLSpec is the part of a logical server's configuration the SQL Server engine acts on. An empty AdminPassword keeps the current one.

type ServiceBusEndpointConfig

type ServiceBusEndpointConfig struct {
	Override string
	Port     int
}

ServiceBusEndpointConfig configures how the ServiceBus resource provider advertises the namespace's serviceBusEndpoint. Unlike Storage's StorageEndpointConfig, this needs no vhost/shared-port scheme: services/azureservicebus has no namespace-in-URL routing at all (a flat host:port reaches it directly), so a single scalar override suffices.

type ServiceBusEntities

type ServiceBusEntities interface {
	CreateQueue(name string, lockDuration, defaultMessageTTL time.Duration, maxDeliveryCount int) error
	DeleteQueue(name string) error
	QueueExists(name string) bool

	CreateTopic(name string, defaultMessageTTL time.Duration) error
	DeleteTopic(name string) error
	TopicExists(name string) bool

	CreateSubscription(topic, name string, lockDuration time.Duration, maxDeliveryCount int) error
	DeleteSubscription(topic, name string) error
	SubscriptionExists(topic, name string) bool
}

ServiceBusEntities is the narrow, consumer-defined seam the Microsoft.ServiceBus resource provider (rp_servicebus.go) delegates queue/topic/subscription lifecycle through, mirroring StorageAccounts's shape above. Uses only primitive types (time.Duration, int, string) rather than services/azureservicebus's own EntityConfig, so this package never imports a data-plane service package (AZURE.md section 10.6) -- the real adapter translating these calls into azureservicebus.EntityConfig lives in cli_adapters.go, which already imports across services.

Unlike StorageAccounts, ServiceBusEntities calls are load-bearing for M9's test plan: services/azureservicebus (M5) is one-process-one-namespace with no ARM-shaped state of its own, so a Terraform-created queue/topic/ subscription must actually exist in the real M5 backend for the REST send->peek-lock->complete liveness round-trip to succeed -- this is not an optional best-effort hook the way Storage's RegisterAccount is.

type ServiceBusPortProvider

type ServiceBusPortProvider interface {
	GetAzureServiceBusPort() int
}

ServiceBusPortProvider is a private interface AppContext.Config may implement to expose the actual services/azureservicebus listener's configured port, so Init can cross-check it against Settings.ServiceBusPort. cli.go implements this via CLI.GetAzureServiceBusPort.

type ServiceBusProvider

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

ServiceBusProvider implements ResourceProvider for Microsoft.ServiceBus. Unlike StorageProvider, its queue/topic/subscription Put calls ARE load-bearing against dataPlane (services/azureservicebus, M5) -- M5 has no ARM-shaped state of its own, so a Terraform-created entity must genuinely exist in the real backend for AZURE.md's M9 test plan (a REST send->peek-lock->complete round-trip) to succeed. Namespace Put is metadata-only: M5 is one-process-one-namespace, so there's nothing to delegate for "creating" one.

func NewServiceBusProvider

func NewServiceBusProvider(cfg ServiceBusEndpointConfig, dataPlane ServiceBusEntities) *ServiceBusProvider

NewServiceBusProvider creates a ServiceBusProvider. dataPlane may be nil, in which case a no-op default is used (see interfaces.go) until cli.go's wireAzureARMResourceProviders wires a real one post-construction.

func (*ServiceBusProvider) Delete

func (p *ServiceBusProvider) Delete(ctx context.Context, id ResourceID) error

Delete implements ResourceProvider.

func (*ServiceBusProvider) DeleteResourcesInGroup

func (p *ServiceBusProvider) DeleteResourcesInGroup(ctx context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider (Registry's cascade delete when a resource group is deleted).

func (*ServiceBusProvider) Get

Get implements ResourceProvider.

func (*ServiceBusProvider) List

func (p *ServiceBusProvider) List(_ context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider, scoped to id.ResourceGroup if set, else every resource of id's LeafType in the subscription.

func (*ServiceBusProvider) ListKeys

func (p *ServiceBusProvider) ListKeys(_ context.Context, id ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider for namespaces/{ns}/authorizationRules/{rule}/listKeys. Response shape -- {"primaryConnectionString","secondaryConnectionString","primaryKey", "secondaryKey","keyName"} -- matches real ARM's Service Bus AuthorizationRules ListKeys AccessKeys model. This emulator has exactly one fixed dev SAS identity (services/azureservicebus/sas.go's DefaultKeyName/DefaultKeyValue, mirrored here as sbDefaultKeyName/ sbDefaultKeyValue), so both primary/secondary key are the same value -- matching StorageProvider.ListKeys's identical key1/key2 convention.

func (*ServiceBusProvider) Namespace

func (p *ServiceBusProvider) Namespace() string

Namespace implements ResourceProvider.

func (*ServiceBusProvider) Put

func (p *ServiceBusProvider) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*ServiceBusProvider) Reset

func (p *ServiceBusProvider) Reset()

Reset implements ResourceProvider (Registry.ResetAll, the /_gopherstack/reset endpoint).

func (*ServiceBusProvider) ResourceTypes

func (p *ServiceBusProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type Settings

type Settings struct {
	TenantID string `` //nolint:lll // config struct tags are intentionally verbose
	/* 227-byte string literal not displayed */
	SubscriptionID string `` //nolint:lll // config struct tags are intentionally verbose
	/* 192-byte string literal not displayed */
	ClientID string `` //nolint:lll // config struct tags are intentionally verbose
	/* 198-byte string literal not displayed */
	ClientSecret string `` //nolint:lll // config struct tags are intentionally verbose
	/* 249-byte string literal not displayed */
	Environment string `` //nolint:lll // config struct tags are intentionally verbose
	/* 270-byte string literal not displayed */
	Location string `` //nolint:lll // config struct tags are intentionally verbose
	/* 229-byte string literal not displayed */
	AdvertiseStorageVHost string `` //nolint:lll // config struct tags are intentionally verbose
	/* 357-byte string literal not displayed */
	TLSCertFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 311-byte string literal not displayed */
	TLSKeyFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 253-byte string literal not displayed */
	AdvertiseServiceBus string `` //nolint:lll // config struct tags are intentionally verbose
	/* 290-byte string literal not displayed */
	AdvertiseKeyVault string `` //nolint:lll // config struct tags are intentionally verbose
	/* 306-byte string literal not displayed */
	AdvertiseCosmosDB string `` //nolint:lll // config struct tags are intentionally verbose
	/* 290-byte string literal not displayed */
	AdvertiseEventHub string `` //nolint:lll // config struct tags are intentionally verbose
	/* 325-byte string literal not displayed */
	AdvertiseEventGrid string `` //nolint:lll // config struct tags are intentionally verbose
	/* 321-byte string literal not displayed */
	AdvertiseAppConfig string `` //nolint:lll // config struct tags are intentionally verbose
	/* 328-byte string literal not displayed */
	AdvertiseACR string `` //nolint:lll // config struct tags are intentionally verbose
	/* 334-byte string literal not displayed */
	ACIEngine string `` //nolint:lll // config struct tags are intentionally verbose
	/* 374-byte string literal not displayed */
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 260-byte string literal not displayed */
	StorageVHostPort int `` //nolint:lll // config struct tags are intentionally verbose
	/* 336-byte string literal not displayed */
	ServiceBusPort int `` //nolint:lll // config struct tags are intentionally verbose
	/* 323-byte string literal not displayed */
	KeyVaultPort int `` //nolint:lll // config struct tags are intentionally verbose
	/* 307-byte string literal not displayed */
	EventHubPort int `` //nolint:lll // config struct tags are intentionally verbose
	/* 273-byte string literal not displayed */
	EventHubAMQPPort int `` //nolint:lll // config struct tags are intentionally verbose
	/* 324-byte string literal not displayed */
	EventGridPort int `` //nolint:lll // config struct tags are intentionally verbose
	/* 323-byte string literal not displayed */
	AppConfigPort int `` //nolint:lll // config struct tags are intentionally verbose
	/* 323-byte string literal not displayed */
	ACRPort int `` //nolint:lll // config struct tags are intentionally verbose
	/* 309-byte string literal not displayed */
	ValidateTokens bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 258-byte string literal not displayed */
}

Settings holds service-level configuration for the ARM emulation backend. Fields are picked up by the Kong CLI parser when embedded in the root CLI command (see cli.go's CLI.AzureARM field), mirroring services/cosmosdb's Settings pattern. Field order below is grouped by type (all strings, then all ints, then the bool) rather than by topic, to satisfy govet's fieldalignment check -- interleaving AdvertiseServiceBus (a string) between the int fields, as a topic-grouped order would, widens the struct's leading run of pointer-containing fields from 152 to 168 bytes. Safe to reorder: every construction of Settings (DefaultSettings, and Kong's tag-driven parsing) uses field names, never positional literals.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the default Settings. Used when no ConfigProvider is available at init time (e.g. tests constructing a Provider directly).

type StorageAccounts

type StorageAccounts interface {
	// RegisterAccount is called when the Storage RP creates a new storage
	// account. A nil-safe no-op default (noopStorageAccounts) is used when no
	// real adapter is wired, so services/azurearm works standalone in unit
	// tests and degrades gracefully if the data plane is disabled.
	RegisterAccount(name string) error
	// DeleteAccount is called when the Storage RP deletes a storage account.
	DeleteAccount(name string) error
}

StorageAccounts is the narrow, consumer-defined seam the Microsoft.Storage resource provider (rp_storage.go) delegates account lifecycle events through, mirroring the wireCrossServiceDependencies adapter pattern cli_adapters.go already uses ~60 times for AWS (see AZURE.md section 10.6). It is declared here even though M7's Storage RP does not need it to serve Blob/Queue/Table traffic today (those backends are already account-name-agnostic -- AZURE.md section 10.4) -- so that M10's per-account namespacing (RegisterAccount/DeleteAccount keying each data plane's top-level map by account name) is additive: rp_storage.go already calls these hooks, they're just no-ops until M10 wires a real adapter in cli_adapters.go.

CosmosResources (M10's equivalent) is deliberately NOT declared here yet -- AZURE.md's own scope note prefers keeping this milestone's interface surface to what it actually uses, over speculatively declaring shapes for resource providers this milestone doesn't implement. ServiceBusEntities below is M9's version of the same pattern, now that M9 actually needs it.

type StorageAccountsProvider

type StorageAccountsProvider interface {
	GetAzureARMStorageAccounts() StorageAccounts
}

StorageAccountsProvider is a private interface AppContext.Config may implement to supply a real StorageAccounts adapter (wired by cli.go's wireCrossServiceDependencies in a future milestone -- see interfaces.go). Absent (the common case for M7), NewStorageProvider falls back to the nil-safe noopStorageAccounts default.

type StorageEndpointConfig

type StorageEndpointConfig struct {
	VHostOverride string
	VHostPort     int
}

StorageEndpointConfig configures how the Storage resource provider advertises Blob/Queue/Table data-plane endpoints in properties.primaryEndpoints, per AZURE.md section 10.4's endpoint-advertisement design. VHostOverride/VHostPort replace this struct's earlier three separate per-service overrides/ports (Blob/Queue/Table): terraform-provider-azurerm's data-plane SDK requires Blob/Queue/Table to share one domain suffix for account-ID parsing, and since Go's url.URL.Host always includes the port, that forces them onto one shared port too -- see services/azurestoragevhost's package doc comment and AZURE.md section 10.8 for the full derivation. advertiseVHostEndpoint below is the only thing that reads these.

type StorageProvider

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

StorageProvider implements ResourceProvider for Microsoft.Storage. Per AZURE.md section 10.4, it is metadata-only: Blob/Queue/Table are already account-name-agnostic, so no data-plane delegation is required for an ARM-created account to be immediately usable. StorageAccounts (accounts StorageAccounts interface) is called best-effort for forward-compat with M10's per-account namespacing.

func NewStorageProvider

func NewStorageProvider(cfg StorageEndpointConfig, dataPlane StorageAccounts) *StorageProvider

NewStorageProvider creates a StorageProvider. dataPlane may be nil, in which case a no-op default is used (see interfaces.go).

func (*StorageProvider) Delete

func (p *StorageProvider) Delete(ctx context.Context, id ResourceID) error

Delete implements ResourceProvider.

func (*StorageProvider) DeleteResourcesInGroup

func (p *StorageProvider) DeleteResourcesInGroup(ctx context.Context, resourceGroup string)

DeleteResourcesInGroup implements the cascade-delete hook Registry.DeleteResourcesInGroup calls when a resource group is deleted (CodeRabbit-flagged: DELETE .../resourceGroups/{name} previously only cleared InMemoryBackend's generic resources, leaving StorageProvider accounts in that group orphaned but still reachable).

func (*StorageProvider) Get

func (p *StorageProvider) Get(_ context.Context, id ResourceID) (map[string]any, error)

Get implements ResourceProvider.

func (*StorageProvider) List

func (p *StorageProvider) List(_ context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider, scoped to id.ResourceGroup if set (per the ResourceProvider interface contract), else every account in the subscription.

func (*StorageProvider) ListKeys

func (p *StorageProvider) ListKeys(_ context.Context, id ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider. The response shape -- {"keys":[{"keyName","value","permissions"}, ...]} -- was verified against the real ARM "Storage Accounts - List Keys" REST API documentation (learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/list-keys): StorageAccountListKeysResult.keys is a StorageAccountKey[] with exactly those three fields, "permissions" taking the KeyPermission enum value "Full" (not "FULL"). Key values are pkgs/azureauth's well-known devstoreaccount1 development key, matching every other Azure service's well-known-credential convention.

func (*StorageProvider) Namespace

func (p *StorageProvider) Namespace() string

Namespace implements ResourceProvider.

func (*StorageProvider) Put

func (p *StorageProvider) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider: creates or updates a storage account.

func (*StorageProvider) Reset

func (p *StorageProvider) Reset()

Reset implements the reset hook Registry.ResetAll calls across every registered provider (Handler.Reset -- CodeRabbit-flagged: without this, accounts created before a /_gopherstack/reset survived it, since only InMemoryBackend was being cleared).

func (*StorageProvider) ResourceTypes

func (p *StorageProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

type TokenResponse

type TokenResponse struct {
	TokenType   string `json:"token_type"`
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

TokenResponse is the client-credentials grant response body, for both the v1 (/{tenant}/oauth2/token) and v2 (/{tenant}/oauth2/v2.0/token) endpoints -- AZURE.md section 10.1 specifies the identical body shape for both.

func IssueToken

func IssueToken(issuer *aadauth.Issuer, baseURL, tenant, clientID, scopeOrResource string) (TokenResponse, error)

IssueToken issues a client-credentials access token for tenant, using issuer, returning the wire response body.

type VHostPortProvider

type VHostPortProvider interface {
	GetAzureStorageVHostPort() int
}

VHostPortProvider is a private interface AppContext.Config may implement to expose the actual services/azurestoragevhost listener's configured port, so Init can cross-check it against Settings.StorageVHostPort. cli.go implements this via CLI.GetAzureStorageVHostPort.

type WebProvider

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

WebProvider implements ResourceProvider for Microsoft.Web function apps and their hosting plans. ARM keeps location, tags, plan links, and site configuration; the app itself (settings, keys, package, host) lives in the Azure Functions data plane.

func NewWebProvider

func NewWebProvider(dataPlane FunctionApps) *WebProvider

NewWebProvider creates a WebProvider; dataPlane may be nil.

func (*WebProvider) CheckName

func (p *WebProvider) CheckName(name string) map[string]any

CheckName answers POST /subscriptions/{sub}/providers/Microsoft.Web/checknameavailability.

func (*WebProvider) Delete

func (p *WebProvider) Delete(_ context.Context, id ResourceID) error

Delete implements ResourceProvider.

func (*WebProvider) DeleteFunctionKey

func (p *WebProvider) DeleteFunctionKey(ctx context.Context, id ResourceID, fn, keyName string) error

DeleteFunctionKey serves DELETE .../functions/{fn}/keys/{name}.

func (*WebProvider) DeleteHostKey

func (p *WebProvider) DeleteHostKey(_ context.Context, id ResourceID, keyType, keyName string) error

DeleteHostKey serves DELETE .../host/default/{keyType}/{name}.

func (*WebProvider) DeleteResourcesInGroup

func (p *WebProvider) DeleteResourcesInGroup(_ context.Context, resourceGroup string)

DeleteResourcesInGroup implements ResourceProvider.

func (*WebProvider) FunctionKeys

func (p *WebProvider) FunctionKeys(ctx context.Context, id ResourceID, fn string) (map[string]any, error)

FunctionKeys serves POST .../functions/{fn}/listkeys.

func (*WebProvider) FunctionSecrets

func (p *WebProvider) FunctionSecrets(ctx context.Context, id ResourceID, fn string) (map[string]any, error)

FunctionSecrets serves POST .../functions/{fn}/listsecrets.

func (*WebProvider) Get

func (p *WebProvider) Get(ctx context.Context, id ResourceID) (map[string]any, error)

Get implements ResourceProvider.

func (*WebProvider) GetConfig

func (p *WebProvider) GetConfig(_ context.Context, id ResourceID, name string) (map[string]any, error)

GetConfig serves GET and POST .../config/{name}[/list].

func (*WebProvider) GetFunction

func (p *WebProvider) GetFunction(ctx context.Context, id ResourceID, fn string) (map[string]any, error)

GetFunction serves GET .../functions/{fn}.

func (*WebProvider) HostKeys

func (p *WebProvider) HostKeys(_ context.Context, id ResourceID) (map[string]any, error)

HostKeys serves POST .../host/default/listkeys.

func (*WebProvider) List

func (p *WebProvider) List(ctx context.Context, id ResourceID) ([]map[string]any, error)

List implements ResourceProvider.

func (*WebProvider) ListFunctions

func (p *WebProvider) ListFunctions(ctx context.Context, id ResourceID) ([]map[string]any, error)

ListFunctions serves GET .../functions.

func (*WebProvider) ListKeys

func (p *WebProvider) ListKeys(_ context.Context, id ResourceID) (map[string]any, error)

ListKeys implements ResourceProvider: POST .../sites/{name}/host/default/listkeys is routed here by type.

func (*WebProvider) Namespace

func (p *WebProvider) Namespace() string

Namespace implements ResourceProvider.

func (*WebProvider) Patch

func (p *WebProvider) Patch(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Patch serves PATCH on a site: properties are merged over the stored ones.

func (*WebProvider) Policy

func (p *WebProvider) Policy(
	_ context.Context, id ResourceID, name string, body map[string]any, put bool,
) (map[string]any, error)

Policy serves GET and PUT .../basicPublishingCredentialsPolicies/{ftp|scm}.

func (*WebProvider) PublishXML

func (p *WebProvider) PublishXML(_ context.Context, id ResourceID) ([]byte, error)

PublishXML serves POST .../publishxml: a ZipDeploy profile that points at the app's Kudu site.

func (*WebProvider) PublishingCredentials

func (p *WebProvider) PublishingCredentials(_ context.Context, id ResourceID) (map[string]any, error)

PublishingCredentials serves POST .../config/publishingcredentials/list.

func (*WebProvider) Put

func (p *WebProvider) Put(ctx context.Context, id ResourceID, body map[string]any) (map[string]any, error)

Put implements ResourceProvider.

func (*WebProvider) PutConfig

func (p *WebProvider) PutConfig(
	_ context.Context, id ResourceID, name string, body map[string]any, merge bool,
) (map[string]any, error)

PutConfig serves PUT (replace) and PATCH (merge) .../config/{name}.

func (*WebProvider) Reset

func (p *WebProvider) Reset()

Reset implements ResourceProvider.

func (*WebProvider) ResourceTypes

func (p *WebProvider) ResourceTypes() []ResourceTypeDef

ResourceTypes implements ResourceProvider.

func (*WebProvider) SetFunctionKey

func (p *WebProvider) SetFunctionKey(
	ctx context.Context, id ResourceID, fn, keyName string, body map[string]any,
) (map[string]any, error)

SetFunctionKey serves PUT .../functions/{fn}/keys/{name}.

func (*WebProvider) SetHostKey

func (p *WebProvider) SetHostKey(
	_ context.Context, id ResourceID, keyType, keyName string, body map[string]any,
) (map[string]any, error)

SetHostKey serves PUT .../host/default/{keyType}/{name}.

func (*WebProvider) SetState

func (p *WebProvider) SetState(_ context.Context, id ResourceID, action string) error

SetState serves POST .../start, .../stop and .../restart.

Jump to

Keyboard shortcuts

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