provisioning

package
v1.23.13 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AzdOperationsFeatureKey = alpha.MustFeatureKey("azd.operations")
View Source
var ErrAzdOperationsNotEnabled = fmt.Errorf(
	"azd operations (alpha feature) is required but disabled. You can enable azd operations by running: %s",
	output.WithGrayFormat("%s", alpha.GetEnableCommand(AzdOperationsFeatureKey)))
View Source
var ErrBindMountOperationDisabled = fmt.Errorf(
	"%sYour project has bind mounts.\n  - %w\n%s\n",
	output.WithWarningFormat("*Note: "),
	ErrAzdOperationsNotEnabled,
	output.WithWarningFormat("Ignoring bind mounts."),
)

Functions

func EnsureSubscription

func EnsureSubscription(
	ctx context.Context,
	envManager environment.Manager,
	env *environment.Environment,
	prompter prompt.Prompter,
) error

func EnsureSubscriptionAndLocation

func EnsureSubscriptionAndLocation(
	ctx context.Context,
	envManager environment.Manager,
	env *environment.Environment,
	prompter prompt.Prompter,
	options EnsureSubscriptionAndLocationOptions,
) error

EnsureSubscriptionAndLocation ensures that that that subscription (AZURE_SUBSCRIPTION_ID) and location (AZURE_LOCATION) variables are set in the environment, prompting the user for the values if they do not exist. locationFilter, when non-nil, filters the locations being displayed.

func NewEnvRefreshResultFromState

func NewEnvRefreshResultFromState(state *State) contracts.EnvRefreshResult

NewEnvRefreshResultFromState creates a EnvRefreshResult from a provisioning state object, applying the required translations.

func OutputParametersFromArmOutputs

func OutputParametersFromArmOutputs(
	templateOutputs azure.ArmTemplateOutputs,
	azureOutputParams map[string]azapi.AzCliDeploymentOutput) map[string]OutputParameter

OutputParametersFromArmOutputs converts the outputs from an ARM deployment to a map of provisioning.OutputParameter.

The casing of the output parameter names will match the casing in the provided templateOutputs. If an output is present in azureOutputParams but not in templateOutputs, the output name will be upper-cased to work around inconsistent casing behavior in Azure (e.g. `azurE_RESOURCE_GROUP`).

Secured outputs are skipped and not included in the result.

func UpdateEnvironment

func UpdateEnvironment(
	ctx context.Context,
	outputs map[string]OutputParameter,
	env *environment.Environment,
	envManager environment.Manager,
) error

Types

type ActionOptions

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

func NewActionOptions

func NewActionOptions(formatter output.Formatter, interactive bool) ActionOptions

func (*ActionOptions) Formatter

func (options *ActionOptions) Formatter() output.Formatter

Gets the specified output format

func (*ActionOptions) IsInteractive

func (options *ActionOptions) IsInteractive() bool

Gets a value determining whether the console is interactive Console is only considered interactive when the interactive flag has been set and an output format has not been defined.

type ChangeType

type ChangeType string

ChangeType defines a type for the valid changes for an Azure resource.

const (
	ChangeTypeCreate      ChangeType = "Create"
	ChangeTypeDelete      ChangeType = "Delete"
	ChangeTypeDeploy      ChangeType = "Deploy"
	ChangeTypeIgnore      ChangeType = "Ignore"
	ChangeTypeModify      ChangeType = "Modify"
	ChangeTypeNoChange    ChangeType = "NoChange"
	ChangeTypeUnsupported ChangeType = "Unsupported"
)

type CurrentPrincipalIdProvider

type CurrentPrincipalIdProvider interface {
	// CurrentPrincipalId returns the object id of the current logged in principal, or an error if it can not be
	// determined.
	CurrentPrincipalId(ctx context.Context) (string, error)
	CurrentPrincipalType(ctx context.Context) (PrincipalType, error)
}

func NewPrincipalIdProvider

func NewPrincipalIdProvider(
	env *environment.Environment,
	userProfileService *azapi.UserProfileService,
	subResolver account.SubscriptionTenantResolver,
	authManager *auth.Manager,
) CurrentPrincipalIdProvider

type DefaultProviderResolver

type DefaultProviderResolver func() (ProviderKind, error)

type DeployPreviewResult

type DeployPreviewResult struct {
	Preview *DeploymentPreview
}

DeployPreviewResult defines one deployment in preview mode, displaying what changes would it be performed, without applying the changes.

type DeployResult

type DeployResult struct {
	Deployment    *Deployment
	SkippedReason SkippedReasonType
}

type Deployment

type Deployment struct {
	Parameters map[string]InputParameter
	Outputs    map[string]OutputParameter
}

type DeploymentPreview

type DeploymentPreview struct {
	Status     string
	Properties *DeploymentPreviewProperties
}

DeploymentPreview defines the general structure for a deployment preview regardless of the deployment provider.

type DeploymentPreviewChange

type DeploymentPreviewChange struct {
	ChangeType        ChangeType
	ResourceId        Resource
	ResourceType      string
	Name              string
	UnsupportedReason string
	Before            any
	After             any
	Delta             []DeploymentPreviewPropertyChange
}

DeploymentPreviewChange represents a change to one Azure resource.

type DeploymentPreviewProperties

type DeploymentPreviewProperties struct {
	Changes []*DeploymentPreviewChange
}

DeploymentPreviewProperties holds the changes for the deployment preview.

type DeploymentPreviewPropertyChange

type DeploymentPreviewPropertyChange struct {
	ChangeType PropertyChangeType
	Path       string
	Before     any
	After      any
	Children   []DeploymentPreviewPropertyChange
}

DeploymentPreviewPropertyChange includes the details and properties from a resource change.

type DestroyOptions

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

Infrastructure destroy options

func NewDestroyOptions

func NewDestroyOptions(force bool, purge bool) DestroyOptions

func (*DestroyOptions) Force

func (o *DestroyOptions) Force() bool

func (*DestroyOptions) Purge

func (o *DestroyOptions) Purge() bool

type DestroyResult

type DestroyResult struct {
	// InvalidatedEnvKeys is a list of keys that should be removed from the environment after the destroy is complete.
	InvalidatedEnvKeys []string
}

type EnsureSubscriptionAndLocationOptions

type EnsureSubscriptionAndLocationOptions struct {
	// LocationFilterPredicate is a function to filter the locations being displayed if prompting the user for the location.
	LocationFiler prompt.LocationFilterPredicate
	// SelectDefaultLocation is the default location that azd mark as selected when prompting the user for the location.
	SelectDefaultLocation *string
}

type InputParameter

type InputParameter struct {
	Type         string
	DefaultValue any
	Value        any
}

func (*InputParameter) HasDefaultValue

func (p *InputParameter) HasDefaultValue() bool

func (*InputParameter) HasValue

func (p *InputParameter) HasValue() bool

type Manager

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

Manages the orchestration of infrastructure provisioning

func NewManager

func NewManager(
	serviceLocator ioc.ServiceLocator,
	defaultProvider DefaultProviderResolver,
	envManager environment.Manager,
	env *environment.Environment,
	console input.Console,
	alphaFeatureManager *alpha.FeatureManager,
	fileShareService storage.FileShareService,
	cloud *cloud.Cloud,
) *Manager

Creates a new instance of the Provisioning Manager

func (*Manager) Deploy

func (m *Manager) Deploy(ctx context.Context) (*DeployResult, error)

Deploys the Azure infrastructure for the specified project

func (*Manager) Destroy

func (m *Manager) Destroy(ctx context.Context, options DestroyOptions) (*DestroyResult, error)

Destroys the Azure infrastructure for the specified project

func (*Manager) Initialize

func (m *Manager) Initialize(ctx context.Context, projectPath string, options Options) error

func (*Manager) Parameters

func (m *Manager) Parameters(ctx context.Context) ([]Parameter, error)

Parameters gets the list of parameters and its value which will be used to provision the infrastructure.

func (*Manager) Preview

func (m *Manager) Preview(ctx context.Context) (*DeployPreviewResult, error)

Preview generates the list of changes to be applied as part of the provisioning.

func (*Manager) State

func (m *Manager) State(ctx context.Context, options *StateOptions) (*StateResult, error)

Gets the latest deployment details for the specified scope

type Mode

type Mode string
const (
	// Default mode for deploying or previewing the deployment.
	ModeDeploy Mode = ""
	// Mode for destroying the deployment.
	ModeDestroy Mode = "destroy"
)

type Options

type Options struct {
	Provider         ProviderKind   `yaml:"provider,omitempty"`
	Path             string         `yaml:"path,omitempty"`
	Module           string         `yaml:"module,omitempty"`
	Name             string         `yaml:"name,omitempty"`
	DeploymentStacks map[string]any `yaml:"deploymentStacks,omitempty"`
	// Provisioning options for each individually defined layer.
	Layers []Options `yaml:"layers,omitempty"`

	// IgnoreDeploymentState when true, skips the deployment state check.
	IgnoreDeploymentState bool `yaml:"-"`
	// The mode in which the deployment is being run.
	Mode Mode `yaml:"-"`
}

Options for a provisioning provider.

func (*Options) GetLayer

func (o *Options) GetLayer(name string) (Options, error)

GetLayer returns the provisioning layer with the provided name. When [Options.Layers] is not defined, an empty name returns the single layer defined.

func (*Options) GetLayers

func (o *Options) GetLayers() []Options

GetLayers return the provisioning layers defined. When [Options.Layers] is not defined, it returns the single layer defined.

The ordering is stable; and reflects the order defined in azure.yaml.

func (Options) GetWithDefaults

func (o Options) GetWithDefaults(other ...Options) (Options, error)

GetWithDefaults merges the provided infra options with the default provisioning options

func (*Options) Validate

func (o *Options) Validate() error

Validate validates the current loaded config for correctness.

This should be called immediately right after Unmarshal() before any defaulting is performed.

type OutputParameter

type OutputParameter struct {
	Type  ParameterType
	Value any
}

type Parameter

type Parameter struct {
	Name          string
	Secret        bool
	Value         any
	EnvVarMapping []string
	// true when the parameter value was set by the user from the command line (prompt)
	LocalPrompt        bool
	UsingEnvVarMapping bool
}

type ParameterType

type ParameterType string
const (
	ParameterTypeString  ParameterType = "string"
	ParameterTypeNumber  ParameterType = "number"
	ParameterTypeBoolean ParameterType = "bool"
	ParameterTypeObject  ParameterType = "object"
	ParameterTypeArray   ParameterType = "array"
)

func ParameterTypeFromArmType

func ParameterTypeFromArmType(armType string) ParameterType

ParameterTypeFromArmType maps an ARM parameter type to a provisioning.ParameterType.

Panics if the provided armType is not recognized.

type PrincipalType

type PrincipalType string
const (
	UserType             PrincipalType = "User"
	ServicePrincipalType PrincipalType = "ServicePrincipal"
)

type PropertyChangeType

type PropertyChangeType string

PropertyChangeType defines a type for the valid properties of a change.

const (
	PropertyChangeTypeArray    PropertyChangeType = "Array"
	PropertyChangeTypeCreate   PropertyChangeType = "Create"
	PropertyChangeTypeDelete   PropertyChangeType = "Delete"
	PropertyChangeTypeModify   PropertyChangeType = "Modify"
	PropertyChangeTypeNoEffect PropertyChangeType = "NoEffect"
)

type Provider

type Provider interface {
	Name() string
	Initialize(ctx context.Context, projectPath string, options Options) error
	State(ctx context.Context, options *StateOptions) (*StateResult, error)
	Deploy(ctx context.Context) (*DeployResult, error)
	Preview(ctx context.Context) (*DeployPreviewResult, error)
	Destroy(ctx context.Context, options DestroyOptions) (*DestroyResult, error)
	EnsureEnv(ctx context.Context) error
	Parameters(ctx context.Context) ([]Parameter, error)
}

type ProviderKind

type ProviderKind string
const (
	NotSpecified ProviderKind = ""
	Bicep        ProviderKind = "bicep"
	Arm          ProviderKind = "arm"
	Terraform    ProviderKind = "terraform"
	Pulumi       ProviderKind = "pulumi"
	Test         ProviderKind = "test"
)

func ParseProvider

func ParseProvider(kind ProviderKind) (ProviderKind, error)

Parses the specified IaC Provider to ensure whether it is valid or not Defaults to `Bicep` if no provider is specified

type Resource

type Resource struct {
	Id string
}

type SkippedReasonType

type SkippedReasonType string
const (
	DeploymentStateSkipped  SkippedReasonType = "deployment State"
	PreflightAbortedSkipped SkippedReasonType = "preflight aborted"
)

type State

type State struct {
	// Outputs from the most recent deployment.
	Outputs map[string]OutputParameter
	// The resources that make up the application.
	Resources []Resource
}

State represents the "current state" of the infrastructure, which is the result of the most recent deployment. For ARM this corresponds to information from the most recent deployment object. For Terraform, it's information from the state file.

func (*State) MergeInto

func (s *State) MergeInto(other State)

MergeInto merges other on top of s, i.e. if a key exists in both s and other, the value from other will be used.

type StateOptions

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

func NewStateOptions

func NewStateOptions(hint string) *StateOptions

func (*StateOptions) Hint

func (o *StateOptions) Hint() string

type StateResult

type StateResult struct {
	State *State
}

Directories

Path Synopsis
Package test contains an test implementation of provider.Provider.
Package test contains an test implementation of provider.Provider.

Jump to

Keyboard shortcuts

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