Documentation
¶
Overview ¶
Package importer moves data from other panels into Ammonode: Pterodactyl (users, nodes, allocations, eggs, servers — following Calagopus' importer), and Paymenter or WHMCS (customers, products, services, invoices, payments, credit — following Paymenter's WHMCS importer). Everything is read first, problems are collected in a report, and the writes happen in one database transaction that a dry run rolls back.
Index ¶
- Variables
- func DecryptLaravel(key []byte, payload string) (string, error)
- func LaravelKey(appKey string) ([]byte, error)
- func ParseEnv(path string) (map[string]string, error)
- func ParseMoney(s string, zeroDecimal bool) (int64, error)
- type Issue
- type MySQL
- type Options
- type Report
- func Paymenter(ctx context.Context, pool *pgxpool.Pool, envPath string, opts Options) (*Report, error)
- func Pterodactyl(ctx context.Context, pool *pgxpool.Pool, envPath string, opts Options) (*Report, error)
- func WHMCS(ctx context.Context, pool *pgxpool.Pool, cfg MySQL, opts Options) (*Report, error)
Constants ¶
This section is empty.
Variables ¶
var ErrAborted = errors.New("some rows cannot be imported (see the report); fix them in the source, or run with --on-invalid=skip")
ErrAborted means rows would be skipped and --on-invalid=abort is in effect.
Functions ¶
func DecryptLaravel ¶
DecryptLaravel decrypts a value from Laravel's encrypter (AES-256-CBC, HMAC-SHA256 MAC), unwrapping PHP serialization of strings.
func LaravelKey ¶
LaravelKey decodes APP_KEY ("base64:..." or raw).
Types ¶
type Issue ¶
type Issue struct {
Entity string `json:"entity"` // user, node, egg, server, product, service, invoice, ...
SourceID string `json:"source_id"` // the row's ID in the source panel
Problem string `json:"problem"`
// Action: "skipped" (the row is not imported; fails the import with --on-invalid=abort),
// "fixed" (imported with a change), or "note" (imported; something does not carry over).
Action string `json:"action"`
}
Issue is one problem found in the source data.
type MySQL ¶
type MySQL struct {
Host, Port, User, Password, Database string
}
MySQL describes a source database.
func WHMCSConfig ¶
WHMCSConfig reads the database settings from WHMCS's configuration.php.
type Options ¶
type Options struct {
DryRun bool
// OnInvalid: "abort" (default) refuses to write when any row must be skipped;
// "skip" imports everything else.
OnInvalid string
// Force imports into a panel that already has data of the same kind.
Force bool
// UnlimitedMemoryMB replaces "unlimited" memory (0) of source servers (Ammonode needs a limit).
UnlimitedMemoryMB int
}
Options control an import.
type Report ¶
type Report struct {
Source string `json:"source"`
DryRun bool `json:"dry_run"`
Started time.Time `json:"started"`
Finished time.Time `json:"finished"`
Imported map[string]int `json:"imported"` // rows written per entity
Linked map[string]int `json:"linked"` // rows matched to existing data (e.g. users by email)
Issues []Issue `json:"issues"`
}
Report is the outcome of an import (also written as JSON with --report).
func Paymenter ¶
func Paymenter(ctx context.Context, pool *pgxpool.Pool, envPath string, opts Options) (*Report, error)
Paymenter imports a Paymenter (v1) installation through its .env: users (passwords and 2FA keep working), credit, categories/products/plans, services, invoices and payments. Run the Pterodactyl import first to link services to their game servers.
func Pterodactyl ¶
func Pterodactyl(ctx context.Context, pool *pgxpool.Pool, envPath string, opts Options) (*Report, error)
Pterodactyl imports a Pterodactyl panel through its .env (database + APP_KEY): users (password hashes and 2FA secrets keep working), nodes, allocations, nests/eggs (as blueprints), servers with their variables and limits, and mail settings. Server UUIDs are kept, so `ammonode-agent migrate-wings` can hand the files over on each node.
func WHMCS ¶
WHMCS imports clients (their WHMCS passwords keep working when stored as bcrypt), admins, credit, products with Pterodactyl module settings, services, invoices and transactions. Run the Pterodactyl import first to link services to their game servers.