Skip to content

Commit

Permalink
fix: don't panic if the machine config doesn't have network (EM)
Browse files Browse the repository at this point in the history
This handles the case if the machine config doesn't contain
`.machine.network` (I got hit by that today).

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Aug 18, 2021
1 parent 8bef41e commit 0b86eda
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (p *Packet) Name() string {
}

// Configuration implements the platform.Platform interface.
//nolint:gocyclo
//nolint:gocyclo,cyclop
func (p *Packet) Configuration(ctx context.Context) ([]byte, error) {
// Fetch and unmarshal both the talos machine config and the
// metadata about the instance from packet's metadata server
Expand Down Expand Up @@ -199,6 +199,14 @@ func (p *Packet) Configuration(ctx context.Context) ([]byte, error) {
}
}

if machineConfig.MachineConfig == nil {
machineConfig.MachineConfig = &v1alpha1.MachineConfig{}
}

if machineConfig.MachineConfig.MachineNetwork == nil {
machineConfig.MachineConfig.MachineNetwork = &v1alpha1.NetworkConfig{}
}

machineConfig.MachineConfig.MachineNetwork.NetworkInterfaces = append(
machineConfig.MachineConfig.MachineNetwork.NetworkInterfaces,
&bondDev,
Expand Down

0 comments on commit 0b86eda

Please sign in to comment.