summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/library/oc_adm_policy_user.py
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2017-05-03 18:14:16 -0600
committerRich Megginson <rmeggins@redhat.com>2017-05-30 10:39:02 -0600
commita1cfec9bbe43dd005ab16792c90cc949555cce12 (patch)
tree8ac6efa0782dd6e6dbd74a6164249c730a607a69 /roles/lib_openshift/library/oc_adm_policy_user.py
parent46411cfc431f7960df542c5bdcf62c65f612a965 (diff)
downloadopenshift-a1cfec9bbe43dd005ab16792c90cc949555cce12.tar.gz
openshift-a1cfec9bbe43dd005ab16792c90cc949555cce12.tar.bz2
openshift-a1cfec9bbe43dd005ab16792c90cc949555cce12.tar.xz
openshift-a1cfec9bbe43dd005ab16792c90cc949555cce12.zip
add support for oc_service for labels, externalIPs
Add support for `labels` and `externalIPs` in Services This also adds support for the `labels` parameter of `oadm registry` and `oadm router` to be a `dict` of values. This also converts `labels` dict values in the router and registry classes into a comma delimited list of `key=value` pairs. The list of `--labels` is sorted for consistency in key pair positioning in the output (and for consistency in testing) - otherwise, the order of the list is not guarantee and has actually been observed to be different from run to run.
Diffstat (limited to 'roles/lib_openshift/library/oc_adm_policy_user.py')
-rw-r--r--roles/lib_openshift/library/oc_adm_policy_user.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/roles/lib_openshift/library/oc_adm_policy_user.py b/roles/lib_openshift/library/oc_adm_policy_user.py
index 5807f41a8..0bdfd0bad 100644
--- a/roles/lib_openshift/library/oc_adm_policy_user.py
+++ b/roles/lib_openshift/library/oc_adm_policy_user.py
@@ -1377,7 +1377,6 @@ class Utils(object): # pragma: no cover
print('returning true')
return True
-
class OpenShiftCLIConfig(object):
'''Generic Config'''
def __init__(self, rname, namespace, kubeconfig, options):
@@ -1391,18 +1390,28 @@ class OpenShiftCLIConfig(object):
''' return config options '''
return self._options
- def to_option_list(self):
- '''return all options as a string'''
- return self.stringify()
-
- def stringify(self):
- ''' return the options hash as cli params in a string '''
+ def to_option_list(self, ascommalist=''):
+ '''return all options as a string
+ if ascommalist is set to the name of a key, and
+ the value of that key is a dict, format the dict
+ as a list of comma delimited key=value pairs'''
+ return self.stringify(ascommalist)
+
+ def stringify(self, ascommalist=''):
+ ''' return the options hash as cli params in a string
+ if ascommalist is set to the name of a key, and
+ the value of that key is a dict, format the dict
+ as a list of comma delimited key=value pairs '''
rval = []
for key in sorted(self.config_options.keys()):
data = self.config_options[key]
if data['include'] \
and (data['value'] or isinstance(data['value'], int)):
- rval.append('--{}={}'.format(key.replace('_', '-'), data['value']))
+ if key == ascommalist:
+ val = ','.join(['{}={}'.format(kk, vv) for kk, vv in sorted(data['value'].items())])
+ else:
+ val = data['value']
+ rval.append('--{}={}'.format(key.replace('_', '-'), val))
return rval