Skip to content

Commit 7052ccb

Browse files
committed
fix(install): add missing check if no OciConfigs have been provided and default to image
1 parent f82d36c commit 7052ccb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

cmd/install.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,20 @@ func (h *hammer) Install(machine *models.V1MachineResponse) (*api.Bootinfo, erro
3434
h.log.Info("checking oci image", "image", image)
3535
if strings.HasPrefix(image, "oci://") {
3636
ociConfigs := h.spec.MetalConfig.OciConfig
37+
ctx := context.Background()
3738

38-
for _, c := range ociConfigs {
39-
ctx := context.Background()
40-
41-
if strings.EqualFold(image, c.RegistryURL) {
42-
err = img.NewImage(h.log).OciPull(ctx, c.RegistryURL, h.osImageDestination, c.Username, c.Password)
43-
} else {
44-
err = img.NewImage(h.log).OciPull(ctx, image, h.osImageDestination, "", "")
45-
}
39+
if len(ociConfigs) == 0 {
40+
err = img.NewImage(h.log).OciPull(ctx, image, h.osImageDestination, "", "")
4641
if err != nil {
4742
return nil, err
4843
}
44+
} else {
45+
for _, c := range ociConfigs {
46+
err = img.NewImage(h.log).OciPull(ctx, c.RegistryURL, h.osImageDestination, c.Username, c.Password)
47+
if err != nil {
48+
return nil, err
49+
}
50+
}
4951
}
5052
} else {
5153
err = img.NewImage(h.log).Pull(image, h.osImageDestination)

0 commit comments

Comments
 (0)