Documentation ¶
Index ¶
- func HclFromJSON(str string) (ast.Node, error)
- func HclListFromJSON(str string) (*ast.ListType, error)
- func HclLiteralFromJSON(str string) (*ast.LiteralType, error)
- type HclDocument
- func (doc *HclDocument) Get(q string) (interface{}, error)
- func (doc *HclDocument) GetAsInt(q string) (int, error)
- func (doc *HclDocument) GetAsIntList(q string) ([]int, error)
- func (doc *HclDocument) GetAsList(q string) ([]interface{}, error)
- func (doc *HclDocument) GetAsString(q string) (string, error)
- func (doc *HclDocument) GetAsStringList(q string) ([]string, error)
- func (doc *HclDocument) GetKeys(q string) ([]string, error)
- func (doc *HclDocument) Print(writer io.Writer) error
- func (doc *HclDocument) Query(queryString string) (results []Result, err error)
- func (doc *HclDocument) QueryKeys(queryString string) (keys []string, err error)
- func (doc *HclDocument) Set(queryString string, listAction func(*ast.ListType) error, ...) error
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HclFromJSON ¶
HclFromJSON converts a JSON string into an HCL ast.Node.
func HclListFromJSON ¶
HclListFromJSON the same as HclFromJSON but converts the result to a list.
func HclLiteralFromJSON ¶
func HclLiteralFromJSON(str string) (*ast.LiteralType, error)
HclLiteralFromJSON the same as HclFromJSON but converts the result to a literal value.
Types ¶
type HclDocument ¶
HclDocument represents an HCL document in memory.
func FromFile ¶
func FromFile(filename string) (*HclDocument, error)
FromFile creates a new document from a file.
func FromReader ¶
func FromReader(reader io.Reader) (*HclDocument, error)
FromReader creates a new document from an io.Reader
func (*HclDocument) Get ¶
func (doc *HclDocument) Get(q string) (interface{}, error)
Get performs a query and returns a deserialized value. The query string is the same format as the command line.
func (*HclDocument) GetAsInt ¶
func (doc *HclDocument) GetAsInt(q string) (int, error)
GetAsInt performs Get but converts the result to a string
func (*HclDocument) GetAsIntList ¶
func (doc *HclDocument) GetAsIntList(q string) ([]int, error)
GetAsIntList does the same as GetAsList but with all values converted to ints. Returns an error if a value is found that is not an int and couldn't be parsed into one.
func (*HclDocument) GetAsList ¶
func (doc *HclDocument) GetAsList(q string) ([]interface{}, error)
GetAsList does the same as Get but converts it to a list for you (with type check)
func (*HclDocument) GetAsString ¶
func (doc *HclDocument) GetAsString(q string) (string, error)
GetAsString performs Get but converts the result to a string
func (*HclDocument) GetAsStringList ¶
func (doc *HclDocument) GetAsStringList(q string) ([]string, error)
GetAsStringList does the same as GetAsList but converts everything to a string for you.
func (*HclDocument) GetKeys ¶
func (doc *HclDocument) GetKeys(q string) ([]string, error)
GetKeys peforms a query and returns just the key or keys, no values.
func (*HclDocument) Print ¶
func (doc *HclDocument) Print(writer io.Writer) error
Print writes the HCL document out to the given io.Writer.
func (*HclDocument) Query ¶
func (doc *HclDocument) Query(queryString string) (results []Result, err error)
Query performs a generic query and returns matching results
func (*HclDocument) QueryKeys ¶
func (doc *HclDocument) QueryKeys(queryString string) (keys []string, err error)
QueryKeys performs a query and returns matching key or keys, no values.
func (*HclDocument) Set ¶
func (doc *HclDocument) Set(queryString string, listAction func(*ast.ListType) error, valueAction func(*token.Token) error) error
Set traverses the document and calls either listAction or valueAction depending on whether or not the value is a list or a literal value. These functions will be invoked for ALL matching nodes in the query.