Skip to content

Commit

Permalink
podman machine image from oci updates
Browse files Browse the repository at this point in the history
It makes more sense to key off the hypervisor/provider when pulling
disks from oci registries.

i.e. quay.io/libpod/podman-machine-images:5.0-qemu

Also, now that we are in 5.0-dev, I also removed the overrides always
making the podman version 4.6.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <[email protected]>
  • Loading branch information
baude committed Nov 22, 2023
1 parent b7ca114 commit da9349c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
10 changes: 2 additions & 8 deletions pkg/machine/ocipull/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,15 @@ func StripOCIReference(input string) string {

func getVersion() *OSVersion {
v := version.Version

// OVERRIDES FOR DEV ONLY
v.Minor = 6
v.Pre = nil
// OVERRIDES FOR DEV ONLY

return &OSVersion{&v}
}

func (o *OSVersion) majorMinor() string {
return fmt.Sprintf("%d.%d", o.Major, o.Minor)
}

func (o *OSVersion) diskImage(diskFlavor define.ImageFormat) string {
return fmt.Sprintf("%s/%s/%s:%s-%s", registry, repo, diskImages, o.majorMinor(), diskFlavor.Kind())
func (o *OSVersion) diskImage(vmType string) string {
return fmt.Sprintf("%s/%s/%s:%s-%s", registry, repo, diskImages, o.majorMinor(), vmType)
}

func unpackOCIDir(ociTb, machineImageDir string) (*define.VMFile, error) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/machine/ocipull/versioned.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ type Versioned struct {
blobDirPath string
cacheDir string
ctx context.Context
imageFormat define.ImageFormat
imageName string
machineImageDir string
machineVersion *OSVersion
vmName string
vmType string
}

func NewVersioned(ctx context.Context, machineImageDir, vmName string) (*Versioned, error) {
func NewVersioned(ctx context.Context, machineImageDir, vmName string, vmType string) (*Versioned, error) {
imageCacheDir := filepath.Join(machineImageDir, "cache")
if err := os.MkdirAll(imageCacheDir, 0777); err != nil {
return nil, err
}
o := getVersion()
return &Versioned{ctx: ctx, cacheDir: imageCacheDir, machineImageDir: machineImageDir, machineVersion: o, vmName: vmName}, nil
return &Versioned{ctx: ctx, cacheDir: imageCacheDir, machineImageDir: machineImageDir, machineVersion: o, vmName: vmName, vmType: vmType}, nil
}

func (d *Versioned) LocalBlob() *types.BlobInfo {
return d.blob
}

func (d *Versioned) DiskEndpoint() string {
return d.machineVersion.diskImage(d.imageFormat)
return d.machineVersion.diskImage(d.vmType)
}

func (d *Versioned) versionedOCICacheDir() string {
Expand Down Expand Up @@ -74,7 +74,7 @@ func (d *Versioned) Pull() error {
remoteDescriptor *v1.Descriptor
)

remoteDiskImage := d.machineVersion.diskImage(define.Qcow)
remoteDiskImage := d.machineVersion.diskImage(d.vmType)
logrus.Debugf("podman disk image name: %s", remoteDiskImage)

// is there a valid oci dir in our cache
Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func Pull(input, machineName string, vp VirtProvider) (*define.VMFile, FCOSStrea
if len(strippedInput) > 0 {
return nil, 0, errors.New("image names are not supported yet")
}
disk, err = ocipull.NewVersioned(context.Background(), dataDir, machineName)
disk, err = ocipull.NewVersioned(context.Background(), dataDir, machineName, vp.VMType().String())
if err != nil {
return nil, 0, err
}
Expand Down

0 comments on commit da9349c

Please sign in to comment.