Merge pull request #3483 from tnqn/validate-ip-family

Add ipFamily validation
This commit is contained in:
Benjamin Elder
2024-02-22 13:03:39 -08:00
committed by GitHub
2 changed files with 15 additions and 0 deletions

View File

@@ -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))

View File

@@ -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 {