Skip to content

Commit a34f279

Browse files
Merge pull request #13233 from baude/v4.0fcosside
[BACKPORT] V4.0fcosside
2 parents aa1a6b6 + 421b746 commit a34f279

File tree

5 files changed

+380
-1
lines changed

5 files changed

+380
-1
lines changed

pkg/machine/fcos.go

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"strings"
1515

1616
"github.com/coreos/stream-metadata-go/fedoracoreos"
17+
"github.com/coreos/stream-metadata-go/release"
1718
"github.com/coreos/stream-metadata-go/stream"
1819
"github.com/pkg/errors"
1920

@@ -28,6 +29,14 @@ var (
2829
Format string = "qcow2.xz"
2930
)
3031

32+
const (
33+
// Used for testing the latest podman in fcos
34+
// special builds
35+
podmanTesting = "podman-testing"
36+
PodmanTestingHost = "fedorapeople.org"
37+
PodmanTestingURL = "groups/podman/testing"
38+
)
39+
3140
type FcosDownload struct {
3241
Download
3342
}
@@ -111,14 +120,39 @@ func getFcosArch() string {
111120
return arch
112121
}
113122

123+
// getStreamURL is a wrapper for the fcos.GetStream URL
124+
// so that we can inject a special stream and url for
125+
// testing podman before it merges into fcos builds
126+
func getStreamURL(streamType string) url2.URL {
127+
// For the podmanTesting stream type, we point to
128+
// a custom url on fedorapeople.org
129+
if streamType == podmanTesting {
130+
return url2.URL{
131+
Scheme: "https",
132+
Host: PodmanTestingHost,
133+
Path: fmt.Sprintf("%s/%s.json", PodmanTestingURL, "podman4"),
134+
}
135+
}
136+
return fedoracoreos.GetStreamURL(streamType)
137+
}
138+
114139
// This should get Exported and stay put as it will apply to all fcos downloads
115140
// getFCOS parses fedoraCoreOS's stream and returns the image download URL and the release version
116141
func getFCOSDownload(imageStream string) (*fcosDownloadInfo, error) {
117142
var (
118143
fcosstable stream.Stream
144+
altMeta release.Release
119145
streamType string
120146
)
147+
148+
// This is being hard set to testing. Once podman4 is in the
149+
// fcos trees, we should remove it and re-release at least on
150+
// macs.
151+
imageStream = "podman-testing"
152+
121153
switch imageStream {
154+
case "podman-testing":
155+
streamType = "podman-testing"
122156
case "testing", "":
123157
streamType = fedoracoreos.StreamTesting
124158
case "next":
@@ -128,7 +162,7 @@ func getFCOSDownload(imageStream string) (*fcosDownloadInfo, error) {
128162
default:
129163
return nil, errors.Errorf("invalid stream %s: valid streams are `testing` and `stable`", imageStream)
130164
}
131-
streamurl := fedoracoreos.GetStreamURL(streamType)
165+
streamurl := getStreamURL(streamType)
132166
resp, err := http.Get(streamurl.String())
133167
if err != nil {
134168
return nil, err
@@ -142,6 +176,27 @@ func getFCOSDownload(imageStream string) (*fcosDownloadInfo, error) {
142176
logrus.Error(err)
143177
}
144178
}()
179+
if imageStream == podmanTesting {
180+
if err := json.Unmarshal(body, &altMeta); err != nil {
181+
return nil, err
182+
}
183+
184+
arches, ok := altMeta.Architectures[getFcosArch()]
185+
if !ok {
186+
return nil, fmt.Errorf("unable to pull VM image: no targetArch in stream")
187+
}
188+
qcow2, ok := arches.Media.Qemu.Artifacts["qcow2.xz"]
189+
if !ok {
190+
return nil, fmt.Errorf("unable to pull VM image: no qcow2.xz format in stream")
191+
}
192+
disk := qcow2.Disk
193+
194+
return &fcosDownloadInfo{
195+
Location: disk.Location,
196+
Sha256Sum: disk.Sha256,
197+
CompressionType: "xz",
198+
}, nil
199+
}
145200

146201
if err := json.Unmarshal(body, &fcosstable); err != nil {
147202
return nil, err

vendor/github.com/coreos/stream-metadata-go/release/release.go

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/coreos/stream-metadata-go/release/rhcos/rhcos.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)