Skip to content

Commit 377efcf

Browse files
committed
concord-cli: do not call System.exit in RemoteSecretsProvider
Make testing simpler by not using System.exit anywhere except the entrypoints.
1 parent 8b3f357 commit 377efcf

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.walmartlabs.concord.cli;
2+
3+
/*-
4+
* *****
5+
* Concord
6+
* -----
7+
* Copyright (C) 2017 - 2025 Walmart Inc.
8+
* -----
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* =====
21+
*/
22+
23+
public class AbortException extends RuntimeException {
24+
25+
public AbortException() {
26+
super("Aborted");
27+
}
28+
}

cli/src/main/java/com/walmartlabs/concord/cli/runner/secrets/RemoteSecretsProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* =====
2121
*/
2222

23+
import com.walmartlabs.concord.cli.AbortException;
2324
import com.walmartlabs.concord.cli.Version;
2425
import com.walmartlabs.concord.client2.*;
2526
import com.walmartlabs.concord.common.secret.BinaryDataSecret;
@@ -190,8 +191,7 @@ private void askForAccessConfirmation(String orgName, String secretName) throws
190191
int response = System.in.read();
191192
// y == 121, Y == 89
192193
if (response != 121 && response != 89) {
193-
System.out.println(ansi().fgRed().a("Aborting.").reset());
194-
System.exit(-1);
194+
throw new AbortException();
195195
}
196196
}
197197
}

0 commit comments

Comments
 (0)