parser

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	File       = "file"
	Yaml       = "yaml"
	Properties = "properties"
	Ini        = "ini"
	Json       = "json"
	Xml        = "xml"
)

The file parsing options that are available for a server configuration file.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigurationFile

type ConfigurationFile struct {
	FileName string                         `json:"file"`
	Parser   ConfigurationParser            `json:"parser"`
	Replace  []ConfigurationFileReplacement `json:"replace"`
	// contains filtered or unexported fields
}

Defines a configuration file for the server startup. These will be looped over and modified before the server finishes booting.

func (*ConfigurationFile) IterateOverJson

func (f *ConfigurationFile) IterateOverJson(data []byte) (*gabs.Container, error)

Iterate over an unstructured JSON/YAML/etc. interface and set all of the required key/value pairs for the configuration file.

We need to support wildcard characters in key searches, this allows you to make modifications to multiple keys at once, especially useful for games with multiple configurations per-world (such as Spigot and Bungeecord) where we'll need to make adjustments to the bind address for the user.

This does not currently support nested wildcard matches. For example, foo.*.bar will work, however foo.*.bar.*.baz will not, since we'll only be splitting at the first wildcard, and not subsequent ones.

func (*ConfigurationFile) LookupConfigurationValue

func (f *ConfigurationFile) LookupConfigurationValue(cfr ConfigurationFileReplacement) (string, error)

Looks up a configuration value on the Daemon given a dot-notated syntax.

func (*ConfigurationFile) Parse

func (f *ConfigurationFile) Parse(path string, internal bool) error

Parses a given configuration file and updates all of the values within as defined in the API response from the Panel.

func (*ConfigurationFile) UnmarshalJSON

func (f *ConfigurationFile) UnmarshalJSON(data []byte) error

Custom unmarshaler for configuration files. If there is an error while parsing out the replacements, don't fail the entire operation, just log a global warning so someone can find the issue, and return an empty array of replacements.

I imagine people will notice configuration replacement isn't working correctly and then the logs should help better expose that issue.

type ConfigurationFileReplacement

type ConfigurationFileReplacement struct {
	Match       string       `json:"match"`
	IfValue     string       `json:"if_value"`
	ReplaceWith ReplaceValue `json:"replace_with"`
}

Defines a single find/replace instance for a given server configuration file.

func (*ConfigurationFileReplacement) SetAtPathway

func (cfr *ConfigurationFileReplacement) SetAtPathway(c *gabs.Container, path string, value []byte) error

Sets the value at a specific pathway, but checks if we were looking for a specific value or not before doing it.

func (*ConfigurationFileReplacement) UnmarshalJSON

func (cfr *ConfigurationFileReplacement) UnmarshalJSON(data []byte) error

Handles unmarshaling the JSON representation into a struct that provides more useful data to this functionality.

type ConfigurationParser

type ConfigurationParser string

func (ConfigurationParser) String

func (cp ConfigurationParser) String() string

type ReplaceValue

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

func (*ReplaceValue) String

func (cv *ReplaceValue) String() string

func (*ReplaceValue) Type

func (cv *ReplaceValue) Type() jsonparser.ValueType

func (*ReplaceValue) Value

func (cv *ReplaceValue) Value() []byte

Jump to

Keyboard shortcuts

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