egg

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

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

View Source
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.

View Source
const MaxSize = 4 << 20

MaxSize is the largest egg export Parse accepts.

Variables

View Source
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.

View Source
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.

View Source
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 Parse

func Parse(data []byte) (*Egg, []Warning, error)

Parse decodes and checks an egg export.

func SplitRules

func SplitRules(s string) []string

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.

func Diff

func Diff(a, b *Egg) []Change

Diff lists what an update from a to b changes, in a fixed field order.

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 Format

type Format string

Format is the export format named in meta.version.

const (
	PTDLv1 Format = "PTDL_v1"
	PTDLv2 Format = "PTDL_v2"
	PLCNv1 Format = "PLCN_v1"
	PLCNv2 Format = "PLCN_v2"
	PLCNv3 Format = "PLCN_v3"
)

type Image

type Image struct {
	Name string `json:"name"`
	Ref  string `json:"ref"`
}

Image is one selectable Docker image, in the order the egg lists them.

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

func (r Rules) MarshalJSON() ([]byte, error)

MarshalJSON keeps only the public parts.

func (Rules) Validate

func (r Rules) Validate(v string) error

Validate checks a value the way Laravel would for a single input.

type StartupCommand

type StartupCommand struct {
	Name    string `json:"name"`
	Command string `json:"command"`
}

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.

type Warning

type Warning struct {
	Code    string `json:"code"`
	Field   string `json:"field"`
	Message string `json:"message"`
}

Warning is a non-fatal problem found while parsing.

Jump to

Keyboard shortcuts

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