diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/machine/fcos.go | 4 | ||||
-rw-r--r-- | pkg/machine/fcos_amd64.go | 14 | ||||
-rw-r--r-- | pkg/machine/fcos_arm64.go | 2 | ||||
-rw-r--r-- | pkg/machine/qemu/machine.go | 24 |
4 files changed, 27 insertions, 17 deletions
diff --git a/pkg/machine/fcos.go b/pkg/machine/fcos.go index 49ec01e67..85cedcd5a 100644 --- a/pkg/machine/fcos.go +++ b/pkg/machine/fcos.go @@ -24,8 +24,8 @@ type FcosDownload struct { Download } -func NewFcosDownloader(vmType, vmName string) (DistributionDownload, error) { - info, err := getFCOSDownload() +func NewFcosDownloader(vmType, vmName, imageStream string) (DistributionDownload, error) { + info, err := getFCOSDownload(imageStream) if err != nil { return nil, err } diff --git a/pkg/machine/fcos_amd64.go b/pkg/machine/fcos_amd64.go index 36676405a..4e2e86d3e 100644 --- a/pkg/machine/fcos_amd64.go +++ b/pkg/machine/fcos_amd64.go @@ -8,16 +8,26 @@ import ( "github.com/coreos/stream-metadata-go/fedoracoreos" "github.com/coreos/stream-metadata-go/stream" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) // This should get Exported and stay put as it will apply to all fcos downloads // getFCOS parses fedoraCoreOS's stream and returns the image download URL and the release version -func getFCOSDownload() (*fcosDownloadInfo, error) { +func getFCOSDownload(imageStream string) (*fcosDownloadInfo, error) { var ( fcosstable stream.Stream + streamType string ) - streamurl := fedoracoreos.GetStreamURL(fedoracoreos.StreamNext) + switch imageStream { + case "testing", "": + streamType = fedoracoreos.StreamNext + case "stable": + streamType = fedoracoreos.StreamStable + default: + return nil, errors.Errorf("invalid stream %s: valid streams are `testing` and `stable`", imageStream) + } + streamurl := fedoracoreos.GetStreamURL(streamType) resp, err := http.Get(streamurl.String()) if err != nil { return nil, err diff --git a/pkg/machine/fcos_arm64.go b/pkg/machine/fcos_arm64.go index f5cd5a505..f45522be0 100644 --- a/pkg/machine/fcos_arm64.go +++ b/pkg/machine/fcos_arm64.go @@ -13,7 +13,7 @@ const aarchBaseURL = "https://fedorapeople.org/groups/fcos-images/builds/latest/ // Total hack until automation is possible. // We need a proper json file at least to automate -func getFCOSDownload() (*fcosDownloadInfo, error) { +func getFCOSDownload(imageStream string) (*fcosDownloadInfo, error) { meta := Build{} resp, err := http.Get(aarchBaseURL + "meta.json") if err != nil { diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index a92892957..871436618 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -138,29 +138,29 @@ func (v *MachineVM) Init(opts machine.InitOptions) error { jsonFile := filepath.Join(vmConfigDir, v.Name) + ".json" v.IdentityPath = filepath.Join(sshDir, v.Name) - // The user has provided an alternate image which can be a file path - // or URL. - if len(opts.ImagePath) > 0 { - g, err := machine.NewGenericDownloader(vmtype, v.Name, opts.ImagePath) + switch opts.ImagePath { + case "testing", "stable", "": + // Get image as usual + dd, err := machine.NewFcosDownloader(vmtype, v.Name, opts.ImagePath) if err != nil { return err } - v.ImagePath = g.Get().LocalUncompressedFile - if err := g.DownloadImage(); err != nil { + v.ImagePath = dd.Get().LocalUncompressedFile + if err := dd.DownloadImage(); err != nil { return err } - } else { - // Get the image as usual - dd, err := machine.NewFcosDownloader(vmtype, v.Name) + default: + // The user has provided an alternate image which can be a file path + // or URL. + g, err := machine.NewGenericDownloader(vmtype, v.Name, opts.ImagePath) if err != nil { return err } - v.ImagePath = dd.Get().LocalUncompressedFile - if err := dd.DownloadImage(); err != nil { + v.ImagePath = g.Get().LocalUncompressedFile + if err := g.DownloadImage(); err != nil { return err } } - // Add arch specific options including image location v.CmdLine = append(v.CmdLine, v.addArchOptions()...) |