oscommon

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EtcMachineID  = "/etc/machine-id"
	DbusMachineID = "/var/lib/dbus/machine-id"
)
View Source
const (
	DefaultGrubPath = "/etc/default/grub"
)
View Source
const (
	EtcHostsPath = "/etc/hosts"
)
View Source
const (
	HostnameFilePath = "/etc/hostname"
)
View Source
const (
	MetalUser = "metal"
)
View Source
const (
	ResolvConfPath = "/etc/resolv.conf"
)
View Source
const (
	TimesyncdConfigPath = "/etc/systemd/timesyncd.conf"
)
View Source
const (
	UserdataPath = "/etc/metal/userdata"
)

Variables

This section is empty.

Functions

func FileExists

func FileExists(fs *afero.Afero, filename string) bool

Types

type CommonTasks

type CommonTasks struct {
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) *CommonTasks

func (*CommonTasks) BootloaderID

func (d *CommonTasks) BootloaderID() string

func (*CommonTasks) BuildCMDLine

func (d *CommonTasks) BuildCMDLine(ctx context.Context) (string, error)

func (*CommonTasks) ConfigureNetwork

func (d *CommonTasks) ConfigureNetwork(ctx context.Context) error

func (*CommonTasks) CopySSHKeys

func (d *CommonTasks) CopySSHKeys(ctx context.Context) error

func (*CommonTasks) CreateMetalUser

func (d *CommonTasks) CreateMetalUser(ctx context.Context, sudoGroup string) error

func (*CommonTasks) FigureOutSerialSpeed

func (d *CommonTasks) FigureOutSerialSpeed() (serialPort, serialSpeed string, err error)

func (*CommonTasks) FixPermissions

func (d *CommonTasks) FixPermissions(ctx context.Context) error

func (*CommonTasks) GetKernelVersion

func (d *CommonTasks) GetKernelVersion(initramdiskFormatString string) (string, error)

func (*CommonTasks) GrubInstall

func (d *CommonTasks) GrubInstall(ctx context.Context, bootloaderID, cmdLine string) error

func (*CommonTasks) InitramdiskFormatString

func (d *CommonTasks) InitramdiskFormatString() string

func (*CommonTasks) KernelAndInitrdPath

func (d *CommonTasks) KernelAndInitrdPath(initramdiskFormatString string) (kern string, initrd string, err error)

func (*CommonTasks) ProcessUserdata

func (d *CommonTasks) ProcessUserdata(ctx context.Context) error

func (*CommonTasks) SudoGroup

func (d *CommonTasks) SudoGroup() string

func (*CommonTasks) SystemdServices

func (d *CommonTasks) SystemdServices(ctx context.Context) error

func (*CommonTasks) UnsetMachineID

func (d *CommonTasks) UnsetMachineID(ctx context.Context) error

func (*CommonTasks) WriteBootInfo

func (d *CommonTasks) WriteBootInfo(ctx context.Context, initramdiskFormatString, bootloaderID, cmdLine string) error

func (*CommonTasks) WriteBuildMeta

func (d *CommonTasks) WriteBuildMeta(ctx context.Context) error

func (*CommonTasks) WriteHostname

func (d *CommonTasks) WriteHostname(ctx context.Context) error

func (*CommonTasks) WriteHosts

func (d *CommonTasks) WriteHosts(ctx context.Context) error

func (*CommonTasks) WriteNTPConf

func (d *CommonTasks) WriteNTPConf(ctx context.Context) error

func (*CommonTasks) WriteNtpConfToPath

func (d *CommonTasks) WriteNtpConfToPath(configPath string, ntpServers []string) error

func (*CommonTasks) WriteResolvConf

func (d *CommonTasks) WriteResolvConf(ctx context.Context) error

type Config

type Config struct {
	Log            *slog.Logger
	Fs             *afero.Afero
	Exec           *exec.CmdExecutor
	MachineDetails *v1.MachineDetails
	Allocation     *apiv2.MachineAllocation
	LookupUserFn   LookupUserFn

	// customization options from installer config
	Name         *string
	BootloaderID *string
}

type DefaultOS

type DefaultOS struct {
	*CommonTasks
	// contains filtered or unexported fields
}

func NewDefaultOS

func NewDefaultOS(cfg *Config) *DefaultOS

func (*DefaultOS) BootloaderID

func (o *DefaultOS) BootloaderID() string

func (*DefaultOS) CreateMetalUser

func (o *DefaultOS) CreateMetalUser(ctx context.Context) error

func (*DefaultOS) GrubInstall

func (o *DefaultOS) GrubInstall(ctx context.Context, cmdLine string) error

func (*DefaultOS) WriteBootInfo

func (o *DefaultOS) WriteBootInfo(ctx context.Context, cmdLine string) error

type LookupUserFn

type LookupUserFn func(name string) (*user.User, error)

type OperatingSystem

type OperatingSystem interface {
	WriteHostname(ctx context.Context) error
	WriteHosts(ctx context.Context) error
	WriteResolvConf(ctx context.Context) error
	WriteNTPConf(ctx context.Context) error
	CreateMetalUser(ctx context.Context) error
	ConfigureNetwork(ctx context.Context) error
	CopySSHKeys(ctx context.Context) error
	FixPermissions(ctx context.Context) error
	ProcessUserdata(ctx context.Context) error
	BuildCMDLine(ctx context.Context) (string, error)
	WriteBootInfo(ctx context.Context, cmdLine string) error
	GrubInstall(ctx context.Context, cmdLine string) error
	UnsetMachineID(ctx context.Context) error
	SystemdServices(ctx context.Context) error
	WriteBuildMeta(ctx context.Context) error

	SudoGroup() string
	InitramdiskFormatString() string
	BootloaderID() string
}

Jump to

Keyboard shortcuts

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