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

azureappconfig

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

README

Azure App Configuration

Parity grade: B · SDK azure-sdk-for-go/sdk/data/azappconfig/v2@v2.2.0 · last audited 2026-10-21 (b1f3fa139)

Coverage

Metric Value
PARITY entries audited 14 (14 ok)
Feature families 4 (4 ok)
Known gaps 13
Deferred items 0
Resource leaks clean
Known gaps
  • Bearer tokens are accepted when JWT-shaped; AAD token validation and RBAC data roles are not implemented.
  • Revision retention (7 or 30 days) is not enforced; history is capped at 50000 entries per store.
  • Snapshots are ready as soon as they are created; there is no provisioning or failed status.
  • Replicas are ARM metadata only; their data is the store's data.
  • Soft-deleted stores keep only ARM metadata; recovering one yields an empty store.
  • Customer-managed key encryption, private endpoint connections and SKU quotas are not modelled.
  • Bearer token validation and AAD data-plane roles are not implemented; JWT-shaped bearer tokens are accepted without verification.
  • Revision retention windows are not enforced and history is capped at 50000 entries per store.
  • Snapshots complete synchronously: no provisioning or failed state, and composition_type key keeps the later filter's key-value when filters select several labels of one key (behaviour inferred, not verified).
  • Replicas are metadata only and do not replicate or serve a separate data set.
  • Soft-deleted stores lose their key-values; recovery restores an empty store.
  • Customer-managed key encryption, private endpoint connections, SKU request quotas and ARM store updates through PATCH are not modelled.
  • No dashboard page.

More

Documentation

Overview

Package azureappconfig emulates Azure App Configuration: key-values with labels, ETags and sync tokens, revisions and point-in-time reads, locks, snapshots and feature flags behind the HMAC-SHA256 authenticated data plane, sharing its stores and access keys with the ARM plane. See PARITY.md.

Index

Constants

View Source
const (
	ContentTypeFeatureFlag = "application/vnd.microsoft.appconfig.ff+json;charset=utf-8"
	ContentTypeKeyVaultRef = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8"
	FeatureFlagPrefix      = ".appconfig.featureflag/"
)

Content types the service and its clients treat specially.

View Source
const DefaultPort = 10008

DefaultPort is the App Configuration HTTPS data-plane port.

View Source
const DefaultStoreName = "default"

DefaultStoreName is the store addressed when a request names none.

Variables

View Source
var (
	ErrStoreNotFound    = errors.New("azureappconfig: configuration store not found")
	ErrKeyNotFound      = errors.New("azureappconfig: key-value not found")
	ErrKeyIDNotFound    = errors.New("azureappconfig: access key not found")
	ErrSnapshotNotFound = errors.New("azureappconfig: snapshot not found")
	ErrSnapshotExists   = errors.New("azureappconfig: snapshot already exists")
	ErrSnapshotStatus   = errors.New("azureappconfig: snapshot is not in a state that allows this change")
	ErrLocked           = errors.New("azureappconfig: key-value is read-only")
	ErrPrecondition     = errors.New("azureappconfig: precondition failed")
	ErrInvalidName      = errors.New("azureappconfig: invalid store name")
	ErrInvalidArgument  = errors.New("azureappconfig: invalid argument")
	ErrUnauthorized     = errors.New("azureappconfig: unauthorized")
	ErrForbidden        = errors.New("azureappconfig: the access key is read-only")
	ErrNilAppContext    = errors.New("azureappconfig: nil app context")
	ErrTooLarge         = errors.New("azureappconfig: request body too large")
)

Backend errors.

Functions

func SignRequest

func SignRequest(r *http.Request, signed []string, secret string) (string, error)

SignRequest computes the HMAC-SHA256 signature of the request for the given signed headers and base64 secret.

func ValidStoreName

func ValidStoreName(name string) bool

ValidStoreName reports whether name is a legal store name (5-50 letters, digits, hyphens).

Types

type AccessKey

type AccessKey struct {
	LastModified time.Time `json:"lastModified"`
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	Secret       string    `json:"secret"`
	ReadOnly     bool      `json:"readOnly,omitempty"`
}

AccessKey is one of a store's four HMAC credentials.

type ConfigProvider

type ConfigProvider interface {
	GetAzureAppConfigSettings() Settings
}

ConfigProvider extracts the App Configuration settings from the AppContext config.

type Filter

type Filter struct {
	Key   string `json:"key,omitempty"`
	Label string `json:"label,omitempty"`
}

Filter selects key-values for a snapshot.

type Handler

type Handler struct {
	Backend *InMemoryBackend

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

Handler owns the HTTPS listener.

func NewHandler

func NewHandler(backend *InMemoryBackend, settings Settings) *Handler

NewHandler returns a Handler over backend.

func (*Handler) ExtractOperation

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

ExtractOperation implements service.Service.

func (*Handler) ExtractResource

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

ExtractResource implements service.Service.

func (*Handler) GetSupportedOperations

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

GetSupportedOperations implements service.Service.

func (*Handler) Handler

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

Handler returns the echo handler of the HTTPS listener.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority implements service.Registerable.

func (*Handler) Name

func (h *Handler) Name() string

Name implements service.Service.

func (*Handler) Reset

func (h *Handler) Reset()

Reset implements service.Resettable.

func (*Handler) Restore

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

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

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

RouteMatcher never matches: App Configuration listens on its own port.

func (*Handler) Shutdown

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

Shutdown implements service.Shutdowner.

func (*Handler) Snapshot

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

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

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

StartWorker binds the HTTPS listener.

type InMemoryBackend

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

InMemoryBackend holds every configuration store; the ARM and data planes share it.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend returns an empty backend using the wall clock.

func (*InMemoryBackend) AccessKeys

func (b *InMemoryBackend) AccessKeys(name string) ([]AccessKey, error)

AccessKeys returns the store's four credentials.

func (*InMemoryBackend) AllKeyValues

func (b *InMemoryBackend) AllKeyValues(storeName string) ([]KeyValue, error)

AllKeyValues returns every current key-value of the store.

func (*InMemoryBackend) CreateSnapshot

func (b *InMemoryBackend) CreateSnapshot(storeName, name string, spec SnapshotSpec) (Snapshot, error)

CreateSnapshot captures the key-values selected by the spec; the snapshot is ready immediately.

func (*InMemoryBackend) DeleteKeyValue

func (b *InMemoryBackend) DeleteKeyValue(storeName, key, label string, p Precondition) (KeyValue, error)

DeleteKeyValue removes a key-value and returns its last state.

func (*InMemoryBackend) DeleteStore

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

DeleteStore removes a store with all its key-values and snapshots.

func (*InMemoryBackend) EnsureStore

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

EnsureStore creates the store when missing; it accepts any non-empty name.

func (*InMemoryBackend) GetKeyValue

func (b *InMemoryBackend) GetKeyValue(storeName, key, label string, at time.Time) (KeyValue, error)

GetKeyValue returns the key-value; a non-zero at reads its state at that time.

func (*InMemoryBackend) GetSnapshot

func (b *InMemoryBackend) GetSnapshot(storeName, name string) (Snapshot, error)

GetSnapshot returns a snapshot's metadata and items.

func (*InMemoryBackend) HasStore

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

HasStore reports whether the store exists.

func (*InMemoryBackend) KeyOwner

func (b *InMemoryBackend) KeyOwner(id string) (string, AccessKey, bool)

KeyOwner finds the credential with the given id across all stores.

func (*InMemoryBackend) ListKeyNames

func (b *InMemoryBackend) ListKeyNames(storeName, name string, at time.Time) ([]string, error)

ListKeyNames returns the distinct keys matching the name filter.

func (*InMemoryBackend) ListKeyValues

func (b *InMemoryBackend) ListKeyValues(storeName string, sel Selector, at time.Time) ([]KeyValue, error)

ListKeyValues returns the key-values matching sel, as of at when non-zero.

func (*InMemoryBackend) ListLabelNames

func (b *InMemoryBackend) ListLabelNames(storeName, name string, at time.Time) ([]string, error)

ListLabelNames returns the distinct non-null labels matching the name filter.

func (*InMemoryBackend) ListRevisions

func (b *InMemoryBackend) ListRevisions(storeName string, sel Selector, at time.Time) ([]KeyValue, error)

ListRevisions returns every recorded state of the key-values matching sel up to at (zero: all).

func (*InMemoryBackend) ListSnapshots

func (b *InMemoryBackend) ListSnapshots(storeName, nameFilter string, statuses []string) ([]Snapshot, error)

ListSnapshots returns snapshots whose name matches the filter and whose status is in statuses.

func (*InMemoryBackend) PutStore

func (b *InMemoryBackend) PutStore(name string) (StoreInfo, error)

PutStore creates a store, or returns the existing one unchanged.

func (*InMemoryBackend) RegenerateKey

func (b *InMemoryBackend) RegenerateKey(name, keyID string) (AccessKey, error)

RegenerateKey replaces the secret (and id) of the credential with the given id.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset drops all state.

func (*InMemoryBackend) Restore

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

Restore implements persistence.Persistable.

func (*InMemoryBackend) SetKeyValue

func (b *InMemoryBackend) SetKeyValue(storeName, key, label string, in KVInput, p Precondition) (KeyValue, error)

SetKeyValue creates or replaces a key-value.

func (*InMemoryBackend) SetLock

func (b *InMemoryBackend) SetLock(storeName, key, label string, locked bool, p Precondition) (KeyValue, error)

SetLock marks a key-value read-only or writable again.

func (*InMemoryBackend) SetSnapshotStatus

func (b *InMemoryBackend) SetSnapshotStatus(storeName, name, status string, p Precondition) (Snapshot, error)

SetSnapshotStatus archives (ready -> archived) or recovers (archived -> ready) a snapshot.

func (*InMemoryBackend) Snapshot

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

Snapshot implements persistence.Persistable.

func (*InMemoryBackend) SnapshotKeyValues

func (b *InMemoryBackend) SnapshotKeyValues(storeName, name string, sel Selector) ([]KeyValue, error)

SnapshotKeyValues returns the items of a snapshot matching sel.

func (*InMemoryBackend) Store

func (b *InMemoryBackend) Store(name string) (StoreInfo, error)

Store returns the ARM-visible view of a store.

func (*InMemoryBackend) StoreNames

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

StoreNames returns the store names sorted.

func (*InMemoryBackend) SyncToken

func (b *InMemoryBackend) SyncToken(name string) string

SyncToken returns the store's current sync token.

type KVInput

type KVInput struct {
	Value       *string
	ContentType *string
	Tags        map[string]string
}

KVInput is the writable part of a key-value.

type KeyValue

type KeyValue struct {
	LastModified time.Time         `json:"lastModified"`
	Value        *string           `json:"value,omitempty"`
	ContentType  *string           `json:"contentType,omitempty"`
	Tags         map[string]string `json:"tags,omitempty"`
	Key          string            `json:"key"`
	Label        string            `json:"label,omitempty"`
	ETag         string            `json:"etag"`
	Locked       bool              `json:"locked,omitempty"`
}

KeyValue is one configuration setting. An empty Label is the null label.

type Precondition

type Precondition struct {
	IfMatch     string
	IfNoneMatch string
}

Precondition carries the If-Match / If-None-Match request headers (already unquoted).

type Provider

type Provider struct{}

Provider implements service.Provider for Azure App Configuration.

func (*Provider) Init

Init builds the backend and handler; the port is bound by Handler.StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type Selector

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

Selector is the parsed key/label/tags filter of a list request.

func NewSelector

func NewSelector(key, label string, tags []string) (Selector, error)

type Settings

type Settings struct {
	TLSCertFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 245-byte string literal not displayed */
	TLSKeyFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 140-byte string literal not displayed */
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 261-byte string literal not displayed */
	ValidateHMAC bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 261-byte string literal not displayed */
	AutoCreate bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 260-byte string literal not displayed */
}

Settings is the Kong-embedded configuration of the App Configuration emulator.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider exists.

type Snapshot

type Snapshot struct {
	Created     time.Time         `json:"created"`
	Expires     *time.Time        `json:"expires,omitempty"`
	Tags        map[string]string `json:"tags,omitempty"`
	Name        string            `json:"name"`
	Status      string            `json:"status"`
	Composition string            `json:"composition"`
	ETag        string            `json:"etag"`
	Filters     []Filter          `json:"filters"`
	Items       []KeyValue        `json:"items"`
	Retention   int64             `json:"retention"`
	Size        int64             `json:"size"`
}

Snapshot is an immutable point-in-time set of key-values.

type SnapshotSpec

type SnapshotSpec struct {
	Tags        map[string]string
	Composition string
	Filters     []Filter
	Retention   int64
}

SnapshotSpec describes a snapshot to create.

type StoreInfo

type StoreInfo struct {
	Created time.Time
	Name    string
}

StoreInfo is the ARM-visible view of a store.

Jump to

Keyboard shortcuts

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