Documentation ¶
Overview ¶
package input handles parsing input data for later processing by Rego.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSVHandler ¶
type CSVHandler struct {
// contains filtered or unexported fields
}
CSVHandler implements a CSV input Handler.
The following options are supported:
csv:comma (rune) the comma-character to use (default: ,)
csv:comment (rune) the comment leader character to use (default: none)
csv:skip_lines (int) number of leading lines to skip, ignored if negative (default: 0)
csv:headers (bool) if true, the first row is treated as headers and used to generate object keys for the remaining rows (default: false)
csv:infer (bool) if true, attempt to convert boolean, integer, or floating point values in the CSV to those types before serialization, otherwise leave all values as strings (default: true)
func (*CSVHandler) Parse ¶
func (c *CSVHandler) Parse(reader io.Reader) (interface{}, error)
Parse implements Handler.Parse().
func (*CSVHandler) SetOption ¶
func (c *CSVHandler) SetOption(name string, value interface{}) error
SetOption implements Handler.SetOption().
type Handler ¶
type Handler interface { // Parse consumes input from a reader and unmarshals it into an // interface. This will later be passed to ast.InterfaceToValue() // for consumption by Rego. Parse(reader io.Reader) (interface{}, error) // SetOption specifies an option to control how the handler should // behave. Setting options that the handler does not implement should // cause SetOption to return nil, this way the CLI handling logic does // not have to determine which handler is being used before deciding // which options to try to set. SetOption(name string, value interface{}) error // Name should return the name of this handler, e.g. "json" or "csv". Name() string }
Handler represents a handler for one type of input format, such as JSON or CSV.
func SelectHandler ¶
SelectHandler chooses a handler based on the name provided.
If name is the empty string, then it default to "yaml".
type JSONHandler ¶
type JSONHandler struct{}
JSONHandler handles parsing JSON data.
func (*JSONHandler) Parse ¶
func (j *JSONHandler) Parse(reader io.Reader) (interface{}, error)
Parse implements Handler.Parse().
func (*JSONHandler) SetOption ¶
func (j *JSONHandler) SetOption(name string, value interface{}) error
SetOption implements Handler.SetOption().
type YAMLHandler ¶
type YAMLHandler struct{}
YAMLHandler handles parsing YAML data.
func (*YAMLHandler) Parse ¶
func (y *YAMLHandler) Parse(reader io.Reader) (interface{}, error)
Parse implements Handler.Parse().
func (*YAMLHandler) SetOption ¶
func (y *YAMLHandler) SetOption(name string, value interface{}) error
SetOption implements Handler.SetOption().