aks

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package aks provides an in-memory mock of Microsoft.ContainerService (Azure Kubernetes Service) — control-plane only.

Wave 1 scope: ManagedClusters + AgentPools + MaintenanceConfigurations CRUD and credential listing. The Kubernetes data-plane API (Deployments, Pods, Services, …) is intentionally NOT modeled here; that is deferred to Wave 2. The mock returns a stub kubeconfig pointing at a sentinel host so callers can detect that the data plane is not implemented.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentPoolResourceID

func AgentPoolResourceID(subscription, rg, cluster, pool string) string

AgentPoolResourceID constructs the canonical ARM resource ID for an agent pool nested under a managed cluster.

func ClusterResourceID

func ClusterResourceID(subscription, rg, name string) string

ClusterResourceID constructs the canonical ARM resource ID for a managed cluster.

func MaintenanceConfigResourceID

func MaintenanceConfigResourceID(subscription, rg, cluster, name string) string

MaintenanceConfigResourceID constructs the canonical ARM resource ID for a maintenance configuration nested under a managed cluster.

Types

type AgentPool

type AgentPool struct {
	Name              string
	ClusterName       string
	ResourceGroup     string
	Count             int32
	VMSize            string
	OSDiskSizeGB      int32
	OSType            string
	Mode              string
	OrchestratorVer   string
	ProvisioningState string
	NodeLabels        map[string]string
	NodeTaints        []string

	CreatedAt time.Time
	UpdatedAt time.Time
}

AgentPool is a node pool attached to a managed cluster.

type AgentPoolInput

type AgentPoolInput struct {
	Name            string
	Count           int32
	VMSize          string
	OSDiskSizeGB    int32
	OSType          string
	Mode            string
	OrchestratorVer string
	NodeLabels      map[string]string
	NodeTaints      []string
}

AgentPoolInput captures the mutable fields of an AgentPool CreateOrUpdate.

type ClusterInput

type ClusterInput struct {
	Subscription      string
	ResourceGroup     string
	Name              string
	Location          string
	KubernetesVersion string
	DNSPrefix         string
	NodeResourceGroup string
	Tags              map[string]string
	// AgentPools may be nil for an empty cluster; otherwise these are the
	// pools shipped inline at create time (system pool typically).
	AgentPools []AgentPoolInput
}

ClusterInput captures the mutable fields of a CreateOrUpdate call.

type MaintenanceConfig

type MaintenanceConfig struct {
	Name          string
	ClusterName   string
	ResourceGroup string
	Properties    map[string]any

	CreatedAt time.Time
	UpdatedAt time.Time
}

MaintenanceConfig is a maintenance window attached to a managed cluster.

type ManagedCluster

type ManagedCluster struct {
	Name              string
	ResourceGroup     string
	Location          string
	KubernetesVersion string
	DNSPrefix         string
	FQDN              string
	NodeResourceGroup string
	ProvisioningState string
	PowerState        string
	Tags              map[string]string
	AgentPoolNames    []string

	CreatedAt time.Time
	UpdatedAt time.Time
}

ManagedCluster is the in-memory representation of an AKS cluster.

type Mock

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

Mock is the in-memory AKS implementation.

func New

func New(opts *config.Options) *Mock

New creates a new AKS mock.

func (*Mock) CreateOrUpdateAgentPool

func (m *Mock) CreateOrUpdateAgentPool(
	_ context.Context, rg, cluster string, in AgentPoolInput,
) (*AgentPool, error)

CreateOrUpdateAgentPool creates or replaces an agent pool on a cluster.

func (*Mock) CreateOrUpdateCluster

func (m *Mock) CreateOrUpdateCluster(_ context.Context, input ClusterInput) (*ManagedCluster, error)

CreateOrUpdateCluster creates a new managed cluster or updates an existing one. The semantics mirror Azure ARM PUT: full replace, idempotent on no-op.

func (*Mock) CreateOrUpdateMaintenanceConfig

func (m *Mock) CreateOrUpdateMaintenanceConfig(
	_ context.Context, rg, cluster, name string, props map[string]any,
) (*MaintenanceConfig, error)

CreateOrUpdateMaintenanceConfig creates or replaces a maintenance config.

func (*Mock) DeleteAgentPool

func (m *Mock) DeleteAgentPool(_ context.Context, rg, cluster, pool string) error

DeleteAgentPool removes an agent pool.

func (*Mock) DeleteCluster

func (m *Mock) DeleteCluster(_ context.Context, rg, name string) error

DeleteCluster removes a managed cluster and all its sub-resources.

func (*Mock) DeleteMaintenanceConfig

func (m *Mock) DeleteMaintenanceConfig(_ context.Context, rg, cluster, name string) error

DeleteMaintenanceConfig removes a maintenance config.

func (*Mock) GetAgentPool

func (m *Mock) GetAgentPool(_ context.Context, rg, cluster, pool string) (*AgentPool, error)

GetAgentPool returns an agent pool by name.

func (*Mock) GetCluster

func (m *Mock) GetCluster(_ context.Context, rg, name string) (*ManagedCluster, error)

GetCluster returns a managed cluster by name within a resource group.

func (*Mock) GetMaintenanceConfig

func (m *Mock) GetMaintenanceConfig(_ context.Context, rg, cluster, name string) (*MaintenanceConfig, error)

GetMaintenanceConfig returns a maintenance config by name.

func (*Mock) Kubeconfig added in v1.6.3

func (m *Mock) Kubeconfig(rg, name string) []byte

Kubeconfig returns a kubeconfig blob for the named managed cluster.

When a shared kubernetes.APIServer is wired (Phase 3 onward) and the cluster has a registered UID, the kubeconfig points at <base>/k8s/<uid> — the real in-memory K8s API server registered to this cluster on Create. When the APIServer isn't wired (Wave 1 fallback), the kubeconfig points at the *-DATAPLANE-NOT-IMPLEMENTED sentinel host instead, so callers in tests can match on it to confirm the data plane is intentionally unimplemented.

func (*Mock) ListAgentPools

func (m *Mock) ListAgentPools(_ context.Context, rg, cluster string) ([]AgentPool, error)

ListAgentPools returns all pools attached to a cluster.

func (*Mock) ListClusters

func (m *Mock) ListClusters(_ context.Context) ([]ManagedCluster, error)

ListClusters returns all managed clusters across all resource groups.

func (*Mock) ListClustersByResourceGroup

func (m *Mock) ListClustersByResourceGroup(_ context.Context, rg string) ([]ManagedCluster, error)

ListClustersByResourceGroup returns all clusters in a resource group.

func (*Mock) ListMaintenanceConfigs

func (m *Mock) ListMaintenanceConfigs(_ context.Context, rg, cluster string) ([]MaintenanceConfig, error)

ListMaintenanceConfigs returns all maintenance configs on a cluster.

func (*Mock) RotateClusterCertificates

func (m *Mock) RotateClusterCertificates(_ context.Context, rg, name string) error

RotateClusterCertificates is a stub that simply marks the cluster updated. Real Azure rotates control-plane certs asynchronously; the mock surface is sufficient for the SDK round-trip.

func (*Mock) SetK8sAPI added in v1.6.3

func (m *Mock) SetK8sAPI(api *kubernetes.APIServer)

SetK8sAPI wires a shared in-memory Kubernetes data-plane server. After this is set, CreateOrUpdateCluster registers a fresh ClusterState with api and Kubeconfig returns a kubeconfig YAML that points at it. Pass the same *kubernetes.APIServer as azureserver.Drivers.K8sAPI when constructing the SDK-compat server, so kubeconfigs land on the right backend.

func (*Mock) SetMonitoring

func (m *Mock) SetMonitoring(mon mondriver.Monitoring)

SetMonitoring wires an Azure-Monitor-style backend for auto-metric emission.

func (*Mock) UpdateClusterTags

func (m *Mock) UpdateClusterTags(_ context.Context, rg, name string, tags map[string]string) (*ManagedCluster, error)

UpdateClusterTags replaces the tags on a managed cluster (PATCH semantics).

Jump to

Keyboard shortcuts

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