bicep

package
v1.23.14 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version semver.Version = semver.MustParse("0.41.2")

Version is the minimum version of bicep that we require (and the one we fetch when we fetch bicep on behalf of a user).

Functions

This section is empty.

Types

type BuildResult

type BuildResult struct {
	// The compiled ARM template
	Compiled string

	// Lint error message, if any
	LintErr string
}

type Cli

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

Cli is a wrapper around the bicep CLI. The CLI automatically ensures bicep is installed before executing commands.

Concurrency notes: The sync.Mutex is per-instance, not global. In normal operation, the IoC container registers Cli as a singleton, so one shared instance is used. However, some code paths (e.g., service_target_containerapp.go) create new instances inline. If multiple instances race to install bicep concurrently, this is safe because downloadBicep uses atomic file operations (temp file + rename). The only downside is potentially redundant downloads, which is rare and harmless.

func NewCli

func NewCli(console input.Console, commandRunner exec.CommandRunner) *Cli

NewCli creates a new Bicep CLI wrapper. The CLI automatically ensures bicep is installed when Build or BuildBicepParam is called.

func (*Cli) Build

func (cli *Cli) Build(ctx context.Context, file string) (BuildResult, error)

func (*Cli) BuildBicepParam

func (cli *Cli) BuildBicepParam(ctx context.Context, file string, env []string) (BuildResult, error)

func (*Cli) Snapshot

func (cli *Cli) Snapshot(ctx context.Context, file string, opts SnapshotOptions) ([]byte, error)

Snapshot runs `bicep snapshot <file>` and reads the resulting snapshot file. The bicep CLI produces a `<basename>.snapshot.json` file next to the input .bicepparam file. This method reads the snapshot content into a byte slice and removes the generated file. If the snapshot file is not produced, it returns an error.

type SnapshotOptions

type SnapshotOptions struct {
	// Mode sets the snapshot mode: "overwrite" (generate new) or "validate" (compare against existing).
	Mode string
	// TenantID is the tenant ID to use for the deployment.
	TenantID string
	// SubscriptionID is the subscription ID to use for the deployment.
	SubscriptionID string
	// ResourceGroup is the resource group name to use for the deployment.
	ResourceGroup string
	// Location is the location to use for the deployment.
	Location string
	// DeploymentName is the deployment name to use.
	DeploymentName string
}

SnapshotOptions configures optional flags for the `bicep snapshot` command. Use the With* methods to set values using the builder pattern:

opts := NewSnapshotOptions().
    WithMode("validate").
    WithSubscriptionID("sub-123").
    WithLocation("eastus2")

func NewSnapshotOptions

func NewSnapshotOptions() SnapshotOptions

NewSnapshotOptions returns a zero-valued SnapshotOptions ready for building.

func (SnapshotOptions) WithDeploymentName

func (o SnapshotOptions) WithDeploymentName(deploymentName string) SnapshotOptions

WithDeploymentName sets the deployment name.

func (SnapshotOptions) WithLocation

func (o SnapshotOptions) WithLocation(location string) SnapshotOptions

WithLocation sets the location for the deployment.

func (SnapshotOptions) WithMode

func (o SnapshotOptions) WithMode(mode string) SnapshotOptions

WithMode sets the snapshot mode ("overwrite" or "validate").

func (SnapshotOptions) WithResourceGroup

func (o SnapshotOptions) WithResourceGroup(resourceGroup string) SnapshotOptions

WithResourceGroup sets the resource group name for the deployment.

func (SnapshotOptions) WithSubscriptionID

func (o SnapshotOptions) WithSubscriptionID(subscriptionID string) SnapshotOptions

WithSubscriptionID sets the subscription ID for the deployment.

func (SnapshotOptions) WithTenantID

func (o SnapshotOptions) WithTenantID(tenantID string) SnapshotOptions

WithTenantID sets the tenant ID for the deployment.

Jump to

Keyboard shortcuts

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