Documentation
¶
Overview ¶
Package egg parses Pterodactyl and Pelican egg exports into one normalised form.
Supported formats: PTDL_v1, PTDL_v2 (Pterodactyl) and PLCN_v1..PLCN_v3 (Pelican). Parse rejects eggs that cannot run and reports softer problems as warnings, so an admin can still import an egg whose variable defaults, say, do not pass its own rules.
The package depends on the standard library only, so it can later move into a module shared with the agent.
Index ¶
Constants ¶
const ( WarnUnsupportedRule = "unsupported_rule" WarnDefaultInvalid = "default_invalid" WarnUnknownParser = "unknown_parser" WarnUnknownFeature = "unknown_feature" WarnUnknownPlaceholder = "unknown_placeholder" WarnReservedEnv = "reserved_env" WarnDuplicateEnv = "duplicate_env" WarnNoStop = "no_stop" WarnNoDone = "no_done_marker" WarnNoInstallScript = "no_install_script" WarnImagesList = "docker_images_list" // WarnRequiredNoDefault is informational: the user must provide the value (e.g. a bot token). WarnRequiredNoDefault = "required_no_default" )
Warning codes.
const MaxSize = 4 << 20
MaxSize is the largest egg export Parse accepts.
Variables ¶
var BuiltinEnv = map[string]bool{ "SERVER_MEMORY": true, "SERVER_IP": true, "SERVER_PORT": true, "TZ": true, "P_SERVER_LOCATION": true, "P_SERVER_UUID": true, "P_SERVER_ALLOCATION_LIMIT": true, }
BuiltinEnv are variables the agent always provides; startup commands may use them.
var KnownFeatures = map[string]bool{"eula": true, "java_version": true, "pid_limit": true, "gsl_token": true, "steam_disk_space": true}
KnownFeatures are features the UI has helpers for.
var KnownParsers = map[string]bool{"properties": true, "ini": true, "yaml": true, "json": true, "xml": true, "file": true}
KnownParsers are the config file parsers the agent implements.
Functions ¶
func SplitRules ¶
SplitRules splits a rule string on "|" while keeping regex patterns that contain "|" intact.
Types ¶
type Change ¶
type Change struct {
Field string `json:"field"`
Kind string `json:"kind"` // added, removed, changed
Before string `json:"before,omitempty"`
After string `json:"after,omitempty"`
}
Change is one difference between two versions of an egg.
type ConfigFile ¶
type ConfigFile struct {
Path string `json:"path"`
Parser string `json:"parser"` // properties, ini, yaml, json, xml, file
Find json.RawMessage `json:"find"` // kept verbatim; interpreted by the agent
}
ConfigFile is one file the agent rewrites before every start.
type Egg ¶
type Egg struct {
Format Format `json:"format"`
UUID string `json:"uuid,omitempty"`
Name string `json:"name"`
Author string `json:"author,omitempty"`
Description string `json:"description,omitempty"`
UpdateURL string `json:"update_url,omitempty"`
Icon string `json:"icon,omitempty"` // data: URI (Pelican v3)
Features []string `json:"features"`
Tags []string `json:"tags"`
Images []Image `json:"images"`
Startup []StartupCommand `json:"startup"`
FileDenylist []string `json:"file_denylist"`
Stop Stop `json:"stop"`
DoneMarkers []string `json:"done_markers"`
ConfigFiles []ConfigFile `json:"config_files"`
Install Install `json:"install"`
Variables []Variable `json:"variables"`
}
Egg is the normalised form of an egg export.
type Install ¶
type Install struct {
Container string `json:"container"`
Entrypoint string `json:"entrypoint"`
Script string `json:"script"`
}
Install is the installation script and the container it runs in (with /mnt/server mounted).
type Rules ¶
type Rules struct {
Raw []string `json:"raw"`
Required bool `json:"required"`
Nullable bool `json:"nullable"`
Numeric bool `json:"numeric"` // size rules compare numbers instead of lengths
Unsupported []string `json:"unsupported,omitempty"`
// contains filtered or unexported fields
}
Rules is a parsed Laravel-style validation rule set, e.g. "required|string|max:20". Values are validated as the strings they become in the environment.
func ParseRules ¶
func ParseRules(raw json.RawMessage) (Rules, []string)
ParseRules parses rules given as a "|"-separated string or as a list of strings. Rules the panel cannot enforce are recorded in Unsupported and returned as warnings; they never make an egg fail to import.
func (Rules) MarshalJSON ¶
MarshalJSON keeps only the public parts.
type StartupCommand ¶
StartupCommand is a named start command. Pterodactyl eggs have exactly one ("Default").
type Stop ¶
type Stop struct {
Command string `json:"command,omitempty"`
Signal string `json:"signal,omitempty"` // "SIGINT" for the egg value "^C"
}
Stop describes how to stop the server: a console command, or a signal when Signal is set.
type Variable ¶
type Variable struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Env string `json:"env"`
Default string `json:"default"`
UserViewable bool `json:"user_viewable"`
UserEditable bool `json:"user_editable"`
Rules Rules `json:"rules"`
}
Variable is an environment variable the server can be configured with.