Documentation ¶
Index ¶
- func ContextWithConfig(ctx context.Context, cfg *Config) context.Context
- func ParseSourceURL(value string) (*url.URL, error)
- type Config
- func (c *Config) ApplyDefaults()
- func (c *Config) GetMode() (os.FileMode, bool, error)
- func (c *Config) MergeFrom(o *Config) *Config
- func (c *Config) ParseDataSourceFlags(datasources, contexts, headers []string) error
- func (c *Config) ParsePluginFlags(plugins []string) error
- func (c *Config) String() string
- func (c Config) Validate() (err error)
- type DataSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithConfig ¶
ContextWithConfig returns a new context with a reference to the config.
func ParseSourceURL ¶
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.
Types ¶
type Config ¶
type Config struct { Stdin io.Reader `yaml:"-"` Stdout io.Writer `yaml:"-"` Stderr io.Writer `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"` DataSources map[string]DataSource `yaml:"datasources,omitempty"` Context map[string]DataSource `yaml:"context,omitempty"` Plugins map[string]string `yaml:"plugins,omitempty"` // Extra HTTP headers not attached to pre-defined datsources. Potentially // used by datasources defined in the template. ExtraHeaders map[string]http.Header `yaml:"-"` Templates []string `yaml:"templates,omitempty"` 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 FromContext ¶
FromContext returns a config from the given context, if any. If no config is present a new default configuration will be returned.
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 ¶
GetMode - parse an os.FileMode out of the string, and let us know if it's an override or not...
func (*Config) MergeFrom ¶
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 ¶
ParseDataSourceFlags - sets the DataSources and Context fields from the key=value format flags as provided at the command-line
func (*Config) ParsePluginFlags ¶
ParsePluginFlags - sets the Plugins field from the key=value format flags as provided at the command-line
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