in src/main/java/com/google/cloud/dfmetrics/utils/ConfigValidator.java [57:90]
public static void validateTemplateLauncherConfig(TemplateLauncherConfig templateLauncherConfig)
throws IllegalArgumentException, IllegalAccessException {
String missingFields = validateForNulls(templateLauncherConfig);
if (!missingFields.isEmpty()) {
throw new IllegalArgumentException(
"Config fields:" + missingFields + " are mandatory and cannot have null values.");
}
// Check fields like pipeline options, environment options are empty or not
if (templateLauncherConfig.getPipelineOptions() == null
|| templateLauncherConfig.getPipelineOptions().size() == 0) {
throw new RuntimeException("Pipeline options cannot be empty.");
}
if (templateLauncherConfig.getEnvironmentOptions() == null
|| templateLauncherConfig.getEnvironmentOptions().size() == 0) {
LOG.warn(
"Environment options is empty. Various options such as subnetwork, service account, user"
+ " labels etcare provided through the environment options");
}
// Validate for specific values
String templateType = templateLauncherConfig.getTemplateType().toLowerCase();
if (!(templateType.equals("flex") || templateType.equals("classic"))) {
throw new RuntimeException(
"Invalid template type. Supported template types are flex,classic.");
}
// Set default values
if (templateLauncherConfig.getTimeoutInMinutes() == null) {
templateLauncherConfig.setTimeoutInMinutes(
(int) DataflowJobManager.getDefaultTimeOut().toMinutes());
}
}