Documentation
¶
Index ¶
- Variables
- func CreateS3Client(cfg *config.Config) *s3.S3
- func DownloadFileWithProgress(url string, name string, filename string, timeout time.Duration) (err error)
- func ExtractDiskImageFromFile(imagepath string, tmpdir string) (diskimage string, err error)
- func FormatNBDSocketURI(socketPath string) string
- func FormatNBDTCPURI(host string, port int) string
- func GenerateErrorPayload(code string) (jsonResponse []byte)
- func GeneratePidFile(name string) (string, error)
- func GenerateSocketFile(name string) (string, error)
- func GenerateUniqueSocketFile(volname string) (string, error)
- func GenerateXMLPayload(locationName string, payload any) any
- func IsSocketURI(nbdURI string) bool
- func KillProcess(pid int) error
- func MarshalJsonPayload(input any, jsonData []byte) []byte
- func MarshalToXML(payload any) ([]byte, error)
- func ReadPidFile(name string) (int, error)
- func RemovePidFile(serviceName string) error
- func SafeInt64ToUint64(v int64) uint64
- func SafeIntToUint64(v int) uint64
- func SafeUint64ToInt64(v uint64) int64
- func StopProcess(serviceName string) error
- func UnmarshalJsonPayload(input any, jsonData []byte) []byte
- func ValidateErrorPayload(payload []byte) (responseError ec2.ResponseError, err error)
- func ValidateKeyPairName(name string) error
- func WaitForPidFileRemoval(instanceID string, timeout time.Duration) error
- func WritePidFile(name string, pid int) error
- type Images
Constants ¶
This section is empty.
Variables ¶
var AvailableImages = map[string]Images{ "debian-12-x86_64": { Name: "debian-12-x86_64", Description: "Debian 12 (Bookworm) x86_64 cloud image (generic cloud)", Distro: "debian", Version: "12", Arch: "x86_64", Platform: "Linux/UNIX", CreatedAt: time.Date(2025, 10, 6, 0, 0, 0, 0, time.UTC), URL: "https://cdimage.debian.org/cdimage/cloud/bookworm/latest/debian-12-generic-amd64.tar.xz", Checksum: "https://cdimage.debian.org/cdimage/cloud/bookworm/latest/SHA512SUMS", ChecksumType: "sha512", BootMode: "bios", Starred: true, }, "debian-12-arm64": { Name: "debian-12-arm64", Description: "Debian 12 (Bookworm) arm64 cloud image (generic cloud)", Distro: "debian", Version: "12", Arch: "arm64", Platform: "Linux/UNIX", CreatedAt: time.Date(2025, 10, 6, 0, 0, 0, 0, time.UTC), URL: "https://cdimage.debian.org/cdimage/cloud/bookworm/latest/debian-12-generic-arm64.tar.xz", Checksum: "https://cdimage.debian.org/cdimage/cloud/bookworm/latest/SHA512SUMS", ChecksumType: "sha512", BootMode: "bios", Starred: true, }, "ubuntu-24.04-x86_64": { Name: "ubuntu-24.04-x86_64", Description: "Ubuntu 24.04 LTS (Noble Numbat) x86_64 cloud image", Distro: "ubuntu", Version: "24.04", Arch: "x86_64", Platform: "Linux/UNIX", CreatedAt: time.Date(2025, 10, 6, 0, 0, 0, 0, time.UTC), URL: "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img", Checksum: "https://cloud-images.ubuntu.com/noble/current/SHA256SUMS", ChecksumType: "sha256", BootMode: "bios", Starred: false, }, "ubuntu-24.04-arm64": { Name: "ubuntu-24.04-arm64", Description: "Ubuntu 24.04 LTS (Noble Numbat) arm64 cloud image", Distro: "ubuntu", Version: "24.04", Arch: "arm64", Platform: "Linux/UNIX", CreatedAt: time.Date(2025, 10, 6, 0, 0, 0, 0, time.UTC), URL: "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-arm64.img", Checksum: "https://cloud-images.ubuntu.com/noble/current/SHA256SUMS", ChecksumType: "sha256", BootMode: "bios", Starred: false, }, "alpine-3.22.2-x86_64": { Name: "alpine-3.22.2-x86_64", Description: "Alpine Linux 3.22.2 x86_64 cloud image", Distro: "alpine", Version: "3.22.2", Arch: "x86_64", Platform: "Linux/UNIX", CreatedAt: time.Date(2025, 10, 6, 0, 0, 0, 0, time.UTC), URL: "https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/cloud/generic_alpine-3.22.2-x86_64-bios-cloudinit-r0.qcow2", Checksum: "https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/cloud/generic_alpine-3.22.2-x86_64-bios-cloudinit-r0.qcow2.sha512", ChecksumType: "sha512", BootMode: "bios", Starred: false, }, }
var ErrQCOWDetected = errors.New("qcow format detected")
Functions ¶
func ExtractDiskImageFromFile ¶
AMI / image extraction utils
func FormatNBDSocketURI ¶ added in v0.2.0
FormatNBDSocketURI formats a socket path as an NBD URI for QEMU. Returns format: nbd:unix:/path/to/socket.sock
func FormatNBDTCPURI ¶ added in v0.2.0
FormatNBDTCPURI formats a host:port as an NBD URI for QEMU. Returns format: nbd://host:port
func GenerateErrorPayload ¶
Generate JSON Error Payload
func GeneratePidFile ¶
func GenerateSocketFile ¶
GenerateSocketFile generates a socket file path for the given name. Deprecated: Use GenerateUniqueSocketFile for new code to ensure uniqueness.
func GenerateUniqueSocketFile ¶ added in v0.2.0
GenerateUniqueSocketFile generates a unique socket file path with unix nano timestamp. Format: nbd-{volname}-{unixnano}.sock This ensures each mount operation gets a unique socket path.
func GenerateXMLPayload ¶
wrapWithLocation decorates payload with the requested locationName tag.
func IsSocketURI ¶ added in v0.2.0
IsSocketURI returns true if the NBD URI is a Unix socket path. Socket URIs end with ".sock" or contain "unix:".
func KillProcess ¶
func MarshalJsonPayload ¶
func ReadPidFile ¶
func RemovePidFile ¶
func SafeInt64ToUint64 ¶ added in v0.2.0
SafeInt64ToUint64 converts int64 to uint64, returning 0 if negative
func SafeIntToUint64 ¶ added in v0.2.0
SafeIntToUint64 converts int to uint64, returning 0 if negative
func SafeUint64ToInt64 ¶ added in v0.2.0
SafeUint64ToInt64 converts uint64 to int64, capping at math.MaxInt64
func StopProcess ¶
func UnmarshalJsonPayload ¶
func ValidateErrorPayload ¶
func ValidateErrorPayload(payload []byte) (responseError ec2.ResponseError, err error)
Validate the payload is an ec2.ResponseError
func ValidateKeyPairName ¶
ValidateKeyPairName validates that a key pair name only contains allowed characters: - Uppercase A-Z - Lowercase a-z - Digits 0-9 - Hyphen (-) - Underscore (_) - Period (.) This prevents path traversal attacks and invalid characters like /etc/passwd, ../../../, etc. Returns ErrorInvalidKeyPairFormat if validation fails
func WaitForPidFileRemoval ¶
func WritePidFile ¶
Types ¶
type Images ¶
type Images struct {
Name string `json:"name"`
Description string `json:"description"`
Distro string `json:"distro"`
Version string `json:"version"`
Arch string `json:"arch"`
Platform string `json:"platform"`
CreatedAt time.Time `json:"created_at"`
URL string `json:"url"`
Checksum string `json:"checksum"`
ChecksumType string `json:"checksum_type"`
BootMode string `json:"boot_mode"`
Starred bool `json:"starred"`
}