Skip to content

Commit

Permalink
Add codestyle tracking, fix codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
micw523 committed Nov 2, 2018
1 parent 2dafb4b commit 7256870
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions kubernetes/utils/create_from_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from os import path

import re
import sys

from six import iteritems
from os import path

import yaml
from six import iteritems

from kubernetes import client


def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):
"""
Perform an action from a yaml file. Pass True for verbose to
print confirmation information.
Input:
yaml_file: string. Contains the path to yaml file.
k8s_cline: an ApiClient object, initialized with the client args.
Expand All @@ -40,7 +40,7 @@ def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):

with open(path.abspath(yaml_file)) as f:
yml_object = yaml.load(f)
#TODO: case of yaml file containing multiple objects
# TODO: case of yaml file containing multiple objects
group, _, version = yml_object["apiVersion"].partition("/")
if version == "":
version = group
Expand All @@ -49,7 +49,7 @@ def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):
# Only replace the last instance
group = "".join(group.rsplit(".k8s.io", 1))
fcn_to_call = "{0}{1}Api".format(group.capitalize(),
version.capitalize())
version.capitalize())
k8s_api = getattr(client, fcn_to_call)(k8s_client)
# Replace CamelCased action_type into snake_case
kind = yml_object["kind"]
Expand All @@ -71,4 +71,3 @@ def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):
if verbose:
print("{0} created. status='{1}'".format(kind, str(resp.status)))
return k8s_api

2 changes: 1 addition & 1 deletion scripts/update-pycodestyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SAVEIFS=$IFS
trap "IFS=$SAVEIFS" EXIT SIGINT
IFS=,

SOURCES="${SCRIPT_ROOT}/../setup.py,${CLIENT_ROOT}/config/*.py,${CLIENT_ROOT}/watch/*.py,${SCRIPT_ROOT}/*.py,${CLIENT_ROOT}/../examples/*.py"
SOURCES="${SCRIPT_ROOT}/../setup.py,${CLIENT_ROOT}/config/*.py,${CLIENT_ROOT}/watch/*.py,${CLIENT_ROOT}/utils/*.py,${SCRIPT_ROOT}/*.py,${CLIENT_ROOT}/../examples/*.py"

echo "--- applying autopep8"
for SOURCE in $SOURCES; do
Expand Down

0 comments on commit 7256870

Please sign in to comment.