diff --git a/pkg/machine/e2e/config_unix_test.go b/pkg/machine/e2e/config_unix_test.go index 6f014d60b3..ae9c1bb6b5 100644 --- a/pkg/machine/e2e/config_unix_test.go +++ b/pkg/machine/e2e/config_unix_test.go @@ -6,11 +6,6 @@ import ( "os/exec" ) -// TODO temporarily suspended -// func getDownloadLocation(p machine.VirtProvider) string { -// return getFCOSDownloadLocation(p) -// } - func pgrep(n string) (string, error) { out, err := exec.Command("pgrep", "gvproxy").Output() return string(out), err diff --git a/pkg/machine/e2e/machine_test.go b/pkg/machine/e2e/machine_test.go index f7af93ad17..663ffa8ae2 100644 --- a/pkg/machine/e2e/machine_test.go +++ b/pkg/machine/e2e/machine_test.go @@ -30,7 +30,6 @@ func TestMain(m *testing.M) { } const ( - defaultStream = machine.Testing defaultDiskSize uint = 11 ) @@ -75,7 +74,7 @@ var _ = BeforeSuite(func() { default: downloadLocation, err = GetDownload(testProvider.VMType()) if err != nil { - Fail("unable to derive download disk from fedora coreos") + Fail(fmt.Sprintf("unable to derive download disk from fedora coreos: %q", err)) } } } diff --git a/pkg/machine/e2e/pull_test.go b/pkg/machine/e2e/pull_test.go index 42a824b2b3..b0ffead981 100644 --- a/pkg/machine/e2e/pull_test.go +++ b/pkg/machine/e2e/pull_test.go @@ -5,9 +5,10 @@ import ( "fmt" "io" "net/http" + "runtime" - "github.com/containers/podman/v5/pkg/machine" "github.com/containers/podman/v5/pkg/machine/define" + "github.com/containers/podman/v5/pkg/machine/vmconfigs" "github.com/coreos/stream-metadata-go/fedoracoreos" "github.com/coreos/stream-metadata-go/stream" "github.com/sirupsen/logrus" @@ -49,11 +50,15 @@ func GetDownload(vmType define.VMType) (string, error) { format = "qcow2.xz" } - arch, ok := fcosstable.Architectures[machine.GetFcosArch()] + arch, err := vmconfigs.NormalizeMachineArch(runtime.GOARCH) + if err != nil { + return "", err + } + fcosArch, ok := fcosstable.Architectures[arch] if !ok { return "", fmt.Errorf("unable to pull VM image: no targetArch in stream") } - upstreamArtifacts := arch.Artifacts + upstreamArtifacts := fcosArch.Artifacts if upstreamArtifacts == nil { return "", fmt.Errorf("unable to pull VM image: no artifact in stream") } diff --git a/pkg/machine/fcos.go b/pkg/machine/fcos.go deleted file mode 100644 index 5707ebbadb..0000000000 --- a/pkg/machine/fcos.go +++ /dev/null @@ -1,239 +0,0 @@ -//go:build amd64 || arm64 - -package machine - -import ( - "encoding/json" - "fmt" - "io" - "net/http" - url2 "net/url" - "os" - "runtime" - "time" - - "github.com/containers/podman/v5/pkg/machine/compression" - "github.com/containers/podman/v5/pkg/machine/define" - "github.com/coreos/stream-metadata-go/fedoracoreos" - "github.com/coreos/stream-metadata-go/release" - "github.com/coreos/stream-metadata-go/stream" - "github.com/opencontainers/go-digest" - "github.com/sirupsen/logrus" -) - -const ( - // Used for testing the latest podman in fcos - // special builds - PodmanTestingHost = "fedorapeople.org" - PodmanTestingURL = "groups/podman/testing" -) - -// -// TODO artifact, imageformat, and imagecompression should be probably combined into some sort -// of object which can "produce" the correct output we are looking for bc things like -// image format contain both the image type AND the compression. This work can be done before -// or after the hyperv work. For now, my preference is to NOT change things and just get things -// typed strongly -// - -type FcosDownload struct { - Download -} - -func (f FcosDownload) Get() *Download { - return &f.Download -} - -type FcosDownloadInfo struct { - CompressionType compression.ImageCompression - Location string - Release string - Sha256Sum string -} - -func (f FcosDownload) HasUsableCache() (bool, error) { - // check the sha of the local image if it exists - // get the sha of the remote image - // == do not bother to pull - if _, err := os.Stat(f.LocalPath); os.IsNotExist(err) { - return false, nil - } - fd, err := os.Open(f.LocalPath) - if err != nil { - return false, err - } - defer func() { - if err := fd.Close(); err != nil { - logrus.Error(err) - } - }() - sum, err := digest.SHA256.FromReader(fd) - if err != nil { - return false, err - } - return sum.Encoded() == f.Sha256sum, nil -} - -func (f FcosDownload) CleanCache() error { - // Set cached image to expire after 2 weeks - // FCOS refreshes around every 2 weeks, assume old images aren't needed - expire := 14 * 24 * time.Hour - return RemoveImageAfterExpire(f.CacheDir, expire) -} - -func GetFcosArch() string { - var arch string - // TODO fill in more architectures - switch runtime.GOARCH { - case "arm64": - arch = "aarch64" - case "riscv64": - arch = "riscv64" - default: - arch = "x86_64" - } - 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 FCOSStream) 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.String()) -} - -// GetFCOSDownload parses fedoraCoreOS's stream and returns the image download URL and the release version -func (dl Download) GetFCOSDownload(imageStream FCOSStream) (*FcosDownloadInfo, error) { - var ( - fcosstable stream.Stream - altMeta release.Release - ) - - streamurl := getStreamURL(imageStream) - resp, err := http.Get(streamurl.String()) - if err != nil { - return nil, err - } - body, err := io.ReadAll(resp.Body) - if err != nil { - return nil, err - } - defer func() { - if err := resp.Body.Close(); err != nil { - 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[define.Qcow.KindWithCompression()] - 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: dl.CompressionType, - }, nil - } - - if err := json.Unmarshal(body, &fcosstable); err != nil { - return nil, err - } - arch, ok := fcosstable.Architectures[GetFcosArch()] - if !ok { - return nil, fmt.Errorf("unable to pull VM image: no targetArch in stream") - } - upstreamArtifacts := arch.Artifacts - if upstreamArtifacts == nil { - return nil, fmt.Errorf("unable to pull VM image: no artifact in stream") - } - upstreamArtifact, ok := upstreamArtifacts[dl.Artifact.String()] - if !ok { - return nil, fmt.Errorf("unable to pull VM image: no %s artifact in stream", dl.Artifact.String()) - } - formats := upstreamArtifact.Formats - if formats == nil { - return nil, fmt.Errorf("unable to pull VM image: no formats in stream") - } - formatType, ok := formats[dl.Format.KindWithCompression()] - if !ok { - return nil, fmt.Errorf("unable to pull VM image: no %s format in stream", dl.Format.KindWithCompression()) - } - disk := formatType.Disk - if disk == nil { - return nil, fmt.Errorf("unable to pull VM image: no disk in stream") - } - return &FcosDownloadInfo{ - Location: disk.Location, - Release: upstreamArtifact.Release, - Sha256Sum: disk.Sha256, - CompressionType: dl.CompressionType, - }, nil -} - -type FCOSStream int64 - -const ( - // FCOS streams - // Testing FCOS stream - Testing FCOSStream = iota - // Next FCOS stream - Next - // Stable FCOS stream - Stable - // Podman-Testing - PodmanTesting - // Custom - CustomStream -) - -// String is a helper func for fcos streams -func (st FCOSStream) String() string { - switch st { - case Testing: - return "testing" - case Next: - return "next" - case PodmanTesting: - return "podman-testing" - case Stable: - return "stable" - } - return "custom" -} - -// TODO can be removed when WSL is refactored into podman 5 -func IsValidFCOSStreamString(s string) bool { - switch s { - case Testing.String(): - fallthrough - case Next.String(): - fallthrough - case PodmanTesting.String(): - fallthrough - case Stable.String(): - return true - case CustomStream.String(): - return true - } - - return false -} diff --git a/pkg/machine/fcos_test.go b/pkg/machine/fcos_test.go deleted file mode 100644 index 2d5a937310..0000000000 --- a/pkg/machine/fcos_test.go +++ /dev/null @@ -1,43 +0,0 @@ -//go:build amd64 || arm64 - -package machine - -import ( - "testing" -) - -func TestFCOSStream_String(t *testing.T) { - tests := []struct { - name string - st FCOSStream - want string - }{ - { - name: "testing", - st: Testing, - want: "testing", - }, - { - name: "stable", - st: Stable, - want: "stable", - }, - { - name: "next", - st: Next, - want: "next", - }, - { - name: "default is custom", - st: CustomStream, - want: "custom", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.st.String(); got != tt.want { - t.Errorf("String() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/machine/pull.go b/pkg/machine/pull.go index 587a58a002..cba6466ee1 100644 --- a/pkg/machine/pull.go +++ b/pkg/machine/pull.go @@ -231,61 +231,3 @@ func isOci(input string) (bool, *ocipull.OCIKind, error) { //nolint:unused } return false, nil, nil } - -// func Pull(input, machineName string, vp VirtProvider) (*define.VMFile, FCOSStream, error) { -// var ( -// disk ocipull.Disker -// ) -// -// ociBased, ociScheme, err := isOci(input) -// if err != nil { -// return nil, 0, err -// } -// if !ociBased { -// // Business as usual -// dl, err := vp.NewDownload(machineName) -// if err != nil { -// return nil, 0, err -// } -// return dl.AcquireVMImage(input) -// } -// oopts := ocipull.OCIOpts{ -// Scheme: ociScheme, -// } -// dataDir, err := GetDataDir(vp.VMType()) -// if err != nil { -// return nil, 0, err -// } -// if ociScheme.IsOCIDir() { -// strippedOCIDir := ocipull.StripOCIReference(input) -// oopts.Dir = &strippedOCIDir -// disk = ocipull.NewOCIDir(context.Background(), input, dataDir, machineName) -// } else { -// // a use of a containers image type here might be -// // tighter -// strippedInput := strings.TrimPrefix(input, "docker://") -// // this is the next piece of work -// if len(strippedInput) > 0 { -// return nil, 0, errors.New("image names are not supported yet") -// } -// disk, err = ocipull.NewVersioned(context.Background(), dataDir, machineName, vp.VMType().String()) -// if err != nil { -// return nil, 0, err -// } -// } -// if err := disk.Pull(); err != nil { -// return nil, 0, err -// } -// unpacked, err := disk.Unpack() -// if err != nil { -// return nil, 0, err -// } -// defer func() { -// logrus.Debugf("cleaning up %q", unpacked.GetPath()) -// if err := unpacked.Delete(); err != nil { -// logrus.Errorf("unable to delete local compressed file %q:%v", unpacked.GetPath(), err) -// } -// }() -// imagePath, err := disk.Decompress(unpacked) -// return imagePath, UnknownStream, err -//} diff --git a/pkg/machine/vmconfigs/arch.go b/pkg/machine/vmconfigs/arch.go new file mode 100644 index 0000000000..f7abd9d0bd --- /dev/null +++ b/pkg/machine/vmconfigs/arch.go @@ -0,0 +1,15 @@ +package vmconfigs + +import ( + "fmt" +) + +func NormalizeMachineArch(arch string) (string, error) { + switch arch { + case "arm64", "aarch64": + return "aarch64", nil + case "x86_64", "amd64": + return "x86_64", nil + } + return "", fmt.Errorf("unsupported platform %s", arch) +} diff --git a/pkg/machine/vmconfigs/arch_test.go b/pkg/machine/vmconfigs/arch_test.go new file mode 100644 index 0000000000..7be635209d --- /dev/null +++ b/pkg/machine/vmconfigs/arch_test.go @@ -0,0 +1,68 @@ +package vmconfigs + +import "testing" + +func TestNormalizeMachineArch(t *testing.T) { + type args struct { + arch string + } + var tests = []struct { + name string + args args + want string + wantErr bool + }{ + { + name: "x86_64", + args: args{ + arch: "x86_64", + }, + want: "x86_64", + wantErr: false, + }, + { + name: "amd64", + args: args{ + arch: "amd64", + }, + want: "x86_64", + wantErr: false, + }, + { + name: "aarch64", + args: args{ + arch: "aarch64", + }, + want: "aarch64", + wantErr: false, + }, + { + name: "arm64", + args: args{ + arch: "arm64", + }, + want: "aarch64", + wantErr: false, + }, + { + name: "Unknown arch should fail", + args: args{ + arch: "foobar", + }, + want: "", + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := NormalizeMachineArch(tt.args.arch) + if (err != nil) != tt.wantErr { + t.Errorf("NormalizeMachineArch() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("NormalizeMachineArch() got = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/pkg/machine/vmconfigs/config.go b/pkg/machine/vmconfigs/config.go index 0de2f34cdb..831c36caaf 100644 --- a/pkg/machine/vmconfigs/config.go +++ b/pkg/machine/vmconfigs/config.go @@ -1,8 +1,6 @@ package vmconfigs import ( - "errors" - "net/url" "time" gvproxy "github.com/containers/gvisor-tap-vsock/pkg/types" @@ -54,23 +52,6 @@ type MachineConfig struct { Starting bool } -// MachineImage describes a podman machine image -type MachineImage struct { - OCI *OCIMachineImage - FCOS *fcosMachineImage -} - -// Pull downloads a machine image -func (m *MachineImage) Pull() error { - if m.OCI != nil { - return m.OCI.download() - } - if m.FCOS != nil { - return m.FCOS.download() - } - return errors.New("no valid machine image provider detected") -} - type machineImage interface { //nolint:unused download() error path() string @@ -93,20 +74,6 @@ func (o OCIMachineImage) download() error { return nil } -type fcosMachineImage struct { - // TODO JSON serial/deserial will write string to disk - // but in code is url.URL - Location url.URL // file://path/.qcow2 https://path/qcow2 -} - -func (f fcosMachineImage) download() error { - return nil -} - -func (f fcosMachineImage) path() string { - return "" -} - type VMProvider interface { //nolint:interfacebloat CreateVM(opts define.CreateVMOpts, mc *MachineConfig, builder *ignition.IgnitionBuilder) error // GetDisk should be only temporary. It is largely here only because WSL disk pulling is different diff --git a/pkg/machine/wsl/fedora.go b/pkg/machine/wsl/fedora.go index 4e4fb9a5b3..ebd95a7cb3 100644 --- a/pkg/machine/wsl/fedora.go +++ b/pkg/machine/wsl/fedora.go @@ -8,14 +8,11 @@ import ( "net/url" "os" "path" - "path/filepath" "strings" "time" - "github.com/sirupsen/logrus" - "github.com/containers/podman/v5/pkg/machine" - "github.com/containers/podman/v5/pkg/machine/define" + "github.com/sirupsen/logrus" ) const ( @@ -27,42 +24,6 @@ type FedoraDownload struct { machine.Download } -// NewFedoraDownloader -// deprecated -func NewFedoraDownloader(vmType define.VMType, vmName, releaseStream string) (machine.DistributionDownload, error) { - downloadURL, version, arch, size, err := GetFedoraDownloadForWSL() - if err != nil { - return nil, err - } - - cacheDir, err := machine.GetCacheDir(vmType) - if err != nil { - return nil, err - } - - imageName := fmt.Sprintf("fedora-podman-%s-%s.tar.xz", arch, version) - - f := FedoraDownload{ - Download: machine.Download{ - Arch: machine.GetFcosArch(), - Artifact: define.None, - CacheDir: cacheDir, - Format: define.Tar, - ImageName: imageName, - LocalPath: filepath.Join(cacheDir, imageName), - URL: downloadURL, - VMName: vmName, - Size: size, - }, - } - dataDir, err := machine.GetDataDir(vmType) - if err != nil { - return nil, err - } - f.Download.LocalUncompressedFile = f.GetLocalUncompressedFile(dataDir) - return f, nil -} - func (f FedoraDownload) Get() *machine.Download { return &f.Download } diff --git a/vendor/github.com/coreos/stream-metadata-go/release/release.go b/vendor/github.com/coreos/stream-metadata-go/release/release.go deleted file mode 100644 index 6691d3429c..0000000000 --- a/vendor/github.com/coreos/stream-metadata-go/release/release.go +++ /dev/null @@ -1,152 +0,0 @@ -// Package release contains APIs for interacting with a -// particular "release". Avoid this unless you are sure -// you need it. It's expected that CoreOS users interact -// with streams instead. -package release - -import ( - relrhcos "github.com/coreos/stream-metadata-go/release/rhcos" -) - -// Index models the release index: -// https://github.com/coreos/fedora-coreos-tracker/tree/main/metadata/release-index -type Index struct { - Note string `json:"note"` // used to note to users not to consume the release metadata index - Releases []IndexRelease `json:"releases"` - Metadata Metadata `json:"metadata"` - Stream string `json:"stream"` -} - -// IndexRelease is a "release pointer" from a release index -type IndexRelease struct { - Commits []IndexReleaseCommit `json:"commits"` - Version string `json:"version"` - MetadataURL string `json:"metadata"` -} - -// IndexReleaseCommit describes an ostree commit plus architecture -type IndexReleaseCommit struct { - Architecture string `json:"architecture"` - Checksum string `json:"checksum"` -} - -// Release contains details from release.json -type Release struct { - Release string `json:"release"` - Stream string `json:"stream"` - Metadata Metadata `json:"metadata"` - Architectures map[string]Arch `json:"architectures"` -} - -// Metadata is common metadata that contains last-modified -type Metadata struct { - LastModified string `json:"last-modified"` -} - -// Arch release details -type Arch struct { - Commit string `json:"commit"` - Media Media `json:"media"` - RHELCoreOSExtensions *relrhcos.Extensions `json:"rhel-coreos-extensions,omitempty"` -} - -// Media contains release details for various platforms -type Media struct { - Aliyun *PlatformAliyun `json:"aliyun"` - AppleHV *PlatformBase `json:"applehv"` - Aws *PlatformAws `json:"aws"` - Azure *PlatformBase `json:"azure"` - AzureStack *PlatformBase `json:"azurestack"` - Digitalocean *PlatformBase `json:"digitalocean"` - Exoscale *PlatformBase `json:"exoscale"` - Gcp *PlatformGcp `json:"gcp"` - HyperV *PlatformBase `json:"hyperv"` - Ibmcloud *PlatformIBMCloud `json:"ibmcloud"` - KubeVirt *PlatformKubeVirt `json:"kubevirt"` - Metal *PlatformBase `json:"metal"` - Nutanix *PlatformBase `json:"nutanix"` - Openstack *PlatformBase `json:"openstack"` - PowerVS *PlatformIBMCloud `json:"powervs"` - Qemu *PlatformBase `json:"qemu"` - QemuSecex *PlatformBase `json:"qemu-secex"` - VirtualBox *PlatformBase `json:"virtualbox"` - Vmware *PlatformBase `json:"vmware"` - Vultr *PlatformBase `json:"vultr"` -} - -// PlatformBase with no cloud images -type PlatformBase struct { - Artifacts map[string]ImageFormat `json:"artifacts"` -} - -// PlatformAliyun contains Aliyun image information -type PlatformAliyun struct { - PlatformBase - Images map[string]CloudImage `json:"images"` -} - -// PlatformAws contains AWS image information -type PlatformAws struct { - PlatformBase - Images map[string]CloudImage `json:"images"` -} - -// PlatformGcp GCP image detail -type PlatformGcp struct { - PlatformBase - Image *GcpImage `json:"image"` -} - -// PlatformIBMCloud IBMCloud/PowerVS image detail -type PlatformIBMCloud struct { - PlatformBase - Images map[string]IBMCloudImage `json:"images"` -} - -// PlatformKubeVirt containerDisk metadata -type PlatformKubeVirt struct { - PlatformBase - Image *ContainerImage `json:"image"` -} - -// ImageFormat contains all artifacts for a single OS image -type ImageFormat struct { - Disk *Artifact `json:"disk,omitempty"` - Kernel *Artifact `json:"kernel,omitempty"` - Initramfs *Artifact `json:"initramfs,omitempty"` - Rootfs *Artifact `json:"rootfs,omitempty"` -} - -// Artifact represents one image file, plus its metadata -type Artifact struct { - Location string `json:"location"` - Signature string `json:"signature"` - Sha256 string `json:"sha256"` - UncompressedSha256 string `json:"uncompressed-sha256,omitempty"` -} - -// CloudImage generic image detail -type CloudImage struct { - Image string `json:"image"` -} - -// ContainerImage represents a tagged container image -type ContainerImage struct { - // Preferred way to reference the image, which might be by tag or digest - Image string `json:"image"` - DigestRef string `json:"digest-ref"` -} - -// GcpImage represents a GCP cloud image -type GcpImage struct { - Project string `json:"project"` - Family string `json:"family,omitempty"` - Name string `json:"name"` -} - -// IBMCloudImage represents an IBMCloud/PowerVS cloud object - which is an ova image for PowerVS and a qcow for IBMCloud in the cloud object storage bucket -type IBMCloudImage struct { - Object string `json:"object"` - Bucket string `json:"bucket"` - Url string `json:"url"` -} diff --git a/vendor/github.com/coreos/stream-metadata-go/release/rhcos/rhcos.go b/vendor/github.com/coreos/stream-metadata-go/release/rhcos/rhcos.go deleted file mode 100644 index aeae2c8be1..0000000000 --- a/vendor/github.com/coreos/stream-metadata-go/release/rhcos/rhcos.go +++ /dev/null @@ -1,14 +0,0 @@ -package rhcos - -// Extensions is data specific to Red Hat Enterprise Linux CoreOS -type Extensions struct { - AzureDisk *AzureDisk `json:"azure-disk,omitempty"` -} - -// AzureDisk represents an Azure cloud image. -type AzureDisk struct { - // URL to an image already stored in Azure infrastructure - // that can be copied into an image gallery. Avoid creating VMs directly - // from this URL as that may lead to performance limitations. - URL string `json:"url,omitempty"` -} diff --git a/vendor/github.com/coreos/stream-metadata-go/release/translate.go b/vendor/github.com/coreos/stream-metadata-go/release/translate.go deleted file mode 100644 index ebc0b8ef9c..0000000000 --- a/vendor/github.com/coreos/stream-metadata-go/release/translate.go +++ /dev/null @@ -1,296 +0,0 @@ -package release - -import ( - "github.com/coreos/stream-metadata-go/stream" - "github.com/coreos/stream-metadata-go/stream/rhcos" -) - -func mapArtifact(ra *Artifact) *stream.Artifact { - if ra == nil { - return nil - } - return &stream.Artifact{ - Location: ra.Location, - Signature: ra.Signature, - Sha256: ra.Sha256, - UncompressedSha256: ra.UncompressedSha256, - } -} - -func mapFormats(m map[string]ImageFormat) map[string]stream.ImageFormat { - r := make(map[string]stream.ImageFormat) - for k, v := range m { - r[k] = stream.ImageFormat{ - Disk: mapArtifact(v.Disk), - Kernel: mapArtifact(v.Kernel), - Initramfs: mapArtifact(v.Initramfs), - Rootfs: mapArtifact(v.Rootfs), - } - } - return r -} - -// Convert a release architecture to a stream architecture -func (releaseArch *Arch) toStreamArch(rel *Release) stream.Arch { - artifacts := make(map[string]stream.PlatformArtifacts) - cloudImages := stream.Images{} - var rhcosExt *rhcos.Extensions - relRHCOSExt := releaseArch.RHELCoreOSExtensions - if relRHCOSExt != nil { - rhcosExt = &rhcos.Extensions{} - } - - if releaseArch.Media.Aliyun != nil { - artifacts["aliyun"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Aliyun.Artifacts), - } - aliyunImages := stream.ReplicatedImage{ - Regions: make(map[string]stream.SingleImage), - } - if releaseArch.Media.Aliyun.Images != nil { - for region, image := range releaseArch.Media.Aliyun.Images { - si := stream.SingleImage{Release: rel.Release, Image: image.Image} - aliyunImages.Regions[region] = si - - } - cloudImages.Aliyun = &aliyunImages - } - } - - if releaseArch.Media.AppleHV != nil { - artifacts["applehv"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.AppleHV.Artifacts), - } - } - - if releaseArch.Media.Aws != nil { - artifacts["aws"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Aws.Artifacts), - } - awsAmis := stream.ReplicatedImage{ - Regions: make(map[string]stream.SingleImage), - } - if releaseArch.Media.Aws.Images != nil { - for region, ami := range releaseArch.Media.Aws.Images { - si := stream.SingleImage{Release: rel.Release, Image: ami.Image} - awsAmis.Regions[region] = si - - } - cloudImages.Aws = &awsAmis - } - } - - if releaseArch.Media.Azure != nil { - artifacts["azure"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Azure.Artifacts), - } - - if relRHCOSExt != nil { - az := relRHCOSExt.AzureDisk - if az != nil { - rhcosExt.AzureDisk = &rhcos.AzureDisk{ - Release: rel.Release, - URL: az.URL, - } - } - } - // In the future this is where we'd also add FCOS Marketplace data. - // See https://github.com/coreos/stream-metadata-go/issues/13 - } - - if releaseArch.Media.AzureStack != nil { - artifacts["azurestack"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.AzureStack.Artifacts), - } - } - - if releaseArch.Media.Digitalocean != nil { - artifacts["digitalocean"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Digitalocean.Artifacts), - } - - /* We're producing artifacts but they're not yet available - in DigitalOcean as distribution images. - digitalOceanImage := stream.CloudImage{Image: fmt.Sprintf("fedora-coreos-%s", Stream)} - cloudImages.Digitalocean = &digitalOceanImage - */ - } - - if releaseArch.Media.Exoscale != nil { - artifacts["exoscale"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Exoscale.Artifacts), - } - } - - if releaseArch.Media.Gcp != nil { - artifacts["gcp"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Gcp.Artifacts), - } - - if releaseArch.Media.Gcp.Image != nil { - cloudImages.Gcp = &stream.GcpImage{ - Release: rel.Release, - Name: releaseArch.Media.Gcp.Image.Name, - Family: releaseArch.Media.Gcp.Image.Family, - Project: releaseArch.Media.Gcp.Image.Project, - } - } - } - - if releaseArch.Media.HyperV != nil { - artifacts["hyperv"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.HyperV.Artifacts), - } - } - - if releaseArch.Media.Ibmcloud != nil { - artifacts["ibmcloud"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Ibmcloud.Artifacts), - } - ibmcloudObjects := stream.ReplicatedObject{ - Regions: make(map[string]stream.SingleObject), - } - if releaseArch.Media.Ibmcloud.Images != nil { - for region, object := range releaseArch.Media.Ibmcloud.Images { - so := stream.SingleObject{ - Release: rel.Release, - Object: object.Object, - Bucket: object.Bucket, - Url: object.Url, - } - ibmcloudObjects.Regions[region] = so - - } - cloudImages.Ibmcloud = &ibmcloudObjects - } - } - - if releaseArch.Media.KubeVirt != nil { - artifacts["kubevirt"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.KubeVirt.Artifacts), - } - if releaseArch.Media.KubeVirt.Image != nil { - cloudImages.KubeVirt = &stream.ContainerImage{ - Release: rel.Release, - Image: releaseArch.Media.KubeVirt.Image.Image, - DigestRef: releaseArch.Media.KubeVirt.Image.DigestRef, - } - } - } - - if releaseArch.Media.Metal != nil { - artifacts["metal"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Metal.Artifacts), - } - } - - if releaseArch.Media.Nutanix != nil { - artifacts["nutanix"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Nutanix.Artifacts), - } - } - - if releaseArch.Media.Openstack != nil { - artifacts["openstack"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Openstack.Artifacts), - } - } - - // if releaseArch.Media.Packet != nil { - // packet := StreamMediaDetails{ - // Release: rel.Release, - // Formats: releaseArch.Media.Packet.Artifacts, - // } - // artifacts.Packet = &packet - - // packetImage := StreamCloudImage{Image: fmt.Sprintf("fedora_coreos_%s", rel.Stream)} - // cloudImages.Packet = &packetImage - // } - - if releaseArch.Media.PowerVS != nil { - artifacts["powervs"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.PowerVS.Artifacts), - } - powervsObjects := stream.ReplicatedObject{ - Regions: make(map[string]stream.SingleObject), - } - if releaseArch.Media.PowerVS.Images != nil { - for region, object := range releaseArch.Media.PowerVS.Images { - so := stream.SingleObject{ - Release: rel.Release, - Object: object.Object, - Bucket: object.Bucket, - Url: object.Url, - } - powervsObjects.Regions[region] = so - - } - cloudImages.PowerVS = &powervsObjects - } - } - - if releaseArch.Media.Qemu != nil { - artifacts["qemu"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Qemu.Artifacts), - } - } - - if releaseArch.Media.QemuSecex != nil { - artifacts["qemu-secex"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.QemuSecex.Artifacts), - } - } - - if releaseArch.Media.VirtualBox != nil { - artifacts["virtualbox"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.VirtualBox.Artifacts), - } - } - - if releaseArch.Media.Vmware != nil { - artifacts["vmware"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Vmware.Artifacts), - } - } - - if releaseArch.Media.Vultr != nil { - artifacts["vultr"] = stream.PlatformArtifacts{ - Release: rel.Release, - Formats: mapFormats(releaseArch.Media.Vultr.Artifacts), - } - } - - return stream.Arch{ - Artifacts: artifacts, - Images: cloudImages, - RHELCoreOSExtensions: rhcosExt, - } -} - -// ToStreamArchitectures converts a release to a stream -func (rel *Release) ToStreamArchitectures() map[string]stream.Arch { - streamArch := make(map[string]stream.Arch) - for arch, releaseArch := range rel.Architectures { - streamArch[arch] = releaseArch.toStreamArch(rel) - } - return streamArch -} diff --git a/vendor/modules.txt b/vendor/modules.txt index f719e58702..cdc3fef896 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -423,8 +423,6 @@ github.com/coreos/go-systemd/v22/sdjournal ## explicit; go 1.18 github.com/coreos/stream-metadata-go/fedoracoreos github.com/coreos/stream-metadata-go/fedoracoreos/internals -github.com/coreos/stream-metadata-go/release -github.com/coreos/stream-metadata-go/release/rhcos github.com/coreos/stream-metadata-go/stream github.com/coreos/stream-metadata-go/stream/rhcos # github.com/crc-org/crc/v2 v2.32.0