Skip to content

Commit 077c13b

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 077c13b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/machine/ocipull/ociartifact.go

Lines changed: 10 additions & 5 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,8 +90,15 @@ 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())
93+
return nil, fmt.Errorf("no machine image endpoint provided")
94+
}
95+
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())
97102
cache = true
98103
}
99104

0 commit comments

Comments
 (0)