Skip to content

Commit

Permalink
fix(amazon): omit spinnaker metadata tags when cloning server groups (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherchrisberry committed Dec 5, 2017
1 parent ba2a3c8 commit fca5a70
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Expand Up @@ -189,10 +189,15 @@ module.exports = angular.module('spinnaker.amazon.serverGroupCommandBuilder.serv
var useAmiBlockDeviceMappings = applicationAwsSettings.useAmiBlockDeviceMappings || false;

const existingTags = {};
// These tags are applied by Clouddriver (if configured to do so), regardless of what the user might enter
// Might be worth feature flagging this if it turns out other folks are hard-coding these values
const reservedTags = [ 'spinnaker:application', 'spinnaker:stack', 'spinnaker:details' ];
if (serverGroup.asg.tags) {
serverGroup.asg.tags.forEach(tag => {
existingTags[tag.key] = tag.value;
});
serverGroup.asg.tags
.filter(t => !reservedTags.includes(t.key))
.forEach(tag => {
existingTags[tag.key] = tag.value;
});
}

var command = {
Expand Down
Expand Up @@ -142,7 +142,7 @@ describe('awsServerGroupCommandBuilder', function() {
expect(command.suspendedProcesses).toEqual([]);
});

it('copies tags', function () {
it('copies tags not in the reserved list:', function () {
spyOn(this.instanceTypeService, 'getCategoryForInstanceType').and.returnValue(this.$q.when('selectedProfile'));

const baseServerGroup = {
Expand All @@ -154,11 +154,15 @@ describe('awsServerGroupCommandBuilder', function() {
vpczoneIdentifier: '',
tags: [
{
key: "some-key",
key: 'some-key',
propagateAtLaunch: true,
resourceId: "some-resource-id",
resourceType: "auto-scaling-group",
value: "some-value"
resourceId: 'some-resource-id',
resourceType: 'auto-scaling-group',
value: 'some-value'
},
{
key: 'spinnaker:application',
value: 'n/a'
}
]
},
Expand All @@ -175,7 +179,7 @@ describe('awsServerGroupCommandBuilder', function() {

this.$scope.$digest();

expect(command.tags).toEqual({"some-key": "some-value"});
expect(command.tags).toEqual({'some-key': 'some-value'});
});
});

Expand Down

0 comments on commit fca5a70

Please sign in to comment.