Documentation
¶
Overview ¶
Package contract defines the recovery contract schema for RestoreLab. A contract describes what to restore, how to restore it, and how to verify it works. Contracts are YAML files parsed into these types.
Index ¶
Constants ¶
const ( KiB ByteSize = 1024 MiB = 1024 * KiB GiB = 1024 * MiB )
const ( SupportedVersion = 1 SupportedProvider = "restic" SupportedEngine = "postgres" SupportedFormat = "custom" SupportedNetwork = "internal" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ByteSize ¶
type ByteSize int64
ByteSize is a size in bytes.
func ParseByteSize ¶
ParseByteSize parses strings like "20GiB", "512MiB", "100MiB". Supported suffixes: KiB, MiB, GiB. No suffix means bytes.
type Check ¶
type Check struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
Query string `yaml:"query"`
Expect CheckExpect `yaml:"expect"`
}
Check is a single SQL validation step.
type CheckExpect ¶
type CheckExpect struct {
Value any `yaml:"value,omitempty"`
Type string `yaml:"type,omitempty"`
GreaterThan *int `yaml:"greater_than,omitempty"`
}
CheckExpect describes the expected outcome of a check.
type Cleanup ¶
type Cleanup struct {
Always bool `yaml:"always"`
RemoveVolumes bool `yaml:"remove_volumes"`
ForceRemove bool `yaml:"force_remove"`
}
Cleanup describes how to clean up after the test.
type Contract ¶
type Contract struct {
Version int `yaml:"version"`
Name string `yaml:"name"`
Description string `yaml:"description,omitempty"`
Source Source `yaml:"source"`
Restore Restore `yaml:"restore"`
Test Test `yaml:"test"`
Isolation Isolation `yaml:"isolation"`
Limits Limits `yaml:"limits"`
Cleanup Cleanup `yaml:"cleanup"`
}
Contract is the root of a recovery contract YAML document.
type Isolation ¶
type Isolation struct {
Network string `yaml:"network"`
PublishPorts bool `yaml:"publish_ports"`
BlockExternalNetwork bool `yaml:"block_external_network"`
InspectOnly bool `yaml:"inspect_only,omitempty"`
}
Isolation describes network and sandbox isolation requirements.
type Limits ¶
type Limits struct {
MaxArtifactSize string `yaml:"max_artifact_size"`
Timeout string `yaml:"timeout"`
Memory string `yaml:"memory"`
Pids int `yaml:"pids"`
ShmSize string `yaml:"shm_size,omitempty"`
}
Limits describes resource constraints for the sandbox.
type Restore ¶
type Restore struct {
Format string `yaml:"format"`
}
Restore describes the format of the artifact to restore.
type Source ¶
type Source struct {
Provider string `yaml:"provider"`
RepositoryEnv string `yaml:"repository_env"`
PasswordFileEnv string `yaml:"password_file_env"`
Snapshot string `yaml:"snapshot"`
Path string `yaml:"path"`
NoLock bool `yaml:"no_lock,omitempty"`
}
Source describes where the backup lives and how to access it.
type Test ¶
type Test struct {
Engine string `yaml:"engine"`
Image string `yaml:"image"`
Database string `yaml:"database"`
Username string `yaml:"username"`
PasswordEnv string `yaml:"password_env"`
RestoreOptions []string `yaml:"restore_options,omitempty"`
Checks []Check `yaml:"checks"`
}
Test describes how to validate the restored database.