util

package
v0.26.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const LOOP_CTL_GET_FREE = 0x4C82

LOOP_CTL_GET_FREE は新しい空きループデバイスを取得するための定数 通常、Linuxカーネルでは 0x4C82 です

Variables

This section is empty.

Functions

func Assign added in v0.9.1

func Assign[T any](dst **T, src *T)

ポインタがNULLでなければ代入するユーティリティ関数

func BoolPtr added in v0.9.1

func BoolPtr(b bool) *bool

ポインタ生成ユーティリティ関数群

func CreateAlpineInterfaces added in v0.23.0

func CreateAlpineInterfaces(requestConfig []api.NetworkInterface, mountPoint string) error

func CreateChannelDir added in v0.9.1

func CreateChannelDir(hostname string) (string, error)

ホストのチャネル用ディレクトリを作成

func CreateNetplanInterfaces added in v0.9.1

func CreateNetplanInterfaces(requestConfig []api.NetworkInterface, mountPoint string) error

NICの設定

func DeepCopy added in v0.9.1

func DeepCopy[T any](src T) (T, error)

DeepCopy performs a deep copy of a generic type T using JSON serialization.

func DerefStrPtr added in v0.14.1

func DerefStrPtr(ptr *string) string

DerefStrPtr returns the string value if ptr is not nil, otherwise "".

func GenerateRandomMAC added in v0.9.1

func GenerateRandomMAC() (net.HardwareAddr, error)

GenerateRandomMAC はランダムなMACアドレスを生成します

func Int64PtrConvMB added in v0.9.1

func Int64PtrConvMB(i uint64) *int64

func Int64PtrInt32 added in v0.9.1

func Int64PtrInt32(i uint64) *int32

func IntPtrInt added in v0.9.1

func IntPtrInt(i int) *int

func IntPtrInt32 added in v0.9.1

func IntPtrInt32(i int) *int32

func IntPtrInt64 added in v0.9.1

func IntPtrInt64(i int) *int64

func MountVolume added in v0.9.1

func MountVolume(v api.Volume) (string, string, error)

LVをマウントポイントへマウント 戻り値:

マウンポイントの絶対パス、使用しているループバックデバイス、エラー

func NameserverForDNSListenAddr added in v0.21.0

func NameserverForDNSListenAddr(dnsListenAddr string) string

NameserverForDNSListenAddr extracts the nameserver IP from a dns_listen_addr string (host:port). "0.0.0.0" and "" are normalized to "127.0.0.1".

func OrDefault added in v0.9.1

func OrDefault[T any](p *T, d T) T

ポインタがNULLの時、デフォルト値取得ユーティリティ関数

func PatchStruct added in v0.9.1

func PatchStruct(dst, src interface{})

src の非ゼロ値フィールドだけを dst にコピーする dst と src は同じ型であることを想定

func RemoveChannelDir added in v0.9.1

func RemoveChannelDir(hostname string) error

ホストのチャネル用ディレクトリを削除

func SetDebugMode added in v0.24.0

func SetDebugMode(enabled bool)

SetDebugMode toggles debug-only prints in pkg/util.

func SetupAlpineLinux added in v0.23.0

func SetupAlpineLinux(spec api.Server) error

func SetupHostBridge added in v0.15.1

func SetupHostBridge() bool

SetupHostBridge checks and configures host bridge for marmot Returns true if bridge was successfully set up, false otherwise

func SetupLinux added in v0.9.1

func SetupLinux(spec api.Server) error

func SetupLocalResolver added in v0.15.3

func SetupLocalResolver(dnsListenAddr string) error

SetupLocalResolver disables systemd-resolved and rewrites /etc/resolv.conf for marmot internal DNS. If /etc/resolv.conf already has a nameserver entry that matches the IP derived from dnsListenAddr, it skips the rewrite entirely.

func StringPtr added in v0.9.1

func StringPtr(s string) *string

func TimePtr added in v0.9.1

func TimePtr(t time.Time) *time.Time

func UnMountVolume added in v0.9.1

func UnMountVolume(v api.Volume, mountPoint string, nbdDevice string) error

LVをアンマウント

Types

type Bridge added in v0.24.0

type Bridge struct {
	Interfaces  []string         `yaml:"interfaces,omitempty"`
	Addresses   []string         `yaml:"addresses,omitempty"`
	DHCP4       bool             `yaml:"dhcp4"`
	DHCP6       bool             `yaml:"dhcp6"`
	Routes      []Route          `yaml:"routes,omitempty"`
	Nameservers Nameserver       `yaml:"nameservers,omitempty"`
	Parameters  BridgeParameters `yaml:"parameters,omitempty"`
}

type BridgeParameters added in v0.24.0

type BridgeParameters struct {
	STP bool `yaml:"stp"`
}

type Ethernet added in v0.9.1

type Ethernet struct {
	Addresses   []string   `yaml:"addresses,omitempty"`
	DHCP4       bool       `yaml:"dhcp4"`
	DHCP6       bool       `yaml:"dhcp6"`
	Routes      []Route    `yaml:"routes,omitempty"`
	Nameservers Nameserver `yaml:"nameservers,omitempty"`
}

type Nameserver added in v0.9.1

type Nameserver struct {
	Addresses []string `yaml:"addresses,omitempty"`
	Search    []string `yaml:"search,omitempty"`
}

type NetplanConfig added in v0.9.1

type NetplanConfig struct {
	Network Network `yaml:"network"`
}

NetplanConfig は Netplan のルート構造体

type Network added in v0.9.1

type Network struct {
	Version   int                 `yaml:"version"`
	Renderer  string              `yaml:"renderer,omitempty"`
	Ethernets map[string]Ethernet `yaml:"ethernets,omitempty"`
	Bridges   map[string]Bridge   `yaml:"bridges,omitempty"`
}

type Route added in v0.9.1

type Route struct {
	To  string `yaml:"to"`
	Via string `yaml:"via"`
}

Jump to

Keyboard shortcuts

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