summaryrefslogtreecommitdiff
path: root/pkg/machine/fcos.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2021-03-29 14:37:58 -0500
committerbaude <bbaude@redhat.com>2021-03-29 14:42:45 -0500
commit236798e001021b6f9d8323afa923d0540396e1d5 (patch)
treedc6ce005fa4af1d2d1f43cad8ef4dabf2a1abdb7 /pkg/machine/fcos.go
parentaa96cb6739303a4bf76aeb6395e8ef79ff8ef0ee (diff)
downloadpodman-236798e001021b6f9d8323afa923d0540396e1d5.tar.gz
podman-236798e001021b6f9d8323afa923d0540396e1d5.tar.bz2
podman-236798e001021b6f9d8323afa923d0540396e1d5.zip
podman machine init user input
users may now provide a fully qualified local file path or a URL to seed the disk-image to be used in the VM. [NO TESTS NEEDED] Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/machine/fcos.go')
-rw-r--r--pkg/machine/fcos.go40
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 {