Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Powell <[email protected]>
  • Loading branch information
ComradeProgrammer and spowelljr committed Dec 9, 2024
1 parent 6e61e68 commit b240f9d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/minikube/cni/cilium.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
_ "embed"
"fmt"
"io"
"os/exec"
"text/template"

Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -99,15 +100,15 @@ 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
encoder := yaml.NewEncoder(&buffer)
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 {
Expand Down

0 comments on commit b240f9d

Please sign in to comment.