@@ -186,22 +186,6 @@ var (
186
186
clusterName: foo
187
187
` , kubeadmapiv1 .GroupName , oldClusterConfigVersion )
188
188
189
- // currentBarClusterConfig is a minimal currently supported ClusterConfiguration
190
- // with a well known value of clusterName (in this case `bar`)
191
- currentBarClusterConfig = fmt .Sprintf (`
192
- apiVersion: %s
193
- kind: ClusterConfiguration
194
- clusterName: bar
195
- ` , kubeadmapiv1 .SchemeGroupVersion )
196
-
197
- // oldBarClusterConfig is a minimal unsupported ClusterConfiguration
198
- // with a well known value of clusterName (in this case `bar`)
199
- oldBarClusterConfig = fmt .Sprintf (`
200
- apiVersion: %s/%s
201
- kind: ClusterConfiguration
202
- clusterName: bar
203
- ` , kubeadmapiv1 .GroupName , oldClusterConfigVersion )
204
-
205
189
// This is the "minimal" valid config that can be unmarshalled to and from YAML.
206
190
// Due to same static defaulting it's not exactly small in size.
207
191
validUnmarshallableClusterConfig = struct {
@@ -490,126 +474,6 @@ func TestLoadingFromCluster(t *testing.T) {
490
474
})
491
475
}
492
476
493
- func TestFetchFromClusterWithLocalOverwrites (t * testing.T ) {
494
- fakeKnownContext (func () {
495
- cases := []struct {
496
- desc string
497
- obj runtime.Object
498
- config string
499
- expectedValue string
500
- isNotLoaded bool
501
- expectedErr bool
502
- }{
503
- {
504
- desc : "appropriate cluster object without overwrite is used" ,
505
- obj : testClusterConfigMap (currentFooClusterConfig , false ),
506
- expectedValue : "foo" ,
507
- },
508
- {
509
- desc : "appropriate cluster object with appropriate overwrite is overwritten" ,
510
- obj : testClusterConfigMap (currentFooClusterConfig , false ),
511
- config : dedent .Dedent (currentBarClusterConfig ),
512
- expectedValue : "bar" ,
513
- },
514
- {
515
- desc : "appropriate cluster object with old overwrite returns an error" ,
516
- obj : testClusterConfigMap (currentFooClusterConfig , false ),
517
- config : dedent .Dedent (oldBarClusterConfig ),
518
- expectedErr : true ,
519
- },
520
- {
521
- desc : "old config without overwrite returns an error" ,
522
- obj : testClusterConfigMap (oldFooClusterConfig , false ),
523
- expectedErr : true ,
524
- },
525
- {
526
- desc : "old config with appropriate overwrite returns the substitute" ,
527
- obj : testClusterConfigMap (oldFooClusterConfig , false ),
528
- config : dedent .Dedent (currentBarClusterConfig ),
529
- expectedValue : "bar" ,
530
- },
531
- {
532
- desc : "old config with old overwrite returns an error" ,
533
- obj : testClusterConfigMap (oldFooClusterConfig , false ),
534
- config : dedent .Dedent (oldBarClusterConfig ),
535
- expectedErr : true ,
536
- },
537
- {
538
- desc : "appropriate signed cluster object without overwrite is used" ,
539
- obj : testClusterConfigMap (currentFooClusterConfig , true ),
540
- expectedValue : "foo" ,
541
- },
542
- {
543
- desc : "appropriate signed cluster object with appropriate overwrite is overwritten" ,
544
- obj : testClusterConfigMap (currentFooClusterConfig , true ),
545
- config : dedent .Dedent (currentBarClusterConfig ),
546
- expectedValue : "bar" ,
547
- },
548
- {
549
- desc : "appropriate signed cluster object with old overwrite returns an error" ,
550
- obj : testClusterConfigMap (currentFooClusterConfig , true ),
551
- config : dedent .Dedent (oldBarClusterConfig ),
552
- expectedErr : true ,
553
- },
554
- {
555
- desc : "old signed config without an overwrite is not loaded" ,
556
- obj : testClusterConfigMap (oldFooClusterConfig , true ),
557
- isNotLoaded : true ,
558
- },
559
- {
560
- desc : "old signed config with appropriate overwrite returns the substitute" ,
561
- obj : testClusterConfigMap (oldFooClusterConfig , true ),
562
- config : dedent .Dedent (currentBarClusterConfig ),
563
- expectedValue : "bar" ,
564
- },
565
- {
566
- desc : "old signed config with old overwrite returns an error" ,
567
- obj : testClusterConfigMap (oldFooClusterConfig , true ),
568
- config : dedent .Dedent (oldBarClusterConfig ),
569
- expectedErr : true ,
570
- },
571
- }
572
-
573
- for _ , test := range cases {
574
- t .Run (test .desc , func (t * testing.T ) {
575
- client := clientsetfake .NewSimpleClientset (test .obj )
576
-
577
- docmap , err := kubeadmutil .SplitYAMLDocuments ([]byte (test .config ))
578
- if err != nil {
579
- t .Fatalf ("unexpected failure of SplitYAMLDocuments: %v" , err )
580
- }
581
-
582
- clusterCfg := testClusterCfg ()
583
-
584
- err = FetchFromClusterWithLocalOverwrites (clusterCfg , client , docmap )
585
- if err != nil {
586
- if ! test .expectedErr {
587
- t .Errorf ("unexpected failure: %v" , err )
588
- }
589
- } else {
590
- if test .expectedErr {
591
- t .Error ("unexpected success" )
592
- } else {
593
- clusterCfg , ok := clusterCfg .ComponentConfigs [kubeadmapiv1 .GroupName ]
594
- if ! ok {
595
- if ! test .isNotLoaded {
596
- t .Error ("no config was loaded when it should have been" )
597
- }
598
- } else {
599
- actualConfig , ok := clusterCfg .(* clusterConfig )
600
- if ! ok {
601
- t .Error ("the config is not of the expected type" )
602
- } else if actualConfig .config .ClusterName != test .expectedValue {
603
- t .Errorf ("unexpected value:\n \t got: %q\n \t expected: %q" , actualConfig .config .ClusterName , test .expectedValue )
604
- }
605
- }
606
- }
607
- }
608
- })
609
- }
610
- })
611
- }
612
-
613
477
func TestGetVersionStates (t * testing.T ) {
614
478
fakeKnownContext (func () {
615
479
versionStateCurrent := outputapiv1alpha3.ComponentConfigVersionState {
0 commit comments