Adding the ability to deal with strings containing yaml seems to repel
to much. So we stay with create_from_yaml with a bad name.
This removes the need fro StringIO to wrap strings.
Also note:
```
with open('foo.txt') as f:
y = yaml.safe_load_all(f)
for i in y:
print(i)
\# raises ValueError: I/O operation on closed file.
```
Hence, we indent the whole method body into the open block.
with open('foo.txt') as f:
y = yaml.safe_load_all(f)
for i in y:
print(i)
The function can create one or more Kuberenetes objects
based on the content of data. It can handle all API objects
incuding `List` type, which by itself can contain more than
one Kuberenetes API objects.
Renaming `yml_document` in `create_from_dict` to data. This is a bit
clearer that this it a data item and not a string (usually document
read from the file system).
Also update the documentation to describe better what the functions
`create_from_dict` and `create_from_yaml` do.
Some models don't have attribute 'status', like V1ConfigMap,
V1ClusterRole, and V1NetworkPolicy. AttributeError would be raised if
these resources are created via create_from_yaml with verbose enabled.
This patch checks if attribute 'status' exists before accessing it.
While this is a really good convention, sometimes one must import
stuff inside a try except block. This block is still at the top, but pycodestyle
treats like it isn't, because it's in an idented block, and the outeer scope.
This fixes of all tests and keeps the original API.
It's the users responsiblility to do something the execptions
when using `create_from_dict`, no air bag or breaks are supplied here.