Skip to content

feat: introduce azd validate command with pipeline and gate framework#8597

Draft
vhvb1989 wants to merge 3 commits into
mainfrom
vhvb1989/azd-validate-pipeline
Draft

feat: introduce azd validate command with pipeline and gate framework#8597
vhvb1989 wants to merge 3 commits into
mainfrom
vhvb1989/azd-validate-pipeline

Conversation

@vhvb1989

Copy link
Copy Markdown
Member

Description

Implements the core validation pipeline framework for azd validate (resolves #7817).

Design Overview

The framework introduces three core concepts:

  1. Pipeline — Orchestrates sequential execution of validation gates. Supports configurable error behavior (abort on first error vs continue through all gates).

  2. Gate — A named validation stage (e.g. local-preflight, project-config). Each gate groups related checks and implements the Gate interface (Name() + Run(ctx, pipelineCtx)).

  3. Check — An individual validation function within a gate, identified by a stable RuleID.

Shared Pipeline Context

A PipelineContext flows through all gates, providing:

  • Console, Environment, and Project references
  • A typed Values map for inter-gate data sharing (e.g. a gate can store computed resource data for downstream gates)

Extension Integration (future)

The design supports two extension contribution models:

  • Model A (v1): Extensions add checks to existing gates via lifecycle events — reuses existing EventStream gRPC, no new proto surface needed.
  • Model B (v2): Extensions contribute full gates via a new validation-gate capability — requires new gRPC messages, deferred.

Files

File Purpose
pkg/validate/types.go Core types: CheckResult, CheckSeverity, GateResult, PipelineResult
pkg/validate/gate.go Gate interface, PipelineContext with typed value accessors
pkg/validate/check.go Check, CheckFn, CheckBasedGate (convenience gate from checks)
pkg/validate/pipeline.go Pipeline engine with abort/continue behavior
pkg/validate/report.go ValidationReport UX rendering (reuses preflight report pattern)
pkg/validate/gate_project_config.go Built-in project configuration validation gate
pkg/validate/pipeline_test.go 11 unit tests covering pipeline execution
internal/cmd/validate.go ValidateAction with --gate filter flag

How existing local-preflight becomes a gate

The existing localArmPreflight in the bicep provider maps directly to a Gate implementation. In a follow-up PR, BicepProvider.validatePreflight() will be wrapped as a gate, making it the first gate in the azd validate pipeline alongside the new project-config gate. The existing checks (role_assignment_permissions, ai_model_quota, reserved_resource_names) become Check entries in that gate.

What is NOT in this PR

  • Migration of the existing bicep local preflight (preserves backward compat, follow-up)
  • Extension gRPC surface for gate/check contribution (Model B — future)
  • azure.yaml configuration for gate enablement (future)

Testing

  • 11 unit tests in pkg/validate/pipeline_test.go covering:
    • Empty pipeline, single gate, warnings vs errors
    • Abort vs continue behavior
    • Gate execution order, context cancellation
    • Nil results (skipped gates), pipeline context values
  • Snapshot tests updated for new command
  • golangci-lint, cspell, gofmt, go fix, copyright check — all clean

Resolves #7817

Implements the core validation pipeline framework for azd validate (#7817).

The design introduces three concepts:
- Pipeline: orchestrates sequential execution of validation gates
- Gate: a named validation stage containing related checks
- Check: an individual validation function within a gate

Key components:
- pkg/validate/types.go: Core types (CheckResult, GateResult, PipelineResult)
- pkg/validate/gate.go: Gate interface and PipelineContext with typed values
- pkg/validate/check.go: CheckBasedGate for composing checks into gates
- pkg/validate/pipeline.go: Pipeline engine with abort/continue behavior
- pkg/validate/report.go: ValidationReport UX rendering (reuses preflight pattern)
- pkg/validate/gate_project_config.go: Example built-in gate
- internal/cmd/validate.go: ValidateAction with --gate filter flag

The pipeline flows a shared PipelineContext through gates, enabling
inter-gate data sharing via a typed Values map. Gates run sequentially
with configurable error behavior (abort on first error vs continue).

The existing local-preflight in the bicep provider can be migrated to
a Gate implementation in a follow-up, making it the first gate in the
pipeline alongside the new project-config gate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
vhvb1989 and others added 2 commits June 10, 2026 21:34
The constructor was creating an empty gates slice without registering
any built-in gates, causing azd validate to succeed immediately with
no checks. Now registers NewProjectConfigGate() by default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add Validate() to the provisioning.Provider interface and implement it
in BicepProvider (reuses plan() + local preflight checks), with stubs
for Terraform, TestProvider, DevCenter, and external gRPC providers.

Create LocalPreflightGate in pkg/validate that delegates to the
provisioning Manager and converts results into the validate framework's
CheckResult types.

Register the local-preflight gate in ValidateAction so 'azd validate'
runs both project-config and local-preflight gates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Spike] azd validate experience - next steps

1 participant