Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GeneratedFile ¶
type GeneratedFile struct {
Path string `yaml:"path"` // Relative path from project root
TemplatePath string `yaml:"template_path,omitempty"` // Path within template
Checksum string `yaml:"checksum"` // SHA256 of generated content
}
GeneratedFile tracks a single file that was generated.
type GenerationMetadata ¶
type GenerationMetadata struct {
Version int `yaml:"version"` // Metadata format version
Command string `yaml:"command"` // "atmos init" or "atmos scaffold generate"
Template TemplateInfo `yaml:"template"` // Which template was used
BaseRef string `yaml:"base_ref,omitempty"` // Git ref used as base (if git-based)
GeneratedAt time.Time `yaml:"generated_at"` // When generated
Variables map[string]string `yaml:"variables"` // Template variables used
Files []GeneratedFile `yaml:"files"` // Files that were generated
StorageType string `yaml:"storage_type"` // "git" or "file"
}
GenerationMetadata tracks what was generated from a template. This is stored in .atmos/init/metadata.yaml (for init) or .atmos/scaffold/metadata.yaml (for scaffold) to enable updates.
This is different from scaffold.yaml which defines the template itself. This metadata tracks what was actually generated from that template.
func NewInitMetadata ¶
func NewInitMetadata(templateName, templateVersion, templateSource, baseRef string, variables map[string]string) *GenerationMetadata
NewInitMetadata creates generation metadata for an init command.
func NewScaffoldMetadata ¶
func NewScaffoldMetadata(templateName, templateVersion, templateSource, baseRef string, variables map[string]string) *GenerationMetadata
NewScaffoldMetadata creates generation metadata for a scaffold command.
func (*GenerationMetadata) AddFile ¶
func (m *GenerationMetadata) AddFile(path, templatePath, checksum string)
AddFile adds a generated file to the metadata.
func (*GenerationMetadata) GetFile ¶
func (m *GenerationMetadata) GetFile(path string) (GeneratedFile, bool)
GetFile retrieves metadata for a specific file by path. Returns a copy of the GeneratedFile to avoid returning pointers into the Files slice that could become stale if the slice is later reallocated. Returns (file, true) if found, (zero-value, false) if not found.
func (*GenerationMetadata) IsFileGenerated ¶
func (m *GenerationMetadata) IsFileGenerated(path string) bool
IsFileGenerated checks if a file was generated from the template.
type GitBaseStorage ¶
type GitBaseStorage struct {
// contains filtered or unexported fields
}
GitBaseStorage provides git-based storage for retrieving base file versions. It uses git references (branches, tags, commits) to access historical file content without needing to store duplicate copies on disk.
func NewGitBaseStorage ¶
func NewGitBaseStorage(repo *git.Repository, baseRef string) *GitBaseStorage
NewGitBaseStorage creates a new git-based storage using the specified repository and base reference. The baseRef parameter can be:
- Branch name: "main", "develop"
- Tag: "v1.0.0"
- Commit hash: "abc123def..."
- Special ref: "HEAD"
func (*GitBaseStorage) GetBaseRef ¶
func (s *GitBaseStorage) GetBaseRef() string
GetBaseRef returns the current base reference.
func (*GitBaseStorage) GetMergeBase ¶
func (s *GitBaseStorage) GetMergeBase(ref1, ref2 string) (string, error)
GetMergeBase returns the merge-base (common ancestor) between two refs. This is useful for finding the original point where files were generated.
Example: GetMergeBase("HEAD", "main") finds the commit where the current branch diverged from main - the ideal base for 3-way merges.
func (*GitBaseStorage) LoadBase ¶
func (s *GitBaseStorage) LoadBase(filePath string) (string, bool, error)
LoadBase retrieves the content of a file at the base reference. The filePath should be relative to the repository root.
Returns:
- File content as string if the file exists at the base ref
- Empty string and nil error if the file doesn't exist at the base ref
- Error if the base ref is invalid or git operation fails
func (*GitBaseStorage) SetBaseRef ¶
func (s *GitBaseStorage) SetBaseRef(baseRef string)
SetBaseRef updates the base reference for this storage. Useful when you want to use a different ref without creating a new storage instance.
func (*GitBaseStorage) ValidateBaseRef ¶
func (s *GitBaseStorage) ValidateBaseRef() error
ValidateBaseRef checks if the base reference exists in the repository. Returns nil if the ref is valid, or an error with helpful guidance if invalid.
type MetadataStorage ¶
type MetadataStorage struct {
// contains filtered or unexported fields
}
MetadataStorage handles reading and writing generation metadata.
func NewMetadataStorage ¶
func NewMetadataStorage(metadataPath string) *MetadataStorage
NewMetadataStorage creates a new metadata storage for the given metadata file path. For init: .atmos/init/metadata.yaml For scaffold: .atmos/scaffold/metadata.yaml.
func (*MetadataStorage) Exists ¶
func (s *MetadataStorage) Exists() bool
Exists checks if the metadata file exists.
func (*MetadataStorage) GetMetadataPath ¶
func (s *MetadataStorage) GetMetadataPath() string
GetMetadataPath returns the path to the metadata file.
func (*MetadataStorage) Load ¶
func (s *MetadataStorage) Load() (*GenerationMetadata, error)
Load reads the generation metadata from disk. Returns nil if the file doesn't exist (first generation).
func (*MetadataStorage) Save ¶
func (s *MetadataStorage) Save(metadata *GenerationMetadata) error
Save writes the generation metadata to disk. Creates parent directories if they don't exist.
type TemplateInfo ¶
type TemplateInfo struct {
Name string `yaml:"name"` // Template name (e.g., "simple", "atmos")
Version string `yaml:"version,omitempty"` // Template version (from scaffold.yaml)
Source string `yaml:"source,omitempty"` // "embedded", "atmos.yaml", or git URL
}
TemplateInfo describes which template was used.