projecttpl

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package projecttpl renders starter project files (app.yaml and, for the pipeline starter, a pipeline file) from a small set of validated templates.

Index

Constants

View Source
const (
	KindString = "string"
	KindInt    = "int"
	KindEnum   = "enum"
	KindCron   = "cron"
)

Param kinds.

Variables

View Source
var ErrUnknownTemplate = errors.New("projecttpl: unknown template")

ErrUnknownTemplate is returned for an id that is not in the catalog.

Functions

This section is empty.

Types

type FieldError

type FieldError struct {
	Param   string `json:"param"`
	Message string `json:"message"`
}

FieldError ties a validation problem to the parameter that caused it.

type File

type File struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

File is one rendered file, path relative to the project root.

func Render

func Render(id string, values map[string]string) ([]File, error)

Render validates values against the template's parameters, fills defaults and returns the files. The result is checked with the platform's own spec and pipeline parsers, so a template can never emit an invalid file.

type Info

type Info struct {
	ID      string  `json:"id"`
	Title   string  `json:"title"`
	Summary string  `json:"summary"`
	Params  []Param `json:"params"`
}

Info describes a template without rendering it.

func List

func List() []Info

List returns the catalog in display order.

type Param

type Param struct {
	Name        string   `json:"name"`
	Label       string   `json:"label"`
	Kind        string   `json:"kind"`
	Default     string   `json:"default,omitempty"`
	Required    bool     `json:"required"`
	Options     []string `json:"options,omitempty"`
	Placeholder string   `json:"placeholder,omitempty"`
}

Param is one value a template asks for.

type ValidationError

type ValidationError struct {
	Fields []FieldError `json:"fields"`
}

ValidationError lists every parameter problem at once.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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