From 4caf6d92eab4468f9dc6044f211d7a3ecf0e0280 Mon Sep 17 00:00:00 2001 From: Michal Kit Date: Wed, 10 Jan 2018 16:27:59 +0000 Subject: [PATCH] ENT-1350 unifying the config-file command line argument (#333) * ENT-1350 unifying the config-file command line argument * Changing README.md --- docs/source/running-signing-service.rst | 2 +- network-management/README.md | 2 +- .../com/r3/corda/networkmanage/doorman/DoormanParameters.kt | 1 + .../r3/corda/networkmanage/hsm/configuration/Configuration.kt | 3 ++- .../networkmanage/hsm/configuration/ConfigurationTest.kt | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/source/running-signing-service.rst b/docs/source/running-signing-service.rst index 47f8637441..6b84578dda 100644 --- a/docs/source/running-signing-service.rst +++ b/docs/source/running-signing-service.rst @@ -13,7 +13,7 @@ See the :doc:`signing-service` for a more detailed description of the service. Configuration file ------------------ -At startup the signing service reads a configuration file, passed with ``--configFile`` on the command line. +At startup the signing service reads a configuration file, passed with ``--config-file`` on the command line. This is an example of what a signing service configuration file might look like: .. literalinclude:: ../../network-management/hsm.conf diff --git a/network-management/README.md b/network-management/README.md index dfbc34e62f..33929abdd0 100644 --- a/network-management/README.md +++ b/network-management/README.md @@ -28,7 +28,7 @@ To run the HSM signing server: ``` cd network-management -java -jar capsule-hsm/build/libs/hsm-.jar --configFile hsm.conf +java -jar capsule-hsm/build/libs/hsm-.jar --config-file hsm.conf ``` For a list of options the HSM signing server takes, run with the `--help` option: diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/DoormanParameters.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/DoormanParameters.kt index 86efb279c8..3d4b47a107 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/DoormanParameters.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/DoormanParameters.kt @@ -84,6 +84,7 @@ fun parseParameters(vararg args: String): NetworkManagementServerParameters { .defaultsTo(Mode.DOORMAN.name) } + // The config-file option is changed to configFile val configFile = if (argConfig.hasPath("configFile")) { Paths.get(argConfig.getString("configFile")) } else { diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/configuration/Configuration.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/configuration/Configuration.kt index b13ac5ba27..6986f3a862 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/configuration/Configuration.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/configuration/Configuration.kt @@ -61,9 +61,10 @@ data class Parameters(val dataSourceProperties: Properties, fun parseParameters(vararg args: String): Parameters { val argConfig = args.toConfigWithOptions { accepts("basedir", "Overriding configuration filepath, default to current directory.").withRequiredArg().defaultsTo(".").describedAs("filepath") - accepts("configFile", "Overriding configuration file.").withRequiredArg().defaultsTo("node.conf").describedAs("filepath") + accepts("config-file", "Overriding configuration file.").withRequiredArg().describedAs("filepath") } + // The config-file option is changed to configFile val configFile = if (argConfig.hasPath("configFile")) { Paths.get(argConfig.getString("configFile")) } else { diff --git a/network-management/src/test/kotlin/com/r3/corda/networkmanage/hsm/configuration/ConfigurationTest.kt b/network-management/src/test/kotlin/com/r3/corda/networkmanage/hsm/configuration/ConfigurationTest.kt index 4d0701286a..2da083f760 100644 --- a/network-management/src/test/kotlin/com/r3/corda/networkmanage/hsm/configuration/ConfigurationTest.kt +++ b/network-management/src/test/kotlin/com/r3/corda/networkmanage/hsm/configuration/ConfigurationTest.kt @@ -15,7 +15,7 @@ class ConfigurationTest : TestBase() { @Test fun `config file is parsed correctly`() { - val paramsWithPassword = parseParameters("--configFile", validConfigPath) + val paramsWithPassword = parseParameters("--config-file", validConfigPath) assertEquals(AuthMode.PASSWORD, paramsWithPassword.authMode) assertEquals("3001@192.168.0.1", paramsWithPassword.device) } @@ -24,7 +24,7 @@ class ConfigurationTest : TestBase() { fun `should fail when config missing database source properties`() { // dataSourceProperties is missing from node_fail.conf and it should fail during parsing, and shouldn't use default from reference.conf. assertFailsWith { - parseParameters("--configFile", invalidConfigPath) + parseParameters("--config-file", invalidConfigPath) } }