Skip to content

Commit

Permalink
fix(pipeline_templates): prevent [object Object] when object's defaul…
Browse files Browse the repository at this point in the history
…tValue is provided (#4975)
  • Loading branch information
Scott Bloch-Wehba-Seaward committed Mar 8, 2018
1 parent e04770a commit 93a20c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,24 @@ describe('Controller: ConfigurePipelineTemplateModalCtrl', () => {
' capacity: 1\n' +
' keyPair: example-keypair\n' +
' loadBalancers:\n' +
' - orca-test\n' +
' - orca-test\n' +
' securityGroups: []\n' +
' strategy: highlander\n' +
' instanceType: m3.xlarge';
' instanceType: m3.xlarge\n';

const yamlAsObj = [{
name: 'orca-test',
region: 'us-west-2',
availabilityZones: [] as any[],
capacity: 1,
keyPair: 'example-keypair',
loadBalancers: [
'orca-test',
],
securityGroups: [] as any[],
strategy: 'highlander',
instanceType: 'm3.xlarge',
}];

const template: any = {
variables: [
Expand All @@ -46,7 +60,7 @@ describe('Controller: ConfigurePipelineTemplateModalCtrl', () => {
name: 'someObject',
group: 'Advanced Settings',
type: 'object',
defaultValue: yaml,
defaultValue: yamlAsObj,
},
{
name: 'someList',
Expand Down Expand Up @@ -239,17 +253,7 @@ describe('Controller: ConfigurePipelineTemplateModalCtrl', () => {
expect(templateConfig.config.pipeline.variables).toEqual({
credentials: 'my-google-account',
cloudProvider: 'gce',
someObject: [{
name: 'orca-test',
region: 'us-west-2',
availabilityZones: [],
capacity: 1,
keyPair: 'example-keypair',
loadBalancers: ['orca-test'],
securityGroups: [],
strategy: 'highlander',
instanceType: 'm3.xlarge'
}],
someObject: yamlAsObj,
someList: ['a', 'b', 'c'],
someInt: 42
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export class ConfigurePipelineTemplateModalController implements IController {
value = dump(value);
}
return value;
} else if (variable.type === 'object' && has(variable, 'defaultValue')) {
return dump(variable.defaultValue);
} else {
return (variable.type === 'list' && !variable.defaultValue) ? [''] : variable.defaultValue;
}
Expand Down

0 comments on commit 93a20c5

Please sign in to comment.