templates

package
v1.224.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatalogStubs

func CatalogStubs(override string) (map[string]Configuration, error)

CatalogStubs returns lightweight Configuration entries (without Files) for the catalog, keyed by template name. They are display/selection placeholders; the caller hydrates the chosen template from its Source before generation.

func GetAvailableConfigurations

func GetAvailableConfigurations() (map[string]Configuration, error)

GetAvailableConfigurations loads available template configurations from the embedded templates filesystem. It scans the templates directory, loads each template configuration, and returns a map of template name to Configuration.

Returns:

  • map[string]Configuration: Map of template names to their configurations
  • error: Non-nil if reading the templates directory fails

The function returns an error only when the templates directory itself cannot be read. Individual template loading errors are silently skipped to allow partial success.

func HasScaffoldConfig

func HasScaffoldConfig(files []File) bool

HasScaffoldConfig checks if the configuration has a scaffold.yaml file.

Types

type CatalogEntry

type CatalogEntry struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Cloud       string `yaml:"cloud"`
	Tier        string `yaml:"tier"`
	Source      string `yaml:"source"`
	Version     string `yaml:"version"`
}

CatalogEntry describes a distributable scaffold template advertised by Atmos. Entries are resolved on demand: the list/select flows display them cheaply (no download) and only the selected template is fetched from its Source.

func LoadCatalog

func LoadCatalog() ([]CatalogEntry, error)

LoadCatalog parses the embedded scaffold catalog.

func (*CatalogEntry) ResolvedSource

func (e *CatalogEntry) ResolvedSource(override string) string

ResolvedSource returns the source to fetch this template from. When override is non-empty it points at a local base directory (override/<cloud>/<tier>) instead of the remote Source — used by CI to resolve templates from the working tree rather than the network. Otherwise the remote Source is pinned to defaultCatalogRef(). A full-commit-SHA ref fetches shallowly just like a branch ref would (see pkg/downloader's CustomGitGetter.cloneShallowCommit); no special-casing is needed here.

type Configuration

type Configuration struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	TemplateID  string `yaml:"template_id"`
	Version     string `yaml:"version"`
	Source      string `yaml:"source"`
	TargetDir   string `yaml:"target_dir"`
	Files       []File `yaml:"files"`
	README      string `yaml:"readme"`
}

Configuration represents a template configuration loaded from the embedded filesystem. It contains metadata about a scaffold template including its name, description, and the collection of files to be generated. Key fields:

  • Name: Human-readable template name
  • Description: Brief description of the template's purpose
  • TemplateID: Unique identifier for the template
  • Version: Template version from scaffold.yaml metadata
  • Source: Where the template came from ("embedded", a local path, ...)
  • TargetDir: Default target directory for template output
  • Files: Collection of files/directories in this template
  • README: Optional README content for the template

func LoadConfigurationFromDir

func LoadConfigurationFromDir(name, dir string) (*Configuration, error)

LoadConfigurationFromDir loads a template configuration from a local directory on disk (e.g. a template referenced by `source:` in the `scaffold.templates` section of atmos.yaml). The directory is read with the same rules as embedded templates: scaffold.yaml provides metadata and the questionnaire, .tmpl files and atmos:template magic comments mark templates.

type File

type File struct {
	Path        string      `yaml:"path"`
	Content     string      `yaml:"content"`
	IsDirectory bool        `yaml:"is_directory"`
	IsTemplate  bool        `yaml:"is_template"`
	Permissions os.FileMode `yaml:"permissions"`
}

File represents an embedded template file used by the generator. This struct is specifically for files loaded from the embedded filesystem (embed.FS) and differs from other File types in the codebase:

  • engine.File: Used for runtime template processing and file generation
  • types.File: Used for API/DTO models and general file representations

Use this File type when:

  • Working with generator templates loaded from embedded assets
  • Loading template configurations from the embedded filesystem
  • Representing files before they are processed by the templating engine

Key fields:

  • Path: Relative path within the template
  • Content: Raw file content (may contain template syntax if IsTemplate is true)
  • IsDirectory: Whether this represents a directory structure
  • IsTemplate: Whether content should be processed as a Go template
  • Permissions: Unix file permissions to apply when creating files

Jump to

Keyboard shortcuts

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