Commit 5b527863 authored by jackgr's avatar jackgr

Fix two bugs in replicatedservice.py

parent c7d35e3a
...@@ -41,9 +41,9 @@ def GenerateConfig(context): ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment