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 { // Required denotes this argument as required. Required bool `yaml:"required"` // Type declares the type of the argument. This is not implemented // yet, so is likely to change in the future. Type string `yaml:"type"` // Values is a list of possible values for this, if empty all input is // considered valid. Values []string `yaml:"values"` // Description is a description of this argument. Optional. Description string `yaml:"description"` }
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 // - remote file w/ different protocol: git@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 name instead // URL is a full URL for a given module URL string `yaml:"url,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. // Note: Setting this equates to pinning the versions, this is not recommended. 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 is the type of repository this is Type TemplateRepositoryType `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 template repository a repository 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. TemplateRepositoryTypeExt TemplateRepositoryType = "extension" // TemplateRepositoryTypeStd denotes a repository as being a // standard template repository. This is the default TemplateRepositoryTypeStd TemplateRepositoryType = "" )
This block contains all of the TemplateRepositoryType values