devcenter

package
v0.0.0-...-d611558 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Environment variable names
	DevCenterNameEnvName          = "AZURE_DEVCENTER_NAME"
	DevCenterCatalogEnvName       = "AZURE_DEVCENTER_CATALOG"
	DevCenterProjectEnvName       = "AZURE_DEVCENTER_PROJECT"
	DevCenterEnvTypeEnvName       = "AZURE_DEVCENTER_ENVIRONMENT_TYPE"
	DevCenterEnvDefinitionEnvName = "AZURE_DEVCENTER_ENVIRONMENT_DEFINITION"
	DevCenterEnvUser              = "AZURE_DEVCENTER_ENVIRONMENT_USER"

	// Environment configuration paths
	DevCenterNamePath          = ConfigPath + ".name"
	DevCenterCatalogPath       = ConfigPath + ".catalog"
	DevCenterProjectPath       = ConfigPath + ".project"
	DevCenterEnvTypePath       = ConfigPath + ".environmentType"
	DevCenterEnvDefinitionPath = ConfigPath + ".environmentDefinition"
	DevCenterUserPath          = ConfigPath + ".user"

	PlatformKindDevCenter platform.PlatformKind = "devcenter"
)
View Source
const (
	ConfigPath                                 = "platform.config"
	RemoteKindDevCenter environment.RemoteKind = "devcenter"
)
View Source
const (
	ProvisionParametersConfigPath string                    = "provision.parameters"
	ProvisionKindDevCenter        provisioning.ProviderKind = "devcenter"

	// ADE environment ARM deployment tags
	DeploymentTagDevCenterName    = "AdeDevCenterName"
	DeploymentTagDevCenterProject = "AdeProjectName"
	DeploymentTagEnvironmentType  = "AdeEnvironmentTypeName"
	DeploymentTagEnvironmentName  = "AdeEnvironmentName"
)
View Source
const (
	SourceKindDevCenter templates.SourceKind = "devcenter"
)

Variables

View Source
var SourceDevCenter = &templates.SourceConfig{
	Key:  "devcenter",
	Name: "Dev Center",
	Type: SourceKindDevCenter,
}

Functions

func NewEnvironmentStore

func NewEnvironmentStore(
	config *Config,
	devCenterClient devcentersdk.DevCenterClient,
	prompter *Prompter,
	manager Manager,
	local environment.LocalDataStore,
) environment.RemoteDataStore

NewEnvironmentStore creates a new devcenter environment store

func NewPlatform

func NewPlatform(config *platform.Config) platform.Provider

func NewProvisionProvider

func NewProvisionProvider(
	console input.Console,
	env *environment.Environment,
	envManager environment.Manager,
	config *Config,
	devCenterClient devcentersdk.DevCenterClient,
	resourceManager *infra.AzureResourceManager,
	manager Manager,
	prompter *Prompter,
) provisioning.Provider

NewProvisionProvider creates a new devcenter provider

func NewTemplateSource

func NewTemplateSource(config *Config, manager Manager, devCenterClient devcentersdk.DevCenterClient) templates.Source

Types

type Config

type Config struct {
	Name                  string `json:"name,omitempty"                  yaml:"name,omitempty"`
	Catalog               string `json:"catalog,omitempty"               yaml:"catalog,omitempty"`
	Project               string `json:"project,omitempty"               yaml:"project,omitempty"`
	EnvironmentType       string `json:"environmentType,omitempty"       yaml:"environmentType,omitempty"`
	EnvironmentDefinition string `json:"environmentDefinition,omitempty" yaml:"environmentDefinition,omitempty"`
	User                  string `json:"user,omitempty"                  yaml:"user,omitempty"`
}

Config provides the Azure DevCenter configuration used for devcenter enabled projects

func MergeConfigs

func MergeConfigs(configs ...*Config) *Config

Merges supplemental configuration into the base config only if the key/value doesn't already exist in the base config Example: If the base config is a fully configured object, then any supplemental configuration will be ignored

func ParseConfig

func ParseConfig(partialConfig any) (*Config, error)

ParseConfig attempts to parse a partial JSON configuration into a devcenter configuration

func (*Config) EnsureValid

func (c *Config) EnsureValid() error

EnsureValid ensures the devcenter configuration is valid to continue with provisioning

type DeploymentFilterPredicate

type DeploymentFilterPredicate func(d *armresources.DeploymentExtended) bool

DeploymentFilterPredicate is a predicate function for filtering deployments

type DevCenterFilterPredicate

type DevCenterFilterPredicate func(dc *devcentersdk.DevCenter) bool

DevCenterFilterPredicate is a predicate function for filtering dev centers

type EnvironmentDefinitionFilterPredicate

type EnvironmentDefinitionFilterPredicate func(ed *devcentersdk.EnvironmentDefinition) bool

EnvironmentDefinitionFilterPredicate is a predicate function for filtering environment definitions

type EnvironmentFilterPredicate

type EnvironmentFilterPredicate func(e *devcentersdk.Environment) bool

EnvironmentFilterPredicate is a predicate function for filtering environments

type EnvironmentStore

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

EnvironmentStore is a remote environment data store for devcenter environments

func (*EnvironmentStore) ConfigPath

func (s *EnvironmentStore) ConfigPath(env *environment.Environment) string

ConfigPath returns the path for the environment configuration

func (*EnvironmentStore) Delete

func (s *EnvironmentStore) Delete(ctx context.Context, name string) error

Delete implements environment.RemoteDataStore. Since the remote data store doesn't store environment configuration / metadata, we only delete the local storage.

func (*EnvironmentStore) EnvPath

EnvPath returns the path for the environment

func (*EnvironmentStore) Get

Get returns the environment for the given name

func (*EnvironmentStore) List

List returns a list of environments for the devcenter configuration

func (*EnvironmentStore) Reload

Reload reloads the environment from the remote data store

func (*EnvironmentStore) Save

Save saves the environment to the remote data store DevCenter doesn't implement any APIs for saving environment configuration / metadata outside of the environment definition itself or the ARM deployment outputs

type Manager

type Manager interface {
	// WritableProjects gets a list of ADE projects that a user has write permissions
	WritableProjects(ctx context.Context) ([]*devcentersdk.Project, error)
	// WritableProjectsWithFilter gets a list of ADE projects that a user has write permissions for deployment
	WritableProjectsWithFilter(
		ctx context.Context,
		devCenterFilter DevCenterFilterPredicate,
		projectFilter ProjectFilterPredicate,
	) ([]*devcentersdk.Project, error)
	// Deployment gets the Resource Group scoped deployment for the specified devcenter environment
	Deployment(
		ctx context.Context,
		config *Config,
		env *devcentersdk.Environment,
		filter DeploymentFilterPredicate,
	) (infra.Deployment, error)
	// LatestArmDeployment gets the latest ARM deployment for the specified devcenter environment
	LatestArmDeployment(
		ctx context.Context,
		config *Config,
		env *devcentersdk.Environment,
		filter DeploymentFilterPredicate,
	) (*armresources.DeploymentExtended, error)
	// Outputs gets the outputs for the specified devcenter environment
	Outputs(
		ctx context.Context,
		config *Config,
		env *devcentersdk.Environment,
	) (map[string]provisioning.OutputParameter, error)
}

func NewManager

func NewManager(
	client devcentersdk.DevCenterClient,
	deploymentsService azapi.Deployments,
	deploymentOperations azapi.DeploymentOperations,
	portalUrlBase string,
) Manager

NewManager creates a new devcenter manager

type Platform

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

Platform manages the Azd configuration of the devcenter platform

func (*Platform) ConfigureContainer

func (p *Platform) ConfigureContainer(container *ioc.NestedContainer) error

ConfigureContainer configures the IoC container for the devcenter platform components

func (*Platform) IsEnabled

func (p *Platform) IsEnabled() bool

IsEnabled returns true if the devcenter platform is enabled

func (*Platform) Name

func (p *Platform) Name() string

Name returns the name of the platform

type ProjectFilterPredicate

type ProjectFilterPredicate func(p *devcentersdk.Project) bool

ProjectFilterPredicate is a predicate function for filtering projects

type Prompter

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

Prompter provides a common set of methods for prompting the user for devcenter configuration values

func NewPrompter

func NewPrompter(
	console input.Console,
	manager Manager,
	devCenterClient devcentersdk.DevCenterClient,
) *Prompter

NewPrompter creates a new devcenter prompter

func (*Prompter) PromptEnvironmentDefinition

func (p *Prompter) PromptEnvironmentDefinition(
	ctx context.Context,
	devCenterName, projectName string,
) (*devcentersdk.EnvironmentDefinition, error)

PromptEnvironmentDefinition prompts the user to select an environment definition for the specified devcenter and project

func (*Prompter) PromptEnvironmentType

func (p *Prompter) PromptEnvironmentType(
	ctx context.Context,
	devCenterName string,
	projectName string,
) (*devcentersdk.EnvironmentType, error)

PromptEnvironmentType prompts the user to select an environment type for the specified devcenter and project If the user only has access to a single environment type, then that environment type will be returned

func (*Prompter) PromptForConfig

func (p *Prompter) PromptForConfig(ctx context.Context, config *Config) error

PromptForConfig prompts the user for devcenter configuration values that have not been previously set

func (*Prompter) PromptParameters

func (p *Prompter) PromptParameters(
	ctx context.Context,
	env *environment.Environment,
	envDef *devcentersdk.EnvironmentDefinition,
) (map[string]any, error)

Prompts the user for values defined within the environment definition parameters Responses for prompt are stored in azd environment configuration and used for future provisioning operations

func (*Prompter) PromptProject

func (p *Prompter) PromptProject(ctx context.Context, devCenterName string) (*devcentersdk.Project, error)

PromptProject prompts the user to select a project for the specified devcenter If the user only has access to a single project, then that project will be returned

type ProvisionProvider

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

ProvisionProvider is a devcenter provider for provisioning ADE environments

func (*ProvisionProvider) Deploy

Deploy deploys the environment from the configured environment definition

func (*ProvisionProvider) Destroy

Destroy destroys the environment by deleting the ADE environment

func (*ProvisionProvider) EnsureEnv

func (p *ProvisionProvider) EnsureEnv(ctx context.Context) error

EnsureEnv ensures that the environment is configured for the Dev Center provider. Require selection for devcenter, project, catalog, environment type, and environment definition

func (*ProvisionProvider) Initialize

func (p *ProvisionProvider) Initialize(ctx context.Context, projectPath string, options provisioning.Options) error

Initialize initializes the provider

func (*ProvisionProvider) Name

func (p *ProvisionProvider) Name() string

Name returns the name of the provider

func (*ProvisionProvider) Preview

Preview previews the deployment of the environment from the configured environment definition

func (*ProvisionProvider) State

State returns the state of the environment from the most recent ARM deployment

type TemplateSource

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

func (*TemplateSource) GetTemplate

func (s *TemplateSource) GetTemplate(ctx context.Context, path string) (*templates.Template, error)

func (*TemplateSource) ListTemplates

func (s *TemplateSource) ListTemplates(ctx context.Context) ([]*templates.Template, error)

func (*TemplateSource) Name

func (s *TemplateSource) Name() string

Jump to

Keyboard shortcuts

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