Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigureNetwork(installChroot *safechroot.Chroot, systemConfig SystemConfig) (err error)
- func GetKernelCmdLineValue(option string) (cmdlineValue string, err error)
- func ParseKickStartPartitionScheme(partitionFile string) (retdisks []Disk, retpartitionSettings []PartitionSetting, err error)
- func SystemBootType() (bootType string)
- func UpdatePackageRepo(installChroot *safechroot.Chroot, config SystemConfig) (err error)
- type Artifact
- type CGroup
- type Config
- func (c *Config) GetBootPartition() (partitionIndex int, partition *Partition)
- func (c *Config) GetDiskContainingPartition(partition *Partition) (disk *Disk)
- func (c *Config) GetDiskPartByID(ID string) (diskPart *Partition)
- func (c *Config) IsValid() (err error)
- func (c *Config) SetDefaultConfig()
- func (c *Config) UnmarshalJSON(b []byte) (err error)
- type Disk
- type FileConfig
- type FileConfigList
- type FilePermissions
- type Group
- type ImaPolicy
- type InstallScript
- type KernelCommandLine
- type MountIdentifier
- type Network
- type PackageRepo
- type Partition
- type PartitionFlag
- type PartitionSetting
- func FindMountpointPartitionSetting(partitionSettings []PartitionSetting, mountPoint string) (partitionSetting *PartitionSetting)
- func FindRootPartitionSetting(partitionSettings []PartitionSetting) (rootPartitionSetting *PartitionSetting)
- func GetDefaultPartitionSetting() (defaultVal PartitionSetting)
- type PartitionTableType
- func (p *PartitionTableType) ConvertToPartedArgument() (partedArgument string, err error)
- func (p *PartitionTableType) GetValidPartitionTableTypes() (types []PartitionTableType)
- func (p *PartitionTableType) IsValid() (err error)
- func (p PartitionTableType) String() string
- func (p *PartitionTableType) UnmarshalJSON(b []byte) (err error)
- type RawBinary
- type RootEncryption
- type SELinux
- type SystemConfig
- func (s *SystemConfig) GetMountpointPartitionSetting(mountPoint string) (partitionSetting *PartitionSetting)
- func (s *SystemConfig) GetRootPartitionSetting() (rootPartitionSetting *PartitionSetting)
- func (s *SystemConfig) IsRootFS() bool
- func (s *SystemConfig) IsValid() (err error)
- func (s *SystemConfig) UnmarshalJSON(b []byte) (err error)
- type TargetDisk
- type User
Constants ¶
const ( EFIPartitionType = "efi" LegacyPartitionType = "legacy" )
const (
SELinuxPolicyDefault = "selinux-policy"
)
Variables ¶
var ( DefaultFileConfig = FileConfig{ Path: "", Permissions: nil, } )
var PartitionTypeNameToUUID = map[string]string{
"linux": "0fc63daf-8483-4772-8e79-3d69d8477de4",
"esp": "c12a7328-f81f-11d2-ba4b-00a0c93ec93b",
"xbootldr": "bc13c2ff-59e6-4262-a352-b275fd6f7172",
"linux-root-amd64": "4f68bce3-e8cd-4db1-96e7-fbcaf984b709",
"linux-swap": "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f",
"linux-home": "933ac7e1-2eb4-4f13-b844-0e14e2aef915",
"linux-srv": "3b8f8425-20e0-4f3b-907f-1a25a76f98e8",
"linux-var": "4d21b016-b534-45c2-a9fb-5c16e091fd2d",
"linux-tmp": "7ec6f557-3bc5-4aca-b293-16ef5df639d1",
"linux-lvm": "e6d6d379-f507-44c2-a23c-238f2a3df928",
"linux-raid": "a19d880f-05fc-4d3b-a006-743f0f84911e",
"linux-luks": "ca7d7ccb-63ed-4c53-861c-1742536059cc",
"linux-dm-crypt": "7ffec5c9-2d00-49b7-8941-3ea10a5586b7",
}
Common partition types: https://wiki.archlinux.org/title/GPT_fdisk#Partition_type More type UUIDs can be found here: https://uapi-group.org/specifications/specs/discoverable_partitions_specification/
Functions ¶
func ConfigureNetwork ¶
func ConfigureNetwork(installChroot *safechroot.Chroot, systemConfig SystemConfig) (err error)
ConfigureNetwork performs network configuration during the installation process
func GetKernelCmdLineValue ¶
GetKernelCmdLineValue returns the output of a specific option setting in /proc/cmdline
func ParseKickStartPartitionScheme ¶
func ParseKickStartPartitionScheme(partitionFile string) (retdisks []Disk, retpartitionSettings []PartitionSetting, err error)
ParseKickStartPartitionScheme parses a kickstart-generated partition file and construct the Disk and PartitionSetting information
func SystemBootType ¶
func SystemBootType() (bootType string)
SystemBootType returns the current boot type of the system being ran on.
func UpdatePackageRepo ¶
func UpdatePackageRepo(installChroot *safechroot.Chroot, config SystemConfig) (err error)
UpdatePackageRepo creates additional repo files specified by image configuration and returns error if the operation fails
Types ¶
type Artifact ¶
type Artifact struct { Compression string `json:"Compression"` Name string `json:"Name"` Type string `json:"Type"` }
Artifact [non-ISO image building only] defines the name, type and optional compression of the output Azure Linux image.
type CGroup ¶
type CGroup string
CGroup sets the CGroup version
func (*CGroup) GetValidCGroup ¶
GetValidCGroup returns a list of all the supported cgroup version options
func (*CGroup) UnmarshalJSON ¶
UnmarshalJSON Unmarshals a CGroup entry
type Config ¶
type Config struct { // Values representing the contents of the config JSON file. Disks []Disk `json:"Disks"` SystemConfigs []SystemConfig `json:"SystemConfigs"` // Computed values not present in the config JSON. DefaultSystemConfig *SystemConfig // A system configuration with the "IsDefault" field set or the first system configuration if there is no explicit default. }
Config holds the parsed values of the configuration schemas as well as a few computed values simplifying access to certain pieces of the configuration.
func LoadWithAbsolutePaths ¶
LoadWithAbsolutePaths loads the config schema from a JSON file found under the 'configFilePath' and resolves all relative paths into absolute ones using 'baseDirPath' as a starting point for all relative paths.
func (*Config) GetBootPartition ¶
func (*Config) GetDiskContainingPartition ¶
GetDiskByPartition returns the disk containing the provided partition
func (*Config) GetDiskPartByID ¶
GetDiskPartByID returns the disk partition object with the desired ID, nil if no partition found
func (*Config) SetDefaultConfig ¶
func (c *Config) SetDefaultConfig()
func (*Config) UnmarshalJSON ¶
UnmarshalJSON Unmarshals a Config entry
type Disk ¶
type Disk struct { PartitionTableType PartitionTableType `json:"PartitionTableType"` MaxSize uint64 `json:"MaxSize"` TargetDisk TargetDisk `json:"TargetDisk"` Artifacts []Artifact `json:"Artifacts"` Partitions []Partition `json:"Partitions"` RawBinaries []RawBinary `json:"RawBinaries"` }
Disk holds the disk partitioning, formatting and size information. It may also define artifacts generated for each disk.
func (*Disk) UnmarshalJSON ¶
UnmarshalJSON Unmarshals a Disk entry
type FileConfig ¶
type FileConfig struct { // The file path in the target OS that the file will be copied to. Path string `json:"Path"` // The file permissions to set on the file. Permissions *FilePermissions `json:"Permissions"` }
FileConfig specifies options for how a file is copied in the target OS.
func (*FileConfig) IsValid ¶
func (f *FileConfig) IsValid() (err error)
func (*FileConfig) UnmarshalJSON ¶
func (f *FileConfig) UnmarshalJSON(b []byte) error
type FileConfigList ¶
type FileConfigList []FileConfig
DestinationFileConfigList is a list of destination files where the source file will be copied to in the final image. This type exists to allow a custom marshaller to be attached to it.
func (*FileConfigList) IsValid ¶
func (l *FileConfigList) IsValid() (err error)
func (*FileConfigList) UnmarshalJSON ¶
func (l *FileConfigList) UnmarshalJSON(b []byte) error
type FilePermissions ¶
The file permissions to set on the file.
Accepted formats:
- Octal string (e.g. "660")
func (*FilePermissions) IsValid ¶
func (p *FilePermissions) IsValid() (err error)
func (FilePermissions) MarshalJSON ¶
func (p FilePermissions) MarshalJSON() ([]byte, error)
func (*FilePermissions) UnmarshalJSON ¶
func (p *FilePermissions) UnmarshalJSON(b []byte) error
type ImaPolicy ¶
type ImaPolicy string
ImaPolicy sets the ima_policy kernel command line option
const ( // ImaPolicyTcb selects the tcb IMA policy ImaPolicyTcb ImaPolicy = "tcb" // ImaPolicyAppraiseTcb selects the appraise_tcb IMA policy ImaPolicyAppraiseTcb ImaPolicy = "appraise_tcb" // ImaPolicySecureBoot selects the secure_boot IMA policy ImaPolicySecureBoot ImaPolicy = "secure_boot" // ImaPolicyNone selects no IMA policy ImaPolicyNone ImaPolicy = "" )
func (*ImaPolicy) GetValidImaPolicies ¶
GetValidImaPolicies returns a list of all the supported disk partition types
func (*ImaPolicy) UnmarshalJSON ¶
UnmarshalJSON Unmarshals an ImaPolicy entry
type InstallScript ¶
InstallScript defines a script to be run before or after other installation steps and provides a way to pass parameters to it.
type KernelCommandLine ¶
type KernelCommandLine struct { CGroup CGroup `json:"CGroup"` ImaPolicy []ImaPolicy `json:"ImaPolicy"` SELinux SELinux `json:"SELinux"` SELinuxPolicy string `json:"SELinuxPolicy"` EnableFIPS bool `json:"EnableFIPS"` ExtraCommandLine string `json:"ExtraCommandLine"` }
KernelCommandLine holds extra command line parameters which can be added to the grub config file.
- ImaPolicy: A list of IMA policies which will be used together
- ExtraCommandLine: Arbitrary parameters which will be appended to the end of the kernel command line
func (*KernelCommandLine) GetSedDelimeter ¶
func (k *KernelCommandLine) GetSedDelimeter() (delimeter string)
GetSedDelimeter returns the delimeter which should be used with sed to find/replace the command line strings.
func (*KernelCommandLine) IsValid ¶
func (k *KernelCommandLine) IsValid() (err error)
IsValid returns an error if the KernelCommandLine is not valid
func (*KernelCommandLine) UnmarshalJSON ¶
func (k *KernelCommandLine) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON Unmarshals a KernelCommandLine entry
type MountIdentifier ¶
type MountIdentifier string
MountIdentifier indicates how a partition should be identified in the fstab file
const ( // MountIdentifierUuid mounts this partition via the filesystem UUID MountIdentifierUuid MountIdentifier = "uuid" // MountIdentifierPartUuid mounts this partition via the GPT/MBR PARTUUID MountIdentifierPartUuid MountIdentifier = "partuuid" // MountIdentifierPartLabel mounts this partition via the GPT PARTLABEL MountIdentifierPartLabel MountIdentifier = "partlabel" MountIdentifierDefault MountIdentifier = MountIdentifierPartUuid MountIdentifierNone MountIdentifier = "" )
label
func GetDefaultMountIdentifier ¶
func GetDefaultMountIdentifier() (defaultVal MountIdentifier)
func (*MountIdentifier) GetValidMountIdentifiers ¶
func (m *MountIdentifier) GetValidMountIdentifiers() (types []MountIdentifier)
GetValidMountIdentifiers returns a list of all the supported mount identifiers
func (*MountIdentifier) IsValid ¶
func (m *MountIdentifier) IsValid() (err error)
IsValid returns an error if the PartitionFlag is not valid
func (MountIdentifier) String ¶
func (m MountIdentifier) String() string
func (*MountIdentifier) UnmarshalJSON ¶
func (m *MountIdentifier) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON Unmarshals an MountIdentifier entry
type Network ¶
type Network struct { BootProto string `json:"BootProto"` GateWay string `json:"GateWay"` Ip string `json:"Ip"` NetMask string `json:"NetMask"` OnBoot bool `json:"OnBoot"` NameServers []string `json:"NameServer"` Device string `json:"Device"` }
func (*Network) UnmarshalJSON ¶
UnmarshalJSON Unmarshals a Network entry
type PackageRepo ¶
type PackageRepo struct { Name string `json:"Name"` BaseUrl string `json:"BaseUrl"` Install bool `json:"Install"` GPGCheck bool `json:"GPGCheck"` // Default value is true RepoGPGCheck bool `json:"RepoGPGCheck"` // Default value is true GPGKeys string `json:"GPGKeys"` // Default value is "file:///etc/pki/rpm-gpg/MICROSOFT-RPM-GPG-KEY" }
PackageRepo defines the RPM repo to pull packages from during the installation or after the system is installed. The "Install" option indicates that the provided repository configuration will be saved in the installed system if specified, and only available during the installation process if not
func (*PackageRepo) IsValid ¶
func (p *PackageRepo) IsValid() (err error)
IsValid returns an error if the PackageRepo struct is not valid
func (*PackageRepo) UnmarshalJSON ¶
func (p *PackageRepo) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON Unmarshals a PackageRepo entry
type Partition ¶
type Partition struct { FsType string `json:"FsType"` Type string `json:"Type"` TypeUUID string `json:"TypeUUID"` ID string `json:"ID"` Name string `json:"Name"` End uint64 `json:"End"` Start uint64 `json:"Start"` Flags []PartitionFlag `json:"Flags"` Artifacts []Artifact `json:"Artifacts"` }
Partition defines the size, name and file system type for a partition. "Start" and "End" fields define the offset from the beginning of the disk in MBs. An "End" value of 0 will determine the size of the partition using the next partition's start offset or the value defined by "MaxSize", if this is the last partition on the disk. "Grow" tells the logical volume to fill up any available space (**Only used for kickstart-style unattended installation**)
func (*Partition) HasFlag ¶
func (p *Partition) HasFlag(flag PartitionFlag) bool
HasFlag returns true if a given partition has a specific flag set.
func (*Partition) UnmarshalJSON ¶
UnmarshalJSON Unmarshals a Partition entry
type PartitionFlag ¶
type PartitionFlag string
PartitionFlag describes the features of a partition
const ( // PartitionFlagESP indicates this is the UEFI esp partition PartitionFlagESP PartitionFlag = "esp" // PartitionFlagGrub indicates this is a grub boot partition PartitionFlagGrub PartitionFlag = "grub" // PartitionFlagBiosGrub indicates this is a bios grub boot partition PartitionFlagBiosGrub PartitionFlag = "bios_grub" // PartitionFlagBiosGrubLegacy indicates this is a bios grub boot partition. Needed to preserve legacy config behavior. PartitionFlagBiosGrubLegacy PartitionFlag = "bios-grub" // PartitionFlagBoot indicates this is a boot partition PartitionFlagBoot PartitionFlag = "boot" // PartitionFlagDeviceMapperRoot indicates this partition will be used for a device mapper root device PartitionFlagDeviceMapperRoot PartitionFlag = "dmroot" )
func BootPartitionConfig ¶
func BootPartitionConfig(bootType string, partitionTableType PartitionTableType) (mountPoint, mountOptions string, flags []PartitionFlag, err error)
BootPartitionConfig returns the partition flags and mount point that should be used for a given boot type.
func (*PartitionFlag) GetValidPartitionFlags ¶
func (p *PartitionFlag) GetValidPartitionFlags() (types []PartitionFlag)
GetValidPartitionFlags returns a list of all the supported partition flags
func (*PartitionFlag) IsValid ¶
func (p *PartitionFlag) IsValid() (err error)
IsValid returns an error if the PartitionFlag is not valid
func (PartitionFlag) String ¶
func (p PartitionFlag) String() string
func (*PartitionFlag) UnmarshalJSON ¶
func (p *PartitionFlag) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON Unmarshals an PartitionFlag entry
type PartitionSetting ¶
type PartitionSetting struct { RemoveDocs bool `json:"RemoveDocs"` ID string `json:"ID"` MountIdentifier MountIdentifier `json:"MountIdentifier"` MountOptions string `json:"MountOptions"` MountPoint string `json:"MountPoint"` OverlayBaseImage string `json:"OverlayBaseImage"` RdiffBaseImage string `json:"RdiffBaseImage"` }
PartitionSetting holds the mounting information for each partition.
func FindMountpointPartitionSetting ¶
func FindMountpointPartitionSetting(partitionSettings []PartitionSetting, mountPoint string) (partitionSetting *PartitionSetting)
FindMountpointPartitionSetting will search a list of partition settings for the partition setting corresponding to a mount point.
func FindRootPartitionSetting ¶
func FindRootPartitionSetting(partitionSettings []PartitionSetting) (rootPartitionSetting *PartitionSetting)
FindRootPartitionSetting returns a pointer to the partition setting describing the disk which will be mounted at "/", or nil if no partition is found
func GetDefaultPartitionSetting ¶
func GetDefaultPartitionSetting() (defaultVal PartitionSetting)
GetDefaultPartitionSetting returns a copy of the default partition setting
func (*PartitionSetting) IsValid ¶
func (p *PartitionSetting) IsValid() (err error)
IsValid returns an error if the PartitionSetting is not valid
func (*PartitionSetting) UnmarshalJSON ¶
func (p *PartitionSetting) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON Unmarshals a PartitionSetting entry
type PartitionTableType ¶
type PartitionTableType string
PartitionTableType is either gpt, mbr, or none
const ( // PartitionTableTypeGpt selects gpt PartitionTableTypeGpt PartitionTableType = "gpt" // PartitionTableTypeMbr selects mbr PartitionTableTypeMbr PartitionTableType = "mbr" // PartitionTableTypeNone selects no partition type PartitionTableTypeNone PartitionTableType = "" )
func (*PartitionTableType) ConvertToPartedArgument ¶
func (p *PartitionTableType) ConvertToPartedArgument() (partedArgument string, err error)
ConvertToPartedArgument returns the parted argument corresponding to the partition table type
func (*PartitionTableType) GetValidPartitionTableTypes ¶
func (p *PartitionTableType) GetValidPartitionTableTypes() (types []PartitionTableType)
GetValidPartitionTableTypes returns a list of all the supported disk partition types
func (*PartitionTableType) IsValid ¶
func (p *PartitionTableType) IsValid() (err error)
IsValid returns an error if the PartitionTableType is not valid
func (PartitionTableType) String ¶
func (p PartitionTableType) String() string
func (*PartitionTableType) UnmarshalJSON ¶
func (p *PartitionTableType) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON Unmarshals a PartitionTableType entry
type RawBinary ¶
type RawBinary struct { BinPath string `json:"BinPath"` BlockSize uint64 `json:"BlockSize"` Seek uint64 `json:"Seek"` }
RawBinary allow the users to specify a binary they would like to copy byte-for-byte onto the disk.
type RootEncryption ¶
RootEncryption enables encryption on the root partition
type SELinux ¶
type SELinux string
SELinux sets the SELinux mode
const ( // SELinuxOff disables SELinux SELinuxOff SELinux = "" // SELinuxEnforcing sets SELinux to enforcing SELinuxEnforcing SELinux = "enforcing" // SELinuxPermissive sets SELinux to permissive SELinuxPermissive SELinux = "permissive" // SELinuxForceEnforcing both sets SELinux to enforcing, and forces it via the kernel command line SELinuxForceEnforcing SELinux = "force_enforcing" )
func (*SELinux) GetValidSELinux ¶
GetValidImaPolicies returns a list of all the supported disk partition types
func (*SELinux) UnmarshalJSON ¶
UnmarshalJSON Unmarshals an SELinux entry
type SystemConfig ¶
type SystemConfig struct { IsDefault bool `json:"IsDefault"` IsKickStartBoot bool `json:"IsKickStartBoot"` IsIsoInstall bool `json:"IsIsoInstall"` BootType string `json:"BootType"` EnableGrubMkconfig bool `json:"EnableGrubMkconfig"` EnableSystemdFirstboot bool `json:"EnableSystemdFirstboot"` Hostname string `json:"Hostname"` Name string `json:"Name"` PackageLists []string `json:"PackageLists"` Packages []string `json:"Packages"` KernelOptions map[string]string `json:"KernelOptions"` KernelCommandLine KernelCommandLine `json:"KernelCommandLine"` AdditionalFiles map[string]FileConfigList `json:"AdditionalFiles"` PartitionSettings []PartitionSetting `json:"PartitionSettings"` PreInstallScripts []InstallScript `json:"PreInstallScripts"` PostInstallScripts []InstallScript `json:"PostInstallScripts"` FinalizeImageScripts []InstallScript `json:"FinalizeImageScripts"` Networks []Network `json:"Networks"` PackageRepos []PackageRepo `json:"PackageRepos"` Groups []Group `json:"Groups"` Users []User `json:"Users"` Encryption RootEncryption `json:"Encryption"` RemoveRpmDb bool `json:"RemoveRpmDb"` PreserveTdnfCache bool `json:"PreserveTdnfCache"` EnableHidepid bool `json:"EnableHidepid"` DisableRpmDocs bool `json:"DisableRpmDocs"` OverrideRpmLocales string `json:"OverrideRpmLocales"` }
SystemConfig defines how each system present on the image is supposed to be configured.
func (*SystemConfig) GetMountpointPartitionSetting ¶
func (s *SystemConfig) GetMountpointPartitionSetting(mountPoint string) (partitionSetting *PartitionSetting)
GetMountpointPartitionSetting will search the system configuration for the partition setting corresponding to a mount point.
func (*SystemConfig) GetRootPartitionSetting ¶
func (s *SystemConfig) GetRootPartitionSetting() (rootPartitionSetting *PartitionSetting)
GetRootPartitionSetting returns a pointer to the partition setting describing the disk which will be mounted at "/", or nil if no partition is found
func (*SystemConfig) IsRootFS ¶
func (s *SystemConfig) IsRootFS() bool
We assume that any image without partitions is describing a rootfs image.
func (*SystemConfig) IsValid ¶
func (s *SystemConfig) IsValid() (err error)
IsValid returns an error if the SystemConfig is not valid
func (*SystemConfig) UnmarshalJSON ¶
func (s *SystemConfig) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON Unmarshals a Disk entry
type TargetDisk ¶
TargetDisk [kickstart-only] defines the physical disk, to which Azure Linux should be installed.
type User ¶
type User struct { Name string `json:"Name"` UID string `json:"UID"` PasswordHashed bool `json:"PasswordHashed"` Password string `json:"Password"` PasswordExpiresDays int64 `json:"PasswordExpiresDays"` SSHPubKeyPaths []string `json:"SSHPubKeyPaths"` SSHPubKeys []string `json:"SSHPubKeys"` PrimaryGroup string `json:"PrimaryGroup"` SecondaryGroups []string `json:"SecondaryGroups"` StartupCommand string `json:"StartupCommand"` HomeDirectory string `json:"HomeDirectory"` }
func (*User) NameIsValid ¶
NameIsValid returns an error if the User name is empty
func (*User) PasswordExpiresDaysIsValid ¶
PasswordExpiresDaysISValid returns an error if the expire days is not within bounds set by the chage -M command
func (*User) UIDIsValid ¶
UIDIsValid returns an error if the UID is outside bounds.
func (*User) UnmarshalJSON ¶
UnmarshalJSON Unmarshals a User entry