Documentation ¶
Overview ¶
Package configuration implements configuration loading logic for stencil repositories and template repositories
Index ¶
Examples ¶
Constants ¶
const ValidateNameRegexp = `^[_a-z][_a-z0-9-]*$`
ValidateNameRegexp is the regex used to validate the service's name
Variables ¶
This section is empty.
Functions ¶
func ValidateName ¶ added in v1.5.0
ValidateName ensures that the name of a service in the manifest fits the criteria we require.
Example ¶
package main import ( "fmt" "github.com/getoutreach/stencil/pkg/configuration" ) func main() { // Normal name success := configuration.ValidateName("test") fmt.Println("success:", success) // Invalid name success = configuration.ValidateName("test.1234") fmt.Println("success:", success) }
Output: success: true success: false
Types ¶
type Argument ¶
type Argument struct { // Description is a description of this argument. Description string `yaml:"description"` // Required denotes this argument as required. Required bool `yaml:"required"` // Default is the default value for this argument if it's not set. // This cannot be set when required is true. Default interface{} `yaml:"default"` // Schema is a JSON schema, in YAML, for the argument. Schema map[string]interface{} `yaml:"schema"` // Deprecated: Use schema instead // Type declares the type of the argument. This is not implemented // yet, so is likely to change in the future. Type string `yaml:"type"` // Deprecated: Use schema instead. // Values is a list of possible values for this, if empty all input is // considered valid. Values []string `yaml:"values"` // From is a reference to an argument in another module, if this is // set, all other fields are ignored and instead the module referenced // field's are used instead. The name of the argument, the key in the map, // must be the same across both modules. From string `yaml:"from"` }
Argument is a user-input argument that can be passed to templates
type PostRunCommandSpec ¶
type PostRunCommandSpec struct { // Name is the name of the command being ran, used for UX Name string `yaml:"name"` // Command is the command to be ran, note: this is ran inside // of a bash shell. Command string `yaml:"command"` }
PostRunCommandSpec is the spec of a command to be ran and its friendly name
type ServiceManifest ¶
type ServiceManifest struct { // Name is the name of the service Name string `yaml:"name"` // Modules are the template modules that this service depends // on and utilizes Modules []*TemplateRepository `yaml:"modules,omitempty"` // Versions is a map of versions of certain tools, this is used by templates // and will likely be replaced with something better in the future. Versions map[string]string `yaml:"versions,omitempty"` // Arguments is a map of arbitrary arguments to pass to the generator Arguments map[string]interface{} `yaml:"arguments"` // Replacements is a list of module names to replace their URI. // Expected format: // - local file: file://path/to/module // - remote file: https://github.com/getoutreach/stencil-base Replacements map[string]string `yaml:"replacements,omitempty"` }
ServiceManifest is a manifest used to describe a service and impact what files are included
func NewDefaultServiceManifest ¶
func NewDefaultServiceManifest() (*ServiceManifest, error)
NewDefaultServiceManifest returns a parsed service manifest from a set default path on disk.
func NewServiceManifest ¶
func NewServiceManifest(path string) (*ServiceManifest, error)
NewServiceManifest reads a service manifest from disk at the specified path, parses it, and returns the output.
Example ¶
package main import ( "fmt" "github.com/getoutreach/stencil/pkg/configuration" ) func main() { sm, err := configuration.NewServiceManifest("testdata/service.yaml") if err != nil { // handle the error fmt.Println("error:", err) return } fmt.Println(sm.Name) fmt.Println(sm.Arguments) }
Output: testing map[hello:world]
type TemplateRepository ¶
type TemplateRepository struct { // Name is the name of this module. This should be a valid go import path Name string `yaml:"name"` // Deprecated: Use 'channel' instead, prerelease sets 'channel' to 'rc'. // Prerelease is a boolean indicating whether or not to consider prerelease versions Prerelease bool `yaml:"prerelease"` // Deprecated: Use name instead // URL is a full URL for a given module URL string `yaml:"url,omitempty"` // Channel is the channel to use for updates to this module // Defaults to "stable" Channel string `yaml:"channel,omitempty"` // Version is a semantic version or branch of the template repository // that should be downloaded if not set then the latest version is used. // // Version can also be a constraint as supported by the underlying resolver: // https://pkg.go.dev/github.com/getoutreach/gobox/pkg/cli/updater/resolver#Resolve Version string `yaml:"version,omitempty"` }
TemplateRepository is a repository of template files.
type TemplateRepositoryManifest ¶
type TemplateRepositoryManifest struct { // Name is the name of this template repository. // This must match the import path. Name string `yaml:"name"` // Modules are template repositories that this manifest requires Modules []*TemplateRepository `yaml:"modules"` // Type stores a comma-separated list of template repository types served by the current module. // Use the TemplateRepositoryTypes.Contains method to check. Type TemplateRepositoryTypes `yaml:"type,omitempty"` // PostRunCommand is a command to be ran after rendering and post-processors // have been ran on the project PostRunCommand []*PostRunCommandSpec `yaml:"postRunCommand,omitempty"` // Arguments are a declaration of arguments to the template generator Arguments map[string]Argument `yaml:"arguments,omitempty"` }
TemplateRepositoryManifest is a manifest of a template repository
type TemplateRepositoryType ¶ added in v1.1.0
type TemplateRepositoryType string
TemplateRepositoryType specifies what type of a stencil repository the current one is.
const ( // TemplateRepositoryTypeExt denotes a repository as being // an extension repository. This means that it contains // a go extension. This repository may also contain go-templates if // this type is used together with the TemplateRepositoryTypeTemplates. TemplateRepositoryTypeExt TemplateRepositoryType = "extension" // TemplateRepositoryTypeTemplates denotes a repository as being a standard template repository. // When the same module/repo serves more than one type, join this explicit value with other // types, e.g. "templates,extension". TemplateRepositoryTypeTemplates TemplateRepositoryType = "templates" )
This block contains all of the TemplateRepositoryType values
type TemplateRepositoryTypes ¶ added in v1.20.0
type TemplateRepositoryTypes struct {
// contains filtered or unexported fields
}
TemplateRepositoryTypes specifies what type of a stencil repository the current one is. Use Contains to check for a type - it has special handling for the default case. Even though it is a struct, it is marshalled and unmarshalled as a string with comma separated values of TemplateRepositoryType.
func (TemplateRepositoryTypes) Contains ¶ added in v1.20.0
func (ts TemplateRepositoryTypes) Contains(t TemplateRepositoryType) bool
Contains returns true if current repo needs to serve inpt type, with default assumed to be a templates-only repo (we do not support repos with no purpose).
func (TemplateRepositoryTypes) MarshalYAML ¶ added in v1.20.0
func (ts TemplateRepositoryTypes) MarshalYAML() (interface{}, error)
MarshalYAML marshals TemplateRepositoryTypes as a string with comma-separated values.
func (*TemplateRepositoryTypes) UnmarshalYAML ¶ added in v1.20.0
func (ts *TemplateRepositoryTypes) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML unmarshals TemplateRepositoryTypes from a string with comma-separated values.