bicep

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

bicep contains functionality for working with the Bicep compiler as well as ARM-JSON templates.

Package bicep is a generated GoMock package.

Index

Constants

View Source
const SemanticVersionRegex = `` /* 177-byte string literal not displayed */

Official regex for semver https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string

Variables

This section is empty.

Functions

func ConvertToMapStringInterface

func ConvertToMapStringInterface(in map[string]map[string]any) map[string]any

ConvertToMapStringInterface takes in a map of strings to maps of strings to any type and returns a map of strings to any type, with the values of the inner maps being the values of the returned map. No errors are returned.

func DefaultValue added in v0.33.0

func DefaultValue(parameter any) (any, bool)

DefaultValue returns the default value of a parameter and a boolean indicating if it was found.

func DeleteBicep

func DeleteBicep() error

DeleteBicep cleans our local copy of bicep

func DownloadBicep

func DownloadBicep() error

DownloadBicep() attempts to download a file from a given URI and save it to a local filepath, retrying up to 10 times if the download fails. If an error occurs, an error is returned.

func ExtractParameters added in v0.33.0

func ExtractParameters(template map[string]any) (map[string]any, error)

ExtractParameters extracts the parameters from the deployment template.

func GetBicepFilePath added in v0.43.0

func GetBicepFilePath() (string, error)

func InjectApplicationParam

func InjectApplicationParam(deploymentTemplate map[string]any, parameters map[string]map[string]any, applicationId string) error

InjectApplicationParam injects an argument for application into the parameters if required.

- parameters.application exists && param not passed in -> inject environmentId - parameters.application does not exist -> noop - input parameters already include application -> noop.

func InjectEnvironmentParam

func InjectEnvironmentParam(deploymentTemplate map[string]any, parameters map[string]map[string]any, environmentId string) error

InjectEnvironmentParam injects an argument for environment into the parameters if required.

- parameters.environment exists && param not passed in -> inject environmentId - parameters.environment does not exist -> noop - input parameters already include environment -> noop.

func IsBicepInstalled

func IsBicepInstalled() (bool, error)

IsBicepInstalled checks if the Bicep binary is installed on the local machine and returns a boolean and an error if one occurs.

func NewParameter

func NewParameter(value any) map[string]any

NewParameter creates a map containing a single key-value pair, where the key is "value" and the value is the parameter passed to the function. If the parameter is invalid, an empty map is returned.

func ReadARMJSON

func ReadARMJSON(filePath string) (map[string]any, error)

ReadARMJSON reads a JSON file from the given file path and returns a map of strings to any type, or an error if the file could not be read or unmarshalled.

func Version

func Version() string

Version() attempts to retrieve the version of Bicep by running the command "--version" and returns the version as a string, or an error message if an error occurs.

Types

type Impl

type Impl struct {
	FileSystem filesystem.FileSystem
	Output     output.Interface
}

Impl is the implementation of Interface.

func (*Impl) Call added in v0.45.0

func (i *Impl) Call(args ...string) ([]byte, error)

Call runs `rad-bicep` with the given arguments.

func (*Impl) PrepareTemplate

func (i *Impl) PrepareTemplate(filePath string) (map[string]any, error)

PrepareTemplate checks if the file is a .json or .bicep file, downloads Bicep if it is not installed, checks if the file exists, and builds the template if it does. It returns a map of strings to any and an error if one occurs.

type Interface

type Interface interface {
	PrepareTemplate(filePath string) (map[string]any, error)
	Call(args ...string) ([]byte, error)
}

Interface is the interface for interacting with Bicep.

type MockInterface

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

MockInterface is a mock of Interface interface.

func NewMockInterface

func NewMockInterface(ctrl *gomock.Controller) *MockInterface

NewMockInterface creates a new mock instance.

func (*MockInterface) Call added in v0.45.0

func (m *MockInterface) Call(arg0 ...string) ([]byte, error)

Call mocks base method.

func (*MockInterface) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockInterface) PrepareTemplate

func (m *MockInterface) PrepareTemplate(arg0 string) (map[string]any, error)

PrepareTemplate mocks base method.

type MockInterfaceCallCall added in v0.45.0

type MockInterfaceCallCall struct {
	*gomock.Call
}

MockInterfaceCallCall wrap *gomock.Call

func (*MockInterfaceCallCall) Do added in v0.45.0

Do rewrite *gomock.Call.Do

func (*MockInterfaceCallCall) DoAndReturn added in v0.45.0

func (c *MockInterfaceCallCall) DoAndReturn(f func(...string) ([]byte, error)) *MockInterfaceCallCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockInterfaceCallCall) Return added in v0.45.0

func (c *MockInterfaceCallCall) Return(arg0 []byte, arg1 error) *MockInterfaceCallCall

Return rewrite *gomock.Call.Return

type MockInterfaceMockRecorder

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

MockInterfaceMockRecorder is the mock recorder for MockInterface.

func (*MockInterfaceMockRecorder) Call added in v0.45.0

Call indicates an expected call of Call.

func (*MockInterfaceMockRecorder) PrepareTemplate

PrepareTemplate indicates an expected call of PrepareTemplate.

type MockInterfacePrepareTemplateCall added in v0.35.0

type MockInterfacePrepareTemplateCall struct {
	*gomock.Call
}

MockInterfacePrepareTemplateCall wrap *gomock.Call

func (*MockInterfacePrepareTemplateCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockInterfacePrepareTemplateCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockInterfacePrepareTemplateCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type ParameterFile

type ParameterFile struct {
	Parameters clients.DeploymentParameters `json:"parameters"`
}

type ParameterParser

type ParameterParser struct {
	FileSystem filesystem.FileSystem
}

ParameterParser is used to parse the parameters as part of the `rad deploy` command. See the docs for `rad deploy` for examples of what we need to support here.

func (ParameterParser) Parse

func (pp ParameterParser) Parse(inputs ...string) (clients.DeploymentParameters, error)

Parse takes in a variable number of strings and returns a DeploymentParameters object and an error, if any. It processes each string input and merges the parameters with the later ones taking precedence, and returns an error if any of the strings fail to be processed.

func (ParameterParser) ParseFileContents

func (pp ParameterParser) ParseFileContents(input map[string]any) (clients.DeploymentParameters, error)

ParseFileContents takes in a map of strings and any type and returns a DeploymentParameters object and an error if one occurs during the process.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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