Documentation
¶
Index ¶
- Constants
- Variables
- func Build(w io.Writer, config Config, options *BuildOptions) error
- func BuildFiles(payload Payload, dir string, options *BuildOptions) error
- func BuildInto(payload *Payload, into Creator, options *BuildOptions) error
- func Enquote(arg string) string
- func Lex(reader io.Reader) chan NgxToken
- func SetTokenChanCap(size int)
- type BuildOptions
- type Config
- type ConfigError
- type Creator
- type Directive
- type Directives
- type FileString
- type NgxToken
- type ParseError
- type ParseOptions
- type Payload
- type PayloadError
- type StringsCreator
Constants ¶
View Source
const MaxIndent = 100
View Source
const TokenChanCap = 2048
Variables ¶
View Source
var (
ErrPrematureLexEnd = errors.New("premature end of file")
)
Functions ¶
func Build ¶
func Build(w io.Writer, config Config, options *BuildOptions) error
Build creates an NGINX config from a crossplane.Config.
func BuildFiles ¶
func BuildFiles(payload Payload, dir string, options *BuildOptions) error
BuildFiles builds all of the config files in a crossplane.Payload and writes them to disk.
func BuildInto ¶
func BuildInto(payload *Payload, into Creator, options *BuildOptions) error
BuildInto builds all of the config files in a crossplane.Payload and writes them to the Creator.
func SetTokenChanCap ¶
func SetTokenChanCap(size int)
note: this is only used during tests, should not be changed
Types ¶
type BuildOptions ¶
type Config ¶
type Config struct { File string `json:"file"` Status string `json:"status"` Errors []ConfigError `json:"errors"` Parsed Directives `json:"parsed"` }
type ConfigError ¶
type Creator ¶
type Creator interface { Create(string) (io.WriteCloser, error) Reset() }
Creator abstracts file creation (to write configs to something other than files).
type Directive ¶
type Directive struct { Directive string `json:"directive"` Line int `json:"line"` Args []string `json:"args"` File string `json:"file,omitempty"` Includes []int `json:"includes,omitempty"` Block Directives `json:"block,omitempty"` Comment *string `json:"comment,omitempty"` }
type Directives ¶
type Directives []*Directive
type FileString ¶
type FileString struct { Name string // contains filtered or unexported fields }
FileString is a string representation of a file.
type ParseError ¶
type ParseError struct { What string File *string Line *int // Raw directive statement causing the parse error. Statement string // Block in which parse error occurred. BlockCtx string // contains filtered or unexported fields }
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) MarshalJSON ¶
func (e *ParseError) MarshalJSON() ([]byte, error)
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type ParseOptions ¶
type ParseOptions struct { // An array of directives to skip over and not include in the payload. IgnoreDirectives []string // If an error is found while parsing, it will be passed to this callback // function. The results of the callback function will be set in the // PayloadError struct that's added to the Payload struct's Errors array. ErrorCallback func(error) interface{} // If specified, use this alternative to open config files Open func(path string) (io.Reader, error) // Glob will return a matching list of files if specified Glob func(path string) ([]string, error) // If true, parsing will stop immediately if an error is found. StopParsingOnError bool // If true, include directives are used to combine all of the Payload's // Config structs into one. CombineConfigs bool // If true, only the config file with the given filename will be parsed // and Parse will not parse files included files. SingleFile bool // If true, comments will be parsed and added to the resulting Payload. ParseComments bool // If true, add an error to the payload when encountering a directive that // is unrecognized. The unrecognized directive will not be included in the // resulting Payload. ErrorOnUnknownDirectives bool // If true, checks that directives are in valid contexts. SkipDirectiveContextCheck bool // If true, checks that directives have a valid number of arguments. SkipDirectiveArgsCheck bool }
ParseOptions determine the behavior of an NGINX config parse.
type Payload ¶
type Payload struct { Status string `json:"status"` Errors []PayloadError `json:"errors"` Config []Config `json:"config"` }
type PayloadError ¶
type StringsCreator ¶
type StringsCreator struct {
Files []*FileString
}
StringsCreator is an option for rendering config files to strings(s).
func (*StringsCreator) Create ¶
func (sc *StringsCreator) Create(file string) (io.WriteCloser, error)
Create makes this a Creator.
func (*StringsCreator) Reset ¶
func (sc *StringsCreator) Reset()
Reset returns the Creator to its initial state.
Click to show internal directories.
Click to hide internal directories.