diff --git a/pkg/config/config.go b/pkg/config/config.go index 0acb2a4d..207db378 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -19,15 +19,16 @@ type TalhelperConfig struct { } type Nodes struct { - Hostname string `yaml:"hostname"` - IPAddress string `yaml:"ipAddress"` - ControlPlane bool `yaml:"controlPlane"` - InstallDisk string `yaml:"installDisk"` - DisableSearchDomain bool `yaml:"disableSearchDomain,omitempty"` - Nameservers []string `yaml:"nameservers,omitempty"` - NetworkInterfaces []*v1alpha1.Device `yaml:"networkInterfaces,omitempty"` - ConfigPatches []map[string]interface{} `yaml:"configPatches,omitempty"` - InlinePatch map[string]interface{} `yaml:"inlinePatch,omitempty"` + Hostname string `yaml:"hostname"` + IPAddress string `yaml:"ipAddress,omitempty"` + ControlPlane bool `yaml:"controlPlane"` + InstallDisk string `yaml:"installDisk,omitempty"` + InstallDiskSelector *v1alpha1.InstallDiskSelector `yaml:"installDiskSelector,omitempty"` + DisableSearchDomain bool `yaml:"disableSearchDomain,omitempty"` + Nameservers []string `yaml:"nameservers,omitempty"` + NetworkInterfaces []*v1alpha1.Device `yaml:"networkInterfaces,omitempty"` + ConfigPatches []map[string]interface{} `yaml:"configPatches,omitempty"` + InlinePatch map[string]interface{} `yaml:"inlinePatch,omitempty"` } type cniConfig struct { diff --git a/pkg/config/validate/config.go b/pkg/config/validate/config.go index e1eebb83..953527cd 100644 --- a/pkg/config/validate/config.go +++ b/pkg/config/validate/config.go @@ -35,13 +35,25 @@ type Node struct { Hostname string `validate:"required"` IPAddress string `validate:"isIP"` ControlPlane string `validate:"isBool"` - InstallDisk string `validate:"required"` + InstallDisk string `validate:"requiredWithout:Nodes.InstallDiskSelector"` + InstallDiskSelector *InstallDiskSelector DisableSearchDomain string `validate:"isBool"` Nameservers []string `validate:"isIPList"` ConfigPatches []map[string]interface{} `validate:"isRFC6902List"` NetworkInterfaces []*NetworkInterface } +type InstallDiskSelector struct { + Size string `validate:"required_with:Nodes.InstallDiskSelector"` + Name string + Model string + Modalias string + UUID string + WWID string + Type string + BusPath string +} + type NetworkInterface struct { Interface string `validate:"required_with:Nodes.NetworkInterfaces"` Addresses []string `validate:"isCIDRList"` diff --git a/pkg/talos/nodeconfig.go b/pkg/talos/nodeconfig.go index 7a11d4cb..62b806a8 100644 --- a/pkg/talos/nodeconfig.go +++ b/pkg/talos/nodeconfig.go @@ -57,6 +57,10 @@ func applyNodeOverride(node *config.Nodes, cfg *v1alpha1.Config) (*v1alpha1.Conf cfg.MachineConfig.MachineNetwork.NetworkInterfaces = node.NetworkInterfaces } + if node.InstallDiskSelector != nil { + cfg.MachineConfig.MachineInstall.InstallDiskSelector = node.InstallDiskSelector + } + return cfg } diff --git a/test/talconfig.yaml b/test/talconfig.yaml index b34c2ba0..c6f115af 100644 --- a/test/talconfig.yaml +++ b/test/talconfig.yaml @@ -15,8 +15,12 @@ cniConfig: nodes: - hostname: kmaster1 ipAddress: 192.168.200.11 + installDiskSelector: + size: 4GB + model: WDC* + name: /sys/block/sda/device/name + busPath: /pci0000:00/0000:00:17.0/ata1/host0/target0:0:0/0:0:0:0 controlPlane: true - installDisk: /dev/sda disableSearchDomain: true nameservers: - 1.1.1.1