From fece70fa8db6c540b90e03aa0fcd40a53de8a503 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Tue, 13 Dec 2016 14:14:59 -0800 Subject: [PATCH] Basic concourse pipeline editor working --- .../util/SimpleTextDocumentService.java | 5 +- .../ide/vscode/commons/util/Renderables.java | 76 +++--- .../completion/AbstractYamlAssistContext.java | 9 +- .../SchemaBasedYamlAssistContextProvider.java | 5 + .../yaml/completion/YTypeAssistContext.java | 54 ++-- .../yaml/completion/YamlAssistContext.java | 2 + .../SchemaBasedYamlASTReconciler.java | 5 +- .../yaml/schema/ASTDynamicSchemaContext.java | 50 ++++ .../yaml/schema/CachingSchemaContext.java | 18 ++ .../yaml/schema/DynamicSchemaContext.java | 50 ++++ .../schema/SNodeDynamicSchemaContext.java | 59 ++++ .../commons/yaml/schema/YTypeFactory.java | 196 +++++++++++++- .../vscode/commons/yaml/schema/YTypeUtil.java | 4 +- .../boot/BootPropertiesLanguageServer.java | 2 +- .../ApplicationYamlAssistContext.java | 33 ++- vscode-extensions/vscode-concourse/.classpath | 36 +++ vscode-extensions/vscode-concourse/.project | 23 ++ .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.eclipse.m2e.core.prefs | 4 + .../vscode-concourse/lib/Main.ts | 2 +- .../vscode-concourse/scripts/preinstall.sh | 2 +- .../ConcourseLanguageServer.java} | 8 +- .../{manifest/yaml => concourse}/Main.java | 6 +- .../vscode/concourse/PipelineYmlSchema.java | 149 +++++++++++ .../ValueParsers.java} | 50 +--- .../manifest/yaml/ManifestYmlSchema.java | 129 --------- .../src/main/resources/desc/GetStep/get.html | 11 + .../main/resources/desc/GetStep/params.html | 3 + .../main/resources/desc/GetStep/passed.html | 15 ++ .../main/resources/desc/GetStep/resource.html | 2 + .../main/resources/desc/GetStep/trigger.html | 4 + .../main/resources/desc/GetStep/version.html | 11 + .../desc/Job/build_logs_to_retain.html | 10 + .../desc/Job/disable_manual_trigger.html | 3 + .../resources/desc/Job/max_in_flight.html | 3 + .../src/main/resources/desc/Job/name.html | 2 + .../src/main/resources/desc/Job/plan.html | 60 +++++ .../src/main/resources/desc/Job/public.html | 5 + .../src/main/resources/desc/Job/serial.html | 2 + .../resources/desc/Job/serial_groups.html | 12 + .../main/resources/desc/Pipeline/jobs.html | 16 ++ .../resources/desc/Pipeline/resources.html | 14 + .../main/resources/desc/PutStep/params.html | 3 + .../src/main/resources/desc/PutStep/put.html | 20 ++ .../main/resources/desc/PutStep/resource.html | 2 + .../main/resources/desc/TaskStep/config.html | 6 + .../resources/desc/TaskStep/privileged.html | 8 + .../main/resources/desc/TaskStep/task.html | 23 ++ .../description-by-prop-name/buildpack.html | 11 - .../description-by-prop-name/buildpack.md | 11 - .../description-by-prop-name/command.html | 34 --- .../description-by-prop-name/command.md | 30 --- .../description-by-prop-name/disk_quota.html | 9 - .../description-by-prop-name/disk_quota.md | 9 - .../description-by-prop-name/domain.html | 27 -- .../description-by-prop-name/domain.md | 25 -- .../description-by-prop-name/domains.html | 10 - .../description-by-prop-name/domains.md | 11 - .../description-by-prop-name/env.html | 28 -- .../resources/description-by-prop-name/env.md | 24 -- .../health-check-type.html | 9 - .../health-check-type.md | 9 - .../description-by-prop-name/host.html | 9 - .../description-by-prop-name/host.md | 9 - .../description-by-prop-name/hosts.html | 11 - .../description-by-prop-name/hosts.md | 11 - .../description-by-prop-name/inherit.html | 62 ----- .../description-by-prop-name/inherit.md | 63 ----- .../description-by-prop-name/instances.html | 11 - .../description-by-prop-name/instances.md | 11 - .../description-by-prop-name/memory.html | 11 - .../description-by-prop-name/memory.md | 11 - .../description-by-prop-name/name.html | 10 - .../description-by-prop-name/name.md | 9 - .../description-by-prop-name/no-hostname.html | 9 - .../description-by-prop-name/no-hostname.md | 9 - .../description-by-prop-name/no-route.html | 18 -- .../description-by-prop-name/no-route.md | 16 -- .../description-by-prop-name/path.html | 9 - .../description-by-prop-name/path.md | 9 - .../random-route.html | 11 - .../description-by-prop-name/random-route.md | 9 - .../description-by-prop-name/services.html | 18 -- .../description-by-prop-name/services.md | 17 -- .../description-by-prop-name/stack.html | 11 - .../description-by-prop-name/stack.md | 11 - .../description-by-prop-name/timeout.html | 14 - .../description-by-prop-name/timeout.md | 15 -- .../manifest/yaml/ManifestYamlEditorTest.java | 5 +- .../yaml/ManifestYamlLanguageServerTest.java | 5 +- .../manifest/yaml/ManifestYmlSchemaTest.java | 252 +++++++++--------- .../test/examples/another-pipeline.yml | 0 92 files changed, 1076 insertions(+), 1054 deletions(-) create mode 100644 vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/ASTDynamicSchemaContext.java create mode 100644 vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/CachingSchemaContext.java create mode 100644 vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/DynamicSchemaContext.java create mode 100644 vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/SNodeDynamicSchemaContext.java create mode 100644 vscode-extensions/vscode-concourse/.classpath create mode 100644 vscode-extensions/vscode-concourse/.project create mode 100644 vscode-extensions/vscode-concourse/.settings/org.eclipse.jdt.core.prefs create mode 100644 vscode-extensions/vscode-concourse/.settings/org.eclipse.m2e.core.prefs rename vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/{manifest/yaml/ManifestYamlLanguageServer.java => concourse/ConcourseLanguageServer.java} (94%) rename vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/{manifest/yaml => concourse}/Main.java (61%) create mode 100644 vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java rename vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/{manifest/yaml/ManifestYmlValueParsers.java => concourse/ValueParsers.java} (59%) delete mode 100644 vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/get.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/params.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/passed.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/resource.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/trigger.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/version.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Job/build_logs_to_retain.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Job/disable_manual_trigger.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Job/max_in_flight.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Job/name.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Job/plan.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Job/public.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Job/serial.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Job/serial_groups.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/jobs.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/resources.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/params.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/put.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/resource.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/config.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/privileged.html create mode 100644 vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/task.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/buildpack.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/buildpack.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/command.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/command.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/disk_quota.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/disk_quota.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domain.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domain.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domains.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domains.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/env.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/env.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/health-check-type.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/health-check-type.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/host.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/host.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/hosts.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/hosts.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/inherit.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/inherit.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/instances.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/instances.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/memory.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/memory.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/name.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/name.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-hostname.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-hostname.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-route.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-route.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/path.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/path.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/random-route.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/random-route.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/services.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/services.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/stack.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/stack.md delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/timeout.html delete mode 100644 vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/timeout.md create mode 100644 vscode-extensions/vscode-concourse/test/examples/another-pipeline.yml diff --git a/vscode-extensions/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java b/vscode-extensions/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java index 64234f694..b5daadcaf 100644 --- a/vscode-extensions/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java +++ b/vscode-extensions/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java @@ -94,6 +94,7 @@ public class SimpleTextDocumentService implements TextDocumentService { try { VersionedTextDocumentIdentifier docId = params.getTextDocument(); String url = docId.getUri(); + LOG.info("didChange: "+url); if (url!=null) { TextDocument doc = getOrCreateDocument(url); for (TextDocumentContentChangeEvent change : params.getContentChanges()) { @@ -108,7 +109,7 @@ public class SimpleTextDocumentService implements TextDocumentService { @Override public void didOpen(DidOpenTextDocumentParams params) { - //LOG.info("didOpen: "+params); + LOG.info("didOpen: "+params.getUri()); //Example message: //{ // "jsonrpc":"2.0", @@ -150,7 +151,7 @@ public class SimpleTextDocumentService implements TextDocumentService { @Override public void didClose(DidCloseTextDocumentParams params) { - System.out.println("closing: "+params.getTextDocument().getUri()); + LOG.info("didClose: "+params.getTextDocument().getUri()); String url = params.getTextDocument().getUri(); if (url!=null) { documents.remove(url); diff --git a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java index 32daec5a2..9c28813de 100644 --- a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java +++ b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java @@ -241,42 +241,52 @@ public class Renderables { } public static Renderable fromClasspath(final Class klass, final String resourcePath) { - return new Renderable() { - - @Override - public void renderAsMarkdown(StringBuilder buffer) { - String extension = ".md"; - String value = getText(klass, resourcePath, extension); - if (value != null) { - buffer.append(value); - } else { - NO_DESCRIPTION.renderAsMarkdown(buffer); - } - } - - @Override - public void renderAsHtml(HtmlBuffer buffer) { - String extension = ".html"; - String value = getText(klass, resourcePath, extension); - if (value != null) { - buffer.raw(value); - } else { - NO_DESCRIPTION.renderAsHtml(buffer); - } - } - - private String getText(final Class klass, final String resourcePath, String extension) { - try { - InputStream stream = klass.getResourceAsStream(resourcePath + extension); - if (stream != null) { - return IOUtil.toString(stream); + if (resourcePath.endsWith(".html")) { + return htmlBlob((HtmlBuffer html) -> { + html.raw(getText(klass, resourcePath, null)); + }); + } else { + return new Renderable() { + + @Override + public void renderAsMarkdown(StringBuilder buffer) { + String extension = ".md"; + String value = getText(klass, resourcePath, extension); + if (value != null) { + buffer.append(value); + } else { + NO_DESCRIPTION.renderAsMarkdown(buffer); } - } catch (Exception e) { - logger.error("Error", e); } - return null; + + @Override + public void renderAsHtml(HtmlBuffer buffer) { + String extension = ".html"; + String value = getText(klass, resourcePath, extension); + if (value != null) { + buffer.raw(value); + } else { + NO_DESCRIPTION.renderAsHtml(buffer); + } + } + + }; + } + } + + private static String getText(final Class klass, String resourcePath, String extension) { + if (extension!=null) { + resourcePath = resourcePath + extension; + } + try { + InputStream stream = klass.getResourceAsStream(resourcePath); + if (stream != null) { + return IOUtil.toString(stream); } - }; + } catch (Exception e) { + logger.error("Error", e); + } + return null; } private static class ConcatRenderables implements Renderable { diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/AbstractYamlAssistContext.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/AbstractYamlAssistContext.java index 269494ddc..84ab265b9 100644 --- a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/AbstractYamlAssistContext.java +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/AbstractYamlAssistContext.java @@ -41,6 +41,8 @@ public abstract class AbstractYamlAssistContext implements YamlAssistContext { public final int documentSelector; public final YamlPath contextPath; + private final YamlDocument doc; + private static PrefixFinder prefixfinder = new PrefixFinder() { protected boolean isPrefixChar(char c) { @@ -48,6 +50,10 @@ public abstract class AbstractYamlAssistContext implements YamlAssistContext { } }; + @Override + public YamlDocument getDocument() { + return doc; + } protected final String getPrefix(YamlDocument doc, SNode node, int offset) { //For value completions... in general we would like to determine the whole text @@ -78,7 +84,8 @@ public abstract class AbstractYamlAssistContext implements YamlAssistContext { } - public AbstractYamlAssistContext(int documentSelector, YamlPath contextPath) { + public AbstractYamlAssistContext(YamlDocument doc, int documentSelector, YamlPath contextPath) { + this.doc = doc; this.documentSelector = documentSelector; this.contextPath = contextPath; } diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/SchemaBasedYamlAssistContextProvider.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/SchemaBasedYamlAssistContextProvider.java index 1b732b474..3c453e5b3 100644 --- a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/SchemaBasedYamlAssistContextProvider.java +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/SchemaBasedYamlAssistContextProvider.java @@ -33,6 +33,11 @@ public class SchemaBasedYamlAssistContextProvider implements YamlAssistContextPr protected YamlAssistContext getDocumentContext(int documentSelector) { return new YTypeAssistContext(this, documentSelector, schema.getTopLevelType(), schema.getTypeUtil()); } + + @Override + public YamlDocument getDocument() { + return doc; + } }; } } diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/YTypeAssistContext.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/YTypeAssistContext.java index 8a2ad6e7b..83352780d 100644 --- a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/YTypeAssistContext.java +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/YTypeAssistContext.java @@ -13,7 +13,6 @@ package org.springframework.ide.vscode.commons.yaml.completion; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -25,18 +24,20 @@ import org.springframework.ide.vscode.commons.languageserver.completion.IComplet import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion; import org.springframework.ide.vscode.commons.util.CollectionUtil; import org.springframework.ide.vscode.commons.util.FuzzyMatcher; +import org.springframework.ide.vscode.commons.util.Log; import org.springframework.ide.vscode.commons.util.Renderable; import org.springframework.ide.vscode.commons.yaml.hover.YPropertyInfoTemplates; import org.springframework.ide.vscode.commons.yaml.path.YamlPath; import org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment; import org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment.YamlPathSegmentType; +import org.springframework.ide.vscode.commons.yaml.schema.DynamicSchemaContext; +import org.springframework.ide.vscode.commons.yaml.schema.SNodeDynamicSchemaContext; import org.springframework.ide.vscode.commons.yaml.schema.YType; import org.springframework.ide.vscode.commons.yaml.schema.YTypeUtil; import org.springframework.ide.vscode.commons.yaml.schema.YTypedProperty; import org.springframework.ide.vscode.commons.yaml.schema.YValueHint; import org.springframework.ide.vscode.commons.yaml.structure.YamlDocument; import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SChildBearingNode; -import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SKeyNode; import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SNode; import org.springframework.ide.vscode.commons.yaml.util.YamlIndentUtil; @@ -49,14 +50,14 @@ public class YTypeAssistContext extends AbstractYamlAssistContext { final private YamlAssistContext parent; public YTypeAssistContext(YTypeAssistContext parent, YamlPath contextPath, YType YType, YTypeUtil typeUtil) { - super(parent.documentSelector, contextPath); + super(parent.getDocument(), parent.documentSelector, contextPath); this.parent = parent; this.type = YType; this.typeUtil = typeUtil; } public YTypeAssistContext(TopLevelAssistContext parent, int documentSelector, YType type, YTypeUtil typeUtil) { - super(documentSelector, YamlPath.EMPTY); + super(parent.getDocument(), documentSelector, YamlPath.EMPTY); this.type = type; this.typeUtil = typeUtil; this.parent = parent; @@ -74,11 +75,12 @@ public class YTypeAssistContext extends AbstractYamlAssistContext { public List getKeyCompletions(YamlDocument doc, int offset, String query) throws Exception { int queryOffset = offset - query.length(); - List properties = typeUtil.getProperties(type); + SNode contextNode = getContextNode(doc); + DynamicSchemaContext dynamicCtxt = new SNodeDynamicSchemaContext(contextNode); + List properties = typeUtil.getProperties(type, dynamicCtxt); if (CollectionUtil.hasElements(properties)) { ArrayList proposals = new ArrayList<>(properties.size()); - SNode contextNode = getContextNode(doc); - Set definedProps = getDefinedProperties(contextNode); + Set definedProps = dynamicCtxt.getDefinedProperties(); for (YTypedProperty p : properties) { String name = p.getName(); double score = FuzzyMatcher.matchScore(query, name); @@ -140,26 +142,6 @@ public class YTypeAssistContext extends AbstractYamlAssistContext { } } - private Set getDefinedProperties(SNode contextNode) { - try { - if (contextNode instanceof SChildBearingNode) { - List children = ((SChildBearingNode)contextNode).getChildren(); - if (CollectionUtil.hasElements(children)) { - Set keys = new HashSet<>(children.size()); - for (SNode c : children) { - if (c instanceof SKeyNode) { - keys.add(((SKeyNode) c).getKey()); - } - } - return keys; - } - } - } catch (Exception e) { - logger.error("Error getting defined props", e); - } - return Collections.emptySet(); - } - private List getValueCompletions(YamlDocument doc, int offset, String query) { YValueHint[] values = typeUtil.getHintValues(type); if (values!=null) { @@ -179,13 +161,15 @@ public class YTypeAssistContext extends AbstractYamlAssistContext { } @Override - public YamlAssistContext traverse(YamlPathSegment s) { + public YamlAssistContext traverse(YamlPathSegment s) throws Exception { if (s.getType()==YamlPathSegmentType.VAL_AT_KEY) { if (typeUtil.isSequencable(type) || typeUtil.isMap(type)) { return contextWith(s, typeUtil.getDomainType(type)); } String key = s.toPropString(); - Map subproperties = typeUtil.getPropertiesMap(type); + SNode contextNode = getContextNode(getDocument()); + DynamicSchemaContext dynamicCtxt = new SNodeDynamicSchemaContext(contextNode); + Map subproperties = typeUtil.getPropertiesMap(type, dynamicCtxt); if (subproperties!=null) { return contextWith(s, getType(subproperties.get(key))); } @@ -246,6 +230,16 @@ public class YTypeAssistContext extends AbstractYamlAssistContext { return null; } + private DynamicSchemaContext getSchemaContext() { + try { + SNode contextNode = getContextNode(getDocument()); + return new SNodeDynamicSchemaContext(contextNode); + } catch (Exception e) { + Log.log(e); + return DynamicSchemaContext.NULL; + } + } + @Override public Renderable getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion) { //By default we don't provide value-specific hover, so just show the same hover @@ -254,6 +248,6 @@ public class YTypeAssistContext extends AbstractYamlAssistContext { } private YTypedProperty getProperty(String name) { - return typeUtil.getPropertiesMap(getType()).get(name); + return typeUtil.getPropertiesMap(getType(), getSchemaContext()).get(name); } } diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/YamlAssistContext.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/YamlAssistContext.java index 549684387..9a4360c84 100644 --- a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/YamlAssistContext.java +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/completion/YamlAssistContext.java @@ -32,4 +32,6 @@ public interface YamlAssistContext extends YamlNavigable { Renderable getHoverInfo(YamlPathSegment lastSegment); Renderable getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion); + + YamlDocument getDocument(); } diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java index ecd3e0121..631287120 100644 --- a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java @@ -10,6 +10,8 @@ import org.springframework.ide.vscode.commons.util.StringUtil; import org.springframework.ide.vscode.commons.util.ValueParser; import org.springframework.ide.vscode.commons.yaml.ast.NodeUtil; import org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST; +import org.springframework.ide.vscode.commons.yaml.schema.ASTDynamicSchemaContext; +import org.springframework.ide.vscode.commons.yaml.schema.DynamicSchemaContext; import org.springframework.ide.vscode.commons.yaml.schema.YType; import org.springframework.ide.vscode.commons.yaml.schema.YTypeUtil; import org.springframework.ide.vscode.commons.yaml.schema.YTypedProperty; @@ -53,7 +55,8 @@ public class SchemaBasedYamlASTReconciler implements YamlASTReconciler { reconcile(entry.getValueNode(), typeUtil.getDomainType(type)); } } else if (typeUtil.isBean(type)) { - Map beanProperties = typeUtil.getPropertiesMap(type); + DynamicSchemaContext schemaContext = new ASTDynamicSchemaContext(map); + Map beanProperties = typeUtil.getPropertiesMap(type, schemaContext); for (NodeTuple entry : map.getValue()) { Node keyNode = entry.getKeyNode(); String key = NodeUtil.asScalar(keyNode); diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/ASTDynamicSchemaContext.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/ASTDynamicSchemaContext.java new file mode 100644 index 000000000..1fb50c7d6 --- /dev/null +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/ASTDynamicSchemaContext.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Pivotal, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.vscode.commons.yaml.schema; + +import java.util.Collections; +import java.util.Set; + +import org.springframework.ide.vscode.commons.yaml.ast.NodeUtil; +import org.yaml.snakeyaml.nodes.MappingNode; +import org.yaml.snakeyaml.nodes.NodeTuple; + +import com.google.common.collect.ImmutableSet; + +/** + * Adapts a SnakeYaml ast node as a {@link DynamicSchemaContext} (so it + * can be used in YamlSchema based reconciler. + * + * @author Kris De Volder + */ +public class ASTDynamicSchemaContext extends CachingSchemaContext { + + private MappingNode mapNode; + + public ASTDynamicSchemaContext(MappingNode map) { + this.mapNode = map; + } + + @Override + protected Set computeDefinedProperties() { + if (mapNode!=null) { + ImmutableSet.Builder builder = ImmutableSet.builder(); + for (NodeTuple entry : mapNode.getValue()) { + String key = NodeUtil.asScalar(entry.getKeyNode()); + if (key!=null) { //key not a scalar? => something funky so skip it + builder.add(key); + } + } + return builder.build(); + } + return Collections.emptySet(); + } +} diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/CachingSchemaContext.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/CachingSchemaContext.java new file mode 100644 index 000000000..bb1dc4b27 --- /dev/null +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/CachingSchemaContext.java @@ -0,0 +1,18 @@ +package org.springframework.ide.vscode.commons.yaml.schema; + +import java.util.Set; + +public abstract class CachingSchemaContext implements DynamicSchemaContext { + + private Set definedProps; + + protected abstract Set computeDefinedProperties(); + + @Override + final public Set getDefinedProperties() { + if (definedProps==null) { + definedProps = computeDefinedProperties(); + } + return definedProps; + } +} diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/DynamicSchemaContext.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/DynamicSchemaContext.java new file mode 100644 index 000000000..d84a97094 --- /dev/null +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/DynamicSchemaContext.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Pivotal, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.vscode.commons.yaml.schema; + +import java.util.Set; + +import com.google.common.collect.ImmutableSet; + +/** + * Exposes some 'dynamic' contextual information to schema implementations. + *

+ * This is necessary to enable the impementation of schema features where one + * part of a yaml structure depends details of another part. A typical example + * could be 'type' property, so that different values assigned to that property + * change the structure that is expected for the rest of the node. + * + * @author Kris De Volder + */ +public interface DynamicSchemaContext { + + DynamicSchemaContext NULL = new DynamicSchemaContext() { + @Override + public Set getDefinedProperties() { + return ImmutableSet.of(); + } + }; + + /** + * Returns the set of property names that are already defined in the current context. + *

+ * In Content assist scenarios this is only a 'best effort' result. An empty set may + * be returned because either no properties are yet defined, or because the sloppy parser + * can not quite make out the yaml structure because yaml text is incomplete or too complex + * for its analysis. + *

+ * In a validation scenario however, the returned information should precisely reflect what + * properties are defined in the surrounding object. + */ + Set getDefinedProperties(); + + +} diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/SNodeDynamicSchemaContext.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/SNodeDynamicSchemaContext.java new file mode 100644 index 000000000..299dcb045 --- /dev/null +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/SNodeDynamicSchemaContext.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2015, 2016 Pivotal, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.vscode.commons.yaml.schema; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.springframework.ide.vscode.commons.util.CollectionUtil; +import org.springframework.ide.vscode.commons.util.Log; +import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SChildBearingNode; +import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SKeyNode; +import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SNode; + +/** + * Adapts an SNode so it can be used by a YamlSchema as a {@link DynamicSchemaContext} + * + * @author Kris De Volder + */ +public class SNodeDynamicSchemaContext extends CachingSchemaContext { + + private SNode contextNode; + + public SNodeDynamicSchemaContext(SNode contextNode) { + this.contextNode = contextNode; + } + + @Override + protected Set computeDefinedProperties() { + try { + if (contextNode instanceof SChildBearingNode) { + List children = ((SChildBearingNode)contextNode).getChildren(); + if (CollectionUtil.hasElements(children)) { + Set keys = new HashSet<>(children.size()); + for (SNode c : children) { + if (c instanceof SKeyNode) { + keys.add(((SKeyNode) c).getKey()); + } + } + return keys; + } + } + } catch (Exception e) { + Log.log(e); + } + return Collections.emptySet(); + } + + +} diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/YTypeFactory.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/YTypeFactory.java index ff74604d0..d6110a774 100644 --- a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/YTypeFactory.java +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/YTypeFactory.java @@ -13,19 +13,26 @@ package org.springframework.ide.vscode.commons.yaml.schema; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import javax.inject.Provider; +import org.springframework.ide.vscode.commons.util.Assert; import org.springframework.ide.vscode.commons.util.EnumValueParser; import org.springframework.ide.vscode.commons.util.Renderable; import org.springframework.ide.vscode.commons.util.Renderables; import org.springframework.ide.vscode.commons.util.ValueParser; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import com.google.common.collect.ImmutableMap; + /** * Static utility method for creating YType objects representing either * 'array-like', 'map-like' or 'object-like' types which can be used @@ -35,6 +42,10 @@ import org.springframework.ide.vscode.commons.util.ValueParser; */ public class YTypeFactory { + public YType yany(String name) { + return new YAny(name); + } + public YType yseq(YType el) { return new YSeqType(el); } @@ -47,6 +58,14 @@ public class YTypeFactory { return new YBeanType(name, properties); } + public YType yunion(String name, YBeanType... types) { + Assert.isLegal(types.length>0); + if (types.length==1) { + return types[0]; + } + return new YBeanUnionType(name, types); + } + /** * YTypeUtil instances capable of 'interpreting' the YType objects created by this * YTypeFactory @@ -69,13 +88,13 @@ public class YTypeFactory { } @Override - public Map getPropertiesMap(YType type) { - return ((AbstractType)type).getPropertiesMap(); + public Map getPropertiesMap(YType type, DynamicSchemaContext dc) { + return ((AbstractType)type).getPropertiesMap(dc); } @Override - public List getProperties(YType type) { - return ((AbstractType)type).getProperties(); + public List getProperties(YType type, DynamicSchemaContext dc) { + return ((AbstractType)type).getProperties(dc); } @Override @@ -164,11 +183,11 @@ public class YTypeFactory { } } - public final List getProperties() { + public List getProperties(DynamicSchemaContext dc) { return Collections.unmodifiableList(propertyList); } - public final Map getPropertiesMap() { + public Map getPropertiesMap(DynamicSchemaContext dc) { if (cachedPropertyMap==null) { cachedPropertyMap = new LinkedHashMap<>(); for (YTypedProperty p : propertyList) { @@ -212,12 +231,55 @@ public class YTypeFactory { } } } + + public void addHints(YValueHint... extraHints) { + for (YValueHint h : extraHints) { + if (!hints.contains(h)) { + hints.add(h); + } + } + } + public void parseWith(ValueParser parser) { this.parser = parser; } public ValueParser getParser() { return parser; } + + } + + /** + * Represents a type that is completely unconstrained. Anything goes: A map, a sequence or some + * atomic value. + */ + public static class YAny extends AbstractType { + private final String name; + + public YAny(String name) { + this.name = name; + } + + @Override + public boolean isAtomic() { + return true; + } + + @Override + public boolean isSequenceable() { + return true; + } + + @Override + public boolean isMap() { + return true; + } + + @Override + public String toString() { + return name; + } + } public static class YMapType extends AbstractType { @@ -293,6 +355,26 @@ public class YTypeFactory { public boolean isBean() { return true; } + + /** + * Deprecated. This method disregards {@link DynamicSchemaContext}. This may be + * alright for Schemas which don't rely on it but it will result in incorrect/inaccurate + * behavior for Schemas that do. + */ + @Deprecated + public List getProperties() { + return getProperties(DynamicSchemaContext.NULL); + } + + /** + * Deprecated. This method disregards {@link DynamicSchemaContext}. This may be + * alright for Schemas which don't rely on it but it will result in incorrect/inaccurate + * behavior for Schemas that do. + */ + @Deprecated + public Map getPropertiesMap() { + return getPropertiesMap(DynamicSchemaContext.NULL); + } } public static class YAtomicType extends AbstractType { @@ -309,6 +391,103 @@ public class YTypeFactory { return true; } } + + /** + * Represents a union of several bean types. It is assumed one primary property + * exists in each of the the sub-bean types that can be used to identify the + * type. In other words the primary property has a unique name so that when + * this property is being assigned a value we can infer from that which + * specific bean-type we are dealing with. + */ + public class YBeanUnionType extends AbstractType { + private final String name; + + private Map typesByPrimary = new HashMap<>(); + + private ImmutableList primaryProps; + + public YBeanUnionType(String name, YBeanType... types) { + this.name = name; + for (YType _t : types) { + AbstractType t = (AbstractType)_t; + typesByPrimary.put(findPrimary(t, types), t); + } + } + private String findPrimary(AbstractType t, YBeanType[] types) { + //Note: passing null dynamic context below is okay, assuming the properties in YBeanType + // do not care about dynamic context. + for (YTypedProperty p : t.getProperties(DynamicSchemaContext.NULL)) { + String name = p.getName(); + if (isUniqueFor(name, t, types)) { + return name; + } + } + Assert.isLegal(false, "Couldn't find a unique property key for "+t); + return null; //unreachable, but compiler doesn't know. + } + private boolean isUniqueFor(String name, AbstractType t, YBeanType[] types) { + for (YBeanType other : types) { + if (other!=t) { + //Note: passing null dynamic context below is okay, assuming the properties in YBeanType + // do not care about dynamic context. + if (other.getPropertiesMap(DynamicSchemaContext.NULL).containsKey(name)) { + return false; + } + } + } + return true; + } + @Override + public String toString() { + return name; + } + @Override + public boolean isBean() { + return true; + } + + @Override + public Map getPropertiesMap(DynamicSchemaContext dc) { + return asMap(getProperties(dc)); + } + + private Map asMap(List properties) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + for (YTypedProperty p : properties) { + builder.put(p.getName(), p); + } + return builder.build(); + } + + @Override + public List getProperties(DynamicSchemaContext dc) { + Set existingProps = dc.getDefinedProperties(); + if (!existingProps.isEmpty()) { + for (Entry entry : typesByPrimary.entrySet()) { + String primaryName = entry.getKey(); + if (existingProps.contains(primaryName)) { + return entry.getValue().getProperties(dc); + } + } + } + //Reaching here means we couldn't guess the type from existing props. + //We'll just return the primary properties, these are good to give as hints + //then, since at least one of them should typically be added. + return getPrimaryProps(dc); + } + + private List getPrimaryProps(DynamicSchemaContext dc) { + if (primaryProps==null) { + Builder builder = ImmutableList.builder(); + for (Entry entry : typesByPrimary.entrySet()) { + builder.add(entry.getValue().getPropertiesMap(dc).get(entry.getKey())); + } + primaryProps = builder.build(); + } + return primaryProps; + } + } + public static class YTypedPropertyImpl implements YTypedProperty { @@ -360,4 +539,9 @@ public class YTypeFactory { t.parseWith(new EnumValueParser(name, values)); return t; } + + public YValueHint hint(String value, String label) { + return new BasicYValueHint(value, label); + } + } diff --git a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/YTypeUtil.java b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/YTypeUtil.java index cb200b437..623605379 100644 --- a/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/YTypeUtil.java +++ b/vscode-extensions/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/schema/YTypeUtil.java @@ -35,6 +35,6 @@ public interface YTypeUtil { ValueParser getValueParser(YType type); //TODO: only one of these two should be enough? - List getProperties(YType type); - Map getPropertiesMap(YType yType); + List getProperties(YType type, DynamicSchemaContext dc); + Map getPropertiesMap(YType yType, DynamicSchemaContext dc); } diff --git a/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/BootPropertiesLanguageServer.java b/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/BootPropertiesLanguageServer.java index 326d0c80d..e0693e887 100644 --- a/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/BootPropertiesLanguageServer.java +++ b/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/BootPropertiesLanguageServer.java @@ -92,7 +92,7 @@ public class BootPropertiesLanguageServer extends SimpleLanguageServer { public YamlAssistContext getGlobalAssistContext(YamlDocument ydoc) { IDocument doc = ydoc.getDocument(); FuzzyMap index = indexProvider.getIndex(doc); - return ApplicationYamlAssistContext.global(index, completionFactory, typeUtilProvider.getTypeUtil(doc), relaxedNameConfig); + return ApplicationYamlAssistContext.global(ydoc, index, completionFactory, typeUtilProvider.getTypeUtil(doc), relaxedNameConfig); } }; diff --git a/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java b/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java index a172f5934..ece6f3619 100644 --- a/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java +++ b/vscode-extensions/vscode-boot-properties/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java @@ -30,9 +30,9 @@ import org.springframework.ide.vscode.boot.metadata.hints.ValueHintHoverInfo; import org.springframework.ide.vscode.boot.metadata.types.Type; import org.springframework.ide.vscode.boot.metadata.types.TypeParser; import org.springframework.ide.vscode.boot.metadata.types.TypeUtil; -import org.springframework.ide.vscode.boot.metadata.types.TypedProperty; import org.springframework.ide.vscode.boot.metadata.types.TypeUtil.BeanPropertyNameMode; import org.springframework.ide.vscode.boot.metadata.types.TypeUtil.EnumCaseMode; +import org.springframework.ide.vscode.boot.metadata.types.TypedProperty; import org.springframework.ide.vscode.boot.metadata.util.FuzzyMap; import org.springframework.ide.vscode.boot.metadata.util.FuzzyMap.Match; import org.springframework.ide.vscode.commons.java.IField; @@ -88,8 +88,8 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon public final TypeUtil typeUtil; - public ApplicationYamlAssistContext(int documentSelector, YamlPath contextPath, TypeUtil typeUtil, RelaxedNameConfig conf) { - super(documentSelector, contextPath); + public ApplicationYamlAssistContext(YamlDocument doc, int documentSelector, YamlPath contextPath, TypeUtil typeUtil, RelaxedNameConfig conf) { + super(doc, documentSelector, contextPath); this.typeUtil = typeUtil; this.conf = conf; } @@ -121,16 +121,16 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon */ protected abstract Type getType(); - public static ApplicationYamlAssistContext subdocument(int documentSelector, FuzzyMap index, PropertyCompletionFactory completionFactory, TypeUtil typeUtil, RelaxedNameConfig conf) { - return new IndexContext(documentSelector, YamlPath.EMPTY, IndexNavigator.with(index), completionFactory, typeUtil, conf); + public static ApplicationYamlAssistContext subdocument(YamlDocument doc, int documentSelector, FuzzyMap index, PropertyCompletionFactory completionFactory, TypeUtil typeUtil, RelaxedNameConfig conf) { + return new IndexContext(doc, documentSelector, YamlPath.EMPTY, IndexNavigator.with(index), completionFactory, typeUtil, conf); } - public static YamlAssistContext forPath(YamlPath contextPath, FuzzyMap index, PropertyCompletionFactory completionFactory, TypeUtil typeUtil, RelaxedNameConfig conf) { + public static YamlAssistContext forPath(YamlDocument doc, YamlPath contextPath, FuzzyMap index, PropertyCompletionFactory completionFactory, TypeUtil typeUtil, RelaxedNameConfig conf) { try { YamlPathSegment documentSelector = contextPath.getSegment(0); if (documentSelector!=null) { contextPath = contextPath.dropFirst(1); - YamlAssistContext context = ApplicationYamlAssistContext.subdocument(documentSelector.toIndex(), index, completionFactory, typeUtil, conf); + YamlAssistContext context = ApplicationYamlAssistContext.subdocument(doc, documentSelector.toIndex(), index, completionFactory, typeUtil, conf); for (YamlPathSegment s : contextPath.getSegments()) { if (context==null) return null; context = context.traverse(s); @@ -155,7 +155,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon public TypeContext(ApplicationYamlAssistContext parent, YamlPath contextPath, Type type, PropertyCompletionFactory completionFactory, TypeUtil typeUtil, RelaxedNameConfig conf, HintProvider hints) { - super(parent.documentSelector, contextPath, typeUtil, conf); + super(parent.getDocument(), parent.documentSelector, contextPath, typeUtil, conf); this.parent = parent; this.completionFactory = completionFactory; this.type = type; @@ -401,9 +401,9 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon private IndexNavigator indexNav; PropertyCompletionFactory completionFactory; - public IndexContext(int documentSelector, YamlPath contextPath, IndexNavigator indexNav, + public IndexContext(YamlDocument doc, int documentSelector, YamlPath contextPath, IndexNavigator indexNav, PropertyCompletionFactory completionFactory, TypeUtil typeUtil, RelaxedNameConfig conf) { - super(documentSelector, contextPath, typeUtil, conf); + super(doc, documentSelector, contextPath, typeUtil, conf); this.indexNav = indexNav; this.completionFactory = completionFactory; } @@ -479,9 +479,9 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon } } if (subIndex.getExtensionCandidate()!=null) { - return new IndexContext(documentSelector, contextPath.append(s), subIndex, completionFactory, typeUtil, conf); + return new IndexContext(getDocument(), documentSelector, contextPath.append(s), subIndex, completionFactory, typeUtil, conf); } else if (subIndex.getExactMatch()!=null) { - IndexContext asIndexContext = new IndexContext(documentSelector, contextPath.append(s), subIndex, completionFactory, typeUtil, conf); + IndexContext asIndexContext = new IndexContext(getDocument(), documentSelector, contextPath.append(s), subIndex, completionFactory, typeUtil, conf); PropertyInfo prop = subIndex.getExactMatch(); return new TypeContext(asIndexContext, contextPath.append(s), TypeParser.parse(prop.getType()), completionFactory, typeUtil, conf, prop.getHints(typeUtil, true)); } @@ -532,11 +532,16 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon return null; } - public static YamlAssistContext global(final FuzzyMap index, final PropertyCompletionFactory completionFactory, final TypeUtil typeUtil, final RelaxedNameConfig conf) { + public static YamlAssistContext global(YamlDocument doc, final FuzzyMap index, final PropertyCompletionFactory completionFactory, final TypeUtil typeUtil, final RelaxedNameConfig conf) { return new TopLevelAssistContext() { @Override protected YamlAssistContext getDocumentContext(int documentSelector) { - return subdocument(documentSelector, index, completionFactory, typeUtil, conf); + return subdocument(doc, documentSelector, index, completionFactory, typeUtil, conf); + } + + @Override + public YamlDocument getDocument() { + return doc; } }; } diff --git a/vscode-extensions/vscode-concourse/.classpath b/vscode-extensions/vscode-concourse/.classpath new file mode 100644 index 000000000..fae1a2b37 --- /dev/null +++ b/vscode-extensions/vscode-concourse/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vscode-extensions/vscode-concourse/.project b/vscode-extensions/vscode-concourse/.project new file mode 100644 index 000000000..58e18ec26 --- /dev/null +++ b/vscode-extensions/vscode-concourse/.project @@ -0,0 +1,23 @@ + + + vscode-concourse + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/vscode-extensions/vscode-concourse/.settings/org.eclipse.jdt.core.prefs b/vscode-extensions/vscode-concourse/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..714351aec --- /dev/null +++ b/vscode-extensions/vscode-concourse/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/vscode-extensions/vscode-concourse/.settings/org.eclipse.m2e.core.prefs b/vscode-extensions/vscode-concourse/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..f897a7f1c --- /dev/null +++ b/vscode-extensions/vscode-concourse/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/vscode-extensions/vscode-concourse/lib/Main.ts b/vscode-extensions/vscode-concourse/lib/Main.ts index add2093d0..0a83140f7 100644 --- a/vscode-extensions/vscode-concourse/lib/Main.ts +++ b/vscode-extensions/vscode-concourse/lib/Main.ts @@ -47,7 +47,7 @@ export function activate(context: VSCode.ExtensionContext) { synchronize: { // TODO: Remove textDocumentFilter property once https://github.com/Microsoft/vscode-languageserver-node/issues/9 is resolved textDocumentFilter: function(textDocument : TextDocument) : boolean { - let result : boolean = /^(.*\/)?pipeline[^\s\\/]*.yml$/i.test(textDocument.fileName); + let result : boolean = /^(.*)pipeline(.*)\.yml$/i.test(textDocument.fileName); return result; } } diff --git a/vscode-extensions/vscode-concourse/scripts/preinstall.sh b/vscode-extensions/vscode-concourse/scripts/preinstall.sh index ae0cb376f..4a3293a24 100755 --- a/vscode-extensions/vscode-concourse/scripts/preinstall.sh +++ b/vscode-extensions/vscode-concourse/scripts/preinstall.sh @@ -2,4 +2,4 @@ set -e (cd ../commons-vscode ; npm install) npm install ../commons-vscode -../mvnw -U -f ../pom.xml -pl vscode-concourse -am clean install +../mvnw -DskipTests -U -f ../pom.xml -pl vscode-concourse -am clean install diff --git a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServer.java b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/ConcourseLanguageServer.java similarity index 94% rename from vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServer.java rename to vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/ConcourseLanguageServer.java index 6e2ac5259..a4b38904b 100644 --- a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServer.java +++ b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/ConcourseLanguageServer.java @@ -1,4 +1,4 @@ -package org.springframework.ide.vscode.manifest.yaml; +package org.springframework.ide.vscode.concourse; import java.util.Collection; @@ -30,15 +30,15 @@ import org.yaml.snakeyaml.Yaml; import com.google.common.collect.ImmutableList; -public class ManifestYamlLanguageServer extends SimpleLanguageServer { +public class ConcourseLanguageServer extends SimpleLanguageServer { private static final Provider> NO_BUILDPACKS = () -> ImmutableList.of(); private Yaml yaml = new Yaml(); - private YamlSchema schema = new ManifestYmlSchema(NO_BUILDPACKS); + private YamlSchema schema = new PipelineYmlSchema(NO_BUILDPACKS); - public ManifestYamlLanguageServer() { + public ConcourseLanguageServer() { SimpleTextDocumentService documents = getTextDocumentService(); YamlASTProvider parser = new YamlParser(yaml); diff --git a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/Main.java b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/Main.java similarity index 61% rename from vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/Main.java rename to vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/Main.java index 7876bd711..ffd67cfd0 100644 --- a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/Main.java +++ b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/Main.java @@ -1,4 +1,4 @@ -package org.springframework.ide.vscode.manifest.yaml; +package org.springframework.ide.vscode.concourse; import java.io.IOException; @@ -6,9 +6,9 @@ import org.springframework.ide.vscode.commons.languageserver.LaunguageServerApp; import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; public class Main { - SimpleLanguageServer server = new ManifestYamlLanguageServer(); + SimpleLanguageServer server = new ConcourseLanguageServer(); public static void main(String[] args) throws IOException { - LaunguageServerApp.start(ManifestYamlLanguageServer::new); + LaunguageServerApp.start(ConcourseLanguageServer::new); } } diff --git a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java new file mode 100644 index 000000000..a48fa863b --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java @@ -0,0 +1,149 @@ +/******************************************************************************* + * Copyright (c) 2016 Pivotal, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.vscode.concourse; + +import java.util.Collection; + +import javax.inject.Provider; + +import org.springframework.ide.vscode.commons.util.Renderable; +import org.springframework.ide.vscode.commons.util.Renderables; +import org.springframework.ide.vscode.commons.yaml.schema.YType; +import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory; +import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YAtomicType; +import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YBeanType; +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.YamlSchema; + +/** + * @author Kris De Volder + */ +public class PipelineYmlSchema implements YamlSchema { + + private final YBeanType TOPLEVEL_TYPE; + private final YTypeUtil TYPE_UTIL; + + private final YTypeFactory f = new YTypeFactory(); + + public PipelineYmlSchema(Provider> buildpackProvider) { + TYPE_UTIL = f.TYPE_UTIL; + + // define schema types + TOPLEVEL_TYPE = f.ybean("Pipeline"); + + YType t_string = f.yatomic("String"); + YAtomicType t_ne_string = f.yatomic("String"); + t_ne_string.parseWith(ValueParsers.NE_STRING); + YType t_strings = f.yseq(t_string); + YAtomicType t_boolean = f.yenum("boolean", "true", "false"); + YAtomicType t_pos_integer = f.yatomic("Positive Integer"); + t_pos_integer.parseWith(ValueParsers.POS_INTEGER); + YType t_any = f.yany("Object"); + YType t_params = f.ymap(t_string, t_any); + + YAtomicType t_version = f.yatomic("Version"); + t_version.addHints("latest", "every"); + + YAtomicType t_resource_type = f.yatomic("ResourceType"); + t_resource_type.addHints( + f.hint("git", "git - The 'git' resource can pull and push to git repositories"), + f.hint("time", "time - The 'time' resource can start jobs on a schedule or timestamp outputs."), + f.hint("s3", "s3 - The 's3' resource can fetch from and upload to S3 buckets."), + f.hint("archive", "archive - The archive resource can fetch and extract .tar.gz archives.") + //TODO: add more resource types and descriptions. +// +// The semver resource can set or bump version numbers. +// +// The github-release resource can fetch and publish versioned GitHub resources. +// +// The docker-image resource can fetch, build, and push Docker images +// +// The tracker resource can deliver stories and bugs on Pivotal Tracker +// +// The pool resource allows you to configure how to serialize use of an external system. This lets you prevent test interference or overwork on shared systems. +// +// The cf resource can deploy an application to Cloud Foundry. +// +// The bosh-io-release resource can track and fetch new BOSH releases from bosh.io. +// +// The bosh-io-stemcell resource can track and fetch new BOSH stemcells from bosh.io. +// +// The bosh-deployment resource can deploy BOSH stemcells and releases. +// +// The vagrant-cloud r + ); + + YBeanType getStep = f.ybean("GetStep"); + prop(getStep, "get", t_ne_string); + prop(getStep, "resource", t_string); + prop(getStep, "version", t_version); + prop(getStep, "passed", t_strings); + prop(getStep, "params", t_params); + prop(getStep, "trigger", t_boolean); + + YBeanType putStep = f.ybean("PutStep"); + prop(putStep, "put", t_ne_string); + prop(putStep, "resource", t_string); + prop(putStep, "params", t_params); + + YBeanType taskStep = f.ybean("TaskStep"); + prop(taskStep, "task", t_ne_string); + prop(taskStep, "file", t_string); + prop(taskStep, "config", t_any); + prop(taskStep, "privileged", t_boolean); + prop(taskStep, "params", t_params); + + YType step = f.yunion("Step", + getStep, + putStep, + taskStep + ); + + YBeanType resource = f.ybean("Resource"); + prop(resource, "name", t_ne_string); + prop(resource, "type", t_resource_type); + prop(resource, "source", t_any); + + YBeanType job = f.ybean("Job"); + prop(job, "name", t_ne_string); + prop(job, "serial", t_boolean); + prop(job, "build_logs_to_retain", t_pos_integer); + prop(job, "serial_groups", t_strings); + prop(job, "max_in_flight", t_pos_integer); + prop(job, "public", t_boolean); + prop(job, "disable_manual_trigger", t_boolean); + prop(job, "plan", f.yseq(step)); + + prop(TOPLEVEL_TYPE, "resources", f.yseq(resource)); + prop(TOPLEVEL_TYPE, "jobs", f.yseq(job)); + + } + + private void prop(YBeanType bean, String name, YType type) { + bean.addProperty(name, type, descriptionFor(bean, name)); + } + + private Renderable descriptionFor(YType owner, String propName) { + String typeName = owner.toString(); + return Renderables.fromClasspath(this.getClass(), "/desc/"+typeName+"/"+propName+".html"); + } + + @Override + public YBeanType getTopLevelType() { + return TOPLEVEL_TYPE; + } + + @Override + public YTypeUtil getTypeUtil() { + return TYPE_UTIL; + } +} diff --git a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlValueParsers.java b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/ValueParsers.java similarity index 59% rename from vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlValueParsers.java rename to vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/ValueParsers.java index a1dae8b28..5f16013c1 100644 --- a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlValueParsers.java +++ b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/concourse/ValueParsers.java @@ -8,60 +8,30 @@ * Contributors: * Pivotal, Inc. - initial API and implementation *******************************************************************************/ -package org.springframework.ide.vscode.manifest.yaml; - -import java.util.Set; +package org.springframework.ide.vscode.concourse; import org.springframework.ide.vscode.commons.util.Assert; +import org.springframework.ide.vscode.commons.util.StringUtil; import org.springframework.ide.vscode.commons.util.ValueParser; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - /** * Methods and constants to create/get parsers for some atomic types * used in manifest yml schema. * * @author Kris De Volder */ -public class ManifestYmlValueParsers { +public class ValueParsers { - public static final ValueParser POS_INTEGER = integerRange(0, null); - - public static final ValueParser MEMORY = new ValueParser() { - - private final ImmutableSet GIGABYTE = ImmutableSet.of("G", "GB"); - private final ImmutableSet MEGABYTE = ImmutableSet.of("M", "MB"); - private final Set UNITS = Sets.union(GIGABYTE, MEGABYTE); - - @Override - public Object parse(String str) { - str = str.trim(); - String unit = getUnit(str.toUpperCase()); - if (unit==null) { - throw new NumberFormatException( - "'"+str+"' doesn't end with a valid unit of memory ('M', 'MB', 'G' or 'GB')" - ); - } - str = str.substring(0, str.length()-unit.length()); - int unitSize = GIGABYTE.contains(unit)?1024:1; - int value = Integer.parseInt(str); - if (value<0) { - throw new NumberFormatException("Negative value is not allowed"); - } - return value * unitSize; - } - - private String getUnit(String str) { - for (String u : UNITS) { - if (str.endsWith(u)) { - return u; - } - } - return null; + public static final ValueParser NE_STRING = (s) -> { + if (StringUtil.hasText(s)) { + return s; + } else { + throw new IllegalArgumentException("String should not be empty"); } }; + public static final ValueParser POS_INTEGER = integerRange(0, null); + public static ValueParser integerAtLeast(final Integer lowerBound) { return integerRange(lowerBound, null); } diff --git a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java b/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java deleted file mode 100644 index 8840d1873..000000000 --- a/vscode-extensions/vscode-concourse/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.manifest.yaml; - -import java.util.Collection; -import java.util.Set; - -import javax.inject.Provider; - -import org.springframework.ide.vscode.commons.util.Renderable; -import org.springframework.ide.vscode.commons.util.Renderables; -import org.springframework.ide.vscode.commons.yaml.schema.YType; -import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory; -import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YAtomicType; -import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YBeanType; -import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YTypedPropertyImpl; -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.YamlSchema; - -import com.google.common.collect.ImmutableSet; - -/** - * @author Kris De Volder - */ -public class ManifestYmlSchema implements YamlSchema { - - private final YBeanType TOPLEVEL_TYPE; - private final YTypeUtil TYPE_UTIL; - private final Provider> buildpackProvider; - - private static final Set TOPLEVEL_EXCLUDED = ImmutableSet.of( - "name", "host", "hosts" - ); - - public ManifestYmlSchema(Provider> buildpackProvider) { - this.buildpackProvider = buildpackProvider; - YTypeFactory f = new YTypeFactory(); - TYPE_UTIL = f.TYPE_UTIL; - - // define schema types - TOPLEVEL_TYPE = f.ybean("manifest.yml schema"); - - YBeanType application = f.ybean("Application"); - YAtomicType t_path = f.yatomic("Path"); - - YAtomicType t_buildpack = f.yatomic("Buildpack"); - - t_buildpack.addHintProvider(this.buildpackProvider); - - YAtomicType t_boolean = f.yenum("boolean", "true", "false"); - YType t_string = f.yatomic("String"); - YType t_strings = f.yseq(t_string); - - YAtomicType t_memory = f.yatomic("Memory"); - t_memory.addHints("256M", "512M", "1024M"); - t_memory.parseWith(ManifestYmlValueParsers.MEMORY); - - YAtomicType t_health_check_type = f.yenum("Health Check Type", "none", "port"); - - YAtomicType t_strictly_pos_integer = f.yatomic("Strictly Positive Integer"); - t_strictly_pos_integer.parseWith(ManifestYmlValueParsers.integerAtLeast(1)); - - YAtomicType t_pos_integer = f.yatomic("Positive Integer"); - t_pos_integer.parseWith(ManifestYmlValueParsers.POS_INTEGER); - - YType t_env = f.ymap(t_string, t_string); - - // define schema structure... - TOPLEVEL_TYPE.addProperty("applications", f.yseq(application)); - TOPLEVEL_TYPE.addProperty("inherit", t_string, descriptionFor("inherit")); - - YTypedPropertyImpl[] props = { - f.yprop("buildpack", t_buildpack), - f.yprop("command", t_string), - f.yprop("disk_quota", t_memory), - f.yprop("domain", t_string), - f.yprop("domains", t_strings), - f.yprop("env", t_env), - f.yprop("host", t_string), - f.yprop("hosts", t_strings), - f.yprop("instances", t_strictly_pos_integer), - f.yprop("memory", t_memory), - f.yprop("name", t_string), - f.yprop("no-hostname", t_boolean), - f.yprop("no-route", t_boolean), - f.yprop("path", t_path), - f.yprop("random-route", t_boolean), - f.yprop("services", t_strings), - f.yprop("stack", t_string), - f.yprop("timeout", t_pos_integer), - f.yprop("health-check-type", t_health_check_type) - }; - - for (YTypedPropertyImpl prop : props) { - prop.setDescriptionProvider(descriptionFor(prop)); - if (!TOPLEVEL_EXCLUDED.contains(prop.getName())) { - TOPLEVEL_TYPE.addProperty(prop); - } - application.addProperty(prop); - } - } - - private Renderable descriptionFor(String propName) { - return Renderables.fromClasspath(this.getClass(), "/description-by-prop-name/"+propName); - } - - private Renderable descriptionFor(YTypedPropertyImpl prop) { - return descriptionFor(prop.getName()); - } - - @Override - public YBeanType getTopLevelType() { - return TOPLEVEL_TYPE; - } - - @Override - public YTypeUtil getTypeUtil() { - return TYPE_UTIL; - } -} diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/get.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/get.html new file mode 100644 index 000000000..3a6a1cbe5 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/get.html @@ -0,0 +1,11 @@ +

Fetches a resource, making it available to subsequent steps via the given +name.

For example, the following plan fetches a version number via the +semver resource, bumps it to the next release candidate, and +puts it back.

plan:
+- get: version
+  params:
+    bump: minor
+    rc: true
+- put: version
+  params:
+    version: version/number

\ No newline at end of file
diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/params.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/params.html
new file mode 100644
index 000000000..2f1f1c177
--- /dev/null
+++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/params.html
@@ -0,0 +1,3 @@
+

Optional. A map of arbitrary configuration to forward to the +resource. Refer to the resource type's documentation to see what it +supports.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/passed.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/passed.html new file mode 100644 index 000000000..bc8bc8bad --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/passed.html @@ -0,0 +1,15 @@ +

Optional. When specified, only the versions of the resource that +made it through the given list of jobs will be considered when triggering +and fetching.

Note that if multiple gets are configured with passed +constraints, all of the mentioned jobs are correlated. That is, with the +following set of inputs:

plan:
+- get: a
+  passed: [a-unit, integration]
+- get: b
+  passed: [b-unit, integration]
+- get: x
+  passed: [integration]

This means "give me the versions of a, b, and x that +have passed the same build of integration, with the same +version of a passing a-unit and the same version of +b passing b-unit."

This is crucial to being able to implement safe "fan-in" semantics as +things progress through a pipeline.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/resource.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/resource.html new file mode 100644 index 000000000..68d05e7d4 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/resource.html @@ -0,0 +1,2 @@ +

Optional. Defaults to name. The resource to fetch, as +configured in resources.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/trigger.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/trigger.html new file mode 100644 index 000000000..87bc54c0b --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/trigger.html @@ -0,0 +1,4 @@ +

Optional. Default false. Set to true to auto-trigger +new builds of the plan's job whenever this step has new versions available, +as specified by the resource and any passed constraints.

Otherwise, if no get steps set this to true, the job can only +be manually triggered.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/version.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/version.html new file mode 100644 index 000000000..6020386a9 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/GetStep/version.html @@ -0,0 +1,11 @@ +

Optional. Defaults to latest. The version of the resource to +fetch.

If set to latest, scheduling will just find the latest available +version of a resource and use it, allowing versions to be skipped. This is +usually what you want, e.g. if someone pushes 100 git commits.

If set to every, builds will walk through all available versions of +the resource. Note that if passed is also configured, it will only +step through the versions satisfying the constraints.

If set to a specific version (e.g. {ref: abcdef123}), only that +version will be used. Note that the version must be available and detected by +the resource, otherwise the input will never be satisfied. You may want to +use check-resource to force detection of resource versions, +if you need to use an older one that was never detected (as all newly +configured resources start from the latest version).

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/build_logs_to_retain.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/build_logs_to_retain.html new file mode 100644 index 000000000..2f2a2bdfd --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/build_logs_to_retain.html @@ -0,0 +1,10 @@ +

Optional. If configured, only the last specified number of builds +will have their build logs persisted. This is useful if you have a job that +runs periodically but after some amount of time the logs aren't worth keeping +around.

Example:

jobs:
+- name: smoke-tests
+  build_logs_to_retain: 100
+  plan:
+  - get: 10m
+  - task: smoke-tests
+    # ...
\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/disable_manual_trigger.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/disable_manual_trigger.html new file mode 100644 index 000000000..1ff175fc4 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/disable_manual_trigger.html @@ -0,0 +1,3 @@ +

Optional. Default false. If set to true, manual +triggering of the job (via the web UI or trigger-job) will be +disabled.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/max_in_flight.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/max_in_flight.html new file mode 100644 index 000000000..4f3c9b2ff --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/max_in_flight.html @@ -0,0 +1,3 @@ +

Optional. If set, specifies a maximum number of builds to run at a +time. If serial or serial_groups are set, they take precedence +and force this value to be 1.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/name.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/name.html new file mode 100644 index 000000000..d28cecdb4 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/name.html @@ -0,0 +1,2 @@ +

Required. The name of the job. This should be short; it will show up +in URLs.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/plan.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/plan.html new file mode 100644 index 000000000..515d2aee3 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/plan.html @@ -0,0 +1,60 @@ +

Each Job has a single build plan. When a build of a job is +created, the plan determines what happens.

A build plan is a sequence of steps to execute. These steps may fetch +down or update Resources, or execute +Tasks.

A new build of the job is scheduled whenever get steps with +trigger: true have new versions available.

To visualize the job in the pipeline, resources that appear as get +steps are drawn as inputs, and resources that appear in put steps +appear as outputs.

A simple unit test job may look something like:

name: banana-unit
+plan:
+- get: banana
+  trigger: true
+- task: unit
+  file: banana/task.yml

This job says: get the banana resource, +and run a task step called unit, using +the configuration from the task.yml file fetched from the banana +step.

When new versions of banana are detected, a new build of +banana-unit will be scheduled, because we've set trigger: true.

Jobs can depend on resources that are produced by or pass through upstream +jobs, by configuring passed: [job-a, job-b] on the +get step.

Putting these pieces together, if we were to propagate banana from +the above example into an integration suite with another apple +component (pretending we also defined its apple-unit job), the +configuration for the integration job may look something like:

name: fruit-basket-integration
+plan:
+- aggregate:
+  - get: banana
+    trigger: true
+    passed: [banana-unit]
+  - get: apple
+    trigger: true
+    passed: [apple-unit]
+  - get: integration-suite
+    trigger: true
+- task: integration
+  file: integration-suite/task.yml

Note the use of the aggregate step to +collect multiple inputs at once.

With this example we've configured a tiny pipeline that will automatically +run unit tests for two components, and continuously run integration tests +against whichever versions pass both unit tests.

This can be further chained into later "stages" of your pipeline; for +example, you may want to continuously deliver an artifact built from +whichever components pass fruit-basket-integration.

To push artifacts, you would use a put step +that targets the destination resource. For example:

name: deliver-food
+plan:
+- aggregate:
+  - get: banana
+    trigger: true
+    passed: [fruit-basket-integration]
+  - get: apple
+    trigger: true
+    passed: [fruit-basket-integration]
+  - get: baggy
+    trigger: true
+- task: shrink-wrap
+  file: baggy/shrink-wrap.yml
+- put: bagged-food
+  params:
+    bag: shrink-wrap/bagged.tgz

This presumes that there's a bagged-food +resource defined, which understands that the +bag parameter points to a file to ship up to the resource's location.

Note that both banana and apple list the same job as an +upstream dependency. This guarantees that deliver-food will only +trigger when a version of both of these dependencies pass through the same +build of the integration job (and transitively, their individual unit jobs). +This prevents bad apples or bruised bananas from being delivered. (I'm sorry.)

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/public.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/public.html new file mode 100644 index 000000000..6a6efde48 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/public.html @@ -0,0 +1,5 @@ +

Optional. Default false. If set to true, the build log +of this job will be viewable by unauthenticated users. Unauthenticated users +will always be able to see the inputs, outputs, and build status history of a +job. This is useful if you would like to expose your pipeline publicly without +showing sensitive information in the build log.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/serial.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/serial.html new file mode 100644 index 000000000..2f736b864 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/serial.html @@ -0,0 +1,2 @@ +

Optional. Default false. If set to true, builds will +queue up and execute one-by-one, rather than executing in parallel.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/serial_groups.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/serial_groups.html new file mode 100644 index 000000000..9669bd49e --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Job/serial_groups.html @@ -0,0 +1,12 @@ +

Optional. Default []. When set to an array of arbitrary +tag-like strings, builds of this job and other jobs referencing the same +tags will be serialized.

This can be used to ensure that certain jobs do not run at the same time, +like so:

jobs:
+- name: job-a
+  serial_groups: [some-tag]
+- name: job-b
+  serial_groups: [some-tag, some-other-tag]
+- name: job-c
+  serial_groups: [some-other-tag]

In this example, job-a and job-c can run concurrently, but +neither job can run builds at the same time as job-b.

The builds are executed in their order of creation, across all jobs with +common tags.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/jobs.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/jobs.html new file mode 100644 index 000000000..02dcf4194 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/jobs.html @@ -0,0 +1,16 @@ +

At a high level, a job describes some actions to perform when dependent +resources change (or when manually triggered). For example, you may define a +job that runs your unit tests whenever new code is pushed to a repository.

Jobs can be thought of as functions with inputs and outputs, that +automatically run when new inputs are available. A job can depend on the +outputs of upstream jobs, which is the root of pipeline functionality.

The definition of actions to perform is done via a +Build Plan, which is a very powerful +composition-based DSL that can express anything from running simple unit +tests to running a matrix of tasks and aggregating the result.

Builds

An instance of execution of a job's plan is called a build. A build +can either succeed or fail, or error if something unrelated to your code +goes wrong (i.e. if one of your workers falls off the face of the earth).

When a build runs, the job's plan is realized. Each step described by the +job's plan is executed, and so long as all Tasks succeed, the +build succeeds. If a task fails, the build fails, and its resources do not +propagate to the rest of the pipeline.

The containers running in a build can be accessed while they're running +(and also shortly after they finish) via +fly intercept, which can greatly help in +debugging.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/resources.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/resources.html new file mode 100644 index 000000000..33f4a0a51 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/Pipeline/resources.html @@ -0,0 +1,14 @@ +

A resource is any entity that can be checked for new versions, pulled down +at a specific version, and/or pushed up to idempotently create new versions. +A common example would be a git repository, but it can also represent more +abstract things like +time itself.

At its core, Concourse knows nothing about things like git. Instead, +it consumes a generic interface implemented by resource types. This +allows Concourse to be extended by configuring workers with resource type +implementations.

This abstraction is immensely powerful, as it does not limit Concourse to +whatever things its authors thought to integrate with. Instead, as a user of +Concourse you can just reuse resource type implementations, or +implement your own.

To use resources, configure them in your pipeline via the +resources section, and use them in +your Build Plans via the get and +put steps.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/params.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/params.html new file mode 100644 index 000000000..2f1f1c177 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/params.html @@ -0,0 +1,3 @@ +

Optional. A map of arbitrary configuration to forward to the +resource. Refer to the resource type's documentation to see what it +supports.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/put.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/put.html new file mode 100644 index 000000000..96a8f78cd --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/put.html @@ -0,0 +1,20 @@ +
put: resource-name
+

Pushes to the given Resource. All artifacts collected +during the plan's execution will be available in the working directory.

For example, the following plan fetches a repo using +get and pushes it to another repo (assuming +repo-develop and repo-master are defined as git resources):

plan:
+- get: repo-develop
+- put: repo-master
+  params:
+    repository: repo-develop

When the put succeeds, the produced version of the resource will be +immediately fetched via an implicit get step. This is so that +later steps in your plan can use the artifact that was produced. The source +will be available under whatever name put specifies, just like as with +get.

So, if the logical name (whatever put specifies) differs from the +concrete resource, you would specify resource as well, like so:

plan:
+- put: resource-image
+  resource: docker-image-resource

Required. The logical name of the resource being pushed. The pushed +resource will be available under this name after the push succeeds.

Optional. Defaults to name. The resource to update, +as configured in resources.

Optional. A map of arbitrary configuration to forward to the +resource. Refer to the resource type's documentation to see what it +supports.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/resource.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/resource.html new file mode 100644 index 000000000..b7eb7a2c3 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/PutStep/resource.html @@ -0,0 +1,2 @@ +

Optional. Defaults to name. The resource to update, as +configured in resources.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/config.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/config.html new file mode 100644 index 000000000..763ede000 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/config.html @@ -0,0 +1,6 @@ +config: object

One required. The configuration for the task's running environment.

file points at a .yml file containing the +task config, which allows this to be tracked +with your resources.

The first segment in the path should refer to another source from the plan, +and the rest of the path is relative to that source.

For example, if in your plan you have the following +get step:

- get: something

And the something resource provided a unit.yml file, you +would set file: something/unit.yml.

config can be defined to inline the task config statically.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/privileged.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/privileged.html new file mode 100644 index 000000000..3b1229b65 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/privileged.html @@ -0,0 +1,8 @@ +privileged: boolean

Optional. Default false. If set to true, the task will +run with full capabilities, as determined by the Garden backend the task runs +on. For Linux-based backends it typically determines whether or not the +container will run in a separate user namespace, and whether the root +user is "actual" root (if set to true) or a user namespaced +root (if set to false, the default).

This is a gaping security hole; use wisely and only if necessary. This is not +part of the task configuration to prevent privilege escalation via pull +requests.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/task.html b/vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/task.html new file mode 100644 index 000000000..feb3dfea8 --- /dev/null +++ b/vscode-extensions/vscode-concourse/src/main/resources/desc/TaskStep/task.html @@ -0,0 +1,23 @@ +

Executes a Task, either from a file fetched via the +preceding steps, or with inlined configuration.

If any task in the build plan fails, the build will complete with failure. By +default, any subsequent steps will not be performed. You can perform additional +steps after failure by adding a on_failure +or ensure step.

For example, the following plan fetches a single repository and executes +multiple tasks, using the aggregate step, +in a build matrix style configuration:

plan:
+- get: my-repo
+- aggregate:
+  - task: go-1.3
+    file: my-repo/go-1.3.yml
+  - task: go-1.4
+    file: my-repo/ci/go-1.4.yml

Only if both tasks succeed will the build go green.

When a task completes, the files in its declared outputs will be made avaliable +to subsequent steps. This allows those subsequent steps to process the result +of a task. For example, the following plan pulls down a repo, makes a commit to +it, and pushes the commit to another repo (the task must have an output called +repo-with-commit):

plan:
+- get: my-repo
+- task: commit
+  file: my-repo/commit.yml
+- put: other-repo
+  params:
+    repository: repo-with-commit

\ No newline at end of file
diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/buildpack.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/buildpack.html
deleted file mode 100644
index 2f3fb4cb2..000000000
--- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/buildpack.html
+++ /dev/null
@@ -1,11 +0,0 @@
-

If your application requires a custom buildpack, you can use the buildpack attribute to specify its URL or name:

- -
----
-  ...
-  buildpack: buildpack_URL
-
- -

Note: The cf buildpacks command lists the buildpacks that you can refer to by name in a manifest or a command line option.

- -

The command line option that overrides this attribute is -b.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/buildpack.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/buildpack.md deleted file mode 100644 index afc713276..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/buildpack.md +++ /dev/null @@ -1,11 +0,0 @@ -If your application requires a custom buildpack, you can use the `buildpack` attribute to specify its URL or name: - -``` ---- - ... - buildpack: buildpack_URL -``` - -**Note**: The `cf buildpacks` command lists the buildpacks that you can refer to by name in a manifest or a command line option. - -The command line option that overrides this attribute is `-b`. diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/command.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/command.html deleted file mode 100644 index aab1e4651..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/command.html +++ /dev/null @@ -1,34 +0,0 @@ -

Some languages and frameworks require that you provide a custom command to start an application. Refer to the buildpack documentation to determine if you need to provide a custom start command.

- -

You can provide the custom start command in your application manifest or on the command line.

- -

To specify the custom start command in your application manifest, add it in the command: START-COMMAND format as the following example shows:

- -
----
-  ...
-  command: bundle exec rake VERBOSE=true
-
- -

On the command line, use the -c option to specify the custom start command as the following example shows:

- -
-$ cf push my-app -c "bundle exec rake VERBOSE=true"
-
- -

Note: The -c option with a value of ‘null’ forces cf push to use the buildpack start command. See About Starting Applications for more information.

- -

If you override the start command for a Buildpack application, Linux uses -bash -c YOUR-COMMAND to invoke your application. -If you override the start command for a Docker application, Linux uses sh -c YOUR-COMMAND to invoke your application. -Because of this, if you override a start command, you should prefix exec to the final command in your custom composite start command.

- -

exec causes the last command to become the root process of your application. The Cloud Foundry Updates and Your Application section of the Considerations for Designing and Running an Application in the Cloud topic explains why your application should handle a termination signal during Cloud Foundry updates. -Without an exec statement, the parent process remains as the implied bash process, and does not propagate signals to your application process.

- -

For example, both of the following composite start commands run database migrations when the first instance of the app starts, then start the app to serve requests, but they behave differently on graceful shutdown.

- -
    -
  • bin/rake cf:on_first_instance db:migrate && bin/rails server -p $PORT -e $RAILS_ENV: The process tree is bash -> ruby, so on graceful shutdown only the bash process receives the TERM signal, and not the ruby process.

  • -
  • bin/rake cf:on_first_instance db:migrate && exec bin/rails server -p $PORT -e $RAILS_ENV: Because of the exec prefix on the final command, the ruby process invoked by rails takes over the bash process managing the execution of the composite command. The process tree is only ruby, so the ruby web server receives the TERM signal can shutdown gracefully for 10 seconds.

  • -
\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/command.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/command.md deleted file mode 100644 index 2d17d293a..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/command.md +++ /dev/null @@ -1,30 +0,0 @@ -Some languages and frameworks require that you provide a custom command to start an application. Refer to the [buildpack](/buildpacks/) documentation to determine if you need to provide a custom start command. - -You can provide the custom start command in your application manifest or on the command line. - -To specify the custom start command in your application manifest, add it in the `command: START-COMMAND` format as the following example shows: - - -``` ---- - ... - command: bundle exec rake VERBOSE=true -``` - -On the command line, use the `-c` option to specify the custom start command as the following example shows: - -``` -$ cf push my-app -c "bundle exec rake VERBOSE=true" -``` - -**Note**: The `-c` option with a value of ‘null’ forces `cf push` to use the buildpack start command. See [About Starting Applications](./app-startup.html) for more information. - -If you override the start command for a Buildpack application, Linux uses `bash -c YOUR-COMMAND` to invoke your application. If you override the start command for a Docker application, Linux uses `sh -c YOUR-COMMAND` to invoke your application. Because of this, if you override a start command, you should prefix `exec` to the final command in your custom composite start command. - -`exec` causes the last command to become the root process of your application. The [Cloud Foundry Updates and Your Application](./prepare-to-deploy.html#moving-apps) section of the _Considerations for Designing and Running an Application in the Cloud_ topic explains why your application should handle a `termination signal` during Cloud Foundry updates. Without an `exec` statement, the parent process remains as the implied bash process, and does not propagate signals to your application process. - -For example, both of the following composite start commands run database migrations when the first instance of the app starts, then start the app to serve requests, but they behave differently on graceful shutdown. - -* `bin/rake cf:on_first_instance db:migrate && bin/rails server -p $PORT -e $RAILS_ENV`: The process tree is `bash -> ruby`, so on graceful shutdown only the `bash` process receives the TERM signal, and not the `ruby` process. - -* `bin/rake cf:on_first_instance db:migrate && exec bin/rails server -p $PORT -e $RAILS_ENV`: Because of the `exec` prefix on the final command, the `ruby` process invoked by `rails` takes over the `bash` process managing the execution of the composite command. The process tree is only `ruby`, so the ruby web server receives the TERM signal can shutdown gracefully for 10 seconds. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/disk_quota.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/disk_quota.html deleted file mode 100644 index f2463dbea..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/disk_quota.html +++ /dev/null @@ -1,9 +0,0 @@ -

Use the disk_quota attribute to allocate the disk space for your app instance. This attribute requires a unit of measurement: M, MB, G, or GB, in upper case or lower case.

- -
----
-  ...
-  disk_quota: 1024M
-
- -

The command line option that overrides this attribute is -k.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/disk_quota.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/disk_quota.md deleted file mode 100644 index dfd347ccd..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/disk_quota.md +++ /dev/null @@ -1,9 +0,0 @@ -Use the `disk_quota` attribute to allocate the disk space for your app instance. This attribute requires a unit of measurement: `M`, `MB`, `G`, or `GB`, in upper case or lower case. - -``` ---- - ... - disk_quota: 1024M -``` - -The command line option that overrides this attribute is `-k`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domain.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domain.html deleted file mode 100644 index 8f1af1c01..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domain.html +++ /dev/null @@ -1,27 +0,0 @@ -

Every cf push deploys applications to one particular Cloud Foundry instance. -Every Cloud Foundry instance may have a shared domain set by an admin. -Unless you specify a domain, Cloud Foundry incorporates that shared domain in the route to your application.

- -

You can use the domain attribute when you want your application to be served from a domain other than the default shared domain.

- -
----
-  ...
-  domain: unique-example.com
-
- -

The command line option that overrides this attribute is -d.

- -

The domains attribute

- -

Use the domains attribute to provide multiple domains. If you define both domain and domains attributes, Cloud Foundry creates routes for domains defined in both of these fields.

- -
----
-  ...
-  domains:
-  - domain-example1.com
-  - domain-example2.org
-
- -

The command line option that overrides this attribute is -d.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domain.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domain.md deleted file mode 100644 index e25a36620..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domain.md +++ /dev/null @@ -1,25 +0,0 @@ -Every `cf push` deploys applications to one particular Cloud Foundry instance. Every Cloud Foundry instance may have a shared domain set by an admin. Unless you specify a domain, Cloud Foundry incorporates that shared domain in the route to your application. - -You can use the `domain` attribute when you want your application to be served from a domain other than the default shared domain. - -``` ---- - ... - domain: unique-example.com -``` - -The command line option that overrides this attribute is `-d`. - -### The domains attribute - -Use the `domains` attribute to provide multiple domains. If you define both `domain` and `domains` attributes, Cloud Foundry creates routes for domains defined in both of these fields. - -``` ---- - ... - domains: - - domain-example1.com - - domain-example2.org -``` - -The command line option that overrides this attribute is `-d`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domains.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domains.html deleted file mode 100644 index 0df6ef33b..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domains.html +++ /dev/null @@ -1,10 +0,0 @@ -

Use the domains attribute to provide multiple domains. If you define both domain and domains attributes, Cloud Foundry creates routes for domains defined in both of these fields.

- -
---
-  ...
-  domains:
-  - domain-example1.com
-  - domain-example2.org
-
- -

The command line option that overrides this attribute is -d.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domains.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domains.md deleted file mode 100644 index d593178e6..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/domains.md +++ /dev/null @@ -1,11 +0,0 @@ -Use the `domains` attribute to provide multiple domains. If you define both `domain` and `domains` attributes, Cloud Foundry creates routes for domains defined in both of these fields. - -``` ---- - ... - domains: - - domain-example1.com - - domain-example2.org -``` - -The command line option that overrides this attribute is `-d`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/env.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/env.html deleted file mode 100644 index 4c35fe3d7..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/env.html +++ /dev/null @@ -1,28 +0,0 @@ -

The env block consists of a heading, then one or more environment variable/value pairs.

- -

For example:

- -
----
-  ...
-  env:
-    RAILS_ENV: production
-    RACK_ENV: production
-
- -

cf push deploys the application to a container on the server. The variables belong to the container environment.

- -

While the application is running, Cloud Foundry allows you to operate on environment variables.

- -
    -
  • View all variables: cf env my-app
  • -
  • Set an individual variable: cf set-env my-app my-variable_name my-variable_value
  • -
  • Unset an individual variable: cf unset-env my-app my-variable_name my-variable_value
  • -
- -

Environment variables interact with manifests in the following ways:

- -
    -
  • When you deploy an application for the first time, Cloud Foundry reads the variables described in the environment block of the manifest, and adds them to the environment of the container where the application is deployed.

  • -
  • When you stop and then restart an application, its environment variables persist.

  • -
diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/env.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/env.md deleted file mode 100644 index 88bd86d01..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/env.md +++ /dev/null @@ -1,24 +0,0 @@ -The `env` block consists of a heading, then one or more environment variable/value pairs. - -For example: - -``` ---- - ... - env: - RAILS_ENV: production - RACK_ENV: production -``` - -`cf push` deploys the application to a container on the server. The variables belong to the container environment. - -While the application is running, Cloud Foundry allows you to operate on environment variables. - -* View all variables: `cf env my-app` -* Set an individual variable: `cf set-env my-app my-variable_name my-variable_value` -* Unset an individual variable: `cf unset-env my-app my-variable_name my-variable_value` - -Environment variables interact with manifests in the following ways: - -* When you deploy an application for the first time, Cloud Foundry reads the variables described in the environment block of the manifest, and adds them to the environment of the container where the application is deployed. -* When you stop and then restart an application, its environment variables persist. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/health-check-type.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/health-check-type.html deleted file mode 100644 index 30be9affb..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/health-check-type.html +++ /dev/null @@ -1,9 +0,0 @@ -

Use the health-check-type attribute to set the health_check_type -flag to either port or none. If you do not provide -a health-check-type attribute, it defaults to port.

- -
----
-  ...
-  health-check-type: none
-
\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/health-check-type.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/health-check-type.md deleted file mode 100644 index fac9be7d7..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/health-check-type.md +++ /dev/null @@ -1,9 +0,0 @@ -Use the `health-check-type` attribute to set the `health_check_type` -flag to either `port` or `none`. If you do not provide a `health-check-type` -attribute, it defaults to `port`. - -``` ---- - ... - health-check-type: none -``` diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/host.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/host.html deleted file mode 100644 index 04de4aa7b..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/host.html +++ /dev/null @@ -1,9 +0,0 @@ -

Use the host attribute to provide a hostname, or subdomain, in the form of a string. This segment of a route helps to ensure that the route is unique. If you do not provide a hostname, the URL for the app takes the form of APP-NAME.DOMAIN.

- -
----
-  ...
-  host: my-app
-
- -

The command line option that overrides this attribute is -n.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/host.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/host.md deleted file mode 100644 index 4658d50bf..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/host.md +++ /dev/null @@ -1,9 +0,0 @@ -Use the `host` attribute to provide a hostname, or subdomain, in the form of a string. This segment of a route helps to ensure that the route is unique. If you do not provide a hostname, the URL for the app takes the form of `APP-NAME.DOMAIN`. - -``` ---- - ... - host: my-app -``` - -The command line option that overrides this attribute is `-n`. diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/hosts.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/hosts.html deleted file mode 100644 index de25f32ef..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/hosts.html +++ /dev/null @@ -1,11 +0,0 @@ -

Use the hosts attribute to provide multiple hostnames, or subdomains. Each hostname generates a unique route for the app. hosts can be used in conjunction with host. If you define both attributes, Cloud Foundry creates routes for hostnames defined in both host and hosts.

- -
----
-  ...
-  hosts:
-  - app_host1
-  - app_host2
-
- -

The command line option that overrides this attribute is -n.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/hosts.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/hosts.md deleted file mode 100644 index 9b69c9cf2..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/hosts.md +++ /dev/null @@ -1,11 +0,0 @@ -Use the `hosts` attribute to provide multiple hostnames, or subdomains. Each hostname generates a unique route for the app. `hosts` can be used in conjunction with `host`. If you define both attributes, Cloud Foundry creates routes for hostnames defined in both `host` and `hosts`. - -``` ---- - ... - hosts: - - app_host1 - - app_host2 -``` - -The command line option that overrides this attribute is `-n`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/inherit.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/inherit.html deleted file mode 100644 index 184350b67..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/inherit.html +++ /dev/null @@ -1,62 +0,0 @@ -

A single manifest can describe multiple applications. Another powerful technique is to create multiple manifests with inheritance. Here, manifests have parent-child relationships such that children inherit descriptions from a parent. Children can use inherited descriptions as-is, extend them, or override them.

- -

Content in the child manifest overrides content in the parent manifest, if the two conflict.

- -

This technique helps in these and other scenarios:

- -
    -
  • An application has a set of different deployment modes, such as debug, local, and public. Each deployment mode is described in child manifests that extend the settings in a base parent manifest.

  • -
  • An application is packaged with a basic configuration described by a parent manifest. Users can extend the basic configuration by creating child manifests that add new properties or override those in the parent manifest.

  • -
- -

The benefits of multiple manifests with inheritance are similar to those of minimizing duplicated content within single manifests. With inheritance, though, we “promote” content by placing it in the parent manifest.

- -

Every child manifest must contain an “inherit” line that points to the parent manifest. Place the inherit line immediately after the three dashes at the top of the child manifest. For example, every child of a parent manifest called base-manifest.yml begins like this:

- -
---
-  ...
-  inherit: base-manifest.yml
-
- -

You do not need to add anything to the parent manifest.

- -

In the simple example below, a parent manifest gives each application minimal resources, while a production child manifest scales them up.

- -

simple-base-manifest.yml

- -
---
-path: .
-domain: shared-domain.com
-memory: 256M
-instances: 1
-services:
-- singular-backend
-
-# app-specific configuration
-applications:
- - name: springtock
-   host: 765shower
-   path: ./april/build/libs/april-weather.war
- - name: wintertick
-   host: 321flurry
-   path: ./december/target/december-weather.war
-
- -

simple-prod-manifest.yml

- -
---
-inherit: simple-base-manifest.yml
-applications:
- - name:springstorm
-   memory: 512M
-   instances: 1
-   host: 765deluge
-   path: ./april/build/libs/april-weather.war
- - name: winterblast
-   memory: 1G
-   instances: 2
-   host: 321blizzard
-   path: ./december/target/december-weather.war
-
- -

Note: Inheritance can add an additional level of complexity to manifest creation and maintenance. Comments that precisely explain how the child manifest extends or overrides the descriptions in the parent manifest can alleviate this complexity. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/inherit.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/inherit.md deleted file mode 100644 index 5270dee89..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/inherit.md +++ /dev/null @@ -1,63 +0,0 @@ -A single manifest can describe multiple applications. Another powerful technique is to create multiple manifests with inheritance. Here, manifests have parent-child relationships such that children inherit descriptions from a parent. Children can use inherited descriptions as-is, extend them, or override them. - -Content in the child manifest overrides content in the parent manifest, if the two conflict. - -This technique helps in these and other scenarios: - -* An application has a set of different deployment modes, such as debug, local, and public. Each deployment mode is described in child manifests that extend the settings in a base parent manifest. - -* An application is packaged with a basic configuration described by a parent manifest. Users can extend the basic configuration by creating child manifests that add new properties or override those in the parent manifest. - -The benefits of multiple manifests with inheritance are similar to those of minimizing duplicated content within single manifests. With inheritance, though, we “promote” content by placing it in the parent manifest. - -Every child manifest must contain an “inherit” line that points to the parent manifest. Place the inherit line immediately after the three dashes at the top of the child manifest. For example, every child of a parent manifest called `base-manifest.yml` begins like this: - -``` ---- - ... - inherit: base-manifest.yml -``` -You do not need to add anything to the parent manifest. - -In the simple example below, a parent manifest gives each application minimal resources, while a production child manifest scales them up. - -**simple-base-manifest.yml** - -``` ---- -path: . -domain: shared-domain.com -memory: 256M -instances: 1 -services: -- singular-backend - -# app-specific configuration -applications: - - name: springtock - host: 765shower - path: ./april/build/libs/april-weather.war - - name: wintertick - host: 321flurry - path: ./december/target/december-weather.war -``` - -**simple-prod-manifest.yml** - -``` ---- -inherit: simple-base-manifest.yml -applications: - - name:springstorm - memory: 512M - instances: 1 - host: 765deluge - path: ./april/build/libs/april-weather.war - - name: winterblast - memory: 1G - instances: 2 - host: 321blizzard - path: ./december/target/december-weather.war -``` - -**Note**: Inheritance can add an additional level of complexity to manifest creation and maintenance. Comments that precisely explain how the child manifest extends or overrides the descriptions in the parent manifest can alleviate this complexity. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/instances.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/instances.html deleted file mode 100644 index 021991fa5..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/instances.html +++ /dev/null @@ -1,11 +0,0 @@ -

Use the instances attribute to specify the number of app instances that you want to start upon push:

- -
----
-  ...
-  instances: 2
-
- -

We recommend that you run at least two instances of any apps for which fault tolerance matters.

- -

The command line option that overrides this attribute is -i.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/instances.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/instances.md deleted file mode 100644 index 27bd30d5d..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/instances.md +++ /dev/null @@ -1,11 +0,0 @@ -Use the `instances` attribute to specify the number of app instances that you want to start upon push: - -``` ---- - ... - instances: 2 -``` - -We recommend that you run at least two instances of any apps for which fault tolerance matters. - -The command line option that overrides this attribute is `-i`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/memory.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/memory.html deleted file mode 100644 index e25ee286e..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/memory.html +++ /dev/null @@ -1,11 +0,0 @@ -

Use the memory attribute to specify the memory limit for all instances of an app. This attribute requires a unit of measurement: M, MB, G, or GB, in upper case or lower case. For example:

- -
----
-  ...
-  memory: 1024M
-
- -

The default memory limit is 1G. You might want to specify a smaller limit to conserve quota space if you know that your app instances do not require 1G of memory.

- -

The command line option that overrides this attribute is -m.

\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/memory.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/memory.md deleted file mode 100644 index 3efb02e41..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/memory.md +++ /dev/null @@ -1,11 +0,0 @@ -Use the `memory` attribute to specify the memory limit for all instances of an app. This attribute requires a unit of measurement: `M`, `MB`, `G`, or `GB`, in upper case or lower case. For example: - -``` ---- - ... - memory: 1024M -``` - -The default memory limit is 1G. You might want to specify a smaller limit to conserve quota space if you know that your app instances do not require 1G of memory. - -The command line option that overrides this attribute is `-m`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/name.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/name.html deleted file mode 100644 index 39d0aac6a..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/name.html +++ /dev/null @@ -1,10 +0,0 @@ -

The name attribute is the only required attribute -for an application in a manifest file.

- -

This is an example of a minimal manifest:

- -
----
-applications:
-- name: nifty-gui
-
\ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/name.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/name.md deleted file mode 100644 index 09419ceee..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/name.md +++ /dev/null @@ -1,9 +0,0 @@ -The `name` attribute is the only required attribute for an application in a manifest file. - -This is an example of a minimal manifest: - -``` ---- -applications: -- name: nifty-gui -``` \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-hostname.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-hostname.html deleted file mode 100644 index b3a6047de..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-hostname.html +++ /dev/null @@ -1,9 +0,0 @@ -

By default, if you do not provide a hostname, the URL for the app takes the form of APP-NAME.DOMAIN. If you want to override this and map the root domain to this app then you can set no-hostname as true.

- -
----
-  ...
-  no-hostname: true
-
- -

The command line option that corresponds to this attribute is --no-hostname.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-hostname.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-hostname.md deleted file mode 100644 index 19b73ed31..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-hostname.md +++ /dev/null @@ -1,9 +0,0 @@ -By default, if you do not provide a hostname, the URL for the app takes the form of `APP-NAME.DOMAIN`. If you want to override this and map the root domain to this app then you can set no-hostname as true. - -``` ---- - ... - no-hostname: true -``` - -The command line option that corresponds to this attribute is `--no-hostname`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-route.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-route.html deleted file mode 100644 index d631024fd..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-route.html +++ /dev/null @@ -1,18 +0,0 @@ -

By default, cf push assigns a route to every application. But some applications process data while running in the background, and should not be assigned routes.

- -

You can use the no-route attribute with a value of true to prevent a route from being created for your application.

- -
----
-  ...
-  no-route: true
-
- -

The command line option that corresponds to this attribute is --no-route.

- -

If you find that an application which should not have a route does have one:

- -
    -
  1. Remove the route using the cf unmap-route command.
  2. -
  3. Push the app again with the no-route: true attribute in the manifest or the --no-route command line option.
  4. -
diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-route.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-route.md deleted file mode 100644 index 7cef4e28f..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/no-route.md +++ /dev/null @@ -1,16 +0,0 @@ -By default, `cf push` assigns a route to every application. But some applications process data while running in the background, and should not be assigned routes. - -You can use the `no-route` attribute with a value of `true` to prevent a route from being created for your application. - -``` ---- - ... - no-route: true -``` - -The command line option that corresponds to this attribute is `--no-route`. - -If you find that an application which should not have a route does have one: - -1. Remove the route using the `cf unmap-route` command. -2. Push the app again with the `no-route: true` attribute in the manifest or the `--no-route` command line option. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/path.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/path.html deleted file mode 100644 index a1b1cfb23..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/path.html +++ /dev/null @@ -1,9 +0,0 @@ -

You can use the path attribute to tell Cloud Foundry where to find your application. This is generally not necessary when you run cf push from the directory where an application is located.

- -
----
-  ...
-  path: path_to_application_bits
-
- -

The command line option that overrides this attribute is -p.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/path.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/path.md deleted file mode 100644 index 24d48cb6a..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/path.md +++ /dev/null @@ -1,9 +0,0 @@ -You can use the `path` attribute to tell Cloud Foundry where to find your application. This is generally not necessary when you run `cf push` from the directory where an application is located. - -``` ---- - ... - path: path_to_application_bits -``` - -The command line option that overrides this attribute is `-p`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/random-route.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/random-route.html deleted file mode 100644 index ef432da78..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/random-route.html +++ /dev/null @@ -1,11 +0,0 @@ -

Use the random-route attribute to create a URL that includes the app name and -random words. -Use this attribute to avoid URL collision when pushing the same app to multiple spaces, or to avoid managing app URLs.

- -

The command line option that corresponds to this attribute is --random-route.

- -
----
-  ...
-  random-route: true
-
diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/random-route.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/random-route.md deleted file mode 100644 index 9a7792b77..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/random-route.md +++ /dev/null @@ -1,9 +0,0 @@ -Use the `random-route` attribute to create a URL that includes the app name and random words. Use this attribute to avoid URL collision when pushing the same app to multiple spaces, or to avoid managing app URLs. - -The command line option that corresponds to this attribute is `--random-route`. - -``` ---- - ... - random-route: true -``` \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/services.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/services.html deleted file mode 100644 index c10713143..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/services.html +++ /dev/null @@ -1,18 +0,0 @@ -

Applications can bind to services such as databases, messaging, and key-value stores.

- -

Applications are deployed into App Spaces. An application can only bind to services instances that exist in the target App Space before the application is deployed.

- -

The services block consists of a heading, then one or more service instance names.

- -

Whoever creates the service chooses the service instance names. These names can convey logical information, as in backend_queue, describe the nature of the service, as in mysql_5.x, or do neither, as in the example below.

- -
----
-  ...
-  services:
-   - instance_ABC
-   - instance_XYZ
-
- -

Binding to a service instance is a special case of setting an environment -variable, namely VCAP_SERVICES. diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/services.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/services.md deleted file mode 100644 index 5fb3e1cb9..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/services.md +++ /dev/null @@ -1,17 +0,0 @@ -Applications can bind to services such as databases, messaging, and key-value stores. - -Applications are deployed into App Spaces. An application can only bind to services instances that exist in the target App Space before the application is deployed. - -The `services` block consists of a heading, then one or more service instance names. - -Whoever creates the service chooses the service instance names. These names can convey logical information, as in `backend_queue`, describe the nature of the service, as in `mysql_5.x`, or do neither, as in the example below. - -``` ---- - ... - services: - - instance_ABC - - instance_XYZ -``` - -Binding to a service instance is a special case of setting an environment variable, namely `VCAP_SERVICES`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/stack.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/stack.html deleted file mode 100644 index 021e2788a..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/stack.html +++ /dev/null @@ -1,11 +0,0 @@ -

Use the stack attribute to specify which stack to deploy your application to.

- -

To see a list of available stacks, run cf stacks from the cf cli.

- -
----
-  ...
-  stack: cflinuxfs2
-
- -

The command line option that overrides this attribute is -s.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/stack.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/stack.md deleted file mode 100644 index c46611e1d..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/stack.md +++ /dev/null @@ -1,11 +0,0 @@ -Use the `stack` attribute to specify which stack to deploy your application to. - -To see a list of available stacks, run `cf stacks` from the cf cli. - -``` ---- - ... - stack: cflinuxfs2 -``` - -The command line option that overrides this attribute is `-s`. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/timeout.html b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/timeout.html deleted file mode 100644 index 063e26405..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/timeout.html +++ /dev/null @@ -1,14 +0,0 @@ -

The timeout attribute defines the number of seconds Cloud Foundry allocates for starting your application.

- -

For example:

- -
----
-  ...
-  timeout: 80
-
- -

You can increase the timeout length for very large apps that require more time to start. The default timeout is 60 seconds with an upper bound of 180 seconds.

-

Note: Administrators can set the upper bound of the maximum_health_check_timeout property to any value. Any changes to Cloud Controller properties in the deployment manifest require running bosh deploy.

- -

The command line option that overrides the timeout attribute for the shell is -t. Manifest values still apply to applications pushed to the deployment.

diff --git a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/timeout.md b/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/timeout.md deleted file mode 100644 index bc6f8fa29..000000000 --- a/vscode-extensions/vscode-concourse/src/main/resources/description-by-prop-name/timeout.md +++ /dev/null @@ -1,15 +0,0 @@ -The `timeout` attribute defines the number of seconds Cloud Foundry allocates for starting your application. - -For example: - -``` ---- - ... - timeout: 80 -``` - -You can increase the timeout length for very large apps that require more time to start. The default timeout is 60 seconds with an upper bound of 180 seconds. - -**Note**: Administrators can set the upper bound of the `maximum_health_check_timeout` property to any value. Any changes to Cloud Controller properties in the deployment manifest require running `bosh deploy`. - -The command line option that overrides the timeout attribute for the shell is `-t`. Manifest values still apply to applications pushed to the deployment. \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java index 9491a37c1..e002b38f5 100644 --- a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java +++ b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java @@ -12,6 +12,7 @@ package org.springframework.ide.vscode.manifest.yaml; import org.junit.Before; import org.junit.Test; +import org.springframework.ide.vscode.concourse.ConcourseLanguageServer; import org.springframework.ide.vscode.languageserver.testharness.Editor; import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; @@ -20,7 +21,7 @@ public class ManifestYamlEditorTest { LanguageServerHarness harness; @Before public void setup() throws Exception { - harness = new LanguageServerHarness(ManifestYamlLanguageServer::new); + harness = new LanguageServerHarness(ConcourseLanguageServer::new); harness.intialize(null); } @@ -36,7 +37,7 @@ public class ManifestYamlEditorTest { } @Test public void reconcileRunsOnDocumentOpenAndChange() throws Exception { - LanguageServerHarness harness = new LanguageServerHarness(ManifestYamlLanguageServer::new); + LanguageServerHarness harness = new LanguageServerHarness(ConcourseLanguageServer::new); harness.intialize(null); Editor editor = harness.newEditor( diff --git a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServerTest.java b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServerTest.java index 7d9d3aeb7..53231a920 100644 --- a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServerTest.java +++ b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServerTest.java @@ -9,6 +9,7 @@ import java.nio.file.Paths; import org.eclipse.lsp4j.InitializeResult; import org.eclipse.lsp4j.TextDocumentSyncKind; import org.junit.Test; +import org.springframework.ide.vscode.concourse.ConcourseLanguageServer; import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; public class ManifestYamlLanguageServerTest { @@ -19,7 +20,7 @@ public class ManifestYamlLanguageServerTest { @Test public void createAndInitializeServerWithWorkspace() throws Exception { - LanguageServerHarness harness = new LanguageServerHarness(ManifestYamlLanguageServer::new); + LanguageServerHarness harness = new LanguageServerHarness(ConcourseLanguageServer::new); File workspaceRoot = getTestResource("/workspace/"); assertExpectedInitResult(harness.intialize(workspaceRoot)); } @@ -27,7 +28,7 @@ public class ManifestYamlLanguageServerTest { @Test public void createAndInitializeServerWithoutWorkspace() throws Exception { File workspaceRoot = null; - LanguageServerHarness harness = new LanguageServerHarness(ManifestYamlLanguageServer::new); + LanguageServerHarness harness = new LanguageServerHarness(ConcourseLanguageServer::new); assertExpectedInitResult(harness.intialize(workspaceRoot)); } diff --git a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchemaTest.java b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchemaTest.java index 02a5f4727..f1aa4d507 100644 --- a/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchemaTest.java +++ b/vscode-extensions/vscode-concourse/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchemaTest.java @@ -1,4 +1,3 @@ -package org.springframework.ide.vscode.manifest.yaml; /******************************************************************************* * Copyright (c) 2015, 2016 Pivotal, Inc. * All rights reserved. This program and the accompanying materials @@ -9,147 +8,138 @@ package org.springframework.ide.vscode.manifest.yaml; * Contributors: * Pivotal, Inc. - initial API and implementation *******************************************************************************/ +package org.springframework.ide.vscode.manifest.yaml; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.List; -import java.util.Map; +import static org.junit.Assert.fail; import org.junit.Test; -import org.springframework.ide.vscode.commons.util.Renderables; -import org.springframework.ide.vscode.commons.util.StringUtil; -import org.springframework.ide.vscode.commons.yaml.schema.YTypedProperty; -import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YBeanType; -import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YSeqType; -import org.springframework.ide.vscode.manifest.yaml.ManifestYmlSchema; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; /** * @author Kris De Volder */ public class ManifestYmlSchemaTest { - private static final String[] NESTED_PROP_NAMES = { -// "applications", - "buildpack", - "command", - "disk_quota", - "domain", - "domains", - "env", - "health-check-type", - "host", - "hosts", -// "inherit", - "instances", - "memory", - "name", - "no-hostname", - "no-route", - "path", - "random-route", - "services", - "stack", - "timeout" - }; - - private static final String[] TOPLEVEL_PROP_NAMES = { - "applications", - "buildpack", - "command", - "disk_quota", - "domain", - "domains", - "env", - "health-check-type", + @Test + public void shouldMakeSomeTests() { + fail("We should make some tests for this"); + } +// +// private static final String[] NESTED_PROP_NAMES = { +//// "applications", +// "buildpack", +// "command", +// "disk_quota", +// "domain", +// "domains", +// "env", +// "health-check-type", // "host", // "hosts", - "inherit", - "instances", - "memory", +//// "inherit", +// "instances", +// "memory", // "name", - "no-hostname", - "no-route", - "path", - "random-route", - "services", - "stack", - "timeout" - }; - - ManifestYmlSchema schema = new ManifestYmlSchema(null); - - @Test - public void toplevelProperties() throws Exception { - assertPropNames(schema.getTopLevelType().getProperties(), TOPLEVEL_PROP_NAMES); - assertPropNames(schema.getTopLevelType().getPropertiesMap(), TOPLEVEL_PROP_NAMES); - } - - @Test - public void nestedProperties() throws Exception { - assertPropNames(getNestedProps(), NESTED_PROP_NAMES); - } - - @Test - public void toplevelPropertiesHaveDescriptions() { - for (YTypedProperty p : schema.getTopLevelType().getProperties()) { - if (!p.getName().equals("applications")) { - assertHasRealDescription(p); - } - } - } - - @Test - public void nestedPropertiesHaveDescriptions() { - for (YTypedProperty p : getNestedProps()) { - assertHasRealDescription(p); - } - } - - ////////////////////////////////////////////////////////////////////////////// - - private void assertHasRealDescription(YTypedProperty p) { - { - String noDescriptionText = Renderables.NO_DESCRIPTION.toHtml(); - String actual = p.getDescription().toHtml(); - String msg = "Description missing for '"+p.getName()+"'"; - assertTrue(msg, StringUtil.hasText(actual)); - assertFalse(msg, noDescriptionText.equals(actual)); - } - { - String noDescriptionText = Renderables.NO_DESCRIPTION.toMarkdown(); - String actual = p.getDescription().toMarkdown(); - String msg = "Description missing for '"+p.getName()+"'"; - assertTrue(msg, StringUtil.hasText(actual)); - assertFalse(msg, noDescriptionText.equals(actual)); - } - } - - private List getNestedProps() { - YSeqType applications = (YSeqType) schema.getTopLevelType().getPropertiesMap().get("applications").getType(); - YBeanType application = (YBeanType) applications.getDomainType(); - return application.getProperties(); - } - - private void assertPropNames(List properties, String... expectedNames) { - assertEquals(ImmutableSet.copyOf(expectedNames), getNames(properties)); - } - - private void assertPropNames(Map propertiesMap, String[] toplevelPropNames) { - assertEquals(ImmutableSet.copyOf(toplevelPropNames), ImmutableSet.copyOf(propertiesMap.keySet())); - } - - private ImmutableSet getNames(Iterable properties) { - Builder builder = ImmutableSet.builder(); - for (YTypedProperty p : properties) { - builder.add(p.getName()); - } - return builder.build(); - } +// "no-hostname", +// "no-route", +// "path", +// "random-route", +// "services", +// "stack", +// "timeout" +// }; +// +// private static final String[] TOPLEVEL_PROP_NAMES = { +// "applications", +// "buildpack", +// "command", +// "disk_quota", +// "domain", +// "domains", +// "env", +// "health-check-type", +//// "host", +//// "hosts", +// "inherit", +// "instances", +// "memory", +//// "name", +// "no-hostname", +// "no-route", +// "path", +// "random-route", +// "services", +// "stack", +// "timeout" +// }; +// +// PipelineYmlSchema schema = new PipelineYmlSchema(null); +// +// @Test +// public void toplevelProperties() throws Exception { +// assertPropNames(schema.getTopLevelType().getProperties(DynamicSchemaContext.NULL), TOPLEVEL_PROP_NAMES); +// assertPropNames(schema.getTopLevelType().getPropertiesMap(DynamicSchemaContext.NULL), TOPLEVEL_PROP_NAMES); +// } +// +// @Test +// public void nestedProperties() throws Exception { +// assertPropNames(getNestedProps(), NESTED_PROP_NAMES); +// } +// +// @Test +// public void toplevelPropertiesHaveDescriptions() { +// for (YTypedProperty p : schema.getTopLevelType().getProperties(DynamicSchemaContext.NULL)) { +// if (!p.getName().equals("applications")) { +// assertHasRealDescription(p); +// } +// } +// } +// +// @Test +// public void nestedPropertiesHaveDescriptions() { +// for (YTypedProperty p : getNestedProps()) { +// assertHasRealDescription(p); +// } +// } +// +// ////////////////////////////////////////////////////////////////////////////// +// +// private void assertHasRealDescription(YTypedProperty p) { +// { +// String noDescriptionText = Renderables.NO_DESCRIPTION.toHtml(); +// String actual = p.getDescription().toHtml(); +// String msg = "Description missing for '"+p.getName()+"'"; +// assertTrue(msg, StringUtil.hasText(actual)); +// assertFalse(msg, noDescriptionText.equals(actual)); +// } +// { +// String noDescriptionText = Renderables.NO_DESCRIPTION.toMarkdown(); +// String actual = p.getDescription().toMarkdown(); +// String msg = "Description missing for '"+p.getName()+"'"; +// assertTrue(msg, StringUtil.hasText(actual)); +// assertFalse(msg, noDescriptionText.equals(actual)); +// } +// } +// +// private List getNestedProps() { +// YSeqType applications = (YSeqType) schema.getTopLevelType().getPropertiesMap().get("applications").getType(); +// YBeanType application = (YBeanType) applications.getDomainType(); +// return application.getProperties(); +// } +// +// private void assertPropNames(List properties, String... expectedNames) { +// assertEquals(ImmutableSet.copyOf(expectedNames), getNames(properties)); +// } +// +// private void assertPropNames(Map propertiesMap, String[] toplevelPropNames) { +// assertEquals(ImmutableSet.copyOf(toplevelPropNames), ImmutableSet.copyOf(propertiesMap.keySet())); +// } +// +// private ImmutableSet getNames(Iterable properties) { +// Builder builder = ImmutableSet.builder(); +// for (YTypedProperty p : properties) { +// builder.add(p.getName()); +// } +// return builder.build(); +// } } diff --git a/vscode-extensions/vscode-concourse/test/examples/another-pipeline.yml b/vscode-extensions/vscode-concourse/test/examples/another-pipeline.yml new file mode 100644 index 000000000..e69de29bb