Fix two bugs in replicatedservice.py

pull/48/head
jackgr 9 years ago
parent c7d35e3a7d
commit 5b5278631a

@ -41,9 +41,9 @@ def GenerateConfig(context):
'properties': { 'properties': {
'apiVersion': 'v1', 'apiVersion': 'v1',
'kind': 'Service', 'kind': 'Service',
'namespace': namespace,
'metadata': { 'metadata': {
'name': service_name, 'name': service_name,
'namespace': namespace,
'labels': GenerateLabels(context, service_name), 'labels': GenerateLabels(context, service_name),
}, },
'spec': { 'spec': {
@ -63,9 +63,9 @@ def GenerateConfig(context):
'properties': { 'properties': {
'apiVersion': 'v1', 'apiVersion': 'v1',
'kind': 'ReplicationController', 'kind': 'ReplicationController',
'namespace': namespace,
'metadata': { 'metadata': {
'name': rc_name, 'name': rc_name,
'namespace': namespace,
'labels': GenerateLabels(context, rc_name), 'labels': GenerateLabels(context, rc_name),
}, },
'spec': { 'spec': {
@ -101,11 +101,11 @@ def GenerateConfig(context):
def GenerateLabels(context, name): def GenerateLabels(context, name):
"""Generates labels either from the context.properties['labels'] or """Generates labels either from the context.properties['labels'] or
generates a default label 'name':name generates a default label 'app':name
We make a deep copy of the context.properties['labels'] section to avoid We make a deep copy of the context.properties['labels'] section to avoid
linking in the yaml document, which I believe reduces readability of the linking in the yaml document, which I believe reduces readability of the
expanded template. If no labels are given, generate a default 'name':name. expanded template. If no labels are given, generate a default 'app':name.
Args: Args:
context: Template context, which can contain the following properties: context: Template context, which can contain the following properties:
@ -115,7 +115,7 @@ def GenerateLabels(context, name):
A dict containing labels in a name:value format A dict containing labels in a name:value format
""" """
tmp_labels = context.properties.get('labels', None) tmp_labels = context.properties.get('labels', None)
ret_labels = {'name': name} ret_labels = {'app': name}
if isinstance(tmp_labels, dict): if isinstance(tmp_labels, dict):
for key, value in tmp_labels.iteritems(): for key, value in tmp_labels.iteritems():
ret_labels[key] = value ret_labels[key] = value

Loading…
Cancel
Save