@@ -51,11 +51,19 @@ const (
51
51
envTestDropgz = "TEST_DROPGZ"
52
52
envCNIDropgzVersion = "CNI_DROPGZ_VERSION"
53
53
envCNSVersion = "CNS_VERSION"
54
+ envCNSImageRepo = "CNS_IMAGE_REPO"
54
55
EnvInstallCNS = "INSTALL_CNS"
55
56
cnsLinuxLabelSelector = "k8s-app=azure-cns"
56
57
cnsWindowsLabelSelector = "k8s-app=azure-cns-win"
58
+ acnImageRepoURL = "acnpublic.azurecr.io"
59
+ mcrImageRepoURL = "mcr.microsoft.com/containernetworking"
57
60
)
58
61
62
+ var imageRepoURL = map [string ]string {
63
+ "ACN" : acnImageRepoURL ,
64
+ "MCR" : mcrImageRepoURL ,
65
+ }
66
+
59
67
var (
60
68
ErrUnsupportedCNSScenario = errors .New ("unsupported CNS scenario" )
61
69
ErrPathNotFound = errors .New ("failed to get the absolute path to directory" )
@@ -517,9 +525,14 @@ func parseCNSDaemonset(cnsVersion, cniDropgzVersion string,
517
525
}
518
526
519
527
cns := MustParseDaemonSet (cnsScenarioDetails .daemonsetPath )
528
+ _ , image , _ := ParseImageString (cns .Spec .Template .Spec .Containers [0 ].Image )
529
+ url , key := imageRepoURL [os .Getenv (string (envCNSImageRepo ))]
530
+ if ! key {
531
+ log .Printf ("%s not set to expected value \" ACN\" , \" MCR\" . Default to %s" , envCNSImageRepo , imageRepoURL ["ACN" ])
532
+ url = imageRepoURL ["ACN" ]
533
+ }
520
534
521
- image , _ := ParseImageString (cns .Spec .Template .Spec .Containers [0 ].Image )
522
- cns .Spec .Template .Spec .Containers [0 ].Image = GetImageString (image , cnsVersion )
535
+ cns .Spec .Template .Spec .Containers [0 ].Image = GetImageString (url , image , cnsVersion )
523
536
524
537
log .Printf ("Checking environment scenario" )
525
538
cns = loadDropgzImage (cns , cniDropgzVersion )
@@ -546,12 +559,12 @@ func loadDropgzImage(cns appsv1.DaemonSet, dropgzVersion string) appsv1.DaemonSe
546
559
installFlag := os .Getenv (envTestDropgz )
547
560
if testDropgzScenario , err := strconv .ParseBool (installFlag ); err == nil && testDropgzScenario {
548
561
log .Printf ("Env %v set to true, deploy cniTest.Dockerfile" , envTestDropgz )
549
- initImage , _ := ParseImageString ("acnpublic.azurecr.io/cni-dropgz-test:latest" )
550
- cns .Spec .Template .Spec .InitContainers [0 ].Image = GetImageString (initImage , dropgzVersion )
562
+ url , initImage , _ := ParseImageString ("acnpublic.azurecr.io/cni-dropgz-test:latest" )
563
+ cns .Spec .Template .Spec .InitContainers [0 ].Image = GetImageString (url , initImage , dropgzVersion )
551
564
} else {
552
565
log .Printf ("Env %v not set to true, deploying cni.Dockerfile" , envTestDropgz )
553
- initImage , _ := ParseImageString (cns .Spec .Template .Spec .InitContainers [0 ].Image )
554
- cns .Spec .Template .Spec .InitContainers [0 ].Image = GetImageString (initImage , dropgzVersion )
566
+ url , initImage , _ := ParseImageString (cns .Spec .Template .Spec .InitContainers [0 ].Image )
567
+ cns .Spec .Template .Spec .InitContainers [0 ].Image = GetImageString (url , initImage , dropgzVersion )
555
568
}
556
569
return cns
557
570
}
0 commit comments