templates

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidTemplate = errors.New("invalid template content")

ErrInvalidTemplate is returned when template content is invalid

View Source
var ErrTemplateNotFound = errors.New("template not found")

ErrTemplateNotFound is returned when a template cannot be found

Functions

This section is empty.

Types

type GitHubReleasesProvider

type GitHubReleasesProvider struct {
	Owner      string
	Repo       string
	HTTPClient *http.Client
}

GitHubReleasesProvider implements TemplateProvider using GitHub Releases

func NewGitHubReleasesProvider

func NewGitHubReleasesProvider(owner, repo string) *GitHubReleasesProvider

NewGitHubReleasesProvider creates a new GitHub releases template provider

func (*GitHubReleasesProvider) DownloadTemplate

func (p *GitHubReleasesProvider) DownloadTemplate(releaseTag string) (string, error)

DownloadTemplate downloads and extracts a template release to a temporary directory

func (*GitHubReleasesProvider) ExtractTemplate

func (p *GitHubReleasesProvider) ExtractTemplate(archivePath, destDir string) error

ExtractTemplate extracts a template archive to the destination directory Note: For GitHub releases, we expect the archive to already be extracted by DownloadTemplate, so this is a no-op that just validates the directory exists.

func (*GitHubReleasesProvider) GetTemplate

func (p *GitHubReleasesProvider) GetTemplate(version string) ([]byte, error)

GetTemplate returns the template content for the given version Note: This implementation downloads the release each time. In practice, you might want to cache this locally.

type TemplateProvider

type TemplateProvider interface {
	// GetTemplate returns the template content for the given version
	GetTemplate(version string) ([]byte, error)

	// DownloadTemplate downloads and extracts a template release to a temporary directory
	DownloadTemplate(releaseTag string) (string, error)

	// ExtractTemplate extracts a template archive to the destination directory
	ExtractTemplate(archivePath, destDir string) error
}

TemplateProvider defines the interface for obtaining project templates

Jump to

Keyboard shortcuts

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