small clean and fix tests with old k8s versions

pull/16029/head
Steven Powell 2023-03-29 09:58:47 -07:00
parent da9065fce4
commit 77f207e01b
4 changed files with 15 additions and 16 deletions

View File

@ -16,20 +16,13 @@ limitations under the License.
package images
// OldDefaultKubernetesRepo is the old default Kubernetes repository
const OldDefaultKubernetesRepo = "k8s.gcr.io"
// NewDefaultKubernetesRepo is the new default Kubernetes repository
const NewDefaultKubernetesRepo = "registry.k8s.io"
// DefaultKubernetesRepo is the default Kubernetes repository
const DefaultKubernetesRepo = "registry.k8s.io"
// kubernetesRepo returns the official Kubernetes repository, or an alternate
func kubernetesRepo(mirror string) string {
if mirror != "" {
return mirror
}
return DefaultKubernetesRepo()
}
func DefaultKubernetesRepo() string {
return NewDefaultKubernetesRepo
return DefaultKubernetesRepo
}

View File

@ -29,7 +29,7 @@ func Test_kubernetesRepo(t *testing.T) {
}{
{
"",
DefaultKubernetesRepo(),
DefaultKubernetesRepo,
},
{
"mirror.k8s.io",
@ -37,11 +37,11 @@ func Test_kubernetesRepo(t *testing.T) {
},
{
"",
NewDefaultKubernetesRepo,
DefaultKubernetesRepo,
},
{
"",
NewDefaultKubernetesRepo,
DefaultKubernetesRepo,
},
}
for _, tc := range tests {

View File

@ -822,7 +822,7 @@ func tryRegistry(r command.Runner, driverName, imageRepository, ip string) {
}
if imageRepository == "" {
imageRepository = images.DefaultKubernetesRepo()
imageRepository = images.DefaultKubernetesRepo
}
opts = append(opts, fmt.Sprintf("https://%s/", imageRepository))

View File

@ -354,7 +354,7 @@ func testPulledImages(ctx context.Context, t *testing.T, profile, version string
rr, err := Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "sudo crictl images -o json"))
if err != nil {
t.Errorf("failed tp get images inside minikube. args %q: %v", rr.Command(), err)
t.Errorf("failed to get images inside minikube. args %q: %v", rr.Command(), err)
}
jv := map[string][]struct {
Tags []string `json:"repoTags"`
@ -377,7 +377,13 @@ func testPulledImages(ctx context.Context, t *testing.T, profile, version string
}
}
}
wantRaw, err := images.Kubeadm("", version)
mirror := ""
// Kubernetes versions prior to v1.25 will contain the old registry due to the preload
if v, _ := util.ParseKubernetesVersion(kubernetesVersion); v.LT(semver.MustParse("1.25.0-alpha.1")) {
mirror = "k8s.gcr.io"
}
wantRaw, err := images.Kubeadm(mirror, version)
if err != nil {
t.Errorf("failed to get kubeadm images for %s : %v", version, err)
}