template

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Overview

Package template implements the "template" command (not to be confused with "pkg/template" home of the templating mechanism itself).

Front-and-center is template.Options. This is both the host of ytt settings parsed from the command-line through Cobra AND the top-level logic that implements the command.

Index

Constants

View Source
const (
	RegularFilesOutputTypeYAML = "yaml"
	RegularFilesOutputTypeJSON = "json"
	RegularFilesOutputTypePos  = "pos"
)

When the FileSource are RegularFilesSource, indicates which file format to use when rendering the output.

View Source
const (
	RegularFilesOutputTypeOpenAPI = "openapi-v3"
	RegularFilesOutputTypeNone    = ""
)

When the FileSource are RegularFilesSource, indicates which schema type to use when rendering the output.

Variables

Collections of each category of output type

Functions

This section is empty.

Types

type BulkFile

type BulkFile struct {
	Name string `json:"name"`
	Data string `json:"data"`
}

type BulkFiles

type BulkFiles struct {
	Files  []BulkFile `json:"files,omitempty"`
	Errors string     `json:"errors,omitempty"`
}

type BulkFilesSource

type BulkFilesSource struct {
	// contains filtered or unexported fields
}

func NewBulkFilesSource

func NewBulkFilesSource(opts BulkFilesSourceOpts, ui ui.UI) *BulkFilesSource

func (*BulkFilesSource) HasInput

func (s *BulkFilesSource) HasInput() bool

func (*BulkFilesSource) HasOutput

func (s *BulkFilesSource) HasOutput() bool

func (BulkFilesSource) Input

func (s BulkFilesSource) Input() (Input, error)

func (*BulkFilesSource) Output

func (s *BulkFilesSource) Output(out Output) error

type BulkFilesSourceOpts

type BulkFilesSourceOpts struct {
	// contains filtered or unexported fields
}

func (*BulkFilesSourceOpts) Set

func (s *BulkFilesSourceOpts) Set(cmdFlags CmdFlags)

Set registers "bulk" flags and wires-up those flags up to this BulkFilesSourceOpts to be set when the corresponding cobra.Command is executed.

type CmdFlags added in v0.48.0

type CmdFlags interface {
	BoolVar(p *bool, name string, value bool, usage string)
	BoolVarP(p *bool, name, shorthand string, value bool, usage string)

	StringVar(p *string, name string, value string, usage string)
	StringVarP(p *string, name, shorthand string, value string, usage string)

	StringArrayVar(p *[]string, name string, value []string, usage string)
	StringArrayVarP(p *[]string, name, shorthand string, value []string, usage string)

	StringSliceVar(p *[]string, name string, value []string, usage string)
	StringSliceVarP(p *[]string, name, shorthand string, value []string, usage string)
}

CmdFlags interface decouples this package from depending on cobra.Command/flags concrete types.

type DataValuesFile added in v0.48.0

type DataValuesFile struct {
	// contains filtered or unexported fields
}

func NewDataValuesFile added in v0.48.0

func NewDataValuesFile(doc *yamlmeta.Document) DataValuesFile

func (DataValuesFile) AsOverlay added in v0.48.0

func (f DataValuesFile) AsOverlay() (*yamlmeta.Document, error)

type DataValuesFlags added in v0.8.0

type DataValuesFlags struct {
	EnvFromStrings []string
	EnvFromYAML    []string

	KVsFromStrings []string
	KVsFromYAML    []string
	KVsFromFiles   []string

	FromFiles []string

	Inspect        bool
	InspectSchema  bool
	SkipValidation bool

	EnvironFunc   func() []string
	ReadFilesFunc func(paths string) ([]*files.File, error)

	*files.SymlinkAllowOpts
}

func (*DataValuesFlags) AsOverlays added in v0.48.0

func (s *DataValuesFlags) AsOverlays(strict bool) ([]*datavalues.Envelope, []*datavalues.Envelope, error)

AsOverlays generates Data Values overlays, one for each setting in this DataValuesFlags.

Returns a collection of overlays targeted for the root library and a separate collection of overlays "addressed" to children libraries.

func (*DataValuesFlags) Set added in v0.8.0

func (s *DataValuesFlags) Set(cmdFlags CmdFlags)

Set registers data values ingestion flags and wires-up those flags up to this DataValuesFlags to be set when the corresponding cobra.Command is executed.

type FileMarksOpts added in v0.25.0

type FileMarksOpts struct {
	FileMarks []string
}

func (*FileMarksOpts) Apply added in v0.25.0

func (s *FileMarksOpts) Apply(filesToProcess []*files.File) ([]*files.File, error)

func (*FileMarksOpts) Set added in v0.25.0

func (s *FileMarksOpts) Set(cmdFlags CmdFlags)

Set registers file mark flags and wires-up those flags up to this FileMarksOpts to be set when the corresponding cobra.Command is executed.

type FileSource

type FileSource interface {
	HasInput() bool
	HasOutput() bool
	Input() (Input, error)
	// Output renders the results (i.e. an instance of Output) to the configured output/sink of this FileSource
	Output(Output) error
}

FileSource provides both a means of loading from sources (i.e. Input) and rendering into sinks (i.e. Output)

type Input added in v0.48.0

type Input struct {
	Files []*files.File
}

type Options added in v0.48.0

type Options struct {
	IgnoreUnknownComments   bool
	ImplicitMapKeyOverrides bool

	StrictYAML   bool
	Debug        bool
	InspectFiles bool

	BulkFilesSourceOpts    BulkFilesSourceOpts
	RegularFilesSourceOpts RegularFilesSourceOpts
	FileMarksOpts          FileMarksOpts
	DataValuesFlags        DataValuesFlags
}

Options both contains the configuration for a "template" command AND the top-level implementation of that command.

For most intents and purposes, RunWithFiles() is the entrypoint.

func NewOptions

func NewOptions() *Options

NewOptions initializes a new instance of template.Options.

func (*Options) BindFlags added in v0.48.0

func (o *Options) BindFlags(cmdFlags CmdFlags)

BindFlags registers template flags for template command.

func (*Options) Run added in v0.48.0

func (o *Options) Run() error

func (*Options) RunWithFiles added in v0.48.0

func (o *Options) RunWithFiles(in Input, ui ui.UI) Output

type Output added in v0.48.0

type Output struct {
	Files  []files.OutputFile
	DocSet *yamlmeta.DocumentSet
	Err    error
}

type OutputType added in v0.48.0

type OutputType struct {
	Types []string
}

OutputType holds the user's desire for two (2) categories of output: - file format type :: yaml, json, pos - schema type :: OpenAPI V3, ytt Schema

func (*OutputType) Format added in v0.48.0

func (o *OutputType) Format() (string, error)

Format returns which of the file format types is in effect

func (*OutputType) Schema added in v0.48.0

func (o *OutputType) Schema() (string, error)

Schema returns which of the schema types is in effect

type RegularFilesSource

type RegularFilesSource struct {
	// contains filtered or unexported fields
}

func NewRegularFilesSource

func NewRegularFilesSource(opts RegularFilesSourceOpts, ui ui.UI) *RegularFilesSource

func (*RegularFilesSource) HasInput

func (s *RegularFilesSource) HasInput() bool

func (*RegularFilesSource) HasOutput

func (s *RegularFilesSource) HasOutput() bool

func (*RegularFilesSource) Input

func (s *RegularFilesSource) Input() (Input, error)

func (*RegularFilesSource) Output

func (s *RegularFilesSource) Output(out Output) error

type RegularFilesSourceOpts

type RegularFilesSourceOpts struct {
	OutputFiles string
	OutputType  OutputType

	*files.SymlinkAllowOpts
	// contains filtered or unexported fields
}

RegularFilesSourceOpts holds configuration for when regular files are the input/output of the execution (via the --files and --output... flags).

func (*RegularFilesSourceOpts) Set

func (s *RegularFilesSourceOpts) Set(cmdFlags CmdFlags)

Set registers flags related to sourcing ordinary files/directories and wires-up those flags up to this RegularFilesSourceOpts to be set when the corresponding cobra.Command is executed.

Jump to

Keyboard shortcuts

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