apphost

package
v0.0.0-...-6cd82ae Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const DaprPubSubComponentType = "pubsub"
View Source
const DaprStateStoreComponentType = "state"
View Source
const RedisContainerAppService = "redis"

Variables

This section is empty.

Functions

func BicepTemplate

func BicepTemplate(name string, manifest *Manifest, options AppHostOptions) (*memfs.FS, error)

BicepTemplate returns a filesystem containing the generated bicep files for the given manifest. These files represent the shared infrastructure that would normally be under the `infra/` folder for the given manifest.

func BuildContainers

func BuildContainers(manifest *Manifest) (map[string]genBuildContainer, error)

BuildContainers returns information about all container.v1 resources from a manifest.

func ContainerSourceBicepContent

func ContainerSourceBicepContent(
	manifest *Manifest, projectName string, options AppHostOptions) (string, error)

func Containers

func Containers(manifest *Manifest) map[string]genContainer

Containers returns information about all container.v0 resources from a manifest.

func Dockerfiles

func Dockerfiles(manifest *Manifest) map[string]genDockerfile

Dockerfiles returns information about all dockerfile.v0 resources from a manifest.

func EvalString

func EvalString(src string, evalExpr func(string) (string, error)) (string, error)

evalString evaluates a given string expression, using the provided evalExpr function to produce values for expressions in the string. It supports strings that contain expressions of the form "{expression}" where "expression" is any string that does not contain a '}' character. The evalExpr function is called with the expression (without the enclosing '{' and '}' characters) and should return the value to be substituted into the string. If the evalExpr function returns an error, evalString will return that error. The '{' and '}' characters can be escaped by doubling them, e.g. "{{" and "}}". If a string is malformed (e.g. an unmatched '{' or '}' character), evalString will return an error.

func GenerateProjectArtifacts

func GenerateProjectArtifacts(
	ctx context.Context,
	projectDir string,
	projectName string,
	manifest *Manifest,
	appHostProject string,
) (map[string]ContentsAndMode, error)

GenerateProjectArtifacts generates all the artifacts to manage a project with `azd`. The azure.yaml file as well as a helpful next-steps.md file.

func ProjectPaths

func ProjectPaths(manifest *Manifest) map[string]string

ProjectPaths returns a map of project names to their paths.

Types

type AppHostOptions

type AppHostOptions struct {
	AzdOperations bool
}

type AspireDashboard

type AspireDashboard struct {
	Link string
}

func AspireDashboardUrl

func AspireDashboardUrl(
	ctx context.Context,
	env *environment.Environment,
	alphaFeatureManager *alpha.FeatureManager) *AspireDashboard

func (*AspireDashboard) MarshalJSON

func (aspireD *AspireDashboard) MarshalJSON() ([]byte, error)

func (*AspireDashboard) ToString

func (aspireD *AspireDashboard) ToString(currentIndentation string) string

type BindMount

type BindMount struct {
	Name     string `json:"-"`
	Source   string `json:"source,omitempty"`
	Target   string `json:"target"`
	ReadOnly bool   `json:"readOnly"`
}

type Binding

type Binding struct {
	TargetPort *int   `json:"targetPort,omitempty"`
	Port       *int   `json:"port,omitempty"`
	Scheme     string `json:"scheme"`
	Protocol   string `json:"protocol"`
	Transport  string `json:"transport"`
	External   bool   `json:"external"`
}

type ContainerAppManifestType

type ContainerAppManifestType string
const (
	ContainerAppManifestTypeYAML  ContainerAppManifestType = "yaml"
	ContainerAppManifestTypeBicep ContainerAppManifestType = "bicep"
)

func ContainerAppManifestTemplateForProject

func ContainerAppManifestTemplateForProject(
	manifest *Manifest, projectName string, options AppHostOptions) (string, ContainerAppManifestType, error)

ContainerAppManifestTemplateForProject returns the container app manifest template for a given project. It can be used (after evaluation) to deploy the service to a container app environment. When the projectName contains `Deployment` it will generate a bicepparam template instead of the yaml template.

type ContainerV1Build

type ContainerV1Build struct {
	// The path to the context directory for the container build.
	// Can be relative of absolute. If relative it is relative to the location of the manifest file.
	Context string `json:"context"`

	// The path to the Dockerfile. Can be relative or absolute. If relative it is relative to the manifest file.
	Dockerfile string `json:"dockerfile"`

	// Args is optionally present on project.v0 and dockerfile.v0 resources and are the arguments to pass to the container.
	Args map[string]string `json:"args,omitempty"`

	// A list of build arguments which are used during container build."
	Secrets map[string]ContainerV1BuildSecrets `json:"secrets,omitempty"`
}

type ContainerV1BuildSecrets

type ContainerV1BuildSecrets struct {
	// "env" (will come with value) or "file" (will come with source).
	Type string `json:"type"`
	// If provided use as the value for the environment variable when docker build is run.
	Value *string `json:"value,omitempty"`
	// Path to secret file. If relative, the path is relative to the manifest file.
	Source *string `json:"source,omitempty"`
}

type ContentsAndMode

type ContentsAndMode struct {
	Contents string
	Mode     fs.FileMode
}

type DaprComponentResourceMetadata

type DaprComponentResourceMetadata struct {
	Type *string `json:"type"`
}

type DaprResourceMetadata

type DaprResourceMetadata struct {
	AppId                  *string `json:"appId,omitempty"`
	Application            *string `json:"application,omitempty"`
	AppPort                *int    `json:"appPort,omitempty"`
	AppProtocol            *string `json:"appProtocol,omitempty"`
	DaprHttpMaxRequestSize *int    `json:"daprHttpMaxRequestSize,omitempty"`
	DaprHttpReadBufferSize *int    `json:"daprHttpReadBufferSize,omitempty"`
	EnableApiLogging       *bool   `json:"enableApiLogging,omitempty"`
	LogLevel               *string `json:"logLevel,omitempty"`
}

type DeploymentMetadata

type DeploymentMetadata struct {
	// Type is the type of deployment. For now, only bicep.v0 is supported.
	Type string `json:"type"`

	// Path is present for a bicep.v0 deployment type, and the path to the bicep file.
	Path *string `json:"path,omitempty"`

	// For a bicep.v0 deployment type, defines the input parameters for the bicep file.
	Params map[string]any `json:"params,omitempty"`
}

type Input

type Input struct {
	Type    string        `json:"type"`
	Secret  bool          `json:"secret"`
	Default *InputDefault `json:"default,omitempty"`
}

func InputParameter

func InputParameter(name string, comp *Resource) (*Input, error)

InputParameter gets the Input from a parameter. If the parameter does not have an input, it returns nil.

type InputDefault

type InputDefault struct {
	Generate *InputDefaultGenerate `json:"generate,omitempty"`
	Value    *string               `json:"value,omitempty"`
}

type InputDefaultGenerate

type InputDefaultGenerate struct {
	MinLength  *uint `json:"minLength,omitempty"`
	Lower      *bool `json:"lower,omitempty"`
	Upper      *bool `json:"upper,omitempty"`
	Numeric    *bool `json:"numeric,omitempty"`
	Special    *bool `json:"special,omitempty"`
	MinLower   *uint `json:"minLower,omitempty"`
	MinUpper   *uint `json:"minUpper,omitempty"`
	MinNumeric *uint `json:"minNumeric,omitempty"`
	MinSpecial *uint `json:"minSpecial,omitempty"`
}

type Manifest

type Manifest struct {
	Schema    string               `json:"$schema"`
	Resources map[string]*Resource `json:"resources"`
	// BicepFiles holds any bicep files generated by Aspire next to the manifest file.
	BicepFiles *memfs.FS `json:"-"`
}

func ManifestFromAppHost

func ManifestFromAppHost(
	ctx context.Context, appHostProject string, dotnetCli *dotnet.Cli, dotnetEnv string,
) (*Manifest, error)

ManifestFromAppHost returns the Manifest from the given app host.

type Reference

type Reference struct {
	Bindings []string `json:"bindings,omitempty"`
}

type Resource

type Resource struct {
	// Type is present on all resource types
	Type string `json:"type"`

	// Path is present on a project.v0 resource and is the path to the project file, and on a dockerfile.v0
	// resource and is the path to the Dockerfile (including the "Dockerfile" filename).
	// For a bicep.v0 resource, it is the path to the bicep file.
	Path *string `json:"path,omitempty"`

	// Context is present on a dockerfile.v0 resource and is the path to the context directory.
	Context *string `json:"context,omitempty"`

	// BuildArgs is present on a dockerfile.v0 resource and is the --build-arg for building the docker image.
	BuildArgs map[string]string `json:"buildArgs,omitempty"`

	// Args is optionally present on project.v0 and dockerfile.v0 resources and are the arguments to pass to the container.
	Args []string `json:"args,omitempty"`

	// Parent is present on a resource which is a child of another. It is the name of the parent resource. For example, a
	// postgres.database.v0 is a child of a postgres.server.v0, and so it would have a parent of which is the name of
	// the server resource.
	Parent *string `json:"parent,omitempty"`

	// Image is present on a container.v0 resource and is the image to use for the container.
	Image *string `json:"image,omitempty"`

	// Bindings is present on container.v0, project.v0 and dockerfile.v0 resources, and is a map of binding names to
	// binding details.
	Bindings custommaps.WithOrder[Binding] `json:"bindings,omitempty"`

	// Env is present on project.v0, container.v0 and dockerfile.v0 resources, and is a map of environment variable
	// names to value  expressions. The value expressions are simple expressions like "{redis.connectionString}" or
	// "{postgres.port}" to allow referencing properties of other resources. The set of properties supported in these
	// expressions depends on the type of resource you are referencing.
	Env map[string]string `json:"env,omitempty"`

	// Queues is optionally present on a azure.servicebus.v0 resource, and is a list of queue names to create.
	Queues *[]string `json:"queues,omitempty"`

	// Topics is optionally present on a azure.servicebus.v0 resource, and is a list of topic names to create.
	Topics *[]string `json:"topics,omitempty"`

	// Some resources just represent connections to existing resources that need not be provisioned.  These resources have
	// a "connectionString" property which is the connection string that should be used during binding.
	ConnectionString *string `json:"connectionString,omitempty"`

	// Dapr is present on dapr.v0 resources.
	Dapr *DaprResourceMetadata `json:"dapr,omitempty"`

	// DaprComponent is present on dapr.component.v0 resources.
	DaprComponent *DaprComponentResourceMetadata `json:"daprComponent,omitempty"`

	// Inputs is present on resources that need inputs from during the provisioning process (e.g asking for an API key, or
	// a password for a database).
	Inputs map[string]Input `json:"inputs,omitempty"`

	// For a bicep.v0 resource, defines the input parameters for the bicep file.
	Params map[string]any `json:"params,omitempty"`

	// parameter.v0 uses value field to define the value of the parameter.
	Value string

	// container.v0 uses volumes field to define the volumes of the container.
	Volumes []*Volume `json:"volumes,omitempty"`

	// The entrypoint to use for the container image when executed.
	Entrypoint string `json:"entrypoint,omitempty"`

	// An object that captures properties that control the building of a container image.
	Build *ContainerV1Build `json:"build,omitempty"`

	// container.v0 uses bind mounts field to define the volumes with initial data of the container.
	BindMounts []*BindMount `json:"bindMounts,omitempty"`

	// project.v1 and container.v1 uses deployment when the AppHost owns the ACA bicep definitions.
	Deployment *DeploymentMetadata `json:"deployment,omitempty"`
}

type Volume

type Volume struct {
	Name     string `json:"name,omitempty"`
	Target   string `json:"target"`
	ReadOnly bool   `json:"readOnly"`
}

Jump to

Keyboard shortcuts

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