omni/client/pkg/template/internal/models/controlplane.go
Utku Ozdemir 0e76483bab
Some checks failed
default / default (push) Has been cancelled
default / e2e-backups (push) Has been cancelled
default / e2e-forced-removal (push) Has been cancelled
default / e2e-omni-upgrade (push) Has been cancelled
default / e2e-scaling (push) Has been cancelled
default / e2e-short (push) Has been cancelled
default / e2e-short-secureboot (push) Has been cancelled
default / e2e-templates (push) Has been cancelled
default / e2e-upgrades (push) Has been cancelled
default / e2e-workload-proxy (push) Has been cancelled
chore: rekres, bump deps, Go, Talos and k8s versions, satisfy linters
- Bump some deps, namely cosi-runtime and Talos machinery.
- Update `auditState` to implement the new methods in COSI's `state.State`.
- Bump default Talos and Kubernetes versions to their latest.
- Rekres, which brings Go 1.24.5. Also update it in go.mod files.
- Fix linter errors coming from new linters.

Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
2025-07-11 18:23:48 +02:00

66 lines
1.9 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package models
import (
"fmt"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/hashicorp/go-multierror"
"github.com/siderolabs/omni/client/pkg/omni/resources/omni"
)
// KindControlPlane is ControlPlane model kind.
const KindControlPlane = "ControlPlane"
// ControlPlane describes Cluster controlplane nodes.
type ControlPlane struct {
MachineSet `yaml:",inline"`
}
// Validate the model.
func (controlplane *ControlPlane) Validate() error {
var multiErr error
if controlplane.Name != "" {
multiErr = multierror.Append(multiErr, fmt.Errorf("custom name is not allowed in the controlplane"))
}
if controlplane.BootstrapSpec != nil {
if controlplane.BootstrapSpec.ClusterUUID == "" {
multiErr = multierror.Append(multiErr, fmt.Errorf("clusterUUID is required in bootstrapSpec"))
}
if controlplane.BootstrapSpec.Snapshot == "" {
multiErr = multierror.Append(multiErr, fmt.Errorf("snapshot is required in bootstrapSpec"))
}
}
if controlplane.UpdateStrategy != nil {
multiErr = multierror.Append(multiErr, fmt.Errorf("updateStrategy is not allowed in the controlplane"))
}
if controlplane.DeleteStrategy != nil {
multiErr = multierror.Append(multiErr, fmt.Errorf("deleteStrategy is not allowed in the controlplane"))
}
multiErr = joinErrors(multiErr, controlplane.MachineSet.Validate(), controlplane.Machines.Validate(), controlplane.Patches.Validate())
if multiErr != nil {
return fmt.Errorf("controlplane is invalid: %w", multiErr)
}
return nil
}
// Translate the model.
func (controlplane *ControlPlane) Translate(ctx TranslateContext) ([]resource.Resource, error) {
return controlplane.translate(ctx, omni.ControlPlanesIDSuffix, omni.LabelControlPlaneRole)
}
func init() {
register[ControlPlane](KindControlPlane)
}