kubeadm: remove unused function in util/staticpod

Signed-off-by: xin.li <xin.li@daocloud.io>
This commit is contained in:
xin.li 2024-07-14 16:57:25 +08:00
parent 46aa8959a0
commit fbf8cf41a7
2 changed files with 0 additions and 65 deletions

View File

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

View File

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