arm

package
v0.0.0-...-65782e4 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 25 Imported by: 14

Documentation

Index

Constants

View Source
const RBACPropagationRetrySteps = 12

Variables

View Source
var TransientBackoff = wait.Backoff{
	Steps:    4,
	Duration: 15 * time.Second,
	Factor:   2.0,
	Jitter:   0.1,
	Cap:      60 * time.Second,
}

TransientBackoff is the retry schedule for ARM write operations when no Retry-After header is present. It is a var so tests can override it; tests that mutate it must not call t.Parallel().

Functions

func BuildStorageAccountsValidationMap

func BuildStorageAccountsValidationMap(storageAccountNames ...string) map[string]map[string]any

func DeployTemplate

func DeployTemplate(ctx context.Context, log *logrus.Entry, deployments features.DeploymentsClient, resourceGroupName string, deploymentName string, template *Template, parameters map[string]any) error

func EnrichMismatchesWithPolicyContext

func EnrichMismatchesWithPolicyContext(
	ctx context.Context,
	log *logrus.Entry,
	policyClient armpolicyinsights.PolicyRestrictionsClient,
	resourceGroupName string,
	mismatches []Mismatch,
)

func MismatchesToCloudError

func MismatchesToCloudError(mismatches []Mismatch) error

func Retryable

func Retryable(ctx context.Context, f func() error, log *logrus.Entry, desc string) error

func RetryableDelete

func RetryableDelete(ctx context.Context, f func() error, log *logrus.Entry, desc string) error

RetryableDelete wraps f with transient ARM retry and logs each attempt, treating 404 as success.

func RetryableWith

func RetryableWith(ctx context.Context, isRetryable func(error) bool, f func() error, log *logrus.Entry, desc string, opts *RetryOptions) error

RetryableWith is like Retryable but with a custom error predicate.

Types

type ArmResource

type ArmResource struct {
	SubscriptionID string
	ResourceGroup  string
	Provider       string
	ResourceName   string
	ResourceType   string
	SubResource    SubResource
}

ArmResource represents a resource and its child resources. Typically we would use the autorest package for this, but It does not have support for subresources

func ParseArmResourceId

func ParseArmResourceId(resourceId string) (*ArmResource, error)

ParseArmResourceId takes in an ARM resource ID and returns an ArmResource object representing that resource. It supports up to two levels of subresource nesting.

func (ArmResource) ParentResource

func (r ArmResource) ParentResource() string

ParentResourcetoString returns a string of the parent object in form of azureResourceID

func (ArmResource) String

func (r ArmResource) String() string

String function returns a string in form of azureResourceID

type Copy

type Copy struct {
	Name      string `json:"name,omitempty"`
	Count     int    `json:"count,omitempty"`
	Mode      string `json:"mode,omitempty"`
	BatchSize int    `json:"batchSize,omitempty"`
}

Copy represents an ARM template copy stanza

type Deployment

type Deployment struct {
	Name       string                `json:"name,omitempty"`
	Type       string                `json:"type,omitempty"`
	Location   string                `json:"location,omitempty"`
	APIVersion string                `json:"apiVersion,omitempty"`
	DependsOn  []string              `json:"dependsOn,omitempty"`
	Condition  any                   `json:"condition,omitempty"`
	Properties *DeploymentProperties `json:"properties,omitempty"`
}

Deployment represents a nested ARM deployment in a deployment

type DeploymentProperties

type DeploymentProperties struct {
	Mode                        string                                          `json:"mode,omitempty"`
	ExpressionEvaluationOptions map[string]*string                              `json:"expressionEvaluationOptions,omitempty"`
	Parameters                  map[string]*DeploymentTemplateResourceParameter `json:"parameters,omitempty"`
	Variables                   map[string]any                                  `json:"variables,omitempty"`
	Template                    *DeploymentTemplate                             `json:"template,omitempty"`
}

DeploDeploymentProperties represents the propertioes of a nested ARM deployment

type DeploymentTemplate

type DeploymentTemplate struct {
	Schema         string                        `json:"$schema,omitempty"`
	APIProfile     string                        `json:"apiProfile,omitempty"`
	ContentVersion string                        `json:"contentVersion,omitempty"`
	Variables      map[string]any                `json:"variables,omitempty"`
	Parameters     map[string]*TemplateParameter `json:"parameters,omitempty"`
	Functions      []any                         `json:"functions,omitempty"`
	Resources      []*DeploymentTemplateResource `json:"resources,omitempty"`
}

DeploymentTemplate represents the inner template of a nested ARM deployment

type DeploymentTemplateResource

type DeploymentTemplateResource struct {
	Name       string `json:"name,omitempty"`
	Type       string `json:"type,omitempty"`
	APIVersion string `json:"apiVersion,omitempty"`
	Properties any    `json:"properties,omitempty"`
}

DeploymentTemplateResource represents the inner template's resource of a nested ARM deployment

type DeploymentTemplateResourceParameter

type DeploymentTemplateResourceParameter struct {
	Value string `json:"value,omitempty"`
}

DeploymentTemplateResourceParameter represents a nested ARM deployment's resource parameter

type Mismatch

type Mismatch struct {
	ResourceName  string              `json:"resourceName"`
	ResourceType  string              `json:"resourceType"`
	ResourceGroup string              `json:"resourceGroup"`
	Property      string              `json:"property"`
	Expected      any                 `json:"expected"`
	Actual        any                 `json:"actual"`
	Policies      []PolicyAttribution `json:"policies,omitempty"`
}

func ValidateDeploymentWithWhatIf

func ValidateDeploymentWithWhatIf(ctx context.Context, log *logrus.Entry, deployments features.DeploymentsClient, resourceGroupName string, deploymentName string, template *Template, resourcesToValidate map[string]map[string]any) []Mismatch

type Output

type Output struct {
	Condition bool   `json:"condition,omitempty"`
	Type      string `json:"type,omitempty"`
	Value     any    `json:"value,omitempty"`
}

Output represents an ARM template output

type Parameters

type Parameters struct {
	Schema         string                          `json:"$schema,omitempty"`
	ContentVersion string                          `json:"contentVersion,omitempty"`
	Parameters     map[string]*ParametersParameter `json:"parameters,omitempty"`
}

Parameters represents ARM parameters

type ParametersParameter

type ParametersParameter struct {
	Ref      string         `json:"$ref,omitempty"`
	Value    any            `json:"value,omitempty"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

ParametersParameter represents an ARM parameters parameter

type PolicyAttribution

type PolicyAttribution struct {
	Field            string     `json:"field"`
	Result           string     `json:"result,omitempty"`
	Effect           string     `json:"effect,omitempty"`
	Values           []string   `json:"values,omitempty"`
	PolicyDefinition *PolicyRef `json:"policyDefinition,omitempty"`
	PolicyAssignment *PolicyRef `json:"policyAssignment,omitempty"`
}

type PolicyRef

type PolicyRef struct {
	Name              string `json:"name,omitempty"`
	SubscriptionID    string `json:"subscriptionId,omitempty"`
	ResourceGroupName string `json:"resourceGroupName,omitempty"`
}

type Resource

type Resource struct {
	Resource any `json:"-"`

	Name       string         `json:"name,omitempty"`
	Type       string         `json:"type,omitempty"`
	Condition  any            `json:"condition,omitempty"`
	APIVersion string         `json:"apiVersion,omitempty"`
	DependsOn  []string       `json:"dependsOn,omitempty"`
	Location   string         `json:"location,omitempty"`
	Tags       map[string]any `json:"tags,omitempty"`
	Copy       *Copy          `json:"copy,omitempty"`
	Comments   string         `json:"comments,omitempty"`
	// Etag is required to omit Etag member when it's not set.
	// arm* SDK uses its own MarshalJSON, and empty members are converted to nil,
	// but Etag: nil fails the ARM template validation.
	Etag string `json:"etag,omitempty"`
}

Resource represents an ARM template resource

func (*Resource) MarshalJSON

func (r *Resource) MarshalJSON() ([]byte, error)

MarshalJSON marshals the nested r.Resource ignoring any MarshalJSON() methods on its types. It then merges remaining fields of r over the result

func (*Resource) UnmarshalJSON

func (r *Resource) UnmarshalJSON(b []byte) error

UnmarshalJSON is not implemented

type RetryOptions

type RetryOptions struct {
	Steps int
}

RetryOptions configures optional behavior for RetryableWith.

type SubResource

type SubResource struct {
	ResourceName string
	ResourceType string
	SubResource  *SubResource
}

SubResource represents an ARM Proxy Resource ARM supports up to 3 levels of nested resources https://eng.ms/docs/products/arm/api_contracts/guidelines/rpc#rpc030-avoid-excessive-resource-type-nesting

type Template

type Template struct {
	Schema         string                        `json:"$schema,omitempty"`
	APIProfile     string                        `json:"apiProfile,omitempty"`
	ContentVersion string                        `json:"contentVersion,omitempty"`
	Variables      map[string]any                `json:"variables,omitempty"`
	Parameters     map[string]*TemplateParameter `json:"parameters,omitempty"`
	Functions      []any                         `json:"functions,omitempty"`
	Resources      []*Resource                   `json:"resources,omitempty"`
	Outputs        map[string]*Output            `json:"outputs,omitempty"`
}

Template represents an ARM template

type TemplateParameter

type TemplateParameter struct {
	Type          string         `json:"type,omitempty"`
	DefaultValue  any            `json:"defaultValue,omitempty"`
	AllowedValues []any          `json:"allowedValues,omitempty"`
	Metadata      map[string]any `json:"metadata,omitempty"`
	MinValue      int            `json:"minValue,omitempty"`
	MaxValue      int            `json:"maxValue,omitempty"`
	MinLength     int            `json:"minLength,omitempty"`
	MaxLength     int            `json:"maxLength,omitempty"`
}

TemplateParameter represents an ARM template parameter

Jump to

Keyboard shortcuts

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