template

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package template fetches a starter tree from a remote source and copies it into a local directory. Used by `txco init --from <source>`.

The convention: a template is a *flat tree* meant to slot directly under `OPS/<stack>/` in the user's workspace. So given:

github:loremlabs/txco-templates/support-basic

where the repo's `support-basic/` directory contains:

support-basic/
  100/resonator.txcl
  200/resonator.txcl
  triage/100/resonator.txcl

running `txco init support --from github:loremlabs/txco-templates/support-basic` produces:

<cwd>/OPS/support/100/resonator.txcl
<cwd>/OPS/support/200/resonator.txcl
<cwd>/OPS/support/triage/100/resonator.txcl

v1 supports the `github:` scheme only. Public repos only — fetched as a tar.gz from codeload.github.com. No variable substitution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch(ctx context.Context, spec, destDir string) (int, error)

Fetch is the one-shot entry point most callers want.

func SetCodeloadBaseURL

func SetCodeloadBaseURL(u string) string

SetCodeloadBaseURL lets tests point the GitHub fetcher at an httptest server. Returns the previous value so callers can restore in t.Cleanup.

Types

type Source

type Source interface {
	Spec() string
	Fetch(ctx context.Context, destDir string) (filesCopied int, err error)
}

Source is anything that knows how to populate destDir with template files. Today there's only one (githubSource); the interface is here so future schemes (gitlab:, file:, etc.) drop in without churning the call sites.

func Parse

func Parse(spec string) (Source, error)

Parse turns a spec like `github:owner/repo[@ref][/subpath]` into a Source. Returns an error for unknown schemes or malformed specs so the caller can surface a clean message before doing any I/O.

Jump to

Keyboard shortcuts

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