Skip to content

Commit 9a3b789

Browse files
committed
changing order of operations
1 parent 5b6833c commit 9a3b789

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The following `environment` variables are supported. See https://www.cockroachl
4848
* `COCKROACH_CERTS_DIR` - The path to the certificate directory containing the CA and client certificates and client key.
4949
* `DATABASE_NAME` - Name of database to create.
5050
* `DATABASE_USER` - Name of new database user to create. __Important__, this user will be created as a CockroachDB `admin`.
51-
* `DATABASE_PASSWORD` - Password for `DATABASE_USER`.
51+
* `DATABASE_PASSWORD` - Password for `DATABASE_USER`. If not provided the password will be set to `NULL` preventing the user from using [password based authentication](https://www.cockroachlabs.com/docs/v20.2/create-user.html#prevent-a-user-from-using-password-authentication).
5252
* `COCKROACH_ORG` - The value of the `cluster.organization` setting.
5353
* `COCKROACH_LICENSE_KEY` - The value of the `enterprise.license` setting.
5454
* `COCKROACH_INIT` - Initializes the CockroachDB cluster with the `cockroach init` command.

src/main/java/io/crdb/docker/RemoteClientApplication.java

+13-15
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ public void run(ApplicationArguments args) throws Exception {
8383

8484
handleProcess(new ProcessBuilder("/cockroach", "sql", "--execute", "SET CLUSTER SETTING server.remote_debugging.mode = 'any'"));
8585

86+
if (StringUtils.hasText(licenseOrg) && StringUtils.hasText(licenseKey)) {
87+
List<String> commands = new ArrayList<>();
88+
commands.add("/cockroach");
89+
commands.add("sql");
90+
commands.add("--execute");
91+
commands.add(String.format("SET CLUSTER SETTING cluster.organization = '%s'", licenseOrg));
92+
commands.add("--execute");
93+
commands.add(String.format("SET CLUSTER SETTING enterprise.license = '%s'", licenseKey));
94+
95+
ProcessBuilder builder = new ProcessBuilder(commands);
96+
handleProcess(builder);
97+
}
98+
8699
if (StringUtils.hasText(databaseName)) {
87100
List<String> commands = new ArrayList<>();
88101
commands.add("/cockroach");
@@ -94,7 +107,6 @@ public void run(ApplicationArguments args) throws Exception {
94107
handleProcess(builder);
95108
}
96109

97-
98110
if (StringUtils.hasText(databaseName) && StringUtils.hasText(databaseUser)) {
99111
List<String> commands = new ArrayList<>();
100112
commands.add("/cockroach");
@@ -116,20 +128,6 @@ public void run(ApplicationArguments args) throws Exception {
116128
handleProcess(builder);
117129
}
118130

119-
120-
if (StringUtils.hasText(licenseOrg) && StringUtils.hasText(licenseKey)) {
121-
List<String> commands = new ArrayList<>();
122-
commands.add("/cockroach");
123-
commands.add("sql");
124-
commands.add("--execute");
125-
commands.add(String.format("SET CLUSTER SETTING cluster.organization = '%s'", licenseOrg));
126-
commands.add("--execute");
127-
commands.add(String.format("SET CLUSTER SETTING enterprise.license = '%s'", licenseKey));
128-
129-
ProcessBuilder builder = new ProcessBuilder(commands);
130-
handleProcess(builder);
131-
}
132-
133131
}
134132

135133
private void handleProcess(ProcessBuilder builder) throws IOException, InterruptedException {

0 commit comments

Comments
 (0)