Skip to content

Commit

Permalink
Check that a label is valid before waiting on it
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Sep 13, 2019
1 parent 5b2fb16 commit a95727d
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ public void validate() throws Exception {

/**
* Label and resource are mutual exclusive.
* The label, if provided, must be configured (at least one resource must have this label).
*/
public static void validate(String resource, String label, int quantity) throws Exception {
if (label != null && !label.isEmpty() && resource != null && !resource.isEmpty()) {
throw new IllegalArgumentException("Label and resource name cannot be specified simultaneously.");
}
if (label != null && !LockableResourcesManager.get().isValidLabel( label ) ) {
throw new IllegalArgumentException("The label does not exist: " + label);
}
}

private static final long serialVersionUID = 1L;
Expand All @@ -108,6 +112,9 @@ public static FormValidation doCheckLabel(@QueryParameter String value, @QueryPa
if ((resourceLabel == null) && (resourceName == null)) {
return FormValidation.error("Either label or resource name must be specified.");
}
if (resourceLabel != null && !LockableResourcesManager.get().isValidLabel(resourceLabel)) {
return FormValidation.error("The label does not exist: " + resourceLabel);
}
return FormValidation.ok();
}

Expand Down

0 comments on commit a95727d

Please sign in to comment.