diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index e77336e5c4..03b4ad8f7a 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -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", diff --git a/pkg/minikube/detect/detect.go b/pkg/minikube/detect/detect.go index ad29310ca9..c5910efc59 100644 --- a/pkg/minikube/detect/detect.go +++ b/pkg/minikube/detect/detect.go @@ -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) +} diff --git a/pkg/minikube/download/iso.go b/pkg/minikube/download/iso.go index 08f4042ba1..994b9c68c3 100644 --- a/pkg/minikube/download/iso.go +++ b/pkg/minikube/download/iso.go @@ -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 diff --git a/test/integration/aaa_download_only_test.go b/test/integration/aaa_download_only_test.go index d1f88dddfd..e9a422f2ae 100644 --- a/test/integration/aaa_download_only_test.go +++ b/test/integration/aaa_download_only_test.go @@ -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) }