Skip to content

Commit

Permalink
fix: deployment enricher should also look for DeploymentConfig kind
Browse files Browse the repository at this point in the history
fixes #271
  • Loading branch information
lholmquist committed Dec 12, 2018
1 parent 092f07c commit 6a2c162
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/resource-enrichers/deployment-config-enricher.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ function defaultDeploymentConfig (config) {

async function createDeploymentConfig (config, resourceList) {
// First check to see if we have a Deployment
if (_.filter(resourceList, { 'kind': 'Deployment' }).length < 1) {
if (_.filter(resourceList, { 'kind': 'Deployment' }).length < 1 && _.filter(resourceList, { 'kind': 'DeploymentConfig' }).length < 1) {
// create the default deployment config and add in to the resource list
resourceList.push(defaultDeploymentConfig(config));
return resourceList;
}

return resourceList.map((resource) => {
if (resource.kind !== 'Deployment') {
if (resource.kind !== 'Deployment' && resource.kind !== 'DeploymentConfig') {
return resource;
}

Expand Down
29 changes: 29 additions & 0 deletions test/enricher-tests/deployment-config-enricher-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,32 @@ test('deployment config enricher - deployment', async (t) => {
t.equal(dce[1].kind, 'DeploymentConfig', 'should have the depoymentConfig type');
t.end();
});

test('deployment config enricher - deployment config', async (t) => {
const deploymentConfigEnricher = proxyquire('../../lib/resource-enrichers/deployment-config-enricher', {
'../definitions/deployment-config-spec': deploymentConfig => deploymentConfig
});

const resourceList = [
{
kind: 'Service',
metadata: {
name: 'service meta'
}
},
{
kind: 'DeploymentConfig',
metadata: {
name: 'deploymentConfigName'
}
}
];

const dce = await deploymentConfigEnricher.enrich(config, resourceList);

t.equal(Array.isArray(dce), true, 'should return an array');
t.equal(dce.length, 2, 'should have the same length');
t.equal(dce[1].kind, 'DeploymentConfig', 'should have the depoymentConfig type');
t.equal(dce[1].metadata.namespace, config.context.namespace, 'should be enriched with the namespace value');
t.end();
});

0 comments on commit 6a2c162

Please sign in to comment.