Skip to content

Commit

Permalink
Merge pull request containers#20750 from baude/removeversionhack
Browse files Browse the repository at this point in the history
podman machine image from oci updates
  • Loading branch information
openshift-merge-bot[bot] authored Nov 27, 2023
2 parents 208ad3b + da9349c commit d1236f4
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 d1236f4

Please sign in to comment.