config

package
v3.11.8 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExperimentalEnabled added in v3.11.0

func ExperimentalEnabled(ctx context.Context) bool

func ParseSourceURL

func ParseSourceURL(value string) (*url.URL, error)

ParseSourceURL parses a datasource URL value, which may be '-' (for stdin://), or it may be a Windows path (with driver letter and back-slack separators) or UNC, or it may be relative. It also might just be a regular absolute URL... In all cases it returns a correct URL for the value.

func SetExperimental added in v3.11.0

func SetExperimental(ctx context.Context) context.Context

Types

type Config

type Config struct {
	Stdin  io.Reader `yaml:"-"`
	Stdout io.Writer `yaml:"-"`
	Stderr io.Writer `yaml:"-"`

	DataSources map[string]DataSource   `yaml:"datasources,omitempty"`
	Context     map[string]DataSource   `yaml:"context,omitempty"`
	Plugins     map[string]PluginConfig `yaml:"plugins,omitempty"`
	Templates   Templates               `yaml:"templates,omitempty"`

	// Extra HTTP headers not attached to pre-defined datsources. Potentially
	// used by datasources defined in the template.
	ExtraHeaders map[string]http.Header `yaml:"-"`

	// internal use only, can't be injected in YAML
	PostExecInput io.Reader `yaml:"-"`

	Input       string   `yaml:"in,omitempty"`
	InputDir    string   `yaml:"inputDir,omitempty"`
	InputFiles  []string `yaml:"inputFiles,omitempty,flow"`
	ExcludeGlob []string `yaml:"excludes,omitempty"`

	OutputDir   string   `yaml:"outputDir,omitempty"`
	OutputMap   string   `yaml:"outputMap,omitempty"`
	OutputFiles []string `yaml:"outputFiles,omitempty,flow"`
	OutMode     string   `yaml:"chmod,omitempty"`

	LDelim string `yaml:"leftDelim,omitempty"`
	RDelim string `yaml:"rightDelim,omitempty"`

	PostExec []string `yaml:"postExec,omitempty,flow"`

	PluginTimeout time.Duration `yaml:"pluginTimeout,omitempty"`

	ExecPipe      bool `yaml:"execPipe,omitempty"`
	SuppressEmpty bool `yaml:"suppressEmpty,omitempty"`
	Experimental  bool `yaml:"experimental,omitempty"`
}

Config - configures the gomplate execution

func Parse

func Parse(in io.Reader) (*Config, error)

Parse a config file

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

ApplyDefaults - any defaults changed here should be added to cmd.InitFlags as well for proper help/usage display.

func (*Config) GetMode

func (c *Config) GetMode() (os.FileMode, bool, error)

GetMode - parse an os.FileMode out of the string, and let us know if it's an override or not...

func (*Config) MergeFrom

func (c *Config) MergeFrom(o *Config) *Config

MergeFrom - use this Config as the defaults, and override it with any non-zero values from the other Config

Note that Input/InputDir/InputFiles will override each other, as well as OutputDir/OutputFiles.

func (*Config) ParseDataSourceFlags

func (c *Config) ParseDataSourceFlags(datasources, contexts, templates, headers []string) error

ParseDataSourceFlags - sets DataSources, Context, and Templates fields from the key=value format flags as provided at the command-line Unreferenced headers will be set in c.ExtraHeaders

func (*Config) ParsePluginFlags

func (c *Config) ParsePluginFlags(plugins []string) error

ParsePluginFlags - sets the Plugins field from the key=value format flags as provided at the command-line

func (*Config) String

func (c *Config) String() string

String -

func (Config) Validate

func (c Config) Validate() (err error)

Validate the Config

type DataSource

type DataSource struct {
	URL    *url.URL    `yaml:"-"`
	Header http.Header `yaml:"header,omitempty,flow"`
}

DataSource - datasource configuration

func (DataSource) MarshalYAML

func (d DataSource) MarshalYAML() (interface{}, error)

MarshalYAML - satisfy the yaml.Marshaler interface - URLs aren't well supported, and anyway we need to do some extra parsing

func (*DataSource) UnmarshalYAML

func (d *DataSource) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML - satisfy the yaml.Umarshaler interface - URLs aren't well supported, and anyway we need to do some extra parsing

type PluginConfig added in v3.11.0

type PluginConfig struct {
	Cmd     string
	Timeout time.Duration
	Pipe    bool
}

func (*PluginConfig) UnmarshalYAML added in v3.11.0

func (p *PluginConfig) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML - satisfy the yaml.Umarshaler interface - plugin configs can either be a plain string (to specify only the name), or a map with a name, timeout, and pipe flag.

type Templates added in v3.11.0

type Templates map[string]DataSource

Templates - a map of templates. We can't just use map[string]DataSource, because we need to be able to marshal both the old (array of '[k=]v' strings) and the new (proper map) formats.

Note that templates use the DataSource type, since they have the exact same shape. TODO: get rid of this and just use map[string]DataSource once the legacy [k=]v array format is no longer supported

func (Templates) MarshalYAML added in v3.11.0

func (t Templates) MarshalYAML() (interface{}, error)

func (*Templates) UnmarshalYAML added in v3.11.0

func (t *Templates) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML - satisfy the yaml.Umarshaler interface

Jump to

Keyboard shortcuts

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