Skip to content

Commit

Permalink
Merge pull request #3483 from tnqn/validate-ip-family
Browse files Browse the repository at this point in the history
Add ipFamily validation
  • Loading branch information
BenTheElder authored Feb 22, 2024
2 parents d59e2ce + 396586f commit 2fb3f42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/internal/apis/config/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func (c *Cluster) Validate() error {
}
}

// ipFamily should be ipv4, ipv6, or dual
if c.Networking.IPFamily != IPv4Family && c.Networking.IPFamily != IPv6Family && c.Networking.IPFamily != DualStackFamily {
errs = append(errs, errors.Errorf("invalid ipFamily: %s", c.Networking.IPFamily))
}

// podSubnet should be a valid CIDR
if err := validateSubnets(c.Networking.PodSubnet, c.Networking.IPFamily); err != nil {
errs = append(errs, errors.Errorf("invalid pod subnet %v", err))
Expand Down
10 changes: 10 additions & 0 deletions pkg/internal/apis/config/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ func TestClusterValidate(t *testing.T) {
}(),
ExpectErrors: 1,
},
{
Name: "bogus ipFamily",
Cluster: func() Cluster {
c := Cluster{}
SetDefaultsCluster(&c)
c.Networking.IPFamily = "ds"
return c
}(),
ExpectErrors: 1,
},
{
Name: "bogus serviceSubnet",
Cluster: func() Cluster {
Expand Down

0 comments on commit 2fb3f42

Please sign in to comment.