template

package
v0.1.0-preview.1.rc Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTemplateURLs

func GetTemplateURLs(config *Config, arch, lang string) (string, string, error)

GetTemplateURLs retrieves both main and contracts template URLs for the given architecture Returns main base URL, main version, contracts base URL, contracts version, and error

Types

type Architecture

type Architecture struct {
	Languages map[string]Language `yaml:"languages"`
	Contracts *ContractConfig     `yaml:"contracts,omitempty"`
}

type CloneEvent

type CloneEvent struct {
	Type     CloneEventType
	Parent   string // for submodule events
	Module   string // current module path
	Name     string // submodule name or module path
	URL      string // for discovery
	Ref      string // current ref we are cloning from
	Progress int    // 0–100
}

CloneEvent is a single “thing that happened” during clone

type CloneEventType

type CloneEventType int

CloneEventType enumerates the kinds of things git clone can tell us

const (
	EventSubmoduleDiscovered CloneEventType = iota
	EventSubmoduleCloneStart
	EventProgress
	EventCloneComplete
	EventCloneFailed
)

type Config

type Config struct {
	Architectures map[string]Architecture `yaml:"architectures"`
}

func LoadConfig

func LoadConfig() (*Config, error)

type ContractConfig

type ContractConfig struct {
	Languages map[string]Language `yaml:"languages"`
}

type GitClient

type GitClient struct {
	Runner         Runner
	ReceivingRegex *regexp.Regexp
	CloningRegex   *regexp.Regexp
	SubmoduleRegex *regexp.Regexp
}

GitClient does our actual clone + parsing

func NewGitClient

func NewGitClient() *GitClient

NewGitClient builds a GitClient using the real exec

func NewGitClientWithRunner

func NewGitClientWithRunner(r Runner) *GitClient

NewGitClientWithRunner enables injecting a custom Runner (e.g. in tests)

func (*GitClient) Clone

func (g *GitClient) Clone(
	ctx context.Context,
	repoURL, ref, dest string,
	config GitFetcherConfig,
	reporter Reporter,
) error

Clone runs the following to enable clones from SHAs, tags and branches:

  • git clone --no-checkout --depth 1 <repoURL> <dest>
  • git -C <dest> checkout --quiet <ref>
  • git -C <dest> submodule update --init --recursive --progress

func (*GitClient) ParseCloneOutput

func (g *GitClient) ParseCloneOutput(r io.Reader, rep Reporter, dest string, ref string) error

ParseCloneOutput scans git’s progress output and emits events

type GitFetcher

type GitFetcher struct {
	Client  *GitClient
	Metrics GitMetrics
	Config  GitFetcherConfig
	Logger  logger.ProgressLogger
}

GitFetcher wraps clone with metrics and reporting

func (*GitFetcher) Fetch

func (f *GitFetcher) Fetch(ctx context.Context, repoURL, ref, targetDir string) error

type GitFetcherConfig

type GitFetcherConfig struct {
	Verbose bool
}

GitFetcherConfig holds options; we only care about Verbose here

type GitMetrics

type GitMetrics interface {
	CloneStarted(repo string)
	CloneFinished(repo string, err error)
}

TODO: implement metric transport

type Language

type Language struct {
	BaseUrl string `yaml:"baseUrl"`
	Version string `yaml:"version"`
}

type Reporter

type Reporter interface {
	Report(CloneEvent)
}

Reporter consumes CloneEvents

func NewCloneReporter

func NewCloneReporter(repoURL string, lg logger.ProgressLogger, m GitMetrics) Reporter

type Runner

type Runner interface {
	// CommandContext mirrors exec.CommandContext
	CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd
}

Runner lets us inject/mock command execution in tests

type SubmoduleReport

type SubmoduleReport struct {
	Name string
	Dest string
	URL  string
}

Jump to

Keyboard shortcuts

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