Documentation ¶
Index ¶
- type Diagnostics
- type File
- type Parser
- func (p *Parser) AddParsedFile(schema SchemaType, filename string, hcl *hcl.File, diags *Diagnostics)
- func (p *Parser) ParseFile(schema SchemaType, filename string) *Diagnostics
- func (p *Parser) ParseHCL(schema SchemaType, src []byte, filename string) *Diagnostics
- func (p *Parser) ParseHCLFile(schema SchemaType, filename string) *Diagnostics
- func (p *Parser) ParseJSON(schema SchemaType, src []byte, filename string) *Diagnostics
- func (p *Parser) ParseJSONFile(schema SchemaType, filename string) *Diagnostics
- func (p *Parser) ProcessDiagnostics(schema SchemaType, filename string) *Diagnostics
- type SchemaType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diagnostics ¶
type Diagnostics struct {
// contains filtered or unexported fields
}
Diagnostics allows examining the diagnostics received by the parser in cases where the schema encounters validation errors or other processing errors.
This is a wrapper around the HCL language diagnostics interface, the raw hcl.Diagnostics may be retrieved use RawDiagnostics() which returns the raw hcl.Diagnostics instance.
func (*Diagnostics) AsJSON ¶
func (d *Diagnostics) AsJSON() ([]byte, error)
AsJSON returns the diagnostic results as JSON for easy representation in an API or as JSON output in a CLI. This has no real use inside of a calling Go application that does not need to represent this data structure as JSON.
func (*Diagnostics) HasErrors ¶
func (d *Diagnostics) HasErrors() bool
HasErrors returns true if the underlying hcl.Diagnostics instance contains validation errors or fale if no errors were received.
func (*Diagnostics) RawDiagnostics ¶
func (d *Diagnostics) RawDiagnostics() hcl.Diagnostics
RawDiagnostics returns the raw hcl.Diagnostics instance received from the low-level HCL schema parser.
func (*Diagnostics) WriteText ¶
WriteText writes the output in a format easily understood by humans to the provided io.Writer. This is useful for showing the output of the diagnostics to end-users in a CLI environment but less useful when the caller is an application.
Setting the width to 0 disabled word wrapping. Setting the color to false will disable coloring of key information in the output. The output will contain relevant context such as line numbers and code snippets.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a single file that has been parsed by the Contaim bueprints parser.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents an instance of the blueprints parser that can be used to parse and validate various blueprint schemas used by the Contaim platform. You must create a new Parser instance using the exported New method.
func NewParser ¶
func NewParser() *Parser
NewParser creates a new instance of the Contaim blueprints parser and returns the newly created instance for parsing and validating Contaim blueprint schemas.
func (*Parser) AddParsedFile ¶
func (p *Parser) AddParsedFile(schema SchemaType, filename string, hcl *hcl.File, diags *Diagnostics)
AddParsedFile adds an already parsed hcl.File for a given schema to the processed map allowing files processed outside of this parser to be merged with files parsed within the parser itself.
func (*Parser) ParseFile ¶
func (p *Parser) ParseFile(schema SchemaType, filename string) *Diagnostics
ParseFile is a generic file parser that determines what underlying file type is being provided based on the extension and then runs that specific parsing function, returning any diagnostics received while parsing the structure.
func (*Parser) ParseHCL ¶
func (p *Parser) ParseHCL(schema SchemaType, src []byte, filename string) *Diagnostics
ParseHCL parses the provided source as HCL, returning any diagnostics encountered when parsing the structure.
func (*Parser) ParseHCLFile ¶
func (p *Parser) ParseHCLFile(schema SchemaType, filename string) *Diagnostics
ParseHCLFile reads the file at the given path and parses the source as HCL, returning any diagnostics encountered when parsing the structure.
func (*Parser) ParseJSON ¶
func (p *Parser) ParseJSON(schema SchemaType, src []byte, filename string) *Diagnostics
ParseJSON parses the provided source as JSON, returning any diagnostics enountered whwn parsing the structure.
func (*Parser) ParseJSONFile ¶
func (p *Parser) ParseJSONFile(schema SchemaType, filename string) *Diagnostics
ParseJSONFile reads the file at the given path and parses the source as HCL, returning any diagnostics encountered when parsing the structure.
func (*Parser) ProcessDiagnostics ¶
func (p *Parser) ProcessDiagnostics(schema SchemaType, filename string) *Diagnostics
ProcessDiagnostics processews the filename provided using the specified schema, returning a Diagnostics instance containing the warnings and errors (if any) from parsing the schema.
type SchemaType ¶
type SchemaType int
SchemaType represents a single schema type supported by Contaim for validating many types using this single parse API.
const ( // GameSchema is the blueprint schema used to define how a game server is ran and configured on the // Contaim platform. GameSchema SchemaType = iota )
Constants used to specify the schema type being parsed and/or validated.