bicep

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 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 Build

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

Build() reads a Bicep file at the given file path and returns a map of the compiled output and an error if the compilation fails.

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 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 {
}

Impl is the implementation of Interface.

func (*Impl) PrepareTemplate

func (*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)
}

Interface is the interface for preparing Bicep or ARM-JSON templates for deployment. This interface is designed to be called from the CLI and will print output to the console.

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) 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 MockInterfaceMockRecorder

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

MockInterfaceMockRecorder is the mock recorder for MockInterface.

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 OSFileSystem

type OSFileSystem struct {
}

func (OSFileSystem) Open

func (OSFileSystem) Open(name string) (fs.File, error)

The Open function opens the file specified by the name parameter and returns a file object and an error if the file cannot be opened.

type ParameterFile

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

type ParameterParser

type ParameterParser struct {
	FileSystem fs.FS
}

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