source

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package source fetches a blueprint's template skeleton into a local directory that the renderer can walk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSpec

func ParseSpec(spec string) (*blueprint.Source, error)

ParseSpec turns what a user typed on the command line into a source.

The accepted forms, in the order they are tried:

./templates/go-api          a local directory
/abs/path/to/template       a local directory
owner/repo                  GitHub, default branch
owner/repo@v1.2.0           GitHub at a branch, tag or commit
https://github.com/owner/repo
https://example.com/t.zip   a zip archive
https://example.com/t.git   any git remote
git@github.com:owner/repo.git

The shorthand is worth the parsing: `rig new api -b JustSteveKing/go-api` is what people will actually type, and making them write a full URL for the common case is the kind of friction that stops a tool being reached for.

Types

type Template

type Template struct {
	// Root is the directory to render from, already narrowed to any subdir.
	Root string

	// Ref identifies exactly what was fetched: a commit SHA for git sources,
	// a "sha256:..." digest for archives, empty for a local directory. It goes
	// into the lockfile, and it is what makes `rig apply` able to tell whether
	// the template moved.
	Ref string

	// Origin describes where the template came from, as declared rather than
	// as resolved on disk.
	//
	// It must never be a local staging path. A blueprint fetched from git is
	// unpacked into a temp directory, so recording the resolved path would put
	// a directory name that no longer exists into the lockfile — and a
	// different one on every run, making the lockfile churn on every apply.
	Origin string
	// contains filtered or unexported fields
}

Template is a fetched skeleton on local disk.

func Fetch

func Fetch(ctx context.Context, bp *blueprint.Blueprint) (*Template, error)

Fetch resolves a blueprint's source into a local directory.

A blueprint with no `source` uses its own directory as the template, which is the ordinary case: a template repository gains a blueprint.yaml at its root and needs no further configuration.

func (*Template) Close

func (t *Template) Close() error

Close releases any temporary directory the fetch created.

Jump to

Keyboard shortcuts

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