Use enum for cilium encryption types

This commit is contained in:
Ole Markus With 2021-08-14 19:49:48 +02:00
parent 0e8d189aee
commit 7534890b3a
5 changed files with 17 additions and 6 deletions

View File

@ -266,6 +266,11 @@ type AmazonVPCNetworkingSpec struct {
const CiliumIpamEni = "eni"
type CiliumEncryptionType string
const CiliumEncryptionTypeIPSec CiliumEncryptionType = "ipsec"
const CiliumEncryptionTypeWireguard CiliumEncryptionType = "wireguard"
// CiliumNetworkingSpec declares that we want Cilium networking
type CiliumNetworkingSpec struct {
// Version is the version of the Cilium agent and the Cilium Operator.
@ -345,7 +350,7 @@ type CiliumNetworkingSpec struct {
EnableEncryption bool `json:"enableEncryption,omitempty"`
// EncryptionType specifies Cilium Encryption method ("ipsec", "wireguard").
// Default: ipsec
EncryptionType string `json:"encryptionType,omitempty"`
EncryptionType CiliumEncryptionType `json:"encryptionType,omitempty"`
// EnvoyLog is not implemented and may be removed in the future.
// Setting this has no effect.
EnvoyLog string `json:"envoyLog,omitempty"`

View File

@ -266,6 +266,11 @@ type AmazonVPCNetworkingSpec struct {
const CiliumIpamEni = "eni"
type CiliumEncryptionType string
const CiliumEncryptionTypeIPSec CiliumEncryptionType = "ipsec"
const CiliumEncryptionTypeWireguard CiliumEncryptionType = "wireguard"
// CiliumNetworkingSpec declares that we want Cilium networking
type CiliumNetworkingSpec struct {
// Version is the version of the Cilium agent and the Cilium Operator.
@ -345,7 +350,7 @@ type CiliumNetworkingSpec struct {
EnableEncryption bool `json:"enableEncryption,omitempty"`
// EncryptionType specifies Cilium Encryption method ("ipsec", "wireguard").
// Default: ipsec
EncryptionType string `json:"encryptionType,omitempty"`
EncryptionType CiliumEncryptionType `json:"encryptionType,omitempty"`
// EnvoyLog is not implemented and may be removed in the future.
// Setting this has no effect.
EnvoyLog string `json:"envoyLog,omitempty"`

View File

@ -1774,7 +1774,7 @@ func autoConvert_v1alpha2_CiliumNetworkingSpec_To_kops_CiliumNetworkingSpec(in *
out.EnableTracing = in.EnableTracing
out.EnablePrometheusMetrics = in.EnablePrometheusMetrics
out.EnableEncryption = in.EnableEncryption
out.EncryptionType = in.EncryptionType
out.EncryptionType = kops.CiliumEncryptionType(in.EncryptionType)
out.EnvoyLog = in.EnvoyLog
out.IdentityAllocationMode = in.IdentityAllocationMode
out.IdentityChangeGracePeriod = in.IdentityChangeGracePeriod
@ -1882,7 +1882,7 @@ func autoConvert_kops_CiliumNetworkingSpec_To_v1alpha2_CiliumNetworkingSpec(in *
out.EnableTracing = in.EnableTracing
out.EnablePrometheusMetrics = in.EnablePrometheusMetrics
out.EnableEncryption = in.EnableEncryption
out.EncryptionType = in.EncryptionType
out.EncryptionType = CiliumEncryptionType(in.EncryptionType)
out.EnvoyLog = in.EnvoyLog
out.IdentityAllocationMode = in.IdentityAllocationMode
out.IdentityChangeGracePeriod = in.IdentityChangeGracePeriod

View File

@ -887,7 +887,8 @@ func validateNetworkingCilium(cluster *kops.Cluster, v *kops.CiliumNetworkingSpe
}
if v.EncryptionType != "" {
allErrs = append(allErrs, IsValidValue(fldPath.Child("encryptionType"), &v.EncryptionType, []string{"ipsec", "wireguard"})...)
encryptionType := string(v.EncryptionType)
allErrs = append(allErrs, IsValidValue(fldPath.Child("encryptionType"), &encryptionType, []string{"ipsec", "wireguard"})...)
version, _ := semver.Parse(v.Version)
if v.EncryptionType == "wireguard" && version.Minor < 10 {

View File

@ -150,7 +150,7 @@ func (b *CiliumOptionsBuilder) BuildOptions(o interface{}) error {
}
if c.EncryptionType == "" {
c.EncryptionType = "ipsec"
c.EncryptionType = kops.CiliumEncryptionTypeIPSec
}
hubble := c.Hubble