infra

package
v0.0.0-...-6cd82ae Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDeploymentsNotFound         = errors.New("no deployments found")
	ErrDeploymentResourcesNotFound = errors.New("no resources found for deployment")
)

Functions

func ResourceId

func ResourceId(name string, env *environment.Environment) (resId *arm.ResourceID, err error)

ResourceId returns the resource ID for the corresponding name.

If the name is a resource ID string, it is immediately parsed without translation.

Types

type AzureResourceManager

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

func (*AzureResourceManager) FindResourceGroupForEnvironment

func (rm *AzureResourceManager) FindResourceGroupForEnvironment(
	ctx context.Context,
	subscriptionId string,
	envName string,
) (string, error)

FindResourceGroupForEnvironment will search for the resource group associated with an environment It will first try to find a resource group tagged with azd-env-name Then it will try to find a resource group that defaults to either {envname}-rg or rg-{envname} If it finds exactly one resource group, then it will use it If it finds more than one or zero resource groups, then it will prompt the user to update azure.yaml or AZURE_RESOURCE_GROUP with the resource group to use.

func (*AzureResourceManager) GetDefaultResourceGroups

func (rm *AzureResourceManager) GetDefaultResourceGroups(
	ctx context.Context,
	subscriptionId string,
	environmentName string,
) ([]*azapi.Resource, error)

GetDefaultResourceGroups gets the default resource groups regardless of azd-env-name setting azd initially released with {envname}-rg for a default resource group name. We now don't hardcode the default We search for them instead using the rg- prefix or -rg suffix

func (*AzureResourceManager) GetDeploymentResourceOperations

func (rm *AzureResourceManager) GetDeploymentResourceOperations(
	ctx context.Context,
	deployment Deployment,
	queryStart *time.Time,
) ([]*armresources.DeploymentOperation, error)

GetDeploymentResourceOperations gets the list of all the resources created as part of the provided deployment. Each DeploymentOperation on the list holds a resource and the result of its deployment. One deployment operation can trigger new deployment operations, GetDeploymentResourceOperations traverses all operations recursively to find the leaf operations.

func (*AzureResourceManager) GetResourceGroupsForEnvironment

func (rm *AzureResourceManager) GetResourceGroupsForEnvironment(
	ctx context.Context,
	subscriptionId string,
	envName string,
) ([]*azapi.Resource, error)

GetResourceGroupsForEnvironment gets all resources groups for a given environment

func (*AzureResourceManager) GetResourceTypeDisplayName

func (rm *AzureResourceManager) GetResourceTypeDisplayName(
	ctx context.Context,
	subscriptionId string,
	resourceId string,
	resourceType azapi.AzureResourceType,
) (string, error)

type Deployment

type Deployment interface {
	Scope
	// Name is the name of this deployment.
	Name() string
	// PortalUrl is the URL that may be used to view this deployment resource in the Azure Portal.
	PortalUrl(ctx context.Context) (string, error)
	// OutputsUrl is the URL that may be used to view this deployment outputs the in Azure Portal.
	OutputsUrl(ctx context.Context) (string, error)
	// DeploymentUrl is the URL that may be used to view this deployment progress in the Azure Portal.
	DeploymentUrl(ctx context.Context) (string, error)
	// Deploy a given template with a set of parameters.
	Deploy(
		ctx context.Context,
		template azure.RawArmTemplate,
		parameters azure.ArmParameters,
		tags map[string]*string,
		options map[string]any,
	) (*azapi.ResourceDeployment, error)
	Delete(ctx context.Context,
		options map[string]any,
		progress *async.Progress[azapi.DeleteDeploymentProgress],
	) error
	// Deploy a given template with a set of parameters.
	DeployPreview(
		ctx context.Context,
		template azure.RawArmTemplate,
		parameters azure.ArmParameters,
	) (*armresources.WhatIfOperationResult, error)
	// Deployment fetches information about this deployment.
	Get(ctx context.Context) (*azapi.ResourceDeployment, error)
	// Operations returns all the operations for this deployment.
	Operations(ctx context.Context) ([]*armresources.DeploymentOperation, error)
	Resources(ctx context.Context) ([]*armresources.ResourceReference, error)
}

type DeploymentManager

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

func NewDeploymentManager

func NewDeploymentManager(
	deploymentService azapi.DeploymentService,
	resourceManager ResourceManager,
	console input.Console,
) *DeploymentManager

func (*DeploymentManager) CalculateTemplateHash

func (dm *DeploymentManager) CalculateTemplateHash(
	ctx context.Context,
	subscriptionId string,
	template azure.RawArmTemplate,
) (string, error)

func (*DeploymentManager) CompletedDeployments

func (dm *DeploymentManager) CompletedDeployments(
	ctx context.Context,
	scope Scope,
	envName string,
	hint string,
) ([]*azapi.ResourceDeployment, error)

func (*DeploymentManager) GenerateDeploymentName

func (dm *DeploymentManager) GenerateDeploymentName(baseName string) string

func (*DeploymentManager) ProgressDisplay

func (dm *DeploymentManager) ProgressDisplay(deployment Deployment) *ProvisioningProgressDisplay

func (*DeploymentManager) ResourceGroupDeployment

func (dm *DeploymentManager) ResourceGroupDeployment(
	scope *ResourceGroupScope,
	deploymentName string,
) *ResourceGroupDeployment

func (*DeploymentManager) ResourceGroupScope

func (dm *DeploymentManager) ResourceGroupScope(subscriptionId string, resourceGroupName string) *ResourceGroupScope

func (*DeploymentManager) SubscriptionDeployment

func (dm *DeploymentManager) SubscriptionDeployment(
	scope *SubscriptionScope,
	deploymentName string,
) *SubscriptionDeployment

func (*DeploymentManager) SubscriptionScope

func (dm *DeploymentManager) SubscriptionScope(subscriptionId string, location string) *SubscriptionScope

type ProvisioningProgressDisplay

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

ProvisioningProgressDisplay displays interactive progress for an ongoing Azure provisioning operation.

func NewProvisioningProgressDisplay

func NewProvisioningProgressDisplay(
	rm ResourceManager,
	console input.Console,
	deployment Deployment,
) *ProvisioningProgressDisplay

func (*ProvisioningProgressDisplay) ReportProgress

func (display *ProvisioningProgressDisplay) ReportProgress(
	ctx context.Context, queryStart *time.Time) error

ReportProgress reports the current deployment progress, setting the currently executing operation title and logging progress.

type ResourceGroupDeployment

type ResourceGroupDeployment struct {
	*ResourceGroupScope
	// contains filtered or unexported fields
}

func NewResourceGroupDeployment

func NewResourceGroupDeployment(scope *ResourceGroupScope, deploymentName string) *ResourceGroupDeployment

func (*ResourceGroupDeployment) Delete

func (*ResourceGroupDeployment) Deploy

func (s *ResourceGroupDeployment) Deploy(
	ctx context.Context,
	template azure.RawArmTemplate,
	parameters azure.ArmParameters,
	tags map[string]*string,
	options map[string]any,
) (*azapi.ResourceDeployment, error)

func (*ResourceGroupDeployment) DeployPreview

func (*ResourceGroupDeployment) DeploymentUrl

func (s *ResourceGroupDeployment) DeploymentUrl(ctx context.Context) (string, error)

Gets the url to view deployment

func (*ResourceGroupDeployment) Get

GetDeployment fetches the result of the most recent deployment.

func (*ResourceGroupDeployment) Name

func (s *ResourceGroupDeployment) Name() string

func (*ResourceGroupDeployment) Operations

Gets the resource deployment operations for the current scope

func (*ResourceGroupDeployment) OutputsUrl

func (s *ResourceGroupDeployment) OutputsUrl(ctx context.Context) (string, error)

Gets the url to view deployment outputs

func (*ResourceGroupDeployment) PortalUrl

func (s *ResourceGroupDeployment) PortalUrl(ctx context.Context) (string, error)

Gets the url to check deployment resource

func (*ResourceGroupDeployment) Resources

type ResourceGroupScope

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

func (*ResourceGroupScope) Deployment

func (s *ResourceGroupScope) Deployment(deploymentName string) Deployment

Deployment gets the deployment with the specified name.

func (*ResourceGroupScope) ListDeployments

func (s *ResourceGroupScope) ListDeployments(ctx context.Context) ([]*azapi.ResourceDeployment, error)

ListDeployments returns all the deployments in this resource group.

func (*ResourceGroupScope) ResourceGroupName

func (s *ResourceGroupScope) ResourceGroupName() string

func (*ResourceGroupScope) SubscriptionId

func (s *ResourceGroupScope) SubscriptionId() string

type ResourceManager

type ResourceManager interface {
	GetDeploymentResourceOperations(
		ctx context.Context, deployment Deployment, queryStart *time.Time) ([]*armresources.DeploymentOperation, error)
	GetResourceTypeDisplayName(
		ctx context.Context,
		subscriptionId string,
		resourceId string,
		resourceType azapi.AzureResourceType,
	) (string, error)
	GetResourceGroupsForEnvironment(
		ctx context.Context,
		subscriptionId string,
		envName string,
	) ([]*azapi.Resource, error)
	FindResourceGroupForEnvironment(
		ctx context.Context,
		subscriptionId string,
		envName string,
	) (string, error)
}

func NewAzureResourceManager

func NewAzureResourceManager(
	resourceService *azapi.ResourceService,
	deploymentService *azapi.StandardDeployments,
) ResourceManager

type Scope

type Scope interface {
	// SubscriptionId is the id of the subscription which this deployment targets.
	SubscriptionId() string
	// ListDeployments returns all the deployments at this scope.
	ListDeployments(ctx context.Context) ([]*azapi.ResourceDeployment, error)
	Deployment(deploymentName string) Deployment
}

type SubscriptionDeployment

type SubscriptionDeployment struct {
	*SubscriptionScope
	// contains filtered or unexported fields
}

func NewSubscriptionDeployment

func NewSubscriptionDeployment(
	scope *SubscriptionScope,
	deploymentName string,
) *SubscriptionDeployment

func (*SubscriptionDeployment) Delete

func (*SubscriptionDeployment) Deploy

func (s *SubscriptionDeployment) Deploy(
	ctx context.Context,
	template azure.RawArmTemplate,
	parameters azure.ArmParameters,
	tags map[string]*string,
	options map[string]any,
) (*azapi.ResourceDeployment, error)

Deploy a given template with a set of parameters.

func (*SubscriptionDeployment) DeployPreview

Deploy a given template with a set of parameters.

func (*SubscriptionDeployment) DeploymentUrl

func (s *SubscriptionDeployment) DeploymentUrl(ctx context.Context) (string, error)

Gets the url to view deployment

func (*SubscriptionDeployment) Get

GetDeployment fetches the result of the most recent deployment.

func (*SubscriptionDeployment) Name

func (s *SubscriptionDeployment) Name() string

func (*SubscriptionDeployment) Operations

Gets the resource deployment operations for the current scope

func (*SubscriptionDeployment) OutputsUrl

func (s *SubscriptionDeployment) OutputsUrl(ctx context.Context) (string, error)

Gets the url to view deployment outputs

func (*SubscriptionDeployment) PortalUrl

func (s *SubscriptionDeployment) PortalUrl(ctx context.Context) (string, error)

Gets the url to check deployment resource

func (*SubscriptionDeployment) Resources

type SubscriptionScope

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

func (*SubscriptionScope) Deployment

func (s *SubscriptionScope) Deployment(deploymentName string) Deployment

func (*SubscriptionScope) ListDeployments

func (s *SubscriptionScope) ListDeployments(ctx context.Context) ([]*azapi.ResourceDeployment, error)

ListDeployments returns all the deployments at subscription scope.

func (*SubscriptionScope) Location

func (s *SubscriptionScope) Location() string

func (*SubscriptionScope) SubscriptionId

func (s *SubscriptionScope) SubscriptionId() string

Gets the Azure subscription id

Directories

Path Synopsis
test
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