From 6e61e68c817810e5c1c8f38d6b84110256bd4d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=A6=E5=8D=97=E8=B7=AF=E4=B9=8B=E8=8A=B1?= Date: Wed, 30 Oct 2024 23:18:57 +0100 Subject: [PATCH 1/2] cilium: remove appArmorProfile for k8s Date: Mon, 9 Dec 2024 22:54:14 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com> --- pkg/minikube/cni/cilium.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/minikube/cni/cilium.go b/pkg/minikube/cni/cilium.go index 02c97da0de61..f02728f6b902 100644 --- a/pkg/minikube/cni/cilium.go +++ b/pkg/minikube/cni/cilium.go @@ -20,6 +20,7 @@ import ( "bytes" _ "embed" "fmt" + "io" "os/exec" "text/template" @@ -58,7 +59,7 @@ func (c Cilium) GenerateCiliumYAML() ([]byte, error) { // see issue #19683, older Kubernetes versions cannot recognize appArmorProfile fields k8sVersion, err := util.ParseKubernetesVersion(c.cc.KubernetesConfig.KubernetesVersion) if err == nil && k8sVersion.LT(semver.MustParse("1.30.0")) { - if ciliumYaml, err = removeAppArorProfile(ciliumYaml); err != nil { + if ciliumYaml, err = removeAppArmorProfile(ciliumYaml); err != nil { return nil, err } } @@ -99,7 +100,7 @@ func (c Cilium) Apply(r Runner) error { return applyManifest(c.cc, r, manifestAsset(ciliumCfg)) } -func removeAppArorProfile(ciliumConfig string) (string, error) { +func removeAppArmorProfile(ciliumConfig string) (string, error) { // remove all appArmorProfile fields decoder := yaml.NewDecoder(bytes.NewBufferString(ciliumConfig)) var buffer bytes.Buffer @@ -107,7 +108,7 @@ func removeAppArorProfile(ciliumConfig string) (string, error) { for { obj := map[string]interface{}{} err := decoder.Decode(&obj) - if err != nil && err.Error() == "EOF" { + if err == io.EOF { // we have unmarshaled all objects break } else if err != nil {