projecttpl

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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