@Test public void testGoodEnvironmentVariableNames() { Map<String, String> violations = jobAssertions.validateEnvironmentVariableNames(ImmutableMap.of( "THIS_IS_GOOD_123", "good name", "_THIS_IS_2_GOOD", "good name", "_AND_THIS", "good name" )); assertThat(violations).isEmpty(); }
public Map<String, String> validateEnvironmentVariableNames(Map<String, String> environment) { if (CollectionsExt.isNullOrEmpty(environment)) { return Collections.emptyMap(); } Map<String, String> violations = new HashMap<>(); environment.forEach((key, value) -> { if (key.isEmpty()) { violations.put("empty", "the environment name cannot be an empty string"); return; } char first = key.charAt(0); if (!isAsciiUpperCase(first) && first != '_') { violations.put("invalidFirstCharacter", "the environment name must start with an upper case ASCII letter or '_'"); } if (key.length() == 1) { return; } for (int i = 1; i < key.length(); i++) { char c = key.charAt(i); if (!isAsciiUpperCase(c) && !isAsciiDigit(c) && c != '_') { violations.put("invalidCharacter", "the environment name characters may be an upper case ASCII letter, a digit or '_'"); break; } } }); return violations; }
JobAssertions { public Map<String, String> validateEnvironmentVariableNames(Map<String, String> environment) { if (CollectionsExt.isNullOrEmpty(environment)) { return Collections.emptyMap(); } Map<String, String> violations = new HashMap<>(); environment.forEach((key, value) -> { if (key.isEmpty()) { violations.put("empty", "the environment name cannot be an empty string"); return; } char first = key.charAt(0); if (!isAsciiUpperCase(first) && first != '_') { violations.put("invalidFirstCharacter", "the environment name must start with an upper case ASCII letter or '_'"); } if (key.length() == 1) { return; } for (int i = 1; i < key.length(); i++) { char c = key.charAt(i); if (!isAsciiUpperCase(c) && !isAsciiDigit(c) && c != '_') { violations.put("invalidCharacter", "the environment name characters may be an upper case ASCII letter, a digit or '_'"); break; } } }); return violations; } }
JobAssertions { public Map<String, String> validateEnvironmentVariableNames(Map<String, String> environment) { if (CollectionsExt.isNullOrEmpty(environment)) { return Collections.emptyMap(); } Map<String, String> violations = new HashMap<>(); environment.forEach((key, value) -> { if (key.isEmpty()) { violations.put("empty", "the environment name cannot be an empty string"); return; } char first = key.charAt(0); if (!isAsciiUpperCase(first) && first != '_') { violations.put("invalidFirstCharacter", "the environment name must start with an upper case ASCII letter or '_'"); } if (key.length() == 1) { return; } for (int i = 1; i < key.length(); i++) { char c = key.charAt(i); if (!isAsciiUpperCase(c) && !isAsciiDigit(c) && c != '_') { violations.put("invalidCharacter", "the environment name characters may be an upper case ASCII letter, a digit or '_'"); break; } } }); return violations; } JobAssertions(JobConfiguration configuration,
                         Function<String, ResourceDimension> maxContainerSizeResolver); }
JobAssertions { public Map<String, String> validateEnvironmentVariableNames(Map<String, String> environment) { if (CollectionsExt.isNullOrEmpty(environment)) { return Collections.emptyMap(); } Map<String, String> violations = new HashMap<>(); environment.forEach((key, value) -> { if (key.isEmpty()) { violations.put("empty", "the environment name cannot be an empty string"); return; } char first = key.charAt(0); if (!isAsciiUpperCase(first) && first != '_') { violations.put("invalidFirstCharacter", "the environment name must start with an upper case ASCII letter or '_'"); } if (key.length() == 1) { return; } for (int i = 1; i < key.length(); i++) { char c = key.charAt(i); if (!isAsciiUpperCase(c) && !isAsciiDigit(c) && c != '_') { violations.put("invalidCharacter", "the environment name characters may be an upper case ASCII letter, a digit or '_'"); break; } } }); return violations; } JobAssertions(JobConfiguration configuration,
                         Function<String, ResourceDimension> maxContainerSizeResolver); boolean isValidSyntax(List<String> securityGroups); boolean isValidIamRole(String iamRole); boolean isEntryPointNotTooLarge(List<String> entryPoint); Map<String, String> validateEnvironmentVariableNames(Map<String, String> environment); boolean areEnvironmentVariablesNotTooLarge(Map<String, String> environment); boolean isValidContainerHealthServiceName(String name); Map<String, String> validateImage(Image image); Map<String, String> notExceedsComputeResources(String capacityGroup, Container container); Map<String, String> notExceedsIpAllocations(Container container, JobDescriptor.JobDescriptorExt extension); }
JobAssertions { public Map<String, String> validateEnvironmentVariableNames(Map<String, String> environment) { if (CollectionsExt.isNullOrEmpty(environment)) { return Collections.emptyMap(); } Map<String, String> violations = new HashMap<>(); environment.forEach((key, value) -> { if (key.isEmpty()) { violations.put("empty", "the environment name cannot be an empty string"); return; } char first = key.charAt(0); if (!isAsciiUpperCase(first) && first != '_') { violations.put("invalidFirstCharacter", "the environment name must start with an upper case ASCII letter or '_'"); } if (key.length() == 1) { return; } for (int i = 1; i < key.length(); i++) { char c = key.charAt(i); if (!isAsciiUpperCase(c) && !isAsciiDigit(c) && c != '_') { violations.put("invalidCharacter", "the environment name characters may be an upper case ASCII letter, a digit or '_'"); break; } } }); return violations; } JobAssertions(JobConfiguration configuration,
                         Function<String, ResourceDimension> maxContainerSizeResolver); boolean isValidSyntax(List<String> securityGroups); boolean isValidIamRole(String iamRole); boolean isEntryPointNotTooLarge(List<String> entryPoint); Map<String, String> validateEnvironmentVariableNames(Map<String, String> environment); boolean areEnvironmentVariablesNotTooLarge(Map<String, String> environment); boolean isValidContainerHealthServiceName(String name); Map<String, String> validateImage(Image image); Map<String, String> notExceedsComputeResources(String capacityGroup, Container container); Map<String, String> notExceedsIpAllocations(Container container, JobDescriptor.JobDescriptorExt extension); static final int MAX_ENTRY_POINT_SIZE_SIZE_KB; static final int MAX_ENTRY_POINT_SIZE_SIZE_BYTES; }