Browse Source

lib/base: Allow for more complex template params

This change allows for the specification of JSON objects like
lists as parameters to templates.

Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Jose A. Rivera 8 years ago
parent
commit
c20195d037

+ 1 - 1
roles/lib_openshift/library/oc_adm_ca_server_cert.py

@@ -952,7 +952,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_adm_manage_node.py

@@ -938,7 +938,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_adm_policy_group.py

@@ -924,7 +924,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_adm_policy_user.py

@@ -924,7 +924,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_adm_registry.py

@@ -1042,7 +1042,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_adm_router.py

@@ -1067,7 +1067,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_clusterrole.py

@@ -916,7 +916,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_configmap.py

@@ -922,7 +922,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_edit.py

@@ -966,7 +966,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_env.py

@@ -933,7 +933,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_group.py

@@ -906,7 +906,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_image.py

@@ -925,7 +925,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_label.py

@@ -942,7 +942,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_obj.py

@@ -945,7 +945,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_objectvalidator.py

@@ -877,7 +877,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_process.py

@@ -934,7 +934,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_project.py

@@ -931,7 +931,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_pvc.py

@@ -926,7 +926,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_route.py

@@ -976,7 +976,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_scale.py

@@ -920,7 +920,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_secret.py

@@ -966,7 +966,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_service.py

@@ -972,7 +972,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_serviceaccount.py

@@ -918,7 +918,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_serviceaccount_secret.py

@@ -918,7 +918,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_user.py

@@ -978,7 +978,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_version.py

@@ -890,7 +890,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/library/oc_volume.py

@@ -967,7 +967,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)
 
 

+ 1 - 1
roles/lib_openshift/src/lib/base.py

@@ -128,7 +128,7 @@ class OpenShiftCLI(object):
         else:
         else:
             cmd.append(template_name)
             cmd.append(template_name)
         if params:
         if params:
-            param_str = ["{}={}".format(key, value) for key, value in params.items()]
+            param_str = ["{}={}".format(key, str(value).replace("'", r'"')) for key, value in params.items()]
             cmd.append('-v')
             cmd.append('-v')
             cmd.extend(param_str)
             cmd.extend(param_str)