@@ -14,6 +14,7 @@ import (
14
14
"strings"
15
15
16
16
"github.com/coreos/stream-metadata-go/fedoracoreos"
17
+ "github.com/coreos/stream-metadata-go/release"
17
18
"github.com/coreos/stream-metadata-go/stream"
18
19
"github.com/pkg/errors"
19
20
28
29
Format string = "qcow2.xz"
29
30
)
30
31
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
+
31
40
type FcosDownload struct {
32
41
Download
33
42
}
@@ -111,14 +120,39 @@ func getFcosArch() string {
111
120
return arch
112
121
}
113
122
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
+
114
139
// This should get Exported and stay put as it will apply to all fcos downloads
115
140
// getFCOS parses fedoraCoreOS's stream and returns the image download URL and the release version
116
141
func getFCOSDownload (imageStream string ) (* fcosDownloadInfo , error ) {
117
142
var (
118
143
fcosstable stream.Stream
144
+ altMeta release.Release
119
145
streamType string
120
146
)
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
+
121
153
switch imageStream {
154
+ case "podman-testing" :
155
+ streamType = "podman-testing"
122
156
case "testing" , "" :
123
157
streamType = fedoracoreos .StreamTesting
124
158
case "next" :
@@ -128,7 +162,7 @@ func getFCOSDownload(imageStream string) (*fcosDownloadInfo, error) {
128
162
default :
129
163
return nil , errors .Errorf ("invalid stream %s: valid streams are `testing` and `stable`" , imageStream )
130
164
}
131
- streamurl := fedoracoreos . GetStreamURL (streamType )
165
+ streamurl := getStreamURL (streamType )
132
166
resp , err := http .Get (streamurl .String ())
133
167
if err != nil {
134
168
return nil , err
@@ -142,6 +176,27 @@ func getFCOSDownload(imageStream string) (*fcosDownloadInfo, error) {
142
176
logrus .Error (err )
143
177
}
144
178
}()
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
+ }
145
200
146
201
if err := json .Unmarshal (body , & fcosstable ); err != nil {
147
202
return nil , err
0 commit comments