Documentation
¶
Index ¶
- Constants
- type ConfigFile
- type ConfigurationFile
- func (f *ConfigurationFile) IterateOverJson(data []byte) ([]byte, error)
- func (f *ConfigurationFile) LookupConfigurationValue(cfr ConfigurationFileReplacement) (result string, err error)
- func (f *ConfigurationFile) Parse(file ConfigFile) error
- func (f *ConfigurationFile) UnmarshalJSON(data []byte) error
- func (f *ConfigurationFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error
- type ConfigurationFileReplacement
- type ConfigurationParser
- type ReplaceValue
- type ValueType
Constants ¶
const ( File = "file" Yaml = "yaml" Properties = "properties" Ini = "ini" Json = "json" Xml = "xml" Toml = "toml" )
The file parsing options that are available for a server configuration file.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigFile ¶
type ConfigFile interface {
io.Reader
io.Writer
io.Seeker
Name() string
Stat() (os.FileInfo, error)
Truncate(size int64) error
}
ConfigFile is the handle to a configuration file that is parsed and then rewritten in place. It is satisfied by both *os.File and filesystem.File.
type ConfigurationFile ¶
type ConfigurationFile struct {
FileName string `json:"file"`
Parser ConfigurationParser `json:"parser"`
Replace []ConfigurationFileReplacement `json:"replace"`
AllowCreateFile bool `json:"create_file"` // assumed true by unmarshal as it was the original behaviour
// contains filtered or unexported fields
}
ConfigurationFile 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) ([]byte, 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) (result string, err error)
Looks up a configuration value on the Daemon given a dot-notated syntax.
func (*ConfigurationFile) Parse ¶
func (f *ConfigurationFile) Parse(file ConfigFile) error
Parse parses a given configuration file and updates all the values within as defined in the API response from the Panel.
func (*ConfigurationFile) UnmarshalJSON ¶
func (f *ConfigurationFile) UnmarshalJSON(data []byte) error
UnmarshalJSON is a custom unmarshaler for configuration files. A replacement that fails to decode doesn't fail the entire operation: it is logged so someone can find the issue and skipped, and the other replacements are kept.
func (*ConfigurationFile) UnmarshalJSONFrom ¶
func (f *ConfigurationFile) UnmarshalJSONFrom(dec *jsontext.Decoder) error
UnmarshalJSONFrom decodes a configuration file in a single pass. A key whose value is null is treated as missing.
type ConfigurationFileReplacement ¶
type ConfigurationFileReplacement struct {
Match string `json:"match"`
IfValue string `json:"if_value"`
ReplaceWith ReplaceValue `json:"replace_with"`
}
ConfigurationFileReplacement defines a single find/replace instance for a given server configuration file.
func (*ConfigurationFileReplacement) UnmarshalJSON ¶
func (cfr *ConfigurationFileReplacement) UnmarshalJSON(data []byte) error
UnmarshalJSON handles unmarshaling the JSON representation into a struct that provides more useful data to this functionality.
func (*ConfigurationFileReplacement) UnmarshalJSONFrom ¶
func (cfr *ConfigurationFileReplacement) UnmarshalJSONFrom(dec *jsontext.Decoder) error
UnmarshalJSONFrom decodes a single replacement in one pass. "match" and "replace_with" are required; "if_value" is optional. Eggs that predate "replace_with" use the old "value" key, which is accepted as a fallback.
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) Bytes ¶
func (cv *ReplaceValue) Bytes() []byte
func (*ReplaceValue) String ¶
func (cv *ReplaceValue) String() string
String returns the value as a string representation.
func (*ReplaceValue) Type ¶
func (cv *ReplaceValue) Type() ValueType
Type returns the underlying data type for the Value field.
func (*ReplaceValue) Value ¶
func (cv *ReplaceValue) Value() []byte
Value returns the underlying value of the replacement. Strings are already unescaped, so a section sign sent as a JSON escape comes back as "§Foo". Other types are returned as their raw JSON text.