Documentation ¶
Index ¶
- Variables
- func Absolute(path string) (string, error)
- func Hyperlink(path string) string
- type ListOptions
- type Metadata
- type Source
- func NewAwesomeAzdTemplateSource(ctx context.Context, name string, url string, httpClient httputil.HttpClient) (Source, error)
- func NewFileTemplateSource(name string, path string) (Source, error)
- func NewJsonTemplateSource(name string, jsonTemplates string) (Source, error)
- func NewTemplateSource(name string, templates []*Template) (Source, error)
- func NewUrlTemplateSource(ctx context.Context, name string, url string, httpClient httputil.HttpClient) (Source, error)
- type SourceConfig
- type SourceKind
- type SourceManager
- type SourceOptions
- type Template
- type TemplateManager
Constants ¶
This section is empty.
Variables ¶
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") )
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.
func NewAwesomeAzdTemplateSource ¶
func NewAwesomeAzdTemplateSource( ctx context.Context, name string, url string, httpClient httputil.HttpClient, ) (Source, error)
NewAwesomeAzdTemplateSource creates a new template source from the awesome-azd templates json file.
func NewFileTemplateSource ¶
NewFileTemplateSource creates a new template source from a file.
func NewJsonTemplateSource ¶
NewJsonTemplateSource creates a new template source from a JSON string.
func NewTemplateSource ¶
NewJsonTemplateSource creates a new template source from a JSON string.
func NewUrlTemplateSource ¶
func NewUrlTemplateSource(ctx context.Context, name string, url string, httpClient httputil.HttpClient) (Source, error)
NewUrlTemplateSource creates a new template source from a URL.
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" SourceKindResource SourceKind = "resource" 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, httpClient httputil.HttpClient, ) 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"` // The source of the template Source 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. An empty Template can be returned if the user selects the minimal template. This corresponds to the minimal azd template. See
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.