You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by bh...@apache.org on 2022/07/25 23:46:54 UTC

[beam] branch master updated: LoadTestsBuilder: Disallow whitespace in option values (#22437)

This is an automated email from the ASF dual-hosted git repository.

bhulette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 01fa485b31b LoadTestsBuilder: Disallow whitespace in option values (#22437)
01fa485b31b is described below

commit 01fa485b31bbaf649873eb27623539e2e2b27cf2
Author: Brian Hulette <bh...@google.com>
AuthorDate: Mon Jul 25 16:46:47 2022 -0700

    LoadTestsBuilder: Disallow whitespace in option values (#22437)
    
    * LoadTestsBuilder: Disallow whitespace in option values
    
    * Allow wrapping in single quotes, also check key for whitespace
    
    * Check that we catch whitespace issues
    
    * Revert "Check that we catch whitespace issues"
    
    This reverts commit 714225825b52f9bf9ba07b1d273780512ef762d0.
    
    * Update message
---
 .test-infra/jenkins/LoadTestsBuilder.groovy | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/.test-infra/jenkins/LoadTestsBuilder.groovy b/.test-infra/jenkins/LoadTestsBuilder.groovy
index 7c5b7390a9c..894b7aecf81 100644
--- a/.test-infra/jenkins/LoadTestsBuilder.groovy
+++ b/.test-infra/jenkins/LoadTestsBuilder.groovy
@@ -60,9 +60,23 @@ class LoadTestsBuilder {
 
   static String parseOptions(Map<String, ?> options) {
     options.collect { entry ->
+
+      if (entry.key.matches(".*\\s.*")) {
+        throw new IllegalArgumentException("""
+          Encountered invalid option name '${entry.key}'. Names must not
+          contain whitespace.
+          """)
+      }
+
       // Flags are indicated by null values
       if (entry.value == null) {
         "--${entry.key}"
+      } else if (entry.value.toString().matches(".*\\s.*") &&
+      !entry.value.toString().matches("'[^']*'")) {
+        throw new IllegalArgumentException("""
+          Option '${entry.key}' has an invalid value, '${entry.value}'. Values
+          must not contain whitespace, or they must be wrapped in singe quotes.
+          """)
       } else {
         "--${entry.key}=$entry.value".replace('\"', '\\\"').replace('\'', '\\\'')
       }