Allow 0 instances in cf manifest
This commit is contained in:
@@ -34,7 +34,6 @@ import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YTypedPro
|
|||||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeUtil;
|
import org.springframework.ide.vscode.commons.yaml.schema.YTypeUtil;
|
||||||
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
|
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
|
||||||
import org.springframework.ide.vscode.commons.yaml.schema.YamlSchema;
|
import org.springframework.ide.vscode.commons.yaml.schema.YamlSchema;
|
||||||
import org.springframework.ide.vscode.commons.yaml.schema.constraints.Constraints;
|
|
||||||
import org.yaml.snakeyaml.nodes.Node;
|
import org.yaml.snakeyaml.nodes.Node;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@@ -202,7 +201,7 @@ public final class ManifestYmlSchema implements YamlSchema {
|
|||||||
f.yprop("env", t_env),
|
f.yprop("env", t_env),
|
||||||
f.yprop("host", t_ne_string),
|
f.yprop("host", t_ne_string),
|
||||||
f.yprop("hosts", f.yseq(t_host)),
|
f.yprop("hosts", f.yseq(t_host)),
|
||||||
f.yprop("instances", t_strictly_pos_integer),
|
f.yprop("instances", t_pos_integer),
|
||||||
f.yprop("memory", t_memory),
|
f.yprop("memory", t_memory),
|
||||||
f.yprop("name", t_application_name).isRequired(true),
|
f.yprop("name", t_application_name).isRequired(true),
|
||||||
f.yprop("no-hostname", t_boolean),
|
f.yprop("no-hostname", t_boolean),
|
||||||
|
|||||||
@@ -134,6 +134,18 @@ public class ManifestYamlEditorTest {
|
|||||||
"applications|Unknown property"
|
"applications|Unknown property"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test public void zeroInstancesIsFine() throws Exception {
|
||||||
|
//See: https://www.pivotaltracker.com/story/show/165839251
|
||||||
|
Editor editor = harness.newEditor(
|
||||||
|
"applications:\n" +
|
||||||
|
"- name: some-name\n" +
|
||||||
|
" instances: -1\n" +
|
||||||
|
"- name: some-other-name\n" +
|
||||||
|
" instances: 0"
|
||||||
|
);
|
||||||
|
editor.assertProblems("-1|Value must be positive");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void reconcileStructuralProblems() throws Exception {
|
public void reconcileStructuralProblems() throws Exception {
|
||||||
@@ -167,7 +179,7 @@ public class ManifestYamlEditorTest {
|
|||||||
);
|
);
|
||||||
editor.assertProblems(
|
editor.assertProblems(
|
||||||
"- bad sequence|Expecting a 'Memory' but found a 'Sequence'",
|
"- bad sequence|Expecting a 'Memory' but found a 'Sequence'",
|
||||||
"bad: map|Expecting a 'Strictly Positive Integer' but found a 'Map'"
|
"bad: map|Expecting a 'Positive Integer' but found a 'Map'"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add a structural case for `buildpacks` (old `buildpack` was scalar, but `buildpacks` is sequence)
|
// Add a structural case for `buildpacks` (old `buildpack` was scalar, but `buildpacks` is sequence)
|
||||||
@@ -212,7 +224,7 @@ public class ManifestYamlEditorTest {
|
|||||||
" disk_quota: -2048M\n"
|
" disk_quota: -2048M\n"
|
||||||
);
|
);
|
||||||
editor.assertProblems(
|
editor.assertProblems(
|
||||||
"-3|Value must be at least 1",
|
"-3|Value must be positive",
|
||||||
"-1024M|Negative value is not allowed",
|
"-1024M|Negative value is not allowed",
|
||||||
"-2048M|Negative value is not allowed"
|
"-2048M|Negative value is not allowed"
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user