scaffold

package
v0.0.0-...-df0e9fc Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlphaSnakeUpper

func AlphaSnakeUpper(name string) string

UpperSnakeAlpha returns a name in upper-snake case alphanumeric name separated only by underscores.

Non-alphanumeric characters are discarded, while consecutive separators ('-', '_', and '.') are treated as a single underscore separator.

func BicepName

func BicepName(name string) string

BicepName returns a name suitable for use as a bicep variable name.

The name is converted to camel case, with treatment for underscore or dash separators, and all non-alphanumeric characters are removed.

func ContainerAppInfix

func ContainerAppInfix(name string) string

ContainerAppInfix returns a suitable infix for a container app resource.

The name is treated to only contain alphanumeric and dash characters, with no repeated dashes, and no dashes as the first or last character.

func ContainerAppName

func ContainerAppName(name string) string

ContainerAppName returns a suitable name a container app resource.

The name is treated to only contain alphanumeric and dash characters, with no repeated dashes, and no dashes as the first or last character.

func ContainerAppSecretName

func ContainerAppSecretName(name string) string

ContainerAppSecretName returns a suitable name a container app secret name.

The name is treated to only contain lowercase alphanumeric and dash characters, and must start and end with an alphanumeric character

func CopyBase

func CopyBase(targetDir string) error

Copy base assets to the target directory.

func EnvFormat

func EnvFormat(src string) string

EnvFormat takes an input parameter like `fooParam` which is expected to be in camel case and returns it in upper snake case with env var template, like `${AZURE_FOO_PARAM}`.

func ExecInfra

func ExecInfra(
	t *template.Template,
	spec InfraSpec,
	target string) error

ExecInfra scaffolds infrastructure files for the given spec, using the loaded templates in t. The resulting files are written to the target directory.

func Execute

func Execute(
	t *template.Template,
	name string,
	data any,
	dest string) error

Execute applies the template associated with t that has the given name to the specified data object and writes the output to the dest path on the filesystem.

func FormatParameter

func FormatParameter(prefix string, indent string, value any) (string, error)

Formats a parameter value for use in a bicep file. If the value is a string, it is quoted inline with no indentation. Otherwise, the value is marshaled with indentation specified by prefix and indent.

func Load

func Load() (*template.Template, error)

Load loads all templates as a template.Template.

To execute a named template, call Execute with the defined name.

Types

type Backend

type Backend struct {
	Frontends []ServiceReference
}

type DatabaseCosmosMongo

type DatabaseCosmosMongo struct {
	DatabaseName string
}

type DatabasePostgres

type DatabasePostgres struct {
	DatabaseUser string
	DatabaseName string
}

type DatabaseReference

type DatabaseReference struct {
	DatabaseName string
}

type Frontend

type Frontend struct {
	Backends []ServiceReference
}

type InfraSpec

type InfraSpec struct {
	Parameters []Parameter
	Services   []ServiceSpec

	// Databases to create
	DbPostgres    *DatabasePostgres
	DbCosmosMongo *DatabaseCosmosMongo
}

type Parameter

type Parameter struct {
	Name   string
	Value  any
	Type   string
	Secret bool
}

type ServiceReference

type ServiceReference struct {
	Name string
}

type ServiceSpec

type ServiceSpec struct {
	Name string
	Port int

	// Front-end properties.
	Frontend *Frontend

	// Back-end properties
	Backend *Backend

	// Connection to a database
	DbPostgres    *DatabaseReference
	DbCosmosMongo *DatabaseReference
	DbRedis       *DatabaseReference
}

Jump to

Keyboard shortcuts

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