aboutsummaryrefslogtreecommitdiff
path: root/pkg/machine/config.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-07-27 12:02:25 -0400
committerGitHub <noreply@github.com>2022-07-27 12:02:25 -0400
commit87f892e5b56c2fab2f394f8cc79794ccce03f510 (patch)
tree1ba831a9dddfb6927698bcb9e0c2bee913ad0dcb /pkg/machine/config.go
parentc57b5c9b831695f8c54d11b4f288d6037c096fea (diff)
parent983cfb90e68d7b292b0f6ee8800c3f23383493cc (diff)
downloadpodman-87f892e5b56c2fab2f394f8cc79794ccce03f510.tar.gz
podman-87f892e5b56c2fab2f394f8cc79794ccce03f510.tar.bz2
podman-87f892e5b56c2fab2f394f8cc79794ccce03f510.zip
Merge pull request #15076 from mheon/bump_420_rc2
Bump to v4.2.0-RC2
Diffstat (limited to 'pkg/machine/config.go')
-rw-r--r--pkg/machine/config.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/pkg/machine/config.go b/pkg/machine/config.go
index 29cd7bc00..253601dad 100644
--- a/pkg/machine/config.go
+++ b/pkg/machine/config.go
@@ -73,6 +73,7 @@ type Download struct {
Arch string
Artifact string
CompressionType string
+ CacheDir string
Format string
ImageName string
LocalPath string
@@ -139,6 +140,7 @@ type VM interface {
type DistributionDownload interface {
HasUsableCache() (bool, error)
Get() *Download
+ CleanCache() error
}
type InspectInfo struct {
ConfigPath VMFile
@@ -172,6 +174,19 @@ func (rc RemoteConnectionType) MakeSSHURL(host, path, port, userName string) url
return uri
}
+// GetCacheDir returns the dir where VM images are downladed into when pulled
+func GetCacheDir(vmType string) (string, error) {
+ dataDir, err := GetDataDir(vmType)
+ if err != nil {
+ return "", err
+ }
+ cacheDir := filepath.Join(dataDir, "cache")
+ if _, err := os.Stat(cacheDir); !errors.Is(err, os.ErrNotExist) {
+ return cacheDir, nil
+ }
+ return cacheDir, os.MkdirAll(cacheDir, 0755)
+}
+
// GetDataDir returns the filepath where vm images should
// live for podman-machine.
func GetDataDir(vmType string) (string, error) {
@@ -180,7 +195,7 @@ func GetDataDir(vmType string) (string, error) {
return "", err
}
dataDir := filepath.Join(dataDirPrefix, vmType)
- if _, err := os.Stat(dataDir); !os.IsNotExist(err) {
+ if _, err := os.Stat(dataDir); !errors.Is(err, os.ErrNotExist) {
return dataDir, nil
}
mkdirErr := os.MkdirAll(dataDir, 0755)
@@ -205,7 +220,7 @@ func GetConfDir(vmType string) (string, error) {
return "", err
}
confDir := filepath.Join(confDirPrefix, vmType)
- if _, err := os.Stat(confDir); !os.IsNotExist(err) {
+ if _, err := os.Stat(confDir); !errors.Is(err, os.ErrNotExist) {
return confDir, nil
}
mkdirErr := os.MkdirAll(confDir, 0755)