Skip to content

Commit 0e9d9b8

Browse files
authored
Merge pull request #13 from loiclefevre/5
12 - Add cli argument to control the double quotes for connection string suffix
2 parents 7381248 + 7c1702f commit 0e9d9b8

6 files changed

Lines changed: 54 additions & 15 deletions

File tree

README.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:linkattrs:
33
:project-owner: oracle-actions
44
:project-name: setup-testpilot
5-
:project-tag: v1.0.26
5+
:project-tag: v1.0.27
66

77
ifdef::env-github[]
88
:tip-caption: :bulb:
@@ -38,6 +38,7 @@ Following inputs may be used as `step.with` keys:
3838
Valid OCI service are: `autonomous-transaction-processing-serverless-19c`, `autonomous-transaction-processing-serverless-26ai`, `base-database-service-19c`, `base-database-service-21c`, `base-database-service-26ai`, and `base-database-service-26ai-rac`.
3939
| user | | | The database username to be used for database creation. If multiple users (up to 10) are required then enter a comma-separated list of usernames (no space). Limit usernames to 118 chars maximum. Accepted chars are: upper case letters, lower case letters, digits, colon, hyphen, underscore, and dot.
4040
| connection-string-format | | easy-connect | The resulting connection string format: `easy-connect` or `tns`.
41+
| surround-connection-string-with-double-quotes | | false | If the connection string must be surrounded by double quotes: `true` or `false`.
4142
| prefix_list | | | A comma separated list of file(s) or folder(s) that if changed should not trigger any test (example: folder containing documentation).
4243
|===
4344

action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ branding:
99
inputs:
1010
version:
1111
description: 'The version to use.'
12-
default: 'v1.0.26'
12+
default: 'v1.0.27'
1313
required: true
1414
action:
1515
description: 'The action to run (create*, delete, skip-testing).'
@@ -26,6 +26,10 @@ inputs:
2626
description: 'The resulting connection string format (easy-connect*, tns).'
2727
default: 'easy-connect'
2828
required: false
29+
surround-connection-string-with-double-quotes:
30+
description: 'If the connection string must be surrounded by double quotes (false*, true).'
31+
default: 'false'
32+
required: false
2933
prefix_list:
3034
description: 'A comma separated list of file(s) or folder(s) that if changed should not trigger any test (example: folder containing documentation).'
3135
required: false
@@ -79,5 +83,7 @@ runs:
7983
JOBID: ${{ job.check_run_id }}
8084
run: |
8185
${GITHUB_ACTION_PATH}/setup-testpilot --${{ inputs.action }} \
82-
--user "${{ inputs.user }}" --oci-service "${{ inputs.oci-service }}" --connection-string-format "${{ inputs.connection-string-format }}"
86+
--user "${{ inputs.user }}" --oci-service "${{ inputs.oci-service }}" \
87+
--connection-string-format "${{ inputs.connection-string-format }}" \
88+
--surround-connection-string-with-double-quotes "${{ inputs.surround-connection-string-with-double-quotes }}"
8389

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.oracle.testpilot</groupId>
88
<artifactId>testpilot-services</artifactId>
9-
<version>1.0.26</version>
9+
<version>1.0.27</version>
1010
<name>Oracle Test Pilot actions</name>
1111
<description>Actions provided by Oracle Test Pilot.</description>
1212

src/main/java/com/oracle/testpilot/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class Main {
2323
System.setProperty("java.net.useSystemProxies", "false");
2424
}
2525

26-
public static final String VERSION="1.0.26";
26+
public static final String VERSION="1.0.27";
2727

2828
public static void main(final String[] args) {
2929
int exitStatus = 0;

src/main/java/com/oracle/testpilot/Session.java

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public class Session {
5858

5959
private ConnectionStringFormat connectionStringFormat;
6060

61+
private boolean useDoubleQuotesForConnectionStringSuffix;
62+
6163
private String prefixList;
6264
private String owner;
6365
private String repository;
@@ -133,11 +135,13 @@ private void analyzeCommandLineParameters(final String[] args) {
133135
users = args[++i];
134136

135137
if(users.length() > MAX_USERS_LENGTH) {
136-
throw new TestPilotException(USER_PARAMETER_TOO_LONG, new IllegalArgumentException("Value for --user parameter is too long, maximum length: "+MAX_USERS_LENGTH));
138+
throw new TestPilotException(USER_PARAMETER_TOO_LONG,
139+
new IllegalArgumentException("Value for --user parameter is too long, maximum length: "+MAX_USERS_LENGTH));
137140
}
138141
}
139142
else {
140-
throw new TestPilotException(USER_MISSING_PARAMETER, new IllegalArgumentException("Missing value for --user parameter"));
143+
throw new TestPilotException(USER_MISSING_PARAMETER,
144+
new IllegalArgumentException("Missing value for --user parameter"));
141145
}
142146
break;
143147

@@ -181,7 +185,20 @@ private void analyzeCommandLineParameters(final String[] args) {
181185
}
182186
}
183187
else {
184-
throw new TestPilotException(CONNECTION_STRING_FORMAT_MISSING_PARAMETER, new IllegalArgumentException("Missing value for --connection-string-format parameter"));
188+
throw new TestPilotException(CONNECTION_STRING_FORMAT_MISSING_PARAMETER,
189+
new IllegalArgumentException("Missing value for --connection-string-format parameter"));
190+
}
191+
break;
192+
193+
case "--surround-connection-string-with-double-quotes":
194+
if (i + 1 < args.length) {
195+
final String temp = args[++i];
196+
197+
useDoubleQuotesForConnectionStringSuffix = "true".equalsIgnoreCase(temp);
198+
}
199+
else {
200+
throw new TestPilotException(SURROUND_CONNECTION_STRING_WITH_DOUBLE_QUOTES_MISSING_PARAMETER,
201+
new IllegalArgumentException("Missing value for --surround-connection-string-with-double-quotes parameter"));
185202
}
186203
break;
187204

@@ -194,7 +211,8 @@ private void analyzeCommandLineParameters(final String[] args) {
194211
prefixList = args[++i];
195212
}
196213
else {
197-
throw new TestPilotException(PREFIX_LIST_MISSING_PARAMETER, new IllegalArgumentException("Missing value for --prefix-list parameter"));
214+
throw new TestPilotException(PREFIX_LIST_MISSING_PARAMETER,
215+
new IllegalArgumentException("Missing value for --prefix-list parameter"));
198216
}
199217
break;
200218

@@ -203,7 +221,8 @@ private void analyzeCommandLineParameters(final String[] args) {
203221
owner = args[++i];
204222
}
205223
else {
206-
throw new TestPilotException(OWNER_MISSING_PARAMETER, new IllegalArgumentException("Missing value for --owner parameter"));
224+
throw new TestPilotException(OWNER_MISSING_PARAMETER,
225+
new IllegalArgumentException("Missing value for --owner parameter"));
207226
}
208227
break;
209228

@@ -240,12 +259,13 @@ private void displayUsage() {
240259
Action:
241260
--create: to provision the requested Oracle Cloud Infrastructure service to test
242261
Options:
243-
--oci-service <value> OCI service type (autonomous-transaction-processing-serverless, base-database-service-19c, base-database-service-21c, base-database-service-26ai, base-database-service-26airac)
262+
--oci-service <value> OCI service type (autonomous-transaction-processing-serverless-26ai, autonomous-transaction-processing-serverless-19c, base-database-service-26ai, base-database-service-26ai-rac, base-database-service-19c, base-database-service-21c)
244263
--user <user> user name to be used (if several, then comma separated list without any space)
245264
--connection-string-format requested connection string format (easy-connect*, or tns)
265+
--surround-connection-string-with-double-quotes tells if the connection string must be surrounded with double quotes (false*, or true)
246266
--delete: to de-provision the Oracle Cloud Infrastructure service
247267
Options:
248-
--oci-service <value> OCI service type (autonomous-transaction-processing-serverless, base-database-service-19c, base-database-service-21c, base-database-service-26ai, base-database-service-26airac)
268+
--oci-service <value> OCI service type (autonomous-transaction-processing-serverless-26ai, autonomous-transaction-processing-serverless-19c, base-database-service-26ai, base-database-service-26ai-rac, base-database-service-19c, base-database-service-21c)
249269
--user <user> user name to be used (if several, then comma separated list without any space)
250270
--skip-testing
251271
Options:
@@ -438,14 +458,25 @@ private void writeDatabaseInformationToGitHubOutput(Database database, String co
438458
if (githubOutput != null) {
439459
try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(githubOutput, true)))) {
440460
System.out.printf("::add-mask::%s%n", database.getPassword());
441-
out.printf("""
461+
if(useDoubleQuotesForConnectionStringSuffix){
462+
out.printf("""
442463
database_host=%s
443464
database_service=%s
444465
database_password=%s
445466
database_version=%s
446467
connection_string_suffix="%s"%n""",
447-
database.getHost(), database.getService(), database.getPassword(), database.getVersion(),
448-
connectionString);
468+
database.getHost(), database.getService(), database.getPassword(), database.getVersion(),
469+
connectionString);
470+
} else {
471+
out.printf("""
472+
database_host=%s
473+
database_service=%s
474+
database_password=%s
475+
database_version=%s
476+
connection_string_suffix=%s%n""",
477+
database.getHost(), database.getService(), database.getPassword(), database.getVersion(),
478+
connectionString);
479+
}
449480
}
450481
}
451482
}

src/main/java/com/oracle/testpilot/exception/TestPilotException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class TestPilotException extends RuntimeException {
2525
public static final int CREATE_DATABASE_MISSING_DB_TYPE = 12;
2626
public static final int SKIP_TESTING_MISSING_OWNER = 13;
2727
public static final int SKIP_TESTING_MISSING_REPOSITORY = 14;
28+
public static final int SURROUND_CONNECTION_STRING_WITH_DOUBLE_QUOTES_MISSING_PARAMETER = 15;
2829
public static final int SKIP_TESTING_MISSING_PREFIX_LIST = 16;
2930
public static final int SKIP_TESTING_WRONG_URI = 17;
3031
public static final int SKIP_TESTING_WRONG_REST_CALL = 18;

0 commit comments

Comments
 (0)