blendle / kubecrt

Convert Helm charts to Kubernetes resources.
ISC License
115 stars 11 forks source link

fix panic for unsatisfiable version constraint #6

Closed JeanMertz closed 7 years ago

JeanMertz commented 7 years ago

If version is set to an unsatisfiable constraint (for example, a version is specified that does not exist), a panic is currently raised:

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/blendle/kubecrt/helm.GetAcceptableVersion(0xc420dd2130, 0xb, 0xc420dd2148, 0x8, 0x0, 0x11, 0xc420bc1460, 0x19)
        /private/tmp/kubecrt-20170513-15659-nlayje/src/github.com/blendle/kubecrt/helm/version.go:35 +0x114
github.com/blendle/kubecrt/chart.locateChartPath(0xc420dd2130, 0xb, 0xc420dd2148, 0x8, 0x1075985, 0x4, 0xc4206e3bd0, 0x101699f)
        /private/tmp/kubecrt-20170513-15659-nlayje/src/github.com/blendle/kubecrt/chart/parser.go:190 +0x589
github.com/blendle/kubecrt/chart.(*Chart).compile(0xc420bba500, 0x7fff5fbffa4d, 0x11, 0x7fff5fbffa2c, 0x19, 0xc420bba680, 0x3a, 0x1, 0x1, 0x1, ...)
        /private/tmp/kubecrt-20170513-15659-nlayje/src/github.com/blendle/kubecrt/chart/parser.go:72 +0x61
github.com/blendle/kubecrt/chart.(*Chart).ParseChart(0xc420bba500, 0x7fff5fbffa4d, 0x11, 0x7fff5fbffa2c, 0x19, 0x0, 0x0, 0x0, 0x0, 0x0)
        /private/tmp/kubecrt-20170513-15659-nlayje/src/github.com/blendle/kubecrt/chart/parser.go:61 +0x253
github.com/blendle/kubecrt/chartsconfig.(*ChartsConfiguration).ParseCharts(0xc420db34a0, 0x0, 0x0, 0xc420db34a0, 0x0, 0x0)
        /private/tmp/kubecrt-20170513-15659-nlayje/src/github.com/blendle/kubecrt/chartsconfig/parser.go:49 +0xa6
main.main()
        /private/tmp/kubecrt-20170513-15659-nlayje/src/github.com/blendle/kubecrt/main.go:72 +0x92d

We should instead inform the user that an acceptable version could not be found in the currently supplied repositories.

JeanMertz commented 7 years ago

This panic also occurs when you specify a repo that is not yet known.