crossplane

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	File   string        `json:"file"`
	Status string        `json:"status"`
	Errors []ConfigError `json:"errors"`
	Parsed []Directive   `json:"parsed"`
}

type ConfigError

type ConfigError struct {
	Line  *int   `json:"line"`
	Error string `json:"error"`
}

type Directive

type Directive struct {
	Directive string       `json:"directive"`
	Line      int          `json:"line"`
	Args      []string     `json:"args"`
	Includes  *[]int       `json:"includes,omitempty"`
	Block     *[]Directive `json:"block,omitempty"`
	Comment   *string      `json:"comment,omitempty"`
}

func (Directive) IsBlock

func (d Directive) IsBlock() bool

IsBlock returns true if this is a block directive.

func (Directive) IsComment

func (d Directive) IsComment() bool

IsComment returns true iff the directive represents a comment.

func (Directive) IsInclude

func (d Directive) IsInclude() bool

IsInclude returns true if this is an include directive.

type ParseError

type ParseError struct {
	// contains filtered or unexported fields
}

func (ParseError) Error

func (e ParseError) Error() string

type ParseOptions

type ParseOptions struct {
	// If true, parsing will stop immediately if an error is found.
	StopParsingOnError bool

	// An array of directives to skip over and not include in the payload.
	IgnoreDirectives []string

	// 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

	// 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)
}

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"`
}

func Parse

func Parse(filename string, options *ParseOptions) (*Payload, error)

Parse parses an NGINX configuration file.

func ParseString

func ParseString(conf string, options *ParseOptions) (*Payload, error)

Parse nginx from string

func (Payload) Combined

func (p Payload) Combined() (*Payload, error)

Combined returns a new Payload that is the same except that the inluding logic is performed on its configs. This means that the resulting Payload will always have 0 or 1 configs in its Config field.

type PayloadError

type PayloadError struct {
	File     string      `json:"file"`
	Line     *int        `json:"line"`
	Error    string      `json:"error"`
	Callback interface{} `json:"callback,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL