From fbf8cf41a7cdfe4e581c454e7031cee4cea33a39 Mon Sep 17 00:00:00 2001 From: "xin.li" Date: Sun, 14 Jul 2024 16:57:25 +0800 Subject: [PATCH] kubeadm: remove unused function in util/staticpod Signed-off-by: xin.li --- cmd/kubeadm/app/util/staticpod/utils.go | 16 ------- cmd/kubeadm/app/util/staticpod/utils_test.go | 49 -------------------- 2 files changed, 65 deletions(-) diff --git a/cmd/kubeadm/app/util/staticpod/utils.go b/cmd/kubeadm/app/util/staticpod/utils.go index fcd28eff4d0..75261011380 100644 --- a/cmd/kubeadm/app/util/staticpod/utils.go +++ b/cmd/kubeadm/app/util/staticpod/utils.go @@ -151,22 +151,6 @@ func VolumeMountMapToSlice(volumeMounts map[string]v1.VolumeMount) []v1.VolumeMo return v } -// GetExtraParameters builds a list of flag arguments two string-string maps, one with default, base commands and one with overrides -func GetExtraParameters(overrides map[string]string, defaults map[string]string) []string { - var command []string - for k, v := range overrides { - if len(v) > 0 { - command = append(command, fmt.Sprintf("--%s=%s", k, v)) - } - } - for k, v := range defaults { - if _, overrideExists := overrides[k]; !overrideExists { - command = append(command, fmt.Sprintf("--%s=%s", k, v)) - } - } - return command -} - // PatchStaticPod applies patches stored in patchesDir to a static Pod. func PatchStaticPod(pod *v1.Pod, patchesDir string, output io.Writer) (*v1.Pod, error) { // Marshal the Pod manifest into YAML. diff --git a/cmd/kubeadm/app/util/staticpod/utils_test.go b/cmd/kubeadm/app/util/staticpod/utils_test.go index 0af59683423..3f1f6cdacff 100644 --- a/cmd/kubeadm/app/util/staticpod/utils_test.go +++ b/cmd/kubeadm/app/util/staticpod/utils_test.go @@ -21,7 +21,6 @@ import ( "os" "path/filepath" "reflect" - "sort" "strconv" "strings" "testing" @@ -576,54 +575,6 @@ func TestVolumeMountMapToSlice(t *testing.T) { } } -func TestGetExtraParameters(t *testing.T) { - var tests = []struct { - name string - overrides map[string]string - defaults map[string]string - expected []string - }{ - { - name: "with admission-control default NamespaceLifecycle", - overrides: map[string]string{ - "admission-control": "NamespaceLifecycle,LimitRanger", - }, - defaults: map[string]string{ - "admission-control": "NamespaceLifecycle", - "allow-privileged": "true", - }, - expected: []string{ - "--admission-control=NamespaceLifecycle,LimitRanger", - "--allow-privileged=true", - }, - }, - { - name: "without admission-control default", - overrides: map[string]string{ - "admission-control": "NamespaceLifecycle,LimitRanger", - }, - defaults: map[string]string{ - "allow-privileged": "true", - }, - expected: []string{ - "--admission-control=NamespaceLifecycle,LimitRanger", - "--allow-privileged=true", - }, - }, - } - - for _, rt := range tests { - t.Run(rt.name, func(t *testing.T) { - actual := GetExtraParameters(rt.overrides, rt.defaults) - sort.Strings(actual) - sort.Strings(rt.expected) - if !reflect.DeepEqual(actual, rt.expected) { - t.Errorf("failed getExtraParameters:\nexpected:\n%v\nsaw:\n%v", rt.expected, actual) - } - }) - } -} - const ( validPod = ` apiVersion: v1