mirror of
https://github.com/siderolabs/omni.git
synced 2025-08-07 18:17:00 +02:00
Some checks are pending
default / default (push) Waiting to run
default / e2e-backups (push) Blocked by required conditions
default / e2e-forced-removal (push) Blocked by required conditions
default / e2e-scaling (push) Blocked by required conditions
default / e2e-short (push) Blocked by required conditions
default / e2e-short-secureboot (push) Blocked by required conditions
default / e2e-templates (push) Blocked by required conditions
default / e2e-upgrades (push) Blocked by required conditions
default / e2e-workload-proxy (push) Blocked by required conditions
Omni can now be configured via a config file instead of the command line flags. The flags `--config-path` will now read the config provided in the YAML format. The config structure was completely changed. It was not public before, so it's fine to ignore backward compatibility. The command line flags were not changed. Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
79 lines
2.3 KiB
Go
79 lines
2.3 KiB
Go
// Copyright (c) 2025 Sidero Labs, Inc.
|
|
//
|
|
// Use of this software is governed by the Business Source License
|
|
// included in the LICENSE file.
|
|
|
|
// Package installimage provides utilities to work with the install images.
|
|
package installimage
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/blang/semver/v4"
|
|
"github.com/cosi-project/runtime/pkg/resource"
|
|
|
|
"github.com/siderolabs/omni/client/api/omni/specs"
|
|
appconfig "github.com/siderolabs/omni/internal/pkg/config"
|
|
)
|
|
|
|
// Build builds the install image for the provided properties.
|
|
func Build(imageFactoryHost string, resID resource.ID, installImage *specs.MachineConfigGenOptionsSpec_InstallImage) (string, error) {
|
|
if imageFactoryHost == "" {
|
|
return "", fmt.Errorf("image factory host is not set")
|
|
}
|
|
|
|
if installImage == nil {
|
|
return "", fmt.Errorf("install image is nil for machine %q", resID)
|
|
}
|
|
|
|
if !installImage.SchematicInitialized {
|
|
return "", fmt.Errorf("machine %q has no schematic information set", resID)
|
|
}
|
|
|
|
schematicID := installImage.SchematicId
|
|
|
|
securityState := installImage.SecurityState
|
|
if securityState == nil { // should never happen - must have been handled before entering this function
|
|
return "", fmt.Errorf("machine %q has no secure boot status set", resID)
|
|
}
|
|
|
|
installerName := "installer"
|
|
if securityState.SecureBoot {
|
|
installerName = "installer-secureboot"
|
|
}
|
|
|
|
if installImage.SchematicInvalid {
|
|
schematicID = ""
|
|
}
|
|
|
|
desiredTalosVersion := installImage.TalosVersion
|
|
|
|
if desiredTalosVersion == "" {
|
|
return "", fmt.Errorf("machine %q has no talos version set", resID)
|
|
}
|
|
|
|
version, err := semver.ParseTolerant(desiredTalosVersion)
|
|
if err != nil {
|
|
return "", fmt.Errorf("failed to parse Talos version %q: %w", desiredTalosVersion, err)
|
|
}
|
|
|
|
if version.Major >= 1 && version.Minor >= 10 { // prepend the platform to the installer name for Talos 1.10+
|
|
if installImage.Platform == "" {
|
|
return "", fmt.Errorf("machine %q has no platform set", resID)
|
|
}
|
|
|
|
installerName = installImage.Platform + "-" + installerName
|
|
}
|
|
|
|
if !strings.HasPrefix(desiredTalosVersion, "v") {
|
|
desiredTalosVersion = "v" + desiredTalosVersion
|
|
}
|
|
|
|
if schematicID != "" {
|
|
return imageFactoryHost + "/" + installerName + "/" + schematicID + ":" + desiredTalosVersion, nil
|
|
}
|
|
|
|
return appconfig.Config.Registries.Talos + ":" + desiredTalosVersion, nil
|
|
}
|