mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
controller-manager: switch to config/option struct pattern
This commit is contained in:
committed by
Dr. Stefan Schimanski
parent
ba791275ce
commit
0cbe0a6034
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package options
|
||||
|
||||
import (
|
||||
"net"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
@@ -32,7 +33,7 @@ import (
|
||||
|
||||
func TestAddFlags(t *testing.T) {
|
||||
f := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
|
||||
s := NewCMServer()
|
||||
s := NewKubeControllerManagerOptions()
|
||||
s.AddFlags(f, []string{""}, []string{""})
|
||||
|
||||
args := []string{
|
||||
@@ -107,13 +108,13 @@ func TestAddFlags(t *testing.T) {
|
||||
f.Parse(args)
|
||||
// Sort GCIgnoredResources because it's built from a map, which means the
|
||||
// insertion order is random.
|
||||
sort.Sort(sortedGCIgnoredResources(s.GCIgnoredResources))
|
||||
sort.Sort(sortedGCIgnoredResources(s.Generic.ComponentConfig.GCIgnoredResources))
|
||||
|
||||
expected := &CMServer{
|
||||
ControllerManagerServer: cmoptions.ControllerManagerServer{
|
||||
KubeControllerManagerConfiguration: componentconfig.KubeControllerManagerConfiguration{
|
||||
Port: 10000,
|
||||
Address: "192.168.4.10",
|
||||
expected := &KubeControllerManagerOptions{
|
||||
Generic: cmoptions.GenericControllerManagerOptions{
|
||||
ComponentConfig: componentconfig.KubeControllerManagerConfiguration{
|
||||
Port: 10252, // Note: InsecureServingOptions.ApplyTo will write the flag value back into the component config
|
||||
Address: "0.0.0.0", // Note: InsecureServingOptions.ApplyTo will write the flag value back into the component config
|
||||
AllocateNodeCIDRs: true,
|
||||
CloudConfigFile: "/cloud-config",
|
||||
CloudProvider: "gce",
|
||||
@@ -204,6 +205,11 @@ func TestAddFlags(t *testing.T) {
|
||||
HorizontalPodAutoscalerUseRESTClients: true,
|
||||
UseServiceAccountCredentials: true,
|
||||
},
|
||||
InsecureServing: &cmoptions.InsecureServingOptions{
|
||||
BindAddress: net.ParseIP("192.168.4.10"),
|
||||
BindPort: int(10000),
|
||||
BindNetwork: "tcp",
|
||||
},
|
||||
Kubeconfig: "/kubeconfig",
|
||||
Master: "192.168.4.20",
|
||||
},
|
||||
@@ -211,7 +217,7 @@ func TestAddFlags(t *testing.T) {
|
||||
|
||||
// Sort GCIgnoredResources because it's built from a map, which means the
|
||||
// insertion order is random.
|
||||
sort.Sort(sortedGCIgnoredResources(expected.GCIgnoredResources))
|
||||
sort.Sort(sortedGCIgnoredResources(expected.Generic.ComponentConfig.GCIgnoredResources))
|
||||
|
||||
if !reflect.DeepEqual(expected, s) {
|
||||
t.Errorf("Got different run options than expected.\nDifference detected on:\n%s", diff.ObjectReflectDiff(expected, s))
|
||||
|
||||
Reference in New Issue
Block a user