add arch to iso cache path, fix download only tests

pull/13539/head
Sharif Elgamal 2022-02-03 10:29:13 -08:00
parent 89213faa34
commit f74ea169b2
4 changed files with 11 additions and 10 deletions

View File

@ -23,7 +23,6 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
"k8s.io/minikube/pkg/minikube/localpath"
)
var (
@ -181,9 +180,6 @@ var (
// kubeadm (kubelet, kubeadm) and the addon manager (kubectl)
KubernetesReleaseBinaries = []string{"kubelet", "kubeadm", "kubectl"}
// ISOCacheDir is the path to the virtual machine image cache directory
ISOCacheDir = localpath.MakeMiniPath("cache", "iso")
// DefaultNamespaces are Kubernetes namespaces used by minikube, including addons
DefaultNamespaces = []string{
"kube-system",

View File

@ -115,12 +115,17 @@ func GithubActionRunner() bool {
return os.Getenv("GITHUB_ACTIONS") == "true"
}
// ImageCacheDir returns the path to the container image cache directory in minikube home folder for the current architecture
// ImageCacheDir returns the path in the minikube home directory to the container image cache for the current architecture
func ImageCacheDir() string {
return filepath.Join(localpath.MakeMiniPath("cache", "images"), runtime.GOARCH)
}
// KICCacheDir returns the path to the container node image cache directory for the current architecture
// KICCacheDir returns the path in the minikube home directory to the container node cache for the current architecture
func KICCacheDir() string {
return filepath.Join(localpath.MakeMiniPath("cache", "kic"), runtime.GOARCH)
}
// ISOCacheDir returns the path in the minikube home directory to the virtual machine image cache for the current architecture
func ISOCacheDir() string {
return filepath.Join(localpath.MakeMiniPath("cache", "iso"), runtime.GOARCH)
}

View File

@ -28,7 +28,7 @@ import (
"github.com/juju/mutex"
"github.com/pkg/errors"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/detect"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/style"
"k8s.io/minikube/pkg/util/lock"
@ -75,7 +75,7 @@ func localISOPath(u *url.URL) string {
return u.String()
}
return filepath.Join(constants.ISOCacheDir, path.Base(u.Path))
return filepath.Join(detect.ISOCacheDir(), path.Base(u.Path))
}
// ISO downloads and returns the path to the downloaded ISO

View File

@ -143,7 +143,7 @@ func TestDownloadOnly(t *testing.T) {
}
// checking binaries downloaded (kubelet,kubeadm)
for _, bin := range constants.KubernetesReleaseBinaries {
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", v, bin)
fp := filepath.Join(localpath.MiniPath(), "cache", "linux", runtime.GOARCH, v, bin)
_, err := os.Stat(fp)
if err != nil {
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
@ -161,7 +161,7 @@ func TestDownloadOnly(t *testing.T) {
if runtime.GOOS == "windows" {
binary = "kubectl.exe"
}
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, v, binary)
fp := filepath.Join(localpath.MiniPath(), "cache", runtime.GOOS, runtime.GOARCH, v, binary)
if _, err := os.Stat(fp); err != nil {
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
}