template

package
v2.7.5 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintSummary

func PrintSummary(summary api.TemplateSummaryResources, out io.Writer, useColor bool, useBorders bool) error

PrintSummary renders high-level info about a template as a table for display on the console.

NOTE: The implementation here is very "static" in that it's hard-coded to look for specific resource-kinds and fields within those kinds. If the API changes to add more kinds / more fields, this function won't automatically pick them up & print them. It'd be nice to rework this to be less opinionated / more resilient to extension in the future...

func ReadSources

func ReadSources(ctx context.Context, sources []Source) ([]api.TemplateApplyTemplate, error)

Types

type DiffPrinter

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

func NewDiffPrinter

func NewDiffPrinter(w io.Writer, hasColor, hasBorder bool) *DiffPrinter

func (*DiffPrinter) Append

func (d *DiffPrinter) Append(slc []string)

func (*DiffPrinter) AppendDiff

func (d *DiffPrinter) AppendDiff(remove, add []string, assumeDiff bool)

AppendDiff appends a diff to the diff printer

assumeDiff says to mark remove/add as a diff (with two lines), even if they are the same. this is used for types that the CLI does not know how to fully compare.

func (*DiffPrinter) Render

func (d *DiffPrinter) Render()

func (*DiffPrinter) SetHeaders

func (d *DiffPrinter) SetHeaders(headers ...string) *DiffPrinter

func (*DiffPrinter) Title

func (d *DiffPrinter) Title(title string) *DiffPrinter

type Encoding

type Encoding int
const (
	EncodingUnknown Encoding = iota
	EncodingJson
	EncodingJsonnet
	EncodingYaml
)

func (*Encoding) Set

func (e *Encoding) Set(v string) error

func (Encoding) String

func (e Encoding) String() string

type OutEncoding

type OutEncoding int
const (
	YamlEncoding OutEncoding = iota
	JsonEncoding
)

type OutParams

type OutParams struct {
	Out      io.Writer
	Encoding OutEncoding
}

func ParseOutParams

func ParseOutParams(path string, fallback io.Writer) (OutParams, func(), error)

func (OutParams) WriteTemplate

func (o OutParams) WriteTemplate(template []api.TemplateEntry) error

type Source

type Source struct {
	Name     string
	Encoding Encoding
	Open     func(context.Context) (io.ReadCloser, error)
}

func SourceFromReader

func SourceFromReader(r io.Reader, encoding Encoding) Source

func SourceFromURL

func SourceFromURL(u *url.URL, encoding Encoding) Source

func SourcesFromPath

func SourcesFromPath(path string, recur bool, encoding Encoding) ([]Source, error)

func (Source) Read

type TablePrinter

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

func NewTablePrinter

func NewTablePrinter(w io.Writer, hasColor, hasBorder bool) *TablePrinter

func (*TablePrinter) Append

func (t *TablePrinter) Append(slc []string)

func (*TablePrinter) Render

func (t *TablePrinter) Render()

func (*TablePrinter) SetHeaders

func (t *TablePrinter) SetHeaders(headers ...string) *TablePrinter

func (*TablePrinter) Title

func (t *TablePrinter) Title(title string) *TablePrinter

Jump to

Keyboard shortcuts

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