Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(amazon): omit spinnaker metadata tags when cloning server groups #4554

Merged
merged 2 commits into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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