Closed thomas-riccardi closed 4 years ago
Partial workaround: if the section is really empty (no comment), then adding compact()
around the split()
will help.
I think creating resources with empty content shouldn't be allowed, added a check in #39 to make this invalid.
Describe the bug The k8s provider panics when given an empty resource definition. It happens regularly when working around #7 by manually splitting multi objects resources (see https://github.com/banzaicloud/terraform-provider-k8s/issues/7#issuecomment-591555068)
Steps to reproduce the issue:
(it also happens with
content = "#empty"
)Actual behavior:
Expected behavior
no crash
Additional context It seems that
YAMLOrJSONDecoder
Decode(&object)
doesn't touchobject
(still nil pointer) when there is no yaml object in the input string. Then all calls toobject.*
will probably panic,object.GetNamespace()
being the first.I'm not sure what to do when the object is nil: we possibly still need to
d.Setid()
somehow to make terraform happy.This will need to be handled as part of a proper fix for #7 too.