Skip to content

Commit

Permalink
fix(health-check enricher): don't fail if there is no dependencies pr…
Browse files Browse the repository at this point in the history
…op in the package.json (#250)

fixes #249
  • Loading branch information
lholmquist committed Jul 3, 2018
1 parent af2a504 commit 96789c1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/resource-enrichers/health-check-enricher.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ async function addHealthCheckInfo (config, resourceList) {
if (resource.kind === 'DeploymentConfig' || resource.kind === 'Deployment') {
// readiness probes and liveness probes should be in the spec.template.spec.containers[] section
// Check that 'kube-probe' has been added to the projects package.json
if (!config.projectPackage.dependencies) {
return resource;
}

if (!config.projectPackage.dependencies['kube-probe']) {
// If not, then just return the resource
return resource;
Expand Down
39 changes: 39 additions & 0 deletions test/enricher-tests/health-check-enricher-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,45 @@ test('health check enricher - no kube probe', async (t) => {
t.end();
});

test('health check enricher - no dependencies property', async (t) => {
const resourceList = [
{
kind: 'DeploymentConfig',
metadata: {
name: 'deployment config meta'
},
spec: {
template: {
spec: {
containers: [
{
ports: []
}
]
}
}
}
}
];

const config = {
projectName: 'Project Name',
projectPackage: {
},
version: '1.0.0',
context: {
namespace: 'namespace'
}
};

const hce = await healthCheckEnricher.enrich(config, resourceList);

t.equal(Array.isArray(hce), true, 'should return an array');
t.equal(hce[0].spec.template.spec.containers[0].livenessProbe, undefined, 'should not have a liveness probe added');
t.equal(hce[0].spec.template.spec.containers[0].readinessProbe, undefined, 'should not have a readiness probe added');
t.end();
});

test('health check enricher - with kube probe', async (t) => {
const resourceList = [
{
Expand Down

0 comments on commit 96789c1

Please sign in to comment.