Merge pull request #126109 from my-git9/staticpod
kubeadm: remove unused function in util/staticpod
This commit is contained in:
		| @@ -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. | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot