circleci-cli
circleci-cli copied to clipboard
`orb init` fails when not setting up a git project
Meta:
When you say "no" to "would you like to set up your git project?", the orb init
command currently fails.
Current behavior:
$ circleci orb init ./hello-world-orb
...
? Would you like to set up your git project? No
panic: runtime error: index out of range [1] with length 1
goroutine 1 [running]:
github.com/CircleCI-Public/circleci-cli/cmd.initOrb(0xc00072e300, 0xc00075fec0, 0xc000089160, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1a579c0, ...)
/home/circleci/project/cmd/orb.go:1264 +0x3f81
github.com/CircleCI-Public/circleci-cli/cmd.newOrbCommand.func21(0xc000182a00, 0xc000089160, 0x1, 0x1, 0x0, 0x0)
/home/circleci/project/cmd/orb.go:316 +0x67
github.com/spf13/cobra.(*Command).execute(0xc000182a00, 0xc0000890d0, 0x1, 0x1, 0xc000182a00, 0xc0000890d0)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:826 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0xc000767900, 0x0, 0x0, 0x0)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:864
github.com/CircleCI-Public/circleci-cli/cmd.Execute()
/home/circleci/project/cmd/root.go:37 +0x27
main.main()
/home/circleci/project/main.go:9 +0x20
Expected behavior:
Should successfully create the orb.
When did this begin / Was this previously working?:
unknown
Additional Information:
I am pretty sure these lines need to be fixed:
- https://github.com/CircleCI-Public/circleci-cli/blob/master/cmd/orb.go#L1264 - change this to a for-loop over all categories rather than use
opts.args[1]
- https://github.com/CircleCI-Public/circleci-cli/blob/master/cmd/orb.go#L1260 - change
false
toopts.private
- when the orb is successfully created in this
if
branch, log some information rather than silently terminating