Use machine image as specified in containers.conf

For podman machine init, deprecate the --image-path option for --image.
--image now accepts the correct image from containers.conf

Also, add the ability to specify an OCI image from the --image flag using the docker:// transport.

Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
Ashley Cui
2024-02-28 00:57:15 -05:00
parent 41fa1c2c5c
commit 527b3793b8
8 changed files with 32 additions and 13 deletions

View File

@ -25,6 +25,7 @@ import (
const (
// TODO This is temporary until we decide on a proper image name
// Also should be moved into c/common once stabilized
artifactRegistry = "quay.io"
artifactRepo = "baude"
artifactImageName = "stage-podman-machine-image"
@ -71,7 +72,7 @@ type DiskArtifactOpts struct {
*/
func NewOCIArtifactPull(ctx context.Context, dirs *define.MachineDirs, vmName string, vmType define.VMType, finalPath *define.VMFile) (*OCIArtifactDisk, error) {
func NewOCIArtifactPull(ctx context.Context, dirs *define.MachineDirs, endpoint string, vmName string, vmType define.VMType, finalPath *define.VMFile) (*OCIArtifactDisk, error) {
var (
arch string
)
@ -91,12 +92,17 @@ func NewOCIArtifactPull(ctx context.Context, dirs *define.MachineDirs, vmName st
diskType: vmType.String(),
os: machineOS,
}
if endpoint == "" {
endpoint = fmt.Sprintf("docker://%s/%s/%s:%s", artifactRegistry, artifactRepo, artifactImageName, artifactVersion.majorMinor())
}
ociDisk := OCIArtifactDisk{
ctx: ctx,
dirs: dirs,
diskArtifactOpts: &diskOpts,
finalPath: finalPath.GetPath(),
imageEndpoint: fmt.Sprintf("docker://%s/%s/%s:%s", artifactRegistry, artifactRepo, artifactImageName, artifactVersion.majorMinor()),
imageEndpoint: endpoint,
machineVersion: artifactVersion,
name: vmName,
pullOptions: &PullOptions{},