Documentation
¶
Overview ¶
Deprecated: Use github.com/stolostron/applier/pkg/templateprocessor project
Index ¶
- Constants
- func ApplierFuncMap() template.FuncMap
- func ConvertArrayOfBytesToArrayOfString(in [][]byte) (out []string)
- func ConvertArrayOfBytesToString(in [][]byte) (out string)
- func ConvertStringToArrayOfBytes(in, delimiter string) (out [][]byte)
- func GenericFuncMap() map[string]interface{}
- func TemplateFuncMap(tmpl *template.Template) (funcMap template.FuncMap)
- func ToYAMLUnstructured(u *unstructured.Unstructured) ([]byte, error)
- func ToYAMLsUnstructured(us []*unstructured.Unstructured) ([][]byte, error)
- type KindsOrder
- type MapReader
- type MissingKeyType
- type Options
- type SortType
- type TemplateProcessor
- func (tp *TemplateProcessor) AssetNamesInPath(path string, excluded []string, recursive bool) ([]string, error)
- func (tp *TemplateProcessor) Assets(path string, excluded []string, recursive bool) (payloads [][]byte, err error)
- func (tp *TemplateProcessor) BytesArrayToUnstructured(assets [][]byte) (us []*unstructured.Unstructured, err error)
- func (tp *TemplateProcessor) BytesToUnstructured(asset []byte) (*unstructured.Unstructured, error)
- func (tp *TemplateProcessor) SetCreateUpdateOrder()
- func (tp *TemplateProcessor) SetDeleteOrder()
- func (tp *TemplateProcessor) TemplateBytes(tmpl *template.Template, b []byte, values interface{}) ([]byte, error)
- func (tp *TemplateProcessor) TemplateResource(templateName string, values interface{}) ([]byte, error)
- func (tp *TemplateProcessor) TemplateResources(templateNames []string, values interface{}) ([][]byte, error)
- func (tp *TemplateProcessor) TemplateResourcesInPathUnstructured(path string, excluded []string, recursive bool, values interface{}) (us []*unstructured.Unstructured, err error)
- func (tp *TemplateProcessor) TemplateResourcesInPathYaml(path string, excluded []string, recursive bool, values interface{}) ([][]byte, error)
- func (tp *TemplateProcessor) TemplateResourcesUnstructured(templateNames []string, values interface{}) (us []*unstructured.Unstructured, err error)
- type TemplateReader
- type YamlFileReader
- type YamlStringReader
Constants ¶
const KubernetesYamlsDelimiter = "(?m)^-{3}$"
KubernetesYamlsDelimiter regular expression for yaml delimiter
const KubernetesYamlsDelimiterString = "---\n"
KubernetesYamlsDelimiterString default yaml delimiter
Variables ¶
This section is empty.
Functions ¶
func ConvertArrayOfBytesToArrayOfString ¶
ConvertArrayOfBytesToArrayOfString converts an [][]byte to []string
func ConvertArrayOfBytesToString ¶
ConvertArrayOfBytesToString converts an [][]byte to string
func ConvertStringToArrayOfBytes ¶
ConvertStringToArrayOfBytes converts a string into a [][]byte using a given delimiter
func GenericFuncMap ¶
func GenericFuncMap() map[string]interface{}
GenericFuncMap returns a copy of the basic function map as a map[string]interface{}.
func TemplateFuncMap ¶
TemplateFuncMap generates function map for "include"
func ToYAMLUnstructured ¶
func ToYAMLUnstructured(u *unstructured.Unstructured) ([]byte, error)
ToYAMLUnstructured converts *unstructured.Unstructured to []byte yaml format
func ToYAMLsUnstructured ¶
func ToYAMLsUnstructured(us []*unstructured.Unstructured) ([][]byte, error)
ToYAMLsUnstructured converts []*unstructured.Unstructured to [][]byte yaml format
Types ¶
type MapReader ¶
type MapReader struct {
// contains filtered or unexported fields
}
YamlFileReader defines a reader for map of string
func NewTestReader ¶
NewTestReader constructs a new YamlFileReader
func (*MapReader) AssetNames ¶
AssetNames returns the name of all assets
type MissingKeyType ¶
type MissingKeyType string
MissingKeyType defines the type missing keys for redering
const ( //MissingKeyTypeZero ... MissingKeyTypeZero MissingKeyType = "missingkey=zero" //MissingKeyTypeError ... MissingKeyTypeError MissingKeyType = "missingkey=error" //MissingKeyTypeInvalid ... MissingKeyTypeInvalid MissingKeyType = "missingkey=invalid" //MissingKeyTypeDefault ... MissingKeyTypeDefault MissingKeyType = "missingkey=default" )
type Options ¶
type Options struct { KindsOrder SortType DelimiterString string Delimiter string //Override the default order, it contains the kind order which the templateProcess must use to sort all resources. CreateUpdateKindsOrder KindsOrder DeleteKindsOrder KindsOrder MissingKeyType MissingKeyType }
Options defines for the available options for the templateProcessor
type TemplateProcessor ¶
type TemplateProcessor struct {
// contains filtered or unexported fields
}
TemplateProcessor this structure holds all objects for the TemplateProcessor
func NewTemplateProcessor ¶
func NewTemplateProcessor( reader TemplateReader, options *Options, ) (*TemplateProcessor, error)
NewTemplateProcessor creates a new applier reader: The TemplateReader to use to read the templates options: The possible options for the templateprocessor
func (*TemplateProcessor) AssetNamesInPath ¶
func (tp *TemplateProcessor) AssetNamesInPath( path string, excluded []string, recursive bool, ) ([]string, error)
AssetNamesInPath returns all asset names with a given path and subpath if recursive is set to true, it excludes the assets contained in the excluded parameter
func (*TemplateProcessor) Assets ¶
func (tp *TemplateProcessor) Assets( path string, excluded []string, recursive bool, ) (payloads [][]byte, err error)
Assets returns all assets with a given path and subpath if recursive set to true, it excludes the assets contained in the excluded parameter
func (*TemplateProcessor) BytesArrayToUnstructured ¶
func (tp *TemplateProcessor) BytesArrayToUnstructured(assets [][]byte) (us []*unstructured.Unstructured, err error)
BytesArrayToUnstructured transform a [][]byte to an []*unstructured.Unstructured using the TemplateProcessor reader
func (*TemplateProcessor) BytesToUnstructured ¶
func (tp *TemplateProcessor) BytesToUnstructured(asset []byte) (*unstructured.Unstructured, error)
BytesToUnstructured transform a []byte to an *unstructured.Unstructured using the TemplateProcessor reader
func (*TemplateProcessor) SetCreateUpdateOrder ¶
func (tp *TemplateProcessor) SetCreateUpdateOrder()
SetCreateUpdateOrder used to set the kind order for create or update
func (*TemplateProcessor) SetDeleteOrder ¶
func (tp *TemplateProcessor) SetDeleteOrder()
SetDeleteOrder used to set the kind order for deletion
func (*TemplateProcessor) TemplateBytes ¶
func (tp *TemplateProcessor) TemplateBytes( tmpl *template.Template, b []byte, values interface{}, ) ([]byte, error)
TemplateBytes render the given template with the provided values
func (*TemplateProcessor) TemplateResource ¶
func (tp *TemplateProcessor) TemplateResource( templateName string, values interface{}, ) ([]byte, error)
TemplateResource render the given template with the provided values
func (*TemplateProcessor) TemplateResources ¶
func (tp *TemplateProcessor) TemplateResources( templateNames []string, values interface{}, ) ([][]byte, error)
TemplateResources render the given templates with the provided values The resources are not sorted and returned in the same template provided order
func (*TemplateProcessor) TemplateResourcesInPathUnstructured ¶
func (tp *TemplateProcessor) TemplateResourcesInPathUnstructured( path string, excluded []string, recursive bool, values interface{}) (us []*unstructured.Unstructured, err error)
TemplateResourcesInPathUnstructured returns all assets in a []unstructured.Unstructured and sort them The []unstructured.Unstructured are sorted following the order defined in variable kindsOrder
func (*TemplateProcessor) TemplateResourcesInPathYaml ¶
func (tp *TemplateProcessor) TemplateResourcesInPathYaml( path string, excluded []string, recursive bool, values interface{}, ) ([][]byte, error)
TemplateResourcesInPathYaml returns all assets in a path using the provided config. The resources are sorted following the order defined in variable kindsOrder
func (*TemplateProcessor) TemplateResourcesUnstructured ¶
func (tp *TemplateProcessor) TemplateResourcesUnstructured( templateNames []string, values interface{}) (us []*unstructured.Unstructured, err error)
TemplateResourcesUnstructured returns all assets in a []unstructured.Unstructured and sort them The []unstructured.Unstructured are sorted following the order defined in variable kindsOrder
type TemplateReader ¶
type TemplateReader interface { //Retreive an asset from the data source Asset(templatePath string) ([]byte, error) //List all available assets in the data source AssetNames() ([]string, error) //Transform the assets into a JSON. This is used to transform the asset into an unstructrued.Unstructured object. //For example: if the asset is a yaml, you can use yaml.YAMLToJSON(b []byte) as implementation as it is shown in //testread_test.go ToJSON(b []byte) ([]byte, error) }
TemplateReader defines the needed functions
type YamlFileReader ¶
type YamlFileReader struct {
// contains filtered or unexported fields
}
YamlFileReader defines a reader for yaml files
func NewYamlFileReader ¶
func NewYamlFileReader( path string, ) *YamlFileReader
NewYamlFileReader constructs a new YamlFileReader
func (*YamlFileReader) Asset ¶
func (r *YamlFileReader) Asset( name string, ) ([]byte, error)
Asset returns an asset
func (*YamlFileReader) AssetNames ¶
func (r *YamlFileReader) AssetNames() ([]string, error)
AssetNames returns the name of all assets
type YamlStringReader ¶
type YamlStringReader struct {
Yamls []string
}
YamlStringReader defines a reader for yaml string
func NewYamlStringReader ¶
func NewYamlStringReader( yamls string, delimiter string, ) *YamlStringReader
NewYamlStringReader returns a YamlStringReader yamls: a string of yaml, separeted by the delimiter. Usually "---\n" delimiter: the delimiter
func (*YamlStringReader) Asset ¶
func (r *YamlStringReader) Asset( name string, ) ([]byte, error)
Asset returns an asset
func (*YamlStringReader) AssetNames ¶
func (r *YamlStringReader) AssetNames() ([]string, error)
AssetNames returns the name of all assets