diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-30 16:07:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 16:07:02 +0200 |
commit | 5e28b35aa511e699dffb2172458fda35ac01a4d2 (patch) | |
tree | 59c6654a54e22a9feb49fbe6f8f68ffce9d58218 /pkg/machine/fcos.go | |
parent | bb66b49cd7b4489940aed8d0109e1e269dad72a1 (diff) | |
parent | 236798e001021b6f9d8323afa923d0540396e1d5 (diff) | |
download | podman-5e28b35aa511e699dffb2172458fda35ac01a4d2.tar.gz podman-5e28b35aa511e699dffb2172458fda35ac01a4d2.tar.bz2 podman-5e28b35aa511e699dffb2172458fda35ac01a4d2.zip |
Merge pull request #9872 from baude/vmaltimage
podman machine init user input
Diffstat (limited to 'pkg/machine/fcos.go')
-rw-r--r-- | pkg/machine/fcos.go | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/pkg/machine/fcos.go b/pkg/machine/fcos.go index 0c6a2485e..32f943c87 100644 --- a/pkg/machine/fcos.go +++ b/pkg/machine/fcos.go @@ -2,17 +2,13 @@ package machine import ( "crypto/sha256" - "io" "io/ioutil" url2 "net/url" - "os" "path/filepath" "runtime" "strings" - "github.com/containers/storage/pkg/archive" digest "github.com/opencontainers/go-digest" - "github.com/sirupsen/logrus" ) // These should eventually be moved into machine/qemu as @@ -75,41 +71,7 @@ func (f FcosDownload) DownloadImage() error { return err } } - uncompressedFileWriter, err := os.OpenFile(f.getLocalUncompressedName(), os.O_CREATE|os.O_RDWR, 0600) - if err != nil { - return err - } - sourceFile, err := ioutil.ReadFile(f.LocalPath) - if err != nil { - return err - } - compressionType := archive.DetectCompression(sourceFile) - f.CompressionType = compressionType.Extension() - - switch f.CompressionType { - case "tar.xz": - return decompressXZ(f.LocalPath, uncompressedFileWriter) - default: - // File seems to be uncompressed, make a copy - if err := copyFile(f.LocalPath, uncompressedFileWriter); err != nil { - return err - } - } - return nil -} - -func copyFile(src string, dest *os.File) error { - source, err := os.Open(src) - if err != nil { - return err - } - defer func() { - if err := source.Close(); err != nil { - logrus.Error(err) - } - }() - _, err = io.Copy(dest, source) - return err + return Decompress(f.LocalPath, f.getLocalUncompressedName()) } func (f FcosDownload) Get() *Download { |