Skip to content

Commit 71fc913

Browse files
committed
Remove hardcoded refs from ociartifact code
Fixes: https://issues.redhat.com/browse/RUN-3578 Signed-off-by: Nicola Sella <[email protected]>
1 parent ae315c4 commit 71fc913

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pkg/machine/ocipull/ociartifact.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/opencontainers/go-digest"
1717
specV1 "github.com/opencontainers/image-spec/specs-go/v1"
1818
"github.com/sirupsen/logrus"
19+
"go.podman.io/common/pkg/config"
1920
"go.podman.io/image/v5/docker"
2021
"go.podman.io/image/v5/docker/reference"
2122
"go.podman.io/image/v5/image"
@@ -24,9 +25,6 @@ import (
2425
)
2526

2627
const (
27-
artifactRegistry = "quay.io"
28-
artifactRepo = "podman"
29-
artifactImageName = "machine-os"
3028
artifactOriginalName = specV1.AnnotationTitle
3129
machineOS = "linux"
3230
)
@@ -92,11 +90,19 @@ func NewOCIArtifactPull(ctx context.Context, dirs *define.MachineDirs, endpoint
9290

9391
cache := false
9492
if endpoint == "" {
95-
imageName := artifactImageName
96-
endpoint = fmt.Sprintf("docker://%s/%s/%s:%s", artifactRegistry, artifactRepo, imageName, artifactVersion.majorMinor())
97-
cache = true
93+
return nil, fmt.Errorf("no machine image endpoint provided")
9894
}
9995

96+
cfg, err := config.Default()
97+
if err != nil {
98+
return nil, fmt.Errorf("failed to get configuration: %w", err)
99+
}
100+
if cfg.Machine.Image == endpoint {
101+
endpoint = fmt.Sprintf("%s:%s", endpoint, artifactVersion.majorMinor())
102+
}
103+
104+
cache = true
105+
100106
ociDisk := OCIArtifactDisk{
101107
ctx: ctx,
102108
cache: cache,

0 commit comments

Comments
 (0)