Skip to content

Commit

Permalink
feat(config): add installDiskSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
budimanjojo committed Sep 21, 2022
1 parent c369bfc commit 40d13e8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
19 changes: 10 additions & 9 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 13 additions & 1 deletion pkg/config/validate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/talos/nodeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 5 additions & 1 deletion test/talconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 40d13e8

Please sign in to comment.