Merge pull request #20750 from baude/removeversionhack

podman machine image from oci updates
This commit is contained in:
openshift-merge-bot[bot] 2023-11-27 14:10:33 +00:00 committed by GitHub
commit d1236f46fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 14 deletions

View File

@ -67,12 +67,6 @@ func StripOCIReference(input string) string {
func getVersion() *OSVersion { func getVersion() *OSVersion {
v := version.Version v := version.Version
// OVERRIDES FOR DEV ONLY
v.Minor = 6
v.Pre = nil
// OVERRIDES FOR DEV ONLY
return &OSVersion{&v} return &OSVersion{&v}
} }
@ -80,8 +74,8 @@ func (o *OSVersion) majorMinor() string {
return fmt.Sprintf("%d.%d", o.Major, o.Minor) return fmt.Sprintf("%d.%d", o.Major, o.Minor)
} }
func (o *OSVersion) diskImage(diskFlavor define.ImageFormat) string { func (o *OSVersion) diskImage(vmType string) string {
return fmt.Sprintf("%s/%s/%s:%s-%s", registry, repo, diskImages, o.majorMinor(), diskFlavor.Kind()) return fmt.Sprintf("%s/%s/%s:%s-%s", registry, repo, diskImages, o.majorMinor(), vmType)
} }
func unpackOCIDir(ociTb, machineImageDir string) (*define.VMFile, error) { func unpackOCIDir(ociTb, machineImageDir string) (*define.VMFile, error) {

View File

@ -20,20 +20,20 @@ type Versioned struct {
blobDirPath string blobDirPath string
cacheDir string cacheDir string
ctx context.Context ctx context.Context
imageFormat define.ImageFormat
imageName string imageName string
machineImageDir string machineImageDir string
machineVersion *OSVersion machineVersion *OSVersion
vmName string 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") imageCacheDir := filepath.Join(machineImageDir, "cache")
if err := os.MkdirAll(imageCacheDir, 0777); err != nil { if err := os.MkdirAll(imageCacheDir, 0777); err != nil {
return nil, err return nil, err
} }
o := getVersion() 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 { func (d *Versioned) LocalBlob() *types.BlobInfo {
@ -41,7 +41,7 @@ func (d *Versioned) LocalBlob() *types.BlobInfo {
} }
func (d *Versioned) DiskEndpoint() string { func (d *Versioned) DiskEndpoint() string {
return d.machineVersion.diskImage(d.imageFormat) return d.machineVersion.diskImage(d.vmType)
} }
func (d *Versioned) versionedOCICacheDir() string { func (d *Versioned) versionedOCICacheDir() string {
@ -74,7 +74,7 @@ func (d *Versioned) Pull() error {
remoteDescriptor *v1.Descriptor remoteDescriptor *v1.Descriptor
) )
remoteDiskImage := d.machineVersion.diskImage(define.Qcow) remoteDiskImage := d.machineVersion.diskImage(d.vmType)
logrus.Debugf("podman disk image name: %s", remoteDiskImage) logrus.Debugf("podman disk image name: %s", remoteDiskImage)
// is there a valid oci dir in our cache // is there a valid oci dir in our cache

View File

@ -270,7 +270,7 @@ func Pull(input, machineName string, vp VirtProvider) (*define.VMFile, FCOSStrea
if len(strippedInput) > 0 { if len(strippedInput) > 0 {
return nil, 0, errors.New("image names are not supported yet") 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 { if err != nil {
return nil, 0, err return nil, 0, err
} }