summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2022-02-11 14:12:39 -0600
committerBrent Baude <bbaude@redhat.com>2022-02-11 17:04:18 -0600
commit73f35ff2ae0343ef45cc92626ea6990bde65a345 (patch)
tree9fcb2d204232e22f8657ec9682827d7259eb6e52 /pkg
parent28ccb79b41553e31c5bf6e6460106f01f0317c6d (diff)
downloadpodman-73f35ff2ae0343ef45cc92626ea6990bde65a345.tar.gz
podman-73f35ff2ae0343ef45cc92626ea6990bde65a345.tar.bz2
podman-73f35ff2ae0343ef45cc92626ea6990bde65a345.zip
Temporarily pull machine images from side repo
Until podman4 is in the fcos trees, we need to pull the machine images from a side repository. There is a hard coded bit that forces the side repo download right now. Simple comment or removal of the bit will revert to normal download behavior. [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/machine/fcos.go57
1 files changed, 56 insertions, 1 deletions
diff --git a/pkg/machine/fcos.go b/pkg/machine/fcos.go
index 60ab471ee..4d3e2edf4 100644
--- a/pkg/machine/fcos.go
+++ b/pkg/machine/fcos.go
@@ -14,6 +14,7 @@ import (
"strings"
"github.com/coreos/stream-metadata-go/fedoracoreos"
+ "github.com/coreos/stream-metadata-go/release"
"github.com/coreos/stream-metadata-go/stream"
"github.com/pkg/errors"
@@ -28,6 +29,14 @@ var (
Format string = "qcow2.xz"
)
+const (
+ // Used for testing the latest podman in fcos
+ // special builds
+ podmanTesting = "podman-testing"
+ PodmanTestingHost = "fedorapeople.org"
+ PodmanTestingURL = "groups/podman/testing"
+)
+
type FcosDownload struct {
Download
}
@@ -111,14 +120,39 @@ func getFcosArch() string {
return arch
}
+// getStreamURL is a wrapper for the fcos.GetStream URL
+// so that we can inject a special stream and url for
+// testing podman before it merges into fcos builds
+func getStreamURL(streamType string) url2.URL {
+ // For the podmanTesting stream type, we point to
+ // a custom url on fedorapeople.org
+ if streamType == podmanTesting {
+ return url2.URL{
+ Scheme: "https",
+ Host: PodmanTestingHost,
+ Path: fmt.Sprintf("%s/%s.json", PodmanTestingURL, "podman4"),
+ }
+ }
+ return fedoracoreos.GetStreamURL(streamType)
+}
+
// 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(imageStream string) (*fcosDownloadInfo, error) {
var (
fcosstable stream.Stream
+ altMeta release.Release
streamType string
)
+
+ // This is being hard set to testing. Once podman4 is in the
+ // fcos trees, we should remove it and re-release at least on
+ // macs.
+ imageStream = "podman-testing"
+
switch imageStream {
+ case "podman-testing":
+ streamType = "podman-testing"
case "testing", "":
streamType = fedoracoreos.StreamTesting
case "next":
@@ -128,7 +162,7 @@ func getFCOSDownload(imageStream string) (*fcosDownloadInfo, error) {
default:
return nil, errors.Errorf("invalid stream %s: valid streams are `testing` and `stable`", imageStream)
}
- streamurl := fedoracoreos.GetStreamURL(streamType)
+ streamurl := getStreamURL(streamType)
resp, err := http.Get(streamurl.String())
if err != nil {
return nil, err
@@ -142,6 +176,27 @@ func getFCOSDownload(imageStream string) (*fcosDownloadInfo, error) {
logrus.Error(err)
}
}()
+ if imageStream == podmanTesting {
+ if err := json.Unmarshal(body, &altMeta); err != nil {
+ return nil, err
+ }
+
+ arches, ok := altMeta.Architectures[getFcosArch()]
+ if !ok {
+ return nil, fmt.Errorf("unable to pull VM image: no targetArch in stream")
+ }
+ qcow2, ok := arches.Media.Qemu.Artifacts["qcow2.xz"]
+ if !ok {
+ return nil, fmt.Errorf("unable to pull VM image: no qcow2.xz format in stream")
+ }
+ disk := qcow2.Disk
+
+ return &fcosDownloadInfo{
+ Location: disk.Location,
+ Sha256Sum: disk.Sha256,
+ CompressionType: "xz",
+ }, nil
+ }
if err := json.Unmarshal(body, &fcosstable); err != nil {
return nil, err