Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SourceDefault = &SourceConfig{ Key: "default", Name: "Default", Type: SourceKindResource, } SourceAwesomeAzd = &SourceConfig{ Key: "awesome-azd", Name: "Awesome AZD", Type: SourceKindAwesomeAzd, Location: "https://aka.ms/awesome-azd/templates.json", } WellKnownSources = map[string]*SourceConfig{ SourceDefault.Key: SourceDefault, SourceAwesomeAzd.Key: SourceAwesomeAzd, } ErrSourceNotFound = errors.New("template source not found") ErrSourceExists = errors.New("template source already exists") ErrSourceTypeInvalid = errors.New("invalid template source type") )
View Source
var (
ErrTemplateNotFound = fmt.Errorf("template not found")
)
Functions ¶
Types ¶
type ListOptions ¶
type Metadata ¶
type Metadata struct { Variables map[string]string `json:"variables,omitempty"` Config map[string]string `json:"config,omitempty"` Project map[string]string `json:"project,omitempty"` }
Metadata contains additional metadata about the template This metadata is used to modify azd project, environment config and environment variables during azd init commands.
type Source ¶
type Source interface { // Name returns the name of the source. Name() string // ListTemplates returns a list of AZD compatible templates. ListTemplates(ctx context.Context) ([]*Template, error) // GetTemplate returns a template by path. GetTemplate(ctx context.Context, path string) (*Template, error) }
Source is a source of AZD compatible templates.
type SourceConfig ¶
type SourceConfig struct { Key string `json:"key,omitempty"` Name string `json:"name,omitempty"` Type SourceKind `json:"type,omitempty"` Location string `json:"location,omitempty"` }
type SourceKind ¶
type SourceKind string
const ( SourceKindFile SourceKind = "file" SourceKindUrl SourceKind = "url" SourceKindGh SourceKind = "gh" SourceKindResource SourceKind = "default" SourceKindAwesomeAzd SourceKind = "awesome-azd" )
type SourceManager ¶
type SourceManager interface { // List returns a list of template sources. List(ctx context.Context) ([]*SourceConfig, error) // Get returns a template source by name. Get(ctx context.Context, name string) (*SourceConfig, error) // Add adds a new template source. Add(ctx context.Context, key string, source *SourceConfig) error // Remove removes a template source. Remove(ctx context.Context, name string) error // CreateSource creates a new template source from a source configuration CreateSource(ctx context.Context, source *SourceConfig) (Source, error) }
SourceManager manages template sources used in azd template list and azd init experiences.
func NewSourceManager ¶
func NewSourceManager( options *SourceOptions, serviceLocator ioc.ServiceLocator, configManager config.UserConfigManager, transport policy.Transporter, ) SourceManager
NewSourceManager creates a new SourceManager.
type SourceOptions ¶
type SourceOptions struct { // List of default template sources to use for listing templates DefaultSources []*SourceConfig // Whether to load template sources from azd configuration LoadConfiguredSources bool }
SourceOptions defines options for the SourceManager.
func NewSourceOptions ¶
func NewSourceOptions() *SourceOptions
NewSourceOptions creates a new SourceOptions with default values
type Template ¶
type Template struct { Id string `json:"id"` // Name is the friendly short name of the template. Name string `json:"name"` Title string `json:"title,omitempty"` // The source of the template Source string `json:"-"` RepoSource string `json:"source,omitempty"` // Description is a long description of the template. Description string `json:"description,omitempty"` // RepositoryPath is a fully qualified URI to a git repository, // "{owner}/{repo}" for GitHub repositories, // or "{repo}" for GitHub repositories under Azure-Samples (default organization). RepositoryPath string `json:"repositoryPath"` // A list of tags associated with the template Tags []string `json:"tags"` // Additional metadata about the template Metadata Metadata `json:"metadata,omitempty"` }
func PromptTemplate ¶
func PromptTemplate( ctx context.Context, message string, templateManager *TemplateManager, console input.Console, options *ListOptions, ) (Template, error)
PromptTemplate asks the user to select a template.
type TemplateManager ¶
type TemplateManager struct {
// contains filtered or unexported fields
}
func NewTemplateManager ¶
func NewTemplateManager(sourceManager SourceManager, console input.Console) (*TemplateManager, error)
func (*TemplateManager) GetTemplate ¶
func (*TemplateManager) ListTemplates ¶
func (tm *TemplateManager) ListTemplates(ctx context.Context, options *ListOptions) ([]*Template, error)
ListTemplates retrieves the list of templates in a deterministic order.
Click to show internal directories.
Click to hide internal directories.