Skip to content

Commit

Permalink
fix: allow empty dnsDomain in machine config
Browse files Browse the repository at this point in the history
This field has a default value, but validation was prohibiting empty
value.

Fixes #6619

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Dec 12, 2022
1 parent eb332cf commit 5b992bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/machinery/config/types/v1alpha1/v1alpha1_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (c *ClusterConfig) Validate() error {
result = multierror.Append(result, fmt.Errorf("invalid controlplane endpoint: %w", err))
}

if c.ClusterNetwork != nil && !isValidDNSName(c.ClusterNetwork.DNSDomain) {
if c.ClusterNetwork != nil && c.ClusterNetwork.DNSDomain != "" && !isValidDNSName(c.ClusterNetwork.DNSDomain) {
result = multierror.Append(result, fmt.Errorf("%q is not a valid DNS name", c.ClusterNetwork.DNSDomain))
}

Expand Down
17 changes: 17 additions & 0 deletions pkg/machinery/config/types/v1alpha1/v1alpha1_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,23 @@ func TestValidate(t *testing.T) {
},
expectedError: "2 errors occurred:\n\t* inline manifest name can't be empty\n\t* inline manifest name \"foo\" is duplicate\n\n",
},
{
name: "DNSDomainEmpty",
config: &v1alpha1.Config{
ConfigVersion: "v1alpha1",
MachineConfig: &v1alpha1.MachineConfig{
MachineType: "controlplane",
},
ClusterConfig: &v1alpha1.ClusterConfig{
ControlPlane: &v1alpha1.ControlPlaneConfig{
Endpoint: &v1alpha1.Endpoint{
endpointURL,
},
},
ClusterNetwork: &v1alpha1.ClusterNetworkConfig{},
},
},
},
{
name: "DeviceCIDRInvalid",
config: &v1alpha1.Config{
Expand Down

0 comments on commit 5b992bd

Please sign in to comment.