defs

package
v0.167.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 25 Imported by: 1

README

Image types definitions in YAML

This directory contains the "image-type" definitions in YAML.

We currently have subdirectories for:

  • fedora
  • rhel-7, rhel-8, rhel-9, rhel-10 (which also provide CentosOS Stream, Alma, Alma Kitten)

Under each of those directories there is a distro.yaml file that contains all image-types for the given distro.

The image types are defined under image_types (and for rhel also in go-code but that will be generalized soon, it is already for fedora).

Example distro.yaml

image_types:
  qcow2: &qcow2
    image_config: &qcow2_image_config
      default_target: "multi-user.target"
      kernel_options: ["console=tty0", "console=ttyS0,115200n8", "no_timer_check"]
      conditions:
        "tweak the rhsm config on rhel":
          when:
            distro_name: "rhel"
          shallow_merge:
            rhsm_config:
              "no-subscription":
                dnf_plugin:
                  product_id:
                    enabled: false
                  subscription_manager:
                    enabled: false
    partition_table:
      <<: *default_partition_tables
    package_sets:
      os:
        - &qcow2_pkgset
          include:
            - "@core"
            - ...
          exclude:
            - "aic94xx-firmware"
            - ...
          conditions:
            "add insights pkgs on rhel":
              when:
                distro_name: "rhel"
              append:
                include:
                  - "insights-client"
                  - "subscription-manager-cockpit"

Common keys:

image_config

This maps directly to https://github.com/osbuild/images/blob/v0.154.0/pkg/distro/image_config.go#L18

Conditions can be used and only the "shallow_merge" action is supported, this means that the image_config from the condition will be merged with the original config (but only as a shallow merge, i.e. only top-levels that are not already set will be merged).

partition_table

This maps directly to https://github.com/osbuild/images/blob/v0.154.0/pkg/disk/partition_table.go#L17

Conditions can be used and only the "override" action is supported, this means that the original partition_table is fully replaced with the one found via the condition.

package_sets

The package sets describe what packages should be included in the "os" or "installer" pipelines. Under each keys there is a list of objects with "include/exclude" sublists (see the example below).

Conditions can be used and only the "append" action is supported, this means that the packages from the conditions is appended to the original package sets.

platforms_override

This can be used to override the platforms for the image type based on some condition. See the rhel-8 "ami" image type for an example where the aarch64 architecture is only available for rhel-8.9+.

conditions

Conditions are expressed using the following form:

conditions:
  <<: *shared_conditions
  "some unique description":
    when:
      distro_name: "rhel"
      arch: "x86_64"
      version_less_than: "9.2"
      version_equal: "9.1"
      version_greater_or_equal: "9.3"
    action:
      # for "image_config" types only shallow_merge is supported
      shallow_merge:
        ...
      # for "partition_tables" types only "override" is supported
      override:
        ...
      # for "package_sets" types only "append" is supported
      append:
        ...

Conditions are a "map" in YAML so that they can be easily shared and merge via the <<: operation.

The when part of the condition can contain one or more of:

  • distro_name
  • not_distro_name
  • arch
  • version_less_than
  • version_equal
  • version_greater If multiple conditions are given under when they are considered logical AND and only if they all match is the condition executed.
Pitfalls

All conditions will be evaluated, there is no ordering.

This means one needs to be careful about having something like:

conditions:
 "f40plus kernel options":
 when:
   version_greater_or_equal: 40
 action:
   shallow_merge:
     kernel_options:
       - f40opts
 "f41plus kernel options":
 when:
   version_greater_or_equal: 41
 action:
   shallow_merge:
     kernel_options:
       - f41opts

On fedora 42 both conditions will be executed but the order is random. Because the merge is shallow only kernel_options will have been set by one of the conditions and it will either be f41opts or f40opts.

In a situation like this use either: version_equal or:

 "f40-42 kernel options":
 when:
   version_greater_or_equal: 40
   version_less_than: 43
 action:
   shallow_merge:
     kernel_options:
       - f40,41,42opts

Documentation

Overview

package defs contain the distro definitions used by the "images" library

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPartitionTableForImgType = errors.New("no partition table for image type")
	ErrNoPartitionTableForArch    = errors.New("no partition table for arch")
)

Functions

func ParseID added in v0.165.0

func ParseID(nameVer string) (*distro.ID, error)

ParseID parse the given nameVer into a distro.ID. It will also apply normalizations from the distros `match` rule. This is needed to support distro names like "rhel-810" without dots.

If no match is found it will "nil" and no error (

Types

type DistroYAML

type DistroYAML struct {
	// Match can be used to match/transform a given name
	// into the canonical <distro>-<major>{,.<minor>} form.
	// E.g.
	//   (?P<distro>rhel)-(?P<major>8)\.?(?P<minor>[0-9]+)
	// will support a format like e.g. rhel-810 and rhel-8.10
	Match string `yaml:"match"`

	// The distro metadata, can contain go text template strings
	// for {{.Major}}, {{.Minor}} which will be expanded by the
	// upper layers.
	Name             string            `yaml:"name"`
	Codename         string            `yaml:"codename"`
	Vendor           string            `yaml:"vendor"`
	Preview          bool              `yaml:"preview"`
	OsVersion        string            `yaml:"os_version"`
	ReleaseVersion   string            `yaml:"release_version"`
	ModulePlatformID string            `yaml:"module_platform_id"`
	Product          string            `yaml:"product"`
	OSTreeRefTmpl    string            `yaml:"ostree_ref_tmpl"`
	Runner           runner.RunnerConf `yaml:"runner"`

	// ISOLabelTmpl can contain {{.Product}},{{.OsVersion}},{{.Arch}},{{.ISOLabel}}
	ISOLabelTmpl string `yaml:"iso_label_tmpl"`

	DefaultFSType disk.FSType `yaml:"default_fs_type"`

	// directory with the actual image defintions, we separate that
	// so that we can point the "centos-10" distro to the "./rhel-10"
	// image types file/directory.
	DefsPath string `yaml:"defs_path"`

	BootstrapContainers map[arch.Arch]string `yaml:"bootstrap_containers"`

	OscapProfilesAllowList []oscap.Profile `yaml:"oscap_profiles_allowlist"`

	// ignore the given image types
	Conditions map[string]distroConditions `yaml:"conditions"`

	// XXX: remove this in favor of a better abstraction, this
	// is currently needed because the manifest pkg has conditionals
	// based on the distro, ideally it would not have this but
	// here we are.
	DistroLike manifest.Distro `yaml:"distro_like"`
	// contains filtered or unexported fields
}

func NewDistroYAML

func NewDistroYAML(nameVer string) (*DistroYAML, error)

NewDistroYAML return the given distro or nil if the distro is not found. This mimics the "distrofactory.GetDistro() interface.

Note that eventually we want something like "Distros()" instead that returns all known distros but for now we keep compatibility with the way distrofactory/reporegistry work which is by defining distros via repository files.

func (*DistroYAML) ImageConfig

func (d *DistroYAML) ImageConfig() *distro.ImageConfig

ImageConfig returns the distro wide default ImageConfig.

Each ImageType gets this as their default ImageConfig.

func (*DistroYAML) ImageTypes

func (d *DistroYAML) ImageTypes() map[string]ImageTypeYAML

func (*DistroYAML) SkipImageType added in v0.164.0

func (d *DistroYAML) SkipImageType(imgTypeName, archName string) bool

type ImageTypeYAML

type ImageTypeYAML struct {
	// This maps "pkgsKey" to their package sets. The
	// map key here is a string that can either be:
	// - "os": packages for the os
	// - "installer": packages for the installer
	// - "container": extra package into an iot container
	//
	// - "blueprint": unused AFAICT
	// - "build": unused AFAICT
	// Note that this does not directly maps to pipeline names
	// but we should look into making it so.
	PackageSetsYAML map[string][]packageSet `yaml:"package_sets"`
	// archStr->partitionTable
	PartitionTables map[string]*disk.PartitionTable `yaml:"partition_table"`
	// override specific aspects of the partition table
	PartitionTablesOverrides *partitionTablesOverrides `yaml:"partition_tables_override"`

	ImageConfigYAML     imageConfig     `yaml:"image_config,omitempty"`
	InstallerConfigYAML installerConfig `yaml:"installer_config,omitempty"`

	Filename    string                      `yaml:"filename"`
	MimeType    string                      `yaml:"mime_type"`
	Compression string                      `yaml:"compression"`
	Environment environment.EnvironmentConf `yaml:"environment"`
	Bootable    bool                        `yaml:"bootable"`

	BootISO bool `yaml:"boot_iso"`
	// XXX merge with BootISO above, controls if grub2 or syslinux are used for ISO boots
	UseSyslinux             bool `yaml:"use_syslinux"`
	UseLegacyAnacondaConfig bool `yaml:"use_legacy_anaconda_config"`

	ISOLabel string `yaml:"iso_label"`
	// XXX: or iso_variant?
	Variant string `yaml:"variant"`

	RPMOSTree bool `yaml:"rpm_ostree"`

	OSTree struct {
		Name       string `yaml:"name"`
		RemoteName string `yaml:"remote_name"`
	} `yaml:"ostree"`
	// XXX: rhel-8 uses this
	UseOstreeRemotes bool `yaml:"use_ostree_remotes"`

	DefaultSize uint64 `yaml:"default_size"`
	// the image func name: disk,container,live-installer,...
	Image                  string            `yaml:"image_func"`
	BuildPipelines         []string          `yaml:"build_pipelines"`
	PayloadPipelines       []string          `yaml:"payload_pipelines"`
	Exports                []string          `yaml:"exports"`
	RequiredPartitionSizes map[string]uint64 `yaml:"required_partition_sizes"`

	InternalPlatforms []platform.PlatformConf `yaml:"platforms"`
	PlatformsOverride *platformsOverride      `yaml:"platforms_override"`

	NameAliases []string `yaml:"name_aliases"`

	InstallWeakDeps *bool `yaml:"install_weak_deps"`

	// for RHEL7 compat
	// TODO: determine a better place for these options, but for now they are here
	DiskImagePartTool     *osbuild.PartTool `yaml:"disk_image_part_tool"`
	DiskImageVPCForceSize *bool             `yaml:"disk_image_vpc_force_size"`

	SupportedPartitioningModes []disk.PartitioningMode `yaml:"supported_partitioning_modes"`
	// contains filtered or unexported fields
}

func (*ImageTypeYAML) ImageConfig

func (imgType *ImageTypeYAML) ImageConfig(distroNameVer, archName string) (*distro.ImageConfig, error)

ImageConfig returns the image type specific ImageConfig

func (*ImageTypeYAML) InstallerConfig

func (imgType *ImageTypeYAML) InstallerConfig(distroNameVer, archName string) (*distro.InstallerConfig, error)

InstallerConfig returns the InstallerConfig for the given imgType Note that on conditions the InstallerConfig is fully replaced, do any merging in YAML

func (*ImageTypeYAML) Name

func (it *ImageTypeYAML) Name() string

func (*ImageTypeYAML) PackageSets

func (imgType *ImageTypeYAML) PackageSets(distroNameVer, archName string) (map[string]rpmmd.PackageSet, error)

PackageSets loads the PackageSets from the yaml source file discovered via the imagetype.

func (*ImageTypeYAML) PartitionTable

func (imgType *ImageTypeYAML) PartitionTable(distroNameVer, archName string) (*disk.PartitionTable, error)

PartitionTable returns the partionTable for the given distro/imgType.

func (*ImageTypeYAML) PlatformsFor added in v0.165.0

func (it *ImageTypeYAML) PlatformsFor(distroNameVer string) ([]platform.PlatformConf, error)

Jump to

Keyboard shortcuts

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