From 7c1702f0ea9632329b2e89abf606141d5cfff286 Mon Sep 17 00:00:00 2001 From: loiclefevre Date: Thu, 9 Jul 2026 12:26:59 +0200 Subject: [PATCH] 12 - Add cli argument to control the double quotes for connection string suffix --- README.adoc | 3 +- action.yml | 10 +++- pom.xml | 2 +- src/main/java/com/oracle/testpilot/Main.java | 2 +- .../java/com/oracle/testpilot/Session.java | 51 +++++++++++++++---- .../exception/TestPilotException.java | 1 + 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/README.adoc b/README.adoc index 867ef6d..1e7d82d 100644 --- a/README.adoc +++ b/README.adoc @@ -2,7 +2,7 @@ :linkattrs: :project-owner: oracle-actions :project-name: setup-testpilot -:project-tag: v1.0.26 +:project-tag: v1.0.27 ifdef::env-github[] :tip-caption: :bulb: @@ -38,6 +38,7 @@ Following inputs may be used as `step.with` keys: 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`. | 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. | connection-string-format | | easy-connect | The resulting connection string format: `easy-connect` or `tns`. +| surround-connection-string-with-double-quotes | | false | If the connection string must be surrounded by double quotes: `true` or `false`. | prefix_list | | | A comma separated list of file(s) or folder(s) that if changed should not trigger any test (example: folder containing documentation). |=== diff --git a/action.yml b/action.yml index 831c1d8..02d7288 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,7 @@ branding: inputs: version: description: 'The version to use.' - default: 'v1.0.26' + default: 'v1.0.27' required: true action: description: 'The action to run (create*, delete, skip-testing).' @@ -26,6 +26,10 @@ inputs: description: 'The resulting connection string format (easy-connect*, tns).' default: 'easy-connect' required: false + surround-connection-string-with-double-quotes: + description: 'If the connection string must be surrounded by double quotes (false*, true).' + default: 'false' + required: false prefix_list: description: 'A comma separated list of file(s) or folder(s) that if changed should not trigger any test (example: folder containing documentation).' required: false @@ -79,5 +83,7 @@ runs: JOBID: ${{ job.check_run_id }} run: | ${GITHUB_ACTION_PATH}/setup-testpilot --${{ inputs.action }} \ - --user "${{ inputs.user }}" --oci-service "${{ inputs.oci-service }}" --connection-string-format "${{ inputs.connection-string-format }}" + --user "${{ inputs.user }}" --oci-service "${{ inputs.oci-service }}" \ + --connection-string-format "${{ inputs.connection-string-format }}" \ + --surround-connection-string-with-double-quotes "${{ inputs.surround-connection-string-with-double-quotes }}" diff --git a/pom.xml b/pom.xml index 6713dbc..21d24f6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.oracle.testpilot testpilot-services - 1.0.26 + 1.0.27 Oracle Test Pilot actions Actions provided by Oracle Test Pilot. diff --git a/src/main/java/com/oracle/testpilot/Main.java b/src/main/java/com/oracle/testpilot/Main.java index de84a16..f4a1115 100644 --- a/src/main/java/com/oracle/testpilot/Main.java +++ b/src/main/java/com/oracle/testpilot/Main.java @@ -23,7 +23,7 @@ public class Main { System.setProperty("java.net.useSystemProxies", "false"); } - public static final String VERSION="1.0.26"; + public static final String VERSION="1.0.27"; public static void main(final String[] args) { int exitStatus = 0; diff --git a/src/main/java/com/oracle/testpilot/Session.java b/src/main/java/com/oracle/testpilot/Session.java index 49b0281..576f7e0 100644 --- a/src/main/java/com/oracle/testpilot/Session.java +++ b/src/main/java/com/oracle/testpilot/Session.java @@ -58,6 +58,8 @@ public class Session { private ConnectionStringFormat connectionStringFormat; + private boolean useDoubleQuotesForConnectionStringSuffix; + private String prefixList; private String owner; private String repository; @@ -133,11 +135,13 @@ private void analyzeCommandLineParameters(final String[] args) { users = args[++i]; if(users.length() > MAX_USERS_LENGTH) { - throw new TestPilotException(USER_PARAMETER_TOO_LONG, new IllegalArgumentException("Value for --user parameter is too long, maximum length: "+MAX_USERS_LENGTH)); + throw new TestPilotException(USER_PARAMETER_TOO_LONG, + new IllegalArgumentException("Value for --user parameter is too long, maximum length: "+MAX_USERS_LENGTH)); } } else { - throw new TestPilotException(USER_MISSING_PARAMETER, new IllegalArgumentException("Missing value for --user parameter")); + throw new TestPilotException(USER_MISSING_PARAMETER, + new IllegalArgumentException("Missing value for --user parameter")); } break; @@ -181,7 +185,20 @@ private void analyzeCommandLineParameters(final String[] args) { } } else { - throw new TestPilotException(CONNECTION_STRING_FORMAT_MISSING_PARAMETER, new IllegalArgumentException("Missing value for --connection-string-format parameter")); + throw new TestPilotException(CONNECTION_STRING_FORMAT_MISSING_PARAMETER, + new IllegalArgumentException("Missing value for --connection-string-format parameter")); + } + break; + + case "--surround-connection-string-with-double-quotes": + if (i + 1 < args.length) { + final String temp = args[++i]; + + useDoubleQuotesForConnectionStringSuffix = "true".equalsIgnoreCase(temp); + } + else { + throw new TestPilotException(SURROUND_CONNECTION_STRING_WITH_DOUBLE_QUOTES_MISSING_PARAMETER, + new IllegalArgumentException("Missing value for --surround-connection-string-with-double-quotes parameter")); } break; @@ -194,7 +211,8 @@ private void analyzeCommandLineParameters(final String[] args) { prefixList = args[++i]; } else { - throw new TestPilotException(PREFIX_LIST_MISSING_PARAMETER, new IllegalArgumentException("Missing value for --prefix-list parameter")); + throw new TestPilotException(PREFIX_LIST_MISSING_PARAMETER, + new IllegalArgumentException("Missing value for --prefix-list parameter")); } break; @@ -203,7 +221,8 @@ private void analyzeCommandLineParameters(final String[] args) { owner = args[++i]; } else { - throw new TestPilotException(OWNER_MISSING_PARAMETER, new IllegalArgumentException("Missing value for --owner parameter")); + throw new TestPilotException(OWNER_MISSING_PARAMETER, + new IllegalArgumentException("Missing value for --owner parameter")); } break; @@ -240,12 +259,13 @@ private void displayUsage() { Action: --create: to provision the requested Oracle Cloud Infrastructure service to test Options: - --oci-service OCI service type (autonomous-transaction-processing-serverless, base-database-service-19c, base-database-service-21c, base-database-service-26ai, base-database-service-26airac) + --oci-service 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) --user user name to be used (if several, then comma separated list without any space) --connection-string-format requested connection string format (easy-connect*, or tns) + --surround-connection-string-with-double-quotes tells if the connection string must be surrounded with double quotes (false*, or true) --delete: to de-provision the Oracle Cloud Infrastructure service Options: - --oci-service OCI service type (autonomous-transaction-processing-serverless, base-database-service-19c, base-database-service-21c, base-database-service-26ai, base-database-service-26airac) + --oci-service 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) --user user name to be used (if several, then comma separated list without any space) --skip-testing Options: @@ -438,14 +458,25 @@ private void writeDatabaseInformationToGitHubOutput(Database database, String co if (githubOutput != null) { try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(githubOutput, true)))) { System.out.printf("::add-mask::%s%n", database.getPassword()); - out.printf(""" + if(useDoubleQuotesForConnectionStringSuffix){ + out.printf(""" database_host=%s database_service=%s database_password=%s database_version=%s connection_string_suffix="%s"%n""", - database.getHost(), database.getService(), database.getPassword(), database.getVersion(), - connectionString); + database.getHost(), database.getService(), database.getPassword(), database.getVersion(), + connectionString); + } else { + out.printf(""" + database_host=%s + database_service=%s + database_password=%s + database_version=%s + connection_string_suffix=%s%n""", + database.getHost(), database.getService(), database.getPassword(), database.getVersion(), + connectionString); + } } } } diff --git a/src/main/java/com/oracle/testpilot/exception/TestPilotException.java b/src/main/java/com/oracle/testpilot/exception/TestPilotException.java index 96e158d..2c02458 100644 --- a/src/main/java/com/oracle/testpilot/exception/TestPilotException.java +++ b/src/main/java/com/oracle/testpilot/exception/TestPilotException.java @@ -25,6 +25,7 @@ public class TestPilotException extends RuntimeException { public static final int CREATE_DATABASE_MISSING_DB_TYPE = 12; public static final int SKIP_TESTING_MISSING_OWNER = 13; public static final int SKIP_TESTING_MISSING_REPOSITORY = 14; + public static final int SURROUND_CONNECTION_STRING_WITH_DOUBLE_QUOTES_MISSING_PARAMETER = 15; public static final int SKIP_TESTING_MISSING_PREFIX_LIST = 16; public static final int SKIP_TESTING_WRONG_URI = 17; public static final int SKIP_TESTING_WRONG_REST_CALL = 18;