Skip to content

Commit

Permalink
feat(cluster): add option to pass in path to custom dhis.conf (#236)
Browse files Browse the repository at this point in the history
* fix: spelling mistake in help text

* feat(cluster): add option to pass in path to custom dhis.conf

* test(cluster): update env in tests

* chore: run tests pre-push
  • Loading branch information
varl committed Jan 9, 2020
1 parent 4b869df commit 80f4cd5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .huskyrc.js
Expand Up @@ -9,5 +9,6 @@ module.exports = {
'd2-style js check --staged',
'd2-style text check --staged',
]),
'pre-push': 'yarn test',
},
}
7 changes: 6 additions & 1 deletion packages/cluster/src/commands/up.js
Expand Up @@ -104,7 +104,7 @@ module.exports = {
},
seed: {
alias: 's',
desc: 'Seed the detabase from a sql dump',
desc: 'Seed the database from a sql dump',
type: 'boolean',
},
seedFile: {
Expand All @@ -126,6 +126,11 @@ module.exports = {
desc: 'Set the DHIS2 version',
type: 'string',
},
dhis2Config: {
desc:
'Path to a custom DHIS2 configuration file to use (dhis.conf)',
type: 'string',
},
dbVersion: {
desc: 'Set the database version',
type: 'string',
Expand Down
3 changes: 2 additions & 1 deletion packages/cluster/src/common.js
@@ -1,5 +1,4 @@
const path = require('path')
const fs = require('fs')

const { reporter } = require('@dhis2/cli-helpers-engine')

Expand Down Expand Up @@ -132,6 +131,7 @@ async function resolveConfiguration(argv = {}) {
channel: resolved.channel,
dbVersion: resolved.dbVersion,
dhis2Version: resolved.dhis2Version,
dhis2Config: resolved.dhis2Config,
customContext: resolved.customContext,
image: resolved.image,
port: resolved.port,
Expand All @@ -155,6 +155,7 @@ module.exports.makeEnvironment = cfg => {
DHIS2_CORE_VERSION: cfg.dhis2Version,
DHIS2_CORE_DB_VERSION: cfg.dbVersion,
DHIS2_CORE_PORT: cfg.port,
DHIS2_CORE_CONFIG: cfg.dhis2Config,
}

reporter.debug('Runtime environment\n', env)
Expand Down
5 changes: 5 additions & 0 deletions packages/cluster/tests/setup-environment.js
Expand Up @@ -27,6 +27,7 @@ test('build runtime environment based on defaults', async function(t) {
DHIS2_CORE_VERSION: 'dev',
DHIS2_CORE_DB_VERSION: 'dev',
DHIS2_CORE_PORT: defaults.port,
DHIS2_CORE_CONFIG: undefined,
}

t.deepEqual(actual, expected, 'default environment')
Expand Down Expand Up @@ -56,6 +57,7 @@ test('build runtime environment based on args', async function(t) {
DHIS2_CORE_VERSION: '2.33',
DHIS2_CORE_DB_VERSION: '2.32',
DHIS2_CORE_PORT: 8233,
DHIS2_CORE_CONFIG: undefined,
}

t.deepEqual(actual, expected, 'args environment')
Expand Down Expand Up @@ -88,6 +90,7 @@ test('build runtime environment based on mixed args and config', async function(
DHIS2_CORE_VERSION: 'master',
DHIS2_CORE_DB_VERSION: 'dev',
DHIS2_CORE_PORT: 8233,
DHIS2_CORE_CONFIG: undefined,
}

t.deepEqual(actual, expected, 'args and config environment')
Expand Down Expand Up @@ -121,6 +124,7 @@ test('build runtime environment based on mixed args, cache, config and defaults'
DHIS2_CORE_VERSION: 'dev',
DHIS2_CORE_DB_VERSION: 'dev',
DHIS2_CORE_PORT: 8233,
DHIS2_CORE_CONFIG: undefined,
}

t.deepEqual(actual, expected, 'merged environment')
Expand Down Expand Up @@ -161,6 +165,7 @@ test('build runtime environment based on mixed args, cache, config, custom per-c
DHIS2_CORE_VERSION: 'apa',
DHIS2_CORE_DB_VERSION: 'dev',
DHIS2_CORE_PORT: 9999,
DHIS2_CORE_CONFIG: undefined,
}

t.deepEqual(actual, expected, 'merged environment')
Expand Down

0 comments on commit 80f4cd5

Please sign in to comment.