crc-org / crc

CRC is a tool to help you run containers. It manages a local OpenShift 4.x cluster, Microshift or a Podman VM optimized for testing and development purposes
https://crc.dev
Apache License 2.0
1.26k stars 242 forks source link

[BUG] `crc setup` panics when image tag is missing #4470

Open redbeam opened 1 day ago

redbeam commented 1 day ago

General information

CRC version

$ crc version
CRC version: 2.43.0+b6ffde
OpenShift version: 4.17.3
MicroShift version: 4.17.3

CRC status

$ crc status --log-level debug
DEBU CRC version: 2.43.0+b6ffde                   
DEBU OpenShift version: 4.17.3                    
DEBU MicroShift version: 4.17.3                   
DEBU Running 'crc status'                         
Machine does not exist. Use 'crc start' to create it

CRC config

$ crc config view
- consent-telemetry                     : no

Host Operating System

$ sw_vers 
ProductName:        macOS
ProductVersion:     15.1
BuildVersion:       24B83

Steps to reproduce

  1. crc setup -b docker://quay.io/crcont/openshift-bundle

Expected

setup should warn user about the missing tag/end with an error/assume "latest" for the tag (or some other default value)

Actual

$ crc setup -b docker://quay.io/crcont/openshift-bundle
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/crc-org/crc/v2/pkg/crc/machine/bundle.GetBundleNameFromURI({0x16d2bb90d, 0x28})
    /Users/mskvarla/crc/pkg/crc/machine/bundle/metadata.go:247 +0x138
github.com/crc-org/crc/v2/pkg/crc/validation.ValidateBundle({0x16d2bb90d, 0x28}, {0x1043cde37, 0x9})
    /Users/mskvarla/crc/pkg/crc/validation/validation.go:92 +0x30
github.com/crc-org/crc/v2/cmd/crc/cmd.runSetup({0x32d7a000000c9c18?, 0x673db5bc?, 0x140000c9b88?})
    /Users/mskvarla/crc/cmd/crc/cmd/setup.go:63 +0x214
github.com/crc-org/crc/v2/cmd/crc/cmd.init.func10(0x1043d7913?, {0x140004a5080, 0x0, 0x2})
    /Users/mskvarla/crc/cmd/crc/cmd/setup.go:42 +0x60
github.com/crc-org/crc/v2/cmd/crc/cmd.attachMiddleware.executeWithLogging.func1(0x105ec68c0, {0x140004a5080, 0x0, 0x2})
    /Users/mskvarla/crc/cmd/crc/cmd/root.go:170 +0xb0
github.com/spf13/cobra.(*Command).execute(0x105ec68c0, {0x140004a5060, 0x2, 0x2})
    /Users/mskvarla/crc/vendor/github.com/spf13/cobra/command.go:985 +0x834
github.com/spf13/cobra.(*Command).ExecuteC(0x105ec65e0)
    /Users/mskvarla/crc/vendor/github.com/spf13/cobra/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
    /Users/mskvarla/crc/vendor/github.com/spf13/cobra/command.go:1041
github.com/spf13/cobra.(*Command).ExecuteContext(...)
    /Users/mskvarla/crc/vendor/github.com/spf13/cobra/command.go:1034
github.com/crc-org/crc/v2/cmd/crc/cmd.Execute()
    /Users/mskvarla/crc/cmd/crc/cmd/root.go:106 +0xcc
main.main()
    /Users/mskvarla/crc/cmd/crc/main.go:8 +0x1c