Browse Source

Fix linting issues

Sean Dawson 7 years ago
parent
commit
ce048f23d8

+ 8 - 8
roles/lib_openshift/library/oc_storageclass.py

@@ -1570,9 +1570,9 @@ class OCStorageClass(OpenShiftCLI):
         return False
 
     @staticmethod
-    def provisionerNameIsFullyQualified(provisionerName):
-        pattern = re.compile('^[a-z0-9A-Z-_.]+\/[a-z0-9A-Z-_.]+$')
-        return pattern.match(provisionerName)
+    def provisioner_name_is_fully_qualified(provisioner_name):
+        pattern = re.compile(r'^[a-z0-9A-Z-_.]+\/[a-z0-9A-Z-_.]+$')
+        return pattern.match(provisioner_name)
 
     @staticmethod
     # pylint: disable=too-many-return-statements,too-many-branches
@@ -1583,14 +1583,14 @@ class OCStorageClass(OpenShiftCLI):
         # Make sure that the provisioner is fully qualified before using it
         # E.g. if 'aws-efs' is provided as a provisioner, convert it to 'kubernetes.io/aws-efs'
         # but if the name is already qualified  (e.g. 'openshift.org/aws-efs') then leave it be.
-        rawProvisionerName = params['provisioner']
-        if OCStorageClass.provisionerNameIsFullyQualified(rawProvisionerName):
-            qualifiedProvisionerName = rawProvisionerName
+        raw_provisioner_name = params['provisioner']
+        if OCStorageClass.provisioner_name_is_fully_qualified(raw_provisioner_name):
+            qualified_provisioner_name = raw_provisioner_name
         else:
-            qualifiedProvisionerName = "kubernetes.io/{}".format(params['provisioner'])
+            qualified_provisioner_name = "kubernetes.io/{}".format(params['provisioner'])
 
         rconfig = StorageClassConfig(params['name'],
-                                     provisioner=qualifiedProvisionerName,
+                                     provisioner=qualified_provisioner_name,
                                      parameters=params['parameters'],
                                      annotations=params['annotations'],
                                      api_version="storage.k8s.io/{}".format(params['api_version']),

+ 8 - 8
roles/lib_openshift/src/class/oc_storageclass.py

@@ -65,9 +65,9 @@ class OCStorageClass(OpenShiftCLI):
         return False
 
     @staticmethod
-    def provisionerNameIsFullyQualified(provisionerName):
-        pattern = re.compile('^[a-z0-9A-Z-_.]+\/[a-z0-9A-Z-_.]+$')
-        return pattern.match(provisionerName)
+    def provisioner_name_is_fully_qualified(provisioner_name):
+        pattern = re.compile(r'^[a-z0-9A-Z-_.]+\/[a-z0-9A-Z-_.]+$')
+        return pattern.match(provisioner_name)
 
     @staticmethod
     # pylint: disable=too-many-return-statements,too-many-branches
@@ -78,14 +78,14 @@ class OCStorageClass(OpenShiftCLI):
         # Make sure that the provisioner is fully qualified before using it
         # E.g. if 'aws-efs' is provided as a provisioner, convert it to 'kubernetes.io/aws-efs'
         # but if the name is already qualified  (e.g. 'openshift.org/aws-efs') then leave it be.
-        rawProvisionerName = params['provisioner']
-        if OCStorageClass.provisionerNameIsFullyQualified(rawProvisionerName):
-            qualifiedProvisionerName = rawProvisionerName
+        raw_provisioner_name = params['provisioner']
+        if OCStorageClass.provisioner_name_is_fully_qualified(raw_provisioner_name):
+            qualified_provisioner_name = raw_provisioner_name
         else:
-            qualifiedProvisionerName = "kubernetes.io/{}".format(params['provisioner'])
+            qualified_provisioner_name = "kubernetes.io/{}".format(params['provisioner'])
 
         rconfig = StorageClassConfig(params['name'],
-                                     provisioner=qualifiedProvisionerName,
+                                     provisioner=qualified_provisioner_name,
                                      parameters=params['parameters'],
                                      annotations=params['annotations'],
                                      api_version="storage.k8s.io/{}".format(params['api_version']),

+ 20 - 19
roles/lib_openshift/src/test/unit/test_oc_storageclass.py

@@ -36,14 +36,15 @@ class OCStorageClassTest(unittest.TestCase):
         # run_ansible input parameters
 
         params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig',
-          'state': 'present',
-          'debug': False,
-          'name': 'testsc',
-          'provisioner': 'aws-ebs',
-          'annotations': {'storageclass.beta.kubernetes.io/is-default-class': "true"},
-          'parameters': {'type': 'gp2'},
-          'api_version': 'v1',
-          'default_storage_class': 'true'}
+           'state': 'present',
+            'debug': False,
+            'name': 'testsc',
+            'provisioner': 'aws-ebs',
+            'annotations': {'storageclass.beta.kubernetes.io/is-default-class': "true"},
+            'parameters': {'type': 'gp2'},
+            'api_version': 'v1',
+            'default_storage_class': 'true'
+        }
 
         valid_result_json = '''{
             "kind": "StorageClass",
@@ -76,7 +77,6 @@ class OCStorageClassTest(unittest.TestCase):
             'oc'
         ]
 
-
         mock_tmpfile_copy.side_effect = [
             '/tmp/mocked_kubeconfig',
         ]
@@ -117,15 +117,17 @@ class OCStorageClassTest(unittest.TestCase):
 
         # run_ansible input parameters
 
-        params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig',
-          'state': 'present',
-          'debug': False,
-          'name': 'testsc',
-          'provisioner': 'kubernetes.io/aws-ebs',
-          'annotations': {'storageclass.beta.kubernetes.io/is-default-class': "true"},
-          'parameters': {'type': 'gp2'},
-          'api_version': 'v1',
-          'default_storage_class': 'true'}
+        params = {
+            'kubeconfig': '/etc/origin/master/admin.kubeconfig',
+            'state': 'present',
+            'debug': False,
+            'name': 'testsc',
+            'provisioner': 'kubernetes.io/aws-ebs',
+            'annotations': {'storageclass.beta.kubernetes.io/is-default-class': "true"},
+            'parameters': {'type': 'gp2'},
+            'api_version': 'v1',
+            'default_storage_class': 'true'
+        }
 
         valid_result_json = '''{
             "kind": "StorageClass",
@@ -158,7 +160,6 @@ class OCStorageClassTest(unittest.TestCase):
             'oc'
         ]
 
-
         mock_tmpfile_copy.side_effect = [
             '/tmp/mocked_kubeconfig',
         ]