Skip to content

Validation: Relax ParseProvider to accept extension provider names #7478

@wbreza

Description

@wbreza

Summary

Update ParseProvider() in pkg/infra/provisioning/provisioning.go to accept any non-empty string as a valid provider kind (not just hardcoded Bicep/Terraform/Test). Also add a Config map[string]any field to the Options struct for extension-specific configuration pass-through via azure.yaml.

Parent Epic

Part of #7465 — Provisioning Providers in the AZD Extension Framework

Context

Current Behavior

func ParseProvider(kind ProviderKind) (ProviderKind, error) {
    switch kind {
    case NotSpecified, Bicep, Terraform, Test:
        return kind, nil
    }
    return ProviderKind(""), fmt.Errorf("unsupported IaC provider '%s'", kind)
}

This rejects any provider name that isn't in the hardcoded list, blocking external providers.

Required Behavior

When azure.yaml specifies infra.provider: myprov, ParseProvider("myprov") must return ("myprov", nil) — the IoC container will resolve the provider by name at runtime.

Config Pass-Through

Extensions need arbitrary configuration from azure.yaml:

infra:
  provider: myprov
  path: ./infra
  config:
    scripts:
      - shell: bash
        run: setup.sh

The config field needs to be in the Options struct and marshaled to google.protobuf.Struct for the proto.

Detailed Requirements

ParseProvider Update

func ParseProvider(kind ProviderKind) (ProviderKind, error) {
    // Accept any non-empty provider name
    // Known providers still work unchanged
    // NotSpecified still defaults correctly via DefaultProviderResolver
    return kind, nil
}

Options.Config Field

type Options struct {
    // ...existing fields...
    Config map[string]any `yaml:"config,omitempty"`
}

Acceptance Criteria

  • ParseProvider() accepts any non-empty string
  • Known providers (Bicep, Terraform, Test) still work unchanged
  • NotSpecified still defaults correctly
  • Options.Config map[string]any field added with yaml tag
  • Config field serializable to/from YAML
  • Unit tests updated for ParseProvider with arbitrary provider names
  • Existing tests still pass

Dependencies

  • None (can be done in parallel with other work)

Files

  • Modify: pkg/infra/provisioning/provisioning.go
  • Modify: pkg/infra/provisioning/provider.go
  • Modify: pkg/infra/provisioning/provisioning_test.go (if exists)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions