pct

package
v0.0.0-...-a56eff2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package pct implements the Puppet Content template specification

Puppet Content Templates (PCT) codify a structure to produce content for any Puppet Product. PCT can create any type of a Puppet Product project: Puppet control repo, Puppet Module, Bolt project, etc. PCT can also create one or more independent files, such as CI files or gitignores. This can be as simple as a name for a Puppet Class or a set of CI files to add to a Puppet Module.

Index

Constants

View Source
const (
	TemplateConfigName         = "pct-config"
	TemplateConfigFileName     = "pct-config.yml"
	UserTemplateConfigName     = "pct"
	UserTemplateConfigFileName = "pct.yml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DeployInfo

type DeployInfo struct {
	SelectedTemplate string
	TemplateDirPath  string
	TargetOutputDir  string
	TargetName       string
	PdkInfo          PDKInfo
}

DeployInfo represents the final set of information needed to deploy a template

type PDKInfo

type PDKInfo struct {
	Version   string
	Commit    string
	BuildDate string
}

PDKInfo contains the current version information of the compiled binary for use in template data

type Pct

type Pct struct {
	OsUtils utils.OsUtilI
	Utils   utils.UtilsHelperI
	AFS     *afero.Afero
	IOFS    *afero.IOFS
}

func (*Pct) Deploy

func (p *Pct) Deploy(info DeployInfo) []string

Deploy deploys a selected template to a target path with a target name using data from both the configuration inside the template and provided by the User in their user config file

func (*Pct) DisplayDefaults

func (*Pct) DisplayDefaults(defaults map[string]interface{}, format string) string

DisplayDefaults returns the Default values from a Templates configuration file

func (*Pct) FilterFiles

func (p *Pct) FilterFiles(ss []PuppetContentTemplate, test func(PuppetContentTemplate) bool) (ret []PuppetContentTemplate)

func (*Pct) FormatDeployment

func (*Pct) FormatDeployment(deployed []string, jsonOutput string) error

FormatDeployment formats the files returned by the Deploy method to display on the console in table format or json format.

func (*Pct) FormatTemplates

func (*Pct) FormatTemplates(tmpls []PuppetContentTemplate, jsonOutput string) (string, error)

FormatTemplates formats one or more templates to display on the console in table format or json format.

func (*Pct) Get

func (p *Pct) Get(templateDirPath string) (PuppetContentTemplate, error)

func (*Pct) GetInfo

func (p *Pct) GetInfo(templateDirPath string) (PuppetContentTemplateInfo, error)

func (*Pct) List

func (p *Pct) List(templatePath string, templateName string) []PuppetContentTemplate

List lists all templates in a given path and parses their configuration. Does not return any errors from parsing invalid templates, but returns them as debug log events

type PctI

type PctI interface {
	GetInfo(templateCache string, selectedTemplate string) (PuppetContentTemplateInfo, error)
	List(templatePath string, templateName string) ([]PuppetContentTemplate, error)
	FormatTemplates(tmpls []PuppetContentTemplate, jsonOutput string) error
	DisplayDefaults(defaults map[string]interface{}, format string) string
	FormatDeployment(deployed []string, jsonOutput string) error
	Deploy(info DeployInfo) []string
}

type PuppetContentTemplate

type PuppetContentTemplate struct {
	install.ConfigParams `mapstructure:",squash"`
	Type                 string `mapstructure:"type"`
	Display              string `mapstructure:"display"`
	URL                  string `mapstructure:"url"`
}

PuppetContentTemplate houses the actual information about each template

type PuppetContentTemplateFileInfo

type PuppetContentTemplateFileInfo struct {
	TemplatePath   string
	TargetFilePath string
	TargetDir      string
	TargetFile     string
	IsDirectory    bool
}

PuppetContentTemplateFileInfo represents the resolved target path information for a given template

type PuppetContentTemplateInfo

type PuppetContentTemplateInfo struct {
	Template PuppetContentTemplate `mapstructure:"template"`
	Defaults map[string]interface{}
}

PuppetContentTemplateInfo is the housing struct for marshaling YAML data

Jump to

Keyboard shortcuts

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