sl1pm4t / k2tf

Kubernetes YAML to Terraform HCL converter
Mozilla Public License 2.0
1.17k stars 108 forks source link

Fix panic while converting networkPolicy #38

Closed sl1pm4t closed 4 years ago

sl1pm4t commented 4 years ago

Fixes #37

Example Panic:

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/sl1pm4t/k2tf/pkg/tfkschema.search(0xc000633740, 0xc000441750, 0x0, 0x0, 0x0)
        /drone/src/pkg/tfkschema/schema.go:78 +0x2e1
github.com/sl1pm4t/k2tf/pkg/tfkschema.IsAttributeRequired(0xc000248f61, 0x19, 0x19)
        /drone/src/pkg/tfkschema/schema.go:68 +0x7e
main.(*hclBlock).isRequired(0xc0000f02c0, 0x1e)
        /drone/src/hcl_block.go:115 +0x47
main.(*hclBlock).isRequired(0xc000077000, 0x2b)
        /drone/src/hcl_block.go:117 +0x82
main.(*hclBlock).isRequired(0xc0001c9480, 0x27d844f)
        /drone/src/hcl_block.go:117 +0x82
main.(*ObjectWalker).closeBlock(0xc0003ebce0, 0x27c9939)
        /drone/src/hcl_writer.go:207 +0x2c8
main.(*ObjectWalker).Exit(0xc0003ebce0, 0x8, 0x0, 0x0)
        /drone/src/hcl_writer.go:253 +0x48
github.com/mitchellh/reflectwalk.walkStruct(0x2648fc0, 0xc0003aafc0, 0x199, 0x2787820, 0xc0003ebce0, 0x0, 0x2541007)
        /go/pkg/mod/github.com/mitchellh/reflectwalk@v1.0.0/reflectwalk.go:397 +0x4c6
github.com/mitchellh/reflectwalk.walk(0x2648fc0, 0xc0003aafc0, 0x199, 0x2787820, 0xc0003ebce0, 0x2bdcc01, 0x2648fc0)
        /go/pkg/mod/github.com/mitchellh/reflectwalk@v1.0.0/reflectwalk.go:188 +0x571
github.com/mitchellh/reflectwalk.walkStruct(0x26bc780, 0xc0003aafc0, 0x199, 0x2787820, 0xc0003ebce0, 0x0, 0x24c8c62)
        /go/pkg/mod/github.com/mitchellh/reflectwalk@v1.0.0/reflectwalk.go:385 +0x3d5
github.com/mitchellh/reflectwalk.walk(0x26bc780, 0xc0003aafc0, 0x199, 0x2787820, 0xc0003ebce0, 0x2bdcc01, 0x26bc780)
        /go/pkg/mod/github.com/mitchellh/reflectwalk@v1.0.0/reflectwalk.go:188 +0x571
github.com/mitchellh/reflectwalk.walkStruct(0x26918a0, 0xc0003aaea0, 0x199, 0x2787820, 0xc0003ebce0, 0x100, 0xc00063d060)
        /go/pkg/mod/github.com/mitchellh/reflectwalk@v1.0.0/reflectwalk.go:385 +0x3d5
github.com/mitchellh/reflectwalk.walk(0x27acea0, 0xc0003aaea0, 0x16, 0x2787820, 0xc0003ebce0, 0x23cff01, 0x2756300)
        /go/pkg/mod/github.com/mitchellh/reflectwalk@v1.0.0/reflectwalk.go:188 +0x571
github.com/mitchellh/reflectwalk.Walk(0x27acea0, 0xc0003aaea0, 0x2787820, 0xc0003ebce0, 0x0, 0x0)
        /go/pkg/mod/github.com/mitchellh/reflectwalk@v1.0.0/reflectwalk.go:92 +0x182
main.WriteObject(0x2b6d140, 0xc0003aaea0, 0xc0005c0d00, 0xc0002b7f48, 0x1, 0x1)
        /drone/src/hcl_writer.go:30 +0x89
main.main()
        /drone/src/main.go:62 +0x2b6