Skip to content

Commit

Permalink
Add validation for container host app cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
Flanker32 committed Jun 24, 2024
1 parent b51a611 commit 4777e67
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 274,13 @@ private void validateContainerHostFunctionConfiguration() {
if (StringUtils.isBlank(this.cpu) && StringUtils.isNoneBlank(this.memory)) {
throw new AzureToolkitRuntimeException("The <cpu> argument is required with <memory>. Please provide both or none.");
}
if (StringUtils.isNoneBlank(this.cpu)) {
try {
Double.valueOf(this.cpu);
} catch (final NumberFormatException nfe) {
throw new AzureToolkitRuntimeException("The value of <cpu> is not valid. Please provide a correct value. e.g. 2.0.");
}
}
if (StringUtils.isNotBlank(this.memory)) {
if (!StringUtils.endsWithIgnoreCase(this.memory, "gi")) {
throw new AzureToolkitRuntimeException("The value of <memory> should end with Gi. Please provide a correct value. e.g. 4.0Gi.");
Expand Down

0 comments on commit 4777e67

Please sign in to comment.