1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- from os import path
15+
1616import re
1717import sys
18-
19- from six import iteritems
18+ from os import path
2019
2120import yaml
21+ from six import iteritems
2222
2323from kubernetes import client
2424
25+
2526def create_from_yaml (k8s_client , yaml_file , verbose = False , ** kwargs ):
2627 """
2728 Perform an action from a yaml file. Pass True for verbose to
2829 print confirmation information.
29-
3030 Input:
3131 yaml_file: string. Contains the path to yaml file.
3232 k8s_cline: an ApiClient object, initialized with the client args.
@@ -40,7 +40,7 @@ def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):
4040
4141 with open (path .abspath (yaml_file )) as f :
4242 yml_object = yaml .load (f )
43- #TODO: case of yaml file containing multiple objects
43+ # TODO: case of yaml file containing multiple objects
4444 group , _ , version = yml_object ["apiVersion" ].partition ("/" )
4545 if version == "" :
4646 version = group
@@ -49,7 +49,7 @@ def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):
4949 # Only replace the last instance
5050 group = "" .join (group .rsplit (".k8s.io" , 1 ))
5151 fcn_to_call = "{0}{1}Api" .format (group .capitalize (),
52- version .capitalize ())
52+ version .capitalize ())
5353 k8s_api = getattr (client , fcn_to_call )(k8s_client )
5454 # Replace CamelCased action_type into snake_case
5555 kind = yml_object ["kind" ]
@@ -71,4 +71,3 @@ def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):
7171 if verbose :
7272 print ("{0} created. status='{1}'" .format (kind , str (resp .status )))
7373 return k8s_api
74-
0 commit comments