scaffold

package
v0.0.0-...-d10ad41 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 14 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 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 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 ExecInfraFs

func ExecInfraFs(
	t *template.Template,
	spec InfraSpec) (*memfs.FS, error)

ExecInfraFs scaffolds infrastructure files for the given spec, using the loaded templates in t. The resulting files are written to the in-memory filesystem.

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.

func RemoveDotAndDash

func RemoveDotAndDash(name string) string

Types

type AIModel

type AIModel struct {
	Name  string
	Model AIModelModel
}

AIModel represents a deployed, ready to use AI model.

type AIModelModel

type AIModelModel struct {
	// The name of the underlying model.
	Name string
	// The version of the underlying model.
	Version string
}

AIModelModel represents a model that backs the AIModel.

type AIModelReference

type AIModelReference struct {
	Name string
}

type Backend

type Backend struct {
	Frontends []ServiceReference
}

type DatabaseCosmosMongo

type DatabaseCosmosMongo struct {
	DatabaseName string
}

type DatabaseMysql

type DatabaseMysql struct {
	DatabaseName string
}

type DatabasePostgres

type DatabasePostgres struct {
	DatabaseName string
}

type DatabaseRedis

type DatabaseRedis struct {
}

type DatabaseReference

type DatabaseReference struct {
	DatabaseName string
}

type EventHubs

type EventHubs struct {
	Hubs []string
}

type Frontend

type Frontend struct {
	Backends []ServiceReference
}

type InfraSpec

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

	// Databases to create
	DbPostgres    *DatabasePostgres
	DbMySql       *DatabaseMysql
	DbCosmosMongo *DatabaseCosmosMongo
	DbRedis       *DatabaseRedis

	// Messaging services
	ServiceBus *ServiceBus
	EventHubs  *EventHubs

	// Storage account
	StorageAccount *StorageAccount

	// ai models
	AIModels []AIModel
}

type Parameter

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

type ServiceBus

type ServiceBus struct {
	Queues []string
	Topics []string
}

type ServiceReference

type ServiceReference struct {
	Name string
}

type ServiceSpec

type ServiceSpec struct {
	Name string
	Port int

	Env map[string]string

	// Front-end properties.
	Frontend *Frontend

	// Back-end properties
	Backend *Backend

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

	StorageAccount *StorageReference

	// AI model connections
	AIModels []AIModelReference

	// Messaging services
	ServiceBus *ServiceBus
	EventHubs  *EventHubs
}

type StorageAccount

type StorageAccount struct {
	Containers []string
}

type StorageReference

type StorageReference struct {
}

Jump to

Keyboard shortcuts

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