Help us shape the future of Go! Take the 2026 Go Developer Survey

repository

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package repository provides multi-repository support for Prism templates.

This package implements the core functionality for managing multiple template repositories with priority-based override capabilities. It handles repository configuration, caching, and template resolution across repositories.

Index

Constants

View Source
const (
	// DefaultRepositoryURL is the URL of the default Prism repository.
	DefaultRepositoryURL = "github.com/scttfrdmn/prism-repository"

	// DefaultRepositoryBranch is the branch to use for the default repository.
	DefaultRepositoryBranch = "main"

	// CacheTTL is the time-to-live for the repository cache in hours.
	CacheTTL = 24

	// ConfigDirName is the name of the Prism configuration directory.
	ConfigDirName = ".prism"

	// ConfigFileName is the name of the configuration file.
	ConfigFileName = "config.json"

	// CacheDirName is the name of the cache directory.
	CacheDirName = "repositories"

	// CacheFileName is the name of the cache metadata file.
	CacheFileName = "cache.json"

	// RepositoryFileName is the name of the repository metadata file.
	RepositoryFileName = "repository.yaml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Repositories is a list of configured repositories
	Repositories []Repository `json:"repositories"`
}

Config represents the repository configuration stored in config.json.

type DependencyGraph

type DependencyGraph struct {
	// Nodes maps template references to dependency nodes
	Nodes map[string]*DependencyNode

	// Resolved is the list of resolved templates in correct order
	Resolved []*DependencyNode
}

DependencyGraph represents a dependency graph for template resolution.

type DependencyNode

type DependencyNode struct {
	// Reference is the template reference
	Reference TemplateReference

	// Dependencies are the template's dependencies
	Dependencies []TemplateReference

	// Visited tracks graph traversal for cycle detection
	Visited bool

	// Resolved indicates the node has been resolved
	Resolved bool
}

DependencyNode represents a node in the dependency graph.

type Manager

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

Manager handles repository operations.

func NewManager

func NewManager() (*Manager, error)

NewManager creates a new repository manager.

func (*Manager) AddRepository

func (m *Manager) AddRepository(repo Repository) error

AddRepository adds a new repository to the configuration.

func (*Manager) DownloadTemplate

func (m *Manager) DownloadTemplate(ref TemplateReference, destDir string) (string, error)

DownloadTemplate downloads a template from a repository to the local templates directory

func (*Manager) FindTemplate

func (m *Manager) FindTemplate(ref TemplateReference) (*TemplateMetadata, *Repository, error)

FindTemplate locates a template across repositories.

func (*Manager) GetRepositories

func (m *Manager) GetRepositories() []Repository

GetRepositories returns the list of configured repositories sorted by priority.

func (*Manager) GetRepository

func (m *Manager) GetRepository(name string) (*Repository, error)

GetRepository returns the repository with the given name.

func (*Manager) GetRepositoryMetadata

func (m *Manager) GetRepositoryMetadata(name string) (*RepositoryMetadata, error)

getRepositoryMetadata retrieves the metadata for a repository from cache.

func (*Manager) ParseTemplateReference

func (m *Manager) ParseTemplateReference(ref string) (TemplateReference, error)

ParseTemplateReference parses a template reference string into a TemplateReference. Format: [repo:]template[@version]

func (*Manager) RemoveRepository

func (m *Manager) RemoveRepository(name string) error

RemoveRepository removes a repository from the configuration.

func (*Manager) ResolveDependencies

func (m *Manager) ResolveDependencies(ref TemplateReference) ([]*DependencyNode, error)

ResolveDependencies builds a dependency graph and resolves dependencies.

func (*Manager) UpdateRepository

func (m *Manager) UpdateRepository(repo Repository) error

UpdateRepository updates an existing repository in the configuration.

func (*Manager) UpdateRepositoryCache

func (m *Manager) UpdateRepositoryCache(repo *Repository) error

updateRepositoryCache ensures a repository is cached and up-to-date.

func (*Manager) UploadTemplate

func (m *Manager) UploadTemplate(templatePath string, ref TemplateReference) error

UploadTemplate uploads a template to a repository

type Repository

type Repository struct {
	// Name is the unique identifier for the repository
	Name string `json:"name"`

	// Type is the repository type (github, local, s3)
	Type string `json:"type"`

	// URL is the repository URL for github repositories
	URL string `json:"url,omitempty"`

	// Branch is the git branch to use for github repositories
	Branch string `json:"branch,omitempty"`

	// Path is the local filesystem path for local repositories
	Path string `json:"path,omitempty"`

	// Bucket is the S3 bucket name for s3 repositories
	Bucket string `json:"bucket,omitempty"`

	// Prefix is the S3 object prefix for s3 repositories
	Prefix string `json:"prefix,omitempty"`

	// Region is the AWS region for s3 repositories
	Region string `json:"region,omitempty"`

	// Priority determines the repository precedence (higher number = higher priority)
	Priority int `json:"priority"`

	// LastUpdated is the timestamp of the last repository update
	LastUpdated time.Time `json:"last_updated,omitempty"`

	// Metadata contains the parsed repository metadata
	Metadata *RepositoryMetadata `json:"-"`
}

Repository represents a template repository configuration.

type RepositoryCache

type RepositoryCache struct {
	// LastUpdated is the timestamp of the last cache update
	LastUpdated time.Time `json:"last_updated"`

	// Repositories maps repository names to cache entries
	Repositories map[string]RepositoryCacheEntry `json:"repositories"`
}

RepositoryCache represents the local cache of repositories.

type RepositoryCacheEntry

type RepositoryCacheEntry struct {
	// LastUpdated is the timestamp of the last repository update
	LastUpdated time.Time `json:"last_updated"`

	// Path is the local cache path
	Path string `json:"path"`

	// Metadata contains the parsed repository metadata
	Metadata *RepositoryMetadata `json:"metadata"`
}

RepositoryCacheEntry represents a cached repository.

type RepositoryMetadata

type RepositoryMetadata struct {
	// Name is the human-readable name of the repository
	Name string `yaml:"name" json:"name"`

	// Description is the repository description
	Description string `yaml:"description" json:"description"`

	// Maintainer is the repository maintainer name
	Maintainer string `yaml:"maintainer" json:"maintainer"`

	// Website is the repository website URL
	Website string `yaml:"website" json:"website"`

	// ContactEmail is the repository contact email
	ContactEmail string `yaml:"contact_email" json:"contact_email"`

	// Version is the repository version
	Version string `yaml:"version" json:"version"`

	// LastUpdated is the timestamp of the last repository update
	LastUpdated string `yaml:"last_updated" json:"last_updated"`

	// Compatibility defines version requirements for Prism
	Compatibility struct {
		// MinVersion is the minimum required Prism version
		MinVersion string `yaml:"min_version" json:"min_version"`

		// MaxVersion is the maximum supported Prism version
		MaxVersion string `yaml:"max_version" json:"max_version"`
	} `yaml:"compatibility" json:"compatibility"`

	// Templates is a list of templates in the repository
	Templates []TemplateMetadata `yaml:"templates" json:"templates"`
}

RepositoryMetadata represents the metadata for a repository.

type TemplateMetadata

type TemplateMetadata struct {
	// Name is the template name
	Name string `yaml:"name" json:"name"`

	// Path is the relative path to the template file
	Path string `yaml:"path" json:"path"`

	// Versions lists available template versions
	Versions []TemplateVersion `yaml:"versions" json:"versions"`
}

TemplateMetadata represents metadata for a template in a repository.

type TemplateReference

type TemplateReference struct {
	// Repository is the repository name (optional)
	Repository string

	// Template is the template name
	Template string

	// Version is the template version (optional)
	Version string
}

TemplateReference specifies a template with optional repository and version.

type TemplateVersion

type TemplateVersion struct {
	// Version is the semantic version of the template
	Version string `yaml:"version" json:"version"`

	// Date is the release date of the template version
	Date string `yaml:"date" json:"date"`
}

TemplateVersion represents a specific version of a template.

Jump to

Keyboard shortcuts

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