Start from a copy of manfest-yaml editor
This commit is contained in:
@@ -13,5 +13,6 @@
|
||||
<module>commons</module>
|
||||
<module>vscode-boot-properties</module>
|
||||
<module>vscode-manifest-yaml</module>
|
||||
<module>vscode-concourse</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
||||
11
vscode-extensions/vscode-concourse/.gitignore
vendored
Normal file
11
vscode-extensions/vscode-concourse/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
out
|
||||
node_modules
|
||||
target
|
||||
*.log
|
||||
*.log.*
|
||||
.idea
|
||||
*.iml
|
||||
dependency-reduced-pom.xml
|
||||
classpath.txt
|
||||
*.vsix
|
||||
repo
|
||||
28
vscode-extensions/vscode-concourse/.vscode/launch.json
vendored
Normal file
28
vscode-extensions/vscode-concourse/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// A launch configuration that compiles the extension and then opens it inside a new window
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
"outDir": "${workspaceRoot}/out/lib",
|
||||
"preLaunchTask": "npm"
|
||||
},
|
||||
{
|
||||
"name": "Launch Tests",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
"outDir": "${workspaceRoot}/out/test",
|
||||
"preLaunchTask": "npm"
|
||||
}
|
||||
]
|
||||
}
|
||||
13
vscode-extensions/vscode-concourse/.vscode/settings.json
vendored
Normal file
13
vscode-extensions/vscode-concourse/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"editor.wordWrap": false,
|
||||
"files.exclude": {
|
||||
"out": false, // set this to true to hide the "out" folder with the compiled JS files
|
||||
"node_modules": false,
|
||||
"target": true
|
||||
},
|
||||
"search.exclude": {
|
||||
"out": true // set this to false to include "out" folder in search results
|
||||
},
|
||||
"typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version
|
||||
}
|
||||
30
vscode-extensions/vscode-concourse/.vscode/tasks.json
vendored
Normal file
30
vscode-extensions/vscode-concourse/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// Available variables which can be used inside of strings.
|
||||
// ${workspaceRoot}: the root folder of the team
|
||||
// ${file}: the current opened file
|
||||
// ${fileBasename}: the current opened file's basename
|
||||
// ${fileDirname}: the current opened file's dirname
|
||||
// ${fileExtname}: the current opened file's extension
|
||||
// ${cwd}: the current working directory of the spawned process
|
||||
|
||||
// A task runner that calls a custom npm script that compiles the extension.
|
||||
{
|
||||
"version": "0.1.0",
|
||||
|
||||
// we want to run npm
|
||||
"command": "npm",
|
||||
|
||||
// the command is a shell script
|
||||
"isShellCommand": true,
|
||||
|
||||
// show the output window only if unrecognized errors occur.
|
||||
"showOutput": "always",
|
||||
|
||||
// we run the custom script "compile" as defined in package.json
|
||||
"args": ["run", "compile"],
|
||||
|
||||
// The tsc compiler is started in watching mode
|
||||
"isWatching": true,
|
||||
|
||||
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
|
||||
"problemMatcher": "$tsc-watch"
|
||||
}
|
||||
30
vscode-extensions/vscode-concourse/.vscodeignore
Normal file
30
vscode-extensions/vscode-concourse/.vscodeignore
Normal file
@@ -0,0 +1,30 @@
|
||||
# IDE configs
|
||||
.vscode/**
|
||||
.idea/**
|
||||
*.iml
|
||||
javaconfig.json
|
||||
classpath.txt
|
||||
tsconfig.json
|
||||
tsd.json
|
||||
*.xml
|
||||
|
||||
# Logs
|
||||
*.log*
|
||||
|
||||
# Sources
|
||||
typings/**
|
||||
src/**
|
||||
test/**
|
||||
lib/**
|
||||
!lib/javaconfig.schema.json
|
||||
repo/**
|
||||
scripts/**
|
||||
|
||||
# Compiler output
|
||||
out/test/**
|
||||
target/**
|
||||
!target/vscode-concourse-*.jar
|
||||
|
||||
# Extensions
|
||||
.gitignore
|
||||
**/*.map
|
||||
62
vscode-extensions/vscode-concourse/README.md
Normal file
62
vscode-extensions/vscode-concourse/README.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# VS Code Language Server for Concourse Pipeline and Task Configuration Files
|
||||
|
||||
A VSCode extension and Language Server providing support for
|
||||
editing Concourse CI configuration files. Supports editing both
|
||||
pipeline definition files and task definition files.
|
||||
|
||||
The editor provides content assist and validation as you type.
|
||||
These feature are activated for `.yml` files that follow certain
|
||||
naming conventions:
|
||||
|
||||
- `**/*pipeline*.yml` : activates support for editing pipelines
|
||||
- `**/tasks/*.yml` : activates support for editing tasks.
|
||||
|
||||
# Developer notes
|
||||
|
||||
## Bulding and Running
|
||||
|
||||
This project consists of three pieces:
|
||||
|
||||
- a vscode-extension which is a language-server client implemented in TypeScript.
|
||||
- commons-vscode: a local npm module with some utilities implemented in TypeScript.
|
||||
- a language server implemented in Java.
|
||||
|
||||
To build all these pieces you normally only need to run:
|
||||
|
||||
npm install
|
||||
|
||||
**However, the first time you build** it might fail trying to
|
||||
find the `commons-vscode` module on npm central. Once we publish a stable
|
||||
version of that module on npm central that will no longer be a problem.
|
||||
Until that time, you can work around this by doing a one time manual
|
||||
run of the `preinstall` script prior to running `npm install`:
|
||||
|
||||
./scripts/preinstall.sh
|
||||
npm install
|
||||
|
||||
Now you can open the client-app in vscode. From the root of this project.
|
||||
|
||||
code .
|
||||
|
||||
To launch the language server in a vscode runtime, press F5.
|
||||
|
||||
## Debugging
|
||||
|
||||
To debug the language server, open `lib/Main.ts` and edit to set the
|
||||
`DEBUG` option to `true`. When you launch the app next by pressing
|
||||
`F5` it will launch with debug options being passed to the JVM.
|
||||
|
||||
You can then connect a 'Remote Java' Eclipse debugger on port 8000.
|
||||
|
||||
## Packaging as a vscode extension
|
||||
|
||||
First make sure the stuff is all built locally:
|
||||
|
||||
./scripts/preinstall.sh # only needed if this is the first build.
|
||||
npm install
|
||||
|
||||
Then package it:
|
||||
|
||||
npm run vsce-package
|
||||
|
||||
This produces a `.vsix` file which you can install directly into vscode.
|
||||
BIN
vscode-extensions/vscode-concourse/icon.png
Normal file
BIN
vscode-extensions/vscode-concourse/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
1
vscode-extensions/vscode-concourse/lib/.gitignore
vendored
Normal file
1
vscode-extensions/vscode-concourse/lib/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.js
|
||||
58
vscode-extensions/vscode-concourse/lib/Main.ts
Normal file
58
vscode-extensions/vscode-concourse/lib/Main.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
// The module 'vscode' contains the VS Code extensibility API
|
||||
// Import the module and reference it with the alias vscode in your code below
|
||||
|
||||
import * as VSCode from 'vscode';
|
||||
import * as commons from 'commons-vscode';
|
||||
import * as Path from 'path';
|
||||
import * as FS from 'fs';
|
||||
import * as Net from 'net';
|
||||
import * as ChildProcess from 'child_process';
|
||||
import {LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, StreamInfo} from 'vscode-languageclient';
|
||||
import {TextDocument, OutputChannel} from 'vscode';
|
||||
|
||||
var DEBUG = false;
|
||||
const DEBUG_ARG = '-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y';
|
||||
|
||||
var log_output : OutputChannel = null;
|
||||
|
||||
function log(msg : string) {
|
||||
if (log_output) {
|
||||
log_output.append(msg +"\n");
|
||||
}
|
||||
}
|
||||
|
||||
function error(msg : string) {
|
||||
if (log_output) {
|
||||
log_output.append("ERR: "+msg+"\n");
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when extension is activated */
|
||||
export function activate(context: VSCode.ExtensionContext) {
|
||||
let options : commons.ActivatorOptions = {
|
||||
DEBUG : false,
|
||||
extensionId: 'vscode-concourse',
|
||||
fatJarFile: 'target/vscode-concourse-0.0.1-SNAPSHOT.jar',
|
||||
clientOptions: {
|
||||
// HACK!!! documentSelector only takes string|string[] where string is language id, but DocumentFilter object is passed instead
|
||||
// Reasons:
|
||||
// 1. documentSelector is just passed over to functions like #registerHoverProvider(documentSelector, ...) that take documentSelector
|
||||
// parameter in string | DocumentFilter | string[] | DocumentFilter[] format
|
||||
// 2. Combination of non string|string[] documentSelector parameter and synchronize.textDocumentFilter function makes doc synchronization
|
||||
// events pass on to Language Server only for documents for which function passed via textDocumentFilter property return true
|
||||
|
||||
// TODO: Remove <any> cast ones https://github.com/Microsoft/vscode-languageserver-node/issues/9 is resolved
|
||||
documentSelector: [ <any> {language: 'yaml', pattern: '**/*pipeline*.yml'}],
|
||||
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);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
commons.activate(options, context);
|
||||
}
|
||||
|
||||
49
vscode-extensions/vscode-concourse/package.json
Normal file
49
vscode-extensions/vscode-concourse/package.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "vscode-concourse",
|
||||
"displayName": "Concourse CI Pipeline Editor",
|
||||
"description": "Provides validation and content assist for Concourse CI pipeline and task configuration yml files",
|
||||
"icon": "icon.png",
|
||||
"version": "0.0.1",
|
||||
"publisher": "Pivotal",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spring-projects/sts4.git"
|
||||
},
|
||||
"license": "EPL-1.0",
|
||||
"engines": {
|
||||
"npm": "^3.0.0",
|
||||
"vscode": "^1.5.0"
|
||||
},
|
||||
"categories": [
|
||||
"Languages",
|
||||
"Linters"
|
||||
],
|
||||
"keywords": [
|
||||
"yaml",
|
||||
"concourse",
|
||||
"pipeline.yml"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onLanguage:yaml"
|
||||
],
|
||||
"main": "./out/lib/Main",
|
||||
"preview": true,
|
||||
"scripts": {
|
||||
"prepublish": "tsc -p .",
|
||||
"clean": "rm -fr node_modules out *.vsix",
|
||||
"compile": "tsc -watch -p ./",
|
||||
"preinstall": "./scripts/preinstall.sh",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install",
|
||||
"vsce-package": "vsce package"
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-languageclient": "2.5.x",
|
||||
"commons-vscode": "^0.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vsce": "^1.17.0",
|
||||
"typescript": "^2.0.x",
|
||||
"@types/node": "^6.0.40",
|
||||
"vscode": "^1.0.0"
|
||||
}
|
||||
}
|
||||
71
vscode-extensions/vscode-concourse/pom.xml
Normal file
71
vscode-extensions/vscode-concourse/pom.xml
Normal file
@@ -0,0 +1,71 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>vscode-concourse</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.ide.vscode</groupId>
|
||||
<artifactId>commons-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../commons/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>distribution-repository</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${basedir}/dist</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- Language Servers -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.ide.vscode</groupId>
|
||||
<artifactId>commons-language-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- Yaml -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.ide.vscode</groupId>
|
||||
<artifactId>commons-yaml</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- Test harness -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.ide.vscode</groupId>
|
||||
<artifactId>language-server-test-harness</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Set source 1.8 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Configure fat jar -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>1.4.1.RELEASE</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
5
vscode-extensions/vscode-concourse/scripts/preinstall.sh
Executable file
5
vscode-extensions/vscode-concourse/scripts/preinstall.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
(cd ../commons-vscode ; npm install)
|
||||
npm install ../commons-vscode
|
||||
../mvnw -U -f ../pom.xml -pl vscode-concourse -am clean install
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.ide.vscode.commons.languageserver.LaunguageServerApp;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
|
||||
public class Main {
|
||||
SimpleLanguageServer server = new ManifestYamlLanguageServer();
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
LaunguageServerApp.start(ManifestYamlLanguageServer::new);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import org.eclipse.lsp4j.CompletionOptions;
|
||||
import org.eclipse.lsp4j.ServerCapabilities;
|
||||
import org.eclipse.lsp4j.TextDocumentSyncKind;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter;
|
||||
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfoProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.hover.VscodeHoverEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.hover.VscodeHoverEngineAdapter;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.IReconcileEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.YamlASTProvider;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.YamlParser;
|
||||
import org.springframework.ide.vscode.commons.yaml.completion.SchemaBasedYamlAssistContextProvider;
|
||||
import org.springframework.ide.vscode.commons.yaml.completion.YamlAssistContextProvider;
|
||||
import org.springframework.ide.vscode.commons.yaml.completion.YamlCompletionEngine;
|
||||
import org.springframework.ide.vscode.commons.yaml.hover.YamlHoverInfoProvider;
|
||||
import org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaBasedReconcileEngine;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YamlSchema;
|
||||
import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureProvider;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class ManifestYamlLanguageServer extends SimpleLanguageServer {
|
||||
|
||||
private static final Provider<Collection<YValueHint>> NO_BUILDPACKS = () -> ImmutableList.of();
|
||||
|
||||
private Yaml yaml = new Yaml();
|
||||
private YamlSchema schema = new ManifestYmlSchema(NO_BUILDPACKS);
|
||||
|
||||
|
||||
public ManifestYamlLanguageServer() {
|
||||
SimpleTextDocumentService documents = getTextDocumentService();
|
||||
|
||||
YamlASTProvider parser = new YamlParser(yaml);
|
||||
|
||||
YamlStructureProvider structureProvider = YamlStructureProvider.DEFAULT;
|
||||
YamlAssistContextProvider contextProvider = new SchemaBasedYamlAssistContextProvider(schema);
|
||||
YamlCompletionEngine yamlCompletionEngine = new YamlCompletionEngine(structureProvider, contextProvider);
|
||||
VscodeCompletionEngine completionEngine = new VscodeCompletionEngineAdapter(this, yamlCompletionEngine);
|
||||
HoverInfoProvider infoProvider = new YamlHoverInfoProvider(parser, structureProvider, contextProvider);
|
||||
VscodeHoverEngine hoverEngine = new VscodeHoverEngineAdapter(this, infoProvider);
|
||||
IReconcileEngine engine = new YamlSchemaBasedReconcileEngine(parser, schema);
|
||||
|
||||
// SimpleWorkspaceService workspace = getWorkspaceService();
|
||||
documents.onDidChangeContent(params -> {
|
||||
TextDocument doc = params.getDocument();
|
||||
validateWith(doc, engine);
|
||||
});
|
||||
|
||||
// workspace.onDidChangeConfiguraton(settings -> {
|
||||
// System.out.println("Config changed: "+params);
|
||||
// Integer val = settings.getInt("languageServerExample", "maxNumberOfProblems");
|
||||
// if (val!=null) {
|
||||
// maxProblems = ((Number) val).intValue();
|
||||
// for (TextDocument doc : documents.getAll()) {
|
||||
// validateDocument(documents, doc);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
documents.onCompletion(completionEngine::getCompletions);
|
||||
documents.onCompletionResolve(completionEngine::resolveCompletion);
|
||||
documents.onHover(hoverEngine ::getHover);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ServerCapabilities getServerCapabilities() {
|
||||
ServerCapabilities c = new ServerCapabilities();
|
||||
|
||||
c.setTextDocumentSync(TextDocumentSyncKind.Incremental);
|
||||
c.setHoverProvider(true);
|
||||
|
||||
CompletionOptions completionProvider = new CompletionOptions();
|
||||
completionProvider.setResolveProvider(false);
|
||||
c.setCompletionProvider(completionProvider);
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*******************************************************************************
|
||||
* 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<Collection<YValueHint>> buildpackProvider;
|
||||
|
||||
private static final Set<String> TOPLEVEL_EXCLUDED = ImmutableSet.of(
|
||||
"name", "host", "hosts"
|
||||
);
|
||||
|
||||
public ManifestYmlSchema(Provider<Collection<YValueHint>> 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*******************************************************************************
|
||||
* 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.Set;
|
||||
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
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 static final ValueParser POS_INTEGER = integerRange(0, null);
|
||||
|
||||
public static final ValueParser MEMORY = new ValueParser() {
|
||||
|
||||
private final ImmutableSet<String> GIGABYTE = ImmutableSet.of("G", "GB");
|
||||
private final ImmutableSet<String> MEGABYTE = ImmutableSet.of("M", "MB");
|
||||
private final Set<String> 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 ValueParser integerAtLeast(final Integer lowerBound) {
|
||||
return integerRange(lowerBound, null);
|
||||
}
|
||||
|
||||
public static ValueParser integerRange(final Integer lowerBound, final Integer upperBound) {
|
||||
Assert.isLegal(lowerBound==null || upperBound==null || lowerBound <= upperBound);
|
||||
return new ValueParser() {
|
||||
@Override
|
||||
public Object parse(String str) {
|
||||
int value = Integer.parseInt(str);
|
||||
if (lowerBound!=null && value<lowerBound) {
|
||||
if (lowerBound==0) {
|
||||
throw new NumberFormatException("Value must be positive");
|
||||
} else {
|
||||
throw new NumberFormatException("Value must be at least "+lowerBound);
|
||||
}
|
||||
}
|
||||
if (upperBound!=null && value>upperBound) {
|
||||
throw new NumberFormatException("Value must be at most "+upperBound);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<p>If your application requires a custom buildpack, you can use the <code>buildpack</code> attribute to specify its URL or name:</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
buildpack: buildpack_URL
|
||||
</pre>
|
||||
|
||||
<p class="note"><strong>Note</strong>: The <code>cf buildpacks</code> command lists the buildpacks that you can refer to by name in a manifest or a command line option.</p>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-b</code>.</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
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`.
|
||||
@@ -0,0 +1,34 @@
|
||||
<p>Some languages and frameworks require that you provide a custom command to start an application. Refer to the <a href="/buildpacks/">buildpack</a> documentation to determine if you need to provide a custom start command.</p>
|
||||
|
||||
<p>You can provide the custom start command in your application manifest or on the command line.</p>
|
||||
|
||||
<p>To specify the custom start command in your application manifest, add it in the <code>command: START-COMMAND</code> format as the following example shows:</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
command: bundle exec rake VERBOSE=true
|
||||
</pre>
|
||||
|
||||
<p>On the command line, use the <code>-c</code> option to specify the custom start command as the following example shows:</p>
|
||||
|
||||
<pre class="terminal">
|
||||
$ cf push my-app -c "bundle exec rake VERBOSE=true"
|
||||
</pre>
|
||||
|
||||
<p class="note"><strong>Note</strong>: The <code>-c</code> option with a value of ‘null’ forces <code>cf push</code> to use the buildpack start command. See <a href="./app-startup.html">About Starting Applications</a> for more information.</p>
|
||||
|
||||
<p>If you override the start command for a Buildpack application, Linux uses
|
||||
<code>bash -c YOUR-COMMAND</code> to invoke your application.
|
||||
If you override the start command for a Docker application, Linux uses <code>sh -c YOUR-COMMAND</code> to invoke your application.
|
||||
Because of this, if you override a start command, you should prefix <code>exec</code> to the final command in your custom composite start command.</p>
|
||||
|
||||
<p><code>exec</code> causes the last command to become the root process of your application. The <a href="./prepare-to-deploy.html#moving-apps">Cloud Foundry Updates and Your Application</a> section of the <em>Considerations for Designing and Running an Application in the Cloud</em> topic explains why your application should handle a <code>termination signal</code> during Cloud Foundry updates.
|
||||
Without an <code>exec</code> statement, the parent process remains as the implied bash process, and does not propagate signals to your application process.</p>
|
||||
|
||||
<p>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. </p>
|
||||
|
||||
<ul>
|
||||
<li><p><code>bin/rake cf:on_first_instance db:migrate && bin/rails server -p $PORT -e $RAILS_ENV</code>: The process tree is <code>bash -> ruby</code>, so on graceful shutdown only the <code>bash</code> process receives the TERM signal, and not the <code>ruby</code> process.</p></li>
|
||||
<li><p><code>bin/rake cf:on_first_instance db:migrate && exec bin/rails server -p $PORT -e $RAILS_ENV</code>: Because of the <code>exec</code> prefix on the final command, the <code>ruby</code> process invoked by <code>rails</code> takes over the <code>bash</code> process managing the execution of the composite command. The process tree is only <code>ruby</code>, so the ruby web server receives the TERM signal can shutdown gracefully for 10 seconds.</p></li>
|
||||
</ul>
|
||||
@@ -0,0 +1,30 @@
|
||||
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.
|
||||
@@ -0,0 +1,9 @@
|
||||
<p>Use the <code>disk_quota</code> attribute to allocate the disk space for your app instance. This attribute requires a unit of measurement: <code>M</code>, <code>MB</code>, <code>G</code>, or <code>GB</code>, in upper case or lower case.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
disk_quota: 1024M
|
||||
</pre>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-k</code>.</p>
|
||||
@@ -0,0 +1,9 @@
|
||||
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`.
|
||||
@@ -0,0 +1,27 @@
|
||||
<p>Every <code>cf push</code> 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.</p>
|
||||
|
||||
<p>You can use the <code>domain</code> attribute when you want your application to be served from a domain other than the default shared domain.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
domain: unique-example.com
|
||||
</pre>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-d</code>.</p>
|
||||
|
||||
<h3><a id='domains'></a>The domains attribute</h3>
|
||||
|
||||
<p>Use the <code>domains</code> attribute to provide multiple domains. If you define both <code>domain</code> and <code>domains</code> attributes, Cloud Foundry creates routes for domains defined in both of these fields.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
domains:
|
||||
- domain-example1.com
|
||||
- domain-example2.org
|
||||
</pre>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-d</code>.</p>
|
||||
@@ -0,0 +1,25 @@
|
||||
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`.
|
||||
@@ -0,0 +1,10 @@
|
||||
<p>Use the <code>domains</code> attribute to provide multiple domains. If you define both <code>domain</code> and <code>domains</code> attributes, Cloud Foundry creates routes for domains defined in both of these fields.</p>
|
||||
|
||||
<pre>---
|
||||
...
|
||||
domains:
|
||||
- domain-example1.com
|
||||
- domain-example2.org
|
||||
</pre>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-d</code>.</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
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`.
|
||||
@@ -0,0 +1,28 @@
|
||||
<p>The <code>env</code> block consists of a heading, then one or more environment variable/value pairs.</p>
|
||||
|
||||
<p>For example:</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
env:
|
||||
RAILS_ENV: production
|
||||
RACK_ENV: production
|
||||
</pre>
|
||||
|
||||
<p><code>cf push</code> deploys the application to a container on the server. The variables belong to the container environment.</p>
|
||||
|
||||
<p>While the application is running, Cloud Foundry allows you to operate on environment variables.</p>
|
||||
|
||||
<ul>
|
||||
<li>View all variables: <code>cf env my-app</code></li>
|
||||
<li>Set an individual variable: <code>cf set-env my-app my-variable_name my-variable_value</code></li>
|
||||
<li>Unset an individual variable: <code>cf unset-env my-app my-variable_name my-variable_value</code></li>
|
||||
</ul>
|
||||
|
||||
<p>Environment variables interact with manifests in the following ways:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>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.</p></li>
|
||||
<li><p>When you stop and then restart an application, its environment variables persist.</p></li>
|
||||
</ul>
|
||||
@@ -0,0 +1,24 @@
|
||||
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.
|
||||
@@ -0,0 +1,9 @@
|
||||
<p>Use the <code>health-check-type</code> attribute to set the <code>health_check_type</code>
|
||||
flag to either <code>port</code> or <code>none</code>. If you do not provide
|
||||
a <code>health-check-type</code> attribute, it defaults to <code>port</code>.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
health-check-type: none
|
||||
</pre>
|
||||
@@ -0,0 +1,9 @@
|
||||
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
|
||||
```
|
||||
@@ -0,0 +1,9 @@
|
||||
<p>Use the <code>host</code> 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 <code>APP-NAME.DOMAIN</code>.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
host: my-app
|
||||
</pre>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-n</code>.</p>
|
||||
@@ -0,0 +1,9 @@
|
||||
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`.
|
||||
@@ -0,0 +1,11 @@
|
||||
<p>Use the <code>hosts</code> attribute to provide multiple hostnames, or subdomains. Each hostname generates a unique route for the app. <code>hosts</code> can be used in conjunction with <code>host</code>. If you define both attributes, Cloud Foundry creates routes for hostnames defined in both <code>host</code> and <code>hosts</code>.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
hosts:
|
||||
- app_host1
|
||||
- app_host2
|
||||
</pre>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-n</code>.</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
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`.
|
||||
@@ -0,0 +1,62 @@
|
||||
<p>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.</p>
|
||||
|
||||
<p>Content in the child manifest overrides content in the parent manifest, if the two conflict.</p>
|
||||
|
||||
<p>This technique helps in these and other scenarios:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>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.</p></li>
|
||||
<li><p>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.</p></li>
|
||||
</ul>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p>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 <code>base-manifest.yml</code> begins like this:</p>
|
||||
|
||||
<pre>---
|
||||
...
|
||||
inherit: base-manifest.yml
|
||||
</pre>
|
||||
|
||||
<p>You do not need to add anything to the parent manifest.</p>
|
||||
|
||||
<p>In the simple example below, a parent manifest gives each application minimal resources, while a production child manifest scales them up.</p>
|
||||
|
||||
<p><strong>simple-base-manifest.yml</strong></p>
|
||||
|
||||
<pre>---
|
||||
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
|
||||
</pre>
|
||||
|
||||
<p><strong>simple-prod-manifest.yml</strong></p>
|
||||
|
||||
<pre>---
|
||||
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
|
||||
</pre>
|
||||
|
||||
<p><class='note'><strong>Note</strong>: 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.</class='note'>
|
||||
@@ -0,0 +1,63 @@
|
||||
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.
|
||||
@@ -0,0 +1,11 @@
|
||||
<p>Use the <code>instances</code> attribute to specify the number of app instances that you want to start upon push:</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
instances: 2
|
||||
</pre>
|
||||
|
||||
<p>We recommend that you run at least two instances of any apps for which fault tolerance matters.</p>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-i</code>.</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
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`.
|
||||
@@ -0,0 +1,11 @@
|
||||
<p>Use the <code>memory</code> attribute to specify the memory limit for all instances of an app. This attribute requires a unit of measurement: <code>M</code>, <code>MB</code>, <code>G</code>, or <code>GB</code>, in upper case or lower case. For example:</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
memory: 1024M
|
||||
</pre>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-m</code>.</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
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`.
|
||||
@@ -0,0 +1,10 @@
|
||||
<p>The <code>name</code> attribute is the only required attribute
|
||||
for an application in a manifest file. </p>
|
||||
|
||||
<p>This is an example of a minimal manifest:</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
applications:
|
||||
- name: nifty-gui
|
||||
</pre>
|
||||
@@ -0,0 +1,9 @@
|
||||
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
|
||||
```
|
||||
@@ -0,0 +1,9 @@
|
||||
<p>By default, if you do not provide a hostname, the URL for the app takes the form of <code>APP-NAME.DOMAIN</code>. If you want to override this and map the root domain to this app then you can set no-hostname as true.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
no-hostname: true
|
||||
</pre>
|
||||
|
||||
<p>The command line option that corresponds to this attribute is <code>--no-hostname</code>.</p>
|
||||
@@ -0,0 +1,9 @@
|
||||
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`.
|
||||
@@ -0,0 +1,18 @@
|
||||
<p>By default, <code>cf push</code> assigns a route to every application. But some applications process data while running in the background, and should not be assigned routes.</p>
|
||||
|
||||
<p>You can use the <code>no-route</code> attribute with a value of <code>true</code> to prevent a route from being created for your application.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
no-route: true
|
||||
</pre>
|
||||
|
||||
<p>The command line option that corresponds to this attribute is <code>--no-route</code>.</p>
|
||||
|
||||
<p>If you find that an application which should not have a route does have one:</p>
|
||||
|
||||
<ol>
|
||||
<li>Remove the route using the <code>cf unmap-route</code> command.</li>
|
||||
<li>Push the app again with the <code>no-route: true</code> attribute in the manifest or the <code>--no-route</code> command line option.</li>
|
||||
</ol>
|
||||
@@ -0,0 +1,16 @@
|
||||
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.
|
||||
@@ -0,0 +1,9 @@
|
||||
<p>You can use the <code>path</code> attribute to tell Cloud Foundry where to find your application. This is generally not necessary when you run <code>cf push</code> from the directory where an application is located.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
path: path_to_application_bits
|
||||
</pre>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-p</code>.</p>
|
||||
@@ -0,0 +1,9 @@
|
||||
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`.
|
||||
@@ -0,0 +1,11 @@
|
||||
<p>Use the <code>random-route</code> 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.</p>
|
||||
|
||||
<p>The command line option that corresponds to this attribute is <code>--random-route</code>.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
random-route: true
|
||||
</pre>
|
||||
@@ -0,0 +1,9 @@
|
||||
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
|
||||
```
|
||||
@@ -0,0 +1,18 @@
|
||||
<p>Applications can bind to services such as databases, messaging, and key-value stores.</p>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p>The <code>services</code> block consists of a heading, then one or more service instance names.</p>
|
||||
|
||||
<p>Whoever creates the service chooses the service instance names. These names can convey logical information, as in <code>backend_queue</code>, describe the nature of the service, as in <code>mysql_5.x</code>, or do neither, as in the example below.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
services:
|
||||
- instance_ABC
|
||||
- instance_XYZ
|
||||
</pre>
|
||||
|
||||
<p>Binding to a service instance is a special case of setting an environment
|
||||
variable, namely <code>VCAP_SERVICES</code>.
|
||||
@@ -0,0 +1,17 @@
|
||||
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`.
|
||||
@@ -0,0 +1,11 @@
|
||||
<p>Use the <code>stack</code> attribute to specify which stack to deploy your application to.</p>
|
||||
|
||||
<p>To see a list of available stacks, run <code>cf stacks</code> from the cf cli.</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
stack: cflinuxfs2
|
||||
</pre>
|
||||
|
||||
<p>The command line option that overrides this attribute is <code>-s</code>.</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
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`.
|
||||
@@ -0,0 +1,14 @@
|
||||
<p>The <code>timeout</code> attribute defines the number of seconds Cloud Foundry allocates for starting your application. </p>
|
||||
|
||||
<p>For example:</p>
|
||||
|
||||
<pre>
|
||||
---
|
||||
...
|
||||
timeout: 80
|
||||
</pre>
|
||||
|
||||
<p>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.</p>
|
||||
<p class="note"><strong>Note</strong>: Administrators can set the upper bound of the <code>maximum_health_check_timeout</code> property to any value. Any changes to Cloud Controller properties in the deployment manifest require running <code>bosh deploy</code>.</p>
|
||||
|
||||
<p>The command line option that overrides the timeout attribute for the shell is <code>-t</code>. Manifest values still apply to applications pushed to the deployment.</p>
|
||||
@@ -0,0 +1,15 @@
|
||||
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.
|
||||
@@ -0,0 +1,492 @@
|
||||
/*******************************************************************************
|
||||
* 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 org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
|
||||
public class ManifestYamlEditorTest {
|
||||
|
||||
LanguageServerHarness harness;
|
||||
|
||||
@Before public void setup() throws Exception {
|
||||
harness = new LanguageServerHarness(ManifestYamlLanguageServer::new);
|
||||
harness.intialize(null);
|
||||
}
|
||||
|
||||
@Test public void testReconcileCatchesParseError() throws Exception {
|
||||
|
||||
Editor editor = harness.newEditor(
|
||||
"somemap: val\n"+
|
||||
"- sequence"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"-|expected <block end>"
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void reconcileRunsOnDocumentOpenAndChange() throws Exception {
|
||||
LanguageServerHarness harness = new LanguageServerHarness(ManifestYamlLanguageServer::new);
|
||||
harness.intialize(null);
|
||||
|
||||
Editor editor = harness.newEditor(
|
||||
"somemap: val\n"+
|
||||
"- sequence"
|
||||
);
|
||||
|
||||
editor.assertProblems(
|
||||
"-|expected <block end>"
|
||||
);
|
||||
|
||||
editor.setText(
|
||||
"- sequence\n" +
|
||||
"zomemap: val"
|
||||
);
|
||||
|
||||
editor.assertProblems(
|
||||
"z|expected <block end>"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reconcileMisSpelledPropertyNames() throws Exception {
|
||||
Editor editor;
|
||||
|
||||
editor = harness.newEditor(
|
||||
"memory: 1G\n" +
|
||||
"aplications:\n" +
|
||||
" - buildpack: zbuildpack\n" +
|
||||
" domain: zdomain\n" +
|
||||
" name: foo"
|
||||
);
|
||||
editor.assertProblems("aplications|Unknown property");
|
||||
|
||||
//mispelled or not allowed at toplevel
|
||||
editor = harness.newEditor(
|
||||
"name: foo\n" +
|
||||
"buildpeck: yahah\n" +
|
||||
"memory: 1G\n" +
|
||||
"memori: 1G\n"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"name|Unknown property",
|
||||
"buildpeck|Unknown property",
|
||||
"memori|Unknown property"
|
||||
);
|
||||
|
||||
//mispelled or not allowed as nested
|
||||
editor = harness.newEditor(
|
||||
"applications:\n" +
|
||||
"- name: fine\n" +
|
||||
" buildpeck: yahah\n" +
|
||||
" memory: 1G\n" +
|
||||
" memori: 1G\n" +
|
||||
" applications: bad\n"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"buildpeck|Unknown property",
|
||||
"memori|Unknown property",
|
||||
"applications|Unknown property"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reconcileStructuralProblems() throws Exception {
|
||||
Editor editor;
|
||||
|
||||
//forgot the 'applications:' heading
|
||||
editor = harness.newEditor(
|
||||
"- name: foo"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"- name: foo|Expecting a 'Map' but found a 'Sequence'"
|
||||
);
|
||||
|
||||
//forgot to make the '-' after applications
|
||||
editor = harness.newEditor(
|
||||
"applications:\n" +
|
||||
" name: foo"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"name: foo|Expecting a 'Sequence' but found a 'Map'"
|
||||
);
|
||||
|
||||
//Using a 'composite' element where a scalar type is expected
|
||||
editor = harness.newEditor(
|
||||
"memory:\n"+
|
||||
"- bad sequence\n" +
|
||||
"buildpack:\n" +
|
||||
" bad: map\n"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"- bad sequence|Expecting a 'Memory' but found a 'Sequence'",
|
||||
"bad: map|Expecting a 'Buildpack' but found a 'Map'"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reconcileSimpleTypes() throws Exception {
|
||||
Editor editor;
|
||||
|
||||
//check for 'format' errors:
|
||||
editor = harness.newEditor(
|
||||
"applications:\n" +
|
||||
"- name: foo\n" +
|
||||
" instances: not a number\n" +
|
||||
" no-route: notBool\n"+
|
||||
" memory: 1024\n" +
|
||||
" disk_quota: 2048\n" +
|
||||
" health-check-type: unhealthy"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"not a number|Positive Integer",
|
||||
"notBool|boolean",
|
||||
"1024|Memory",
|
||||
"2048|Memory",
|
||||
"unhealthy|Health Check Type"
|
||||
);
|
||||
|
||||
//check for 'range' errors:
|
||||
editor = harness.newEditor(
|
||||
"applications:\n" +
|
||||
"- name: foo\n" +
|
||||
" instances: -3\n" +
|
||||
" memory: -1024M\n" +
|
||||
" disk_quota: -2048M\n"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"-3|Positive Integer",
|
||||
"-1024M|Memory",
|
||||
"-2048M|Memory"
|
||||
);
|
||||
|
||||
//check that correct values are indeed accepted
|
||||
editor = harness.newEditor(
|
||||
"applications:\n" +
|
||||
"- name: foo\n" +
|
||||
" instances: 2\n" +
|
||||
" no-route: true\n"+
|
||||
" memory: 1024M\n" +
|
||||
" disk_quota: 2048MB\n"
|
||||
);
|
||||
editor.assertProblems(/*none*/);
|
||||
|
||||
//check that correct values are indeed accepted
|
||||
editor = harness.newEditor(
|
||||
"applications:\n" +
|
||||
"- name: foo\n" +
|
||||
" instances: 2\n" +
|
||||
" no-route: false\n" +
|
||||
" memory: 1024m\n" +
|
||||
" disk_quota: 2048mb\n"
|
||||
);
|
||||
editor.assertProblems(/*none*/);
|
||||
|
||||
editor = harness.newEditor(
|
||||
"applications:\n" +
|
||||
"- name: foo\n" +
|
||||
" instances: 2\n" +
|
||||
" memory: 1G\n" +
|
||||
" disk_quota: 2g\n"
|
||||
);
|
||||
editor.assertProblems(/*none*/);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noListIndent() throws Exception {
|
||||
Editor editor;
|
||||
editor = harness.newEditor("appl<*>");
|
||||
editor.assertCompletions(
|
||||
"applications:\n"+
|
||||
"- <*>"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toplevelCompletions() throws Exception {
|
||||
Editor editor;
|
||||
editor = harness.newEditor("<*>");
|
||||
editor.assertCompletions(
|
||||
"applications:\n"+
|
||||
"- <*>",
|
||||
// ---------------
|
||||
"buildpack: <*>",
|
||||
// ---------------
|
||||
"command: <*>",
|
||||
// ---------------
|
||||
"disk_quota: <*>",
|
||||
// ---------------
|
||||
"domain: <*>",
|
||||
// ---------------
|
||||
"domains:\n"+
|
||||
"- <*>",
|
||||
// ---------------
|
||||
"env:\n"+
|
||||
" <*>",
|
||||
// ---------------
|
||||
"health-check-type: <*>",
|
||||
// ---------------
|
||||
// "host: <*>",
|
||||
// ---------------
|
||||
// "hosts: \n"+
|
||||
// " - <*>",
|
||||
// ---------------
|
||||
"inherit: <*>",
|
||||
// ---------------
|
||||
"instances: <*>",
|
||||
// ---------------
|
||||
"memory: <*>",
|
||||
// ---------------
|
||||
// "name: <*>",
|
||||
// ---------------
|
||||
"no-hostname: <*>",
|
||||
// ---------------
|
||||
"no-route: <*>",
|
||||
// ---------------
|
||||
"path: <*>",
|
||||
// ---------------
|
||||
"random-route: <*>",
|
||||
// ---------------
|
||||
"services:\n"+
|
||||
"- <*>",
|
||||
// ---------------
|
||||
"stack: <*>",
|
||||
// ---------------
|
||||
"timeout: <*>"
|
||||
);
|
||||
|
||||
editor = harness.newEditor("ranro<*>");
|
||||
editor.assertCompletions(
|
||||
"random-route: <*>"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nestedCompletions() throws Exception {
|
||||
Editor editor;
|
||||
editor = harness.newEditor(
|
||||
"applications:\n" +
|
||||
"- <*>"
|
||||
);
|
||||
editor.assertCompletions(
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- buildpack: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- command: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- disk_quota: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- domain: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- domains:\n"+
|
||||
" - <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- env:\n"+
|
||||
" <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- health-check-type: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- host: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- hosts:\n"+
|
||||
" - <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- instances: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- memory: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- name: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- no-hostname: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- no-route: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- path: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- random-route: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- services:\n"+
|
||||
" - <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- stack: <*>",
|
||||
// ---------------
|
||||
"applications:\n" +
|
||||
"- timeout: <*>"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void completionDetailsAndDocs() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"applications:\n" +
|
||||
"- build<*>"
|
||||
);
|
||||
editor.assertCompletionDetails("buildpack", "Buildpack", "If your application requires a custom buildpack");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valueCompletions() throws Exception {
|
||||
assertCompletions("disk_quota: <*>",
|
||||
"disk_quota: 1024M<*>",
|
||||
"disk_quota: 256M<*>",
|
||||
"disk_quota: 512M<*>"
|
||||
);
|
||||
assertCompletions("memory: <*>",
|
||||
"memory: 1024M<*>",
|
||||
"memory: 256M<*>",
|
||||
"memory: 512M<*>"
|
||||
);
|
||||
assertCompletions("no-hostname: <*>",
|
||||
"no-hostname: false<*>",
|
||||
"no-hostname: true<*>"
|
||||
);
|
||||
assertCompletions("no-route: <*>",
|
||||
"no-route: false<*>",
|
||||
"no-route: true<*>"
|
||||
);
|
||||
assertCompletions("random-route: <*>",
|
||||
"random-route: false<*>",
|
||||
"random-route: true<*>"
|
||||
);
|
||||
|
||||
assertCompletions("health-check-type: <*>",
|
||||
"health-check-type: none<*>",
|
||||
"health-check-type: port<*>"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hoverInfos() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"memory: 1G\n" +
|
||||
"#comment\n" +
|
||||
"inherit: base-manifest.yml\n"+
|
||||
"applications:\n" +
|
||||
"- buildpack: zbuildpack\n" +
|
||||
" domain: zdomain\n" +
|
||||
" name: foo\n" +
|
||||
" command: java main.java\n" +
|
||||
" disk_quota: 1024M\n" +
|
||||
" domains:\n" +
|
||||
" - pivotal.io\n" +
|
||||
" - otherdomain.org\n" +
|
||||
" env:\n" +
|
||||
" RAILS_ENV: production\n" +
|
||||
" RACK_ENV: production\n" +
|
||||
" host: apppage\n" +
|
||||
" hosts:\n" +
|
||||
" - apppage2\n" +
|
||||
" - appage3\n" +
|
||||
" instances: 2\n" +
|
||||
" no-hostname: true\n" +
|
||||
" no-route: true\n" +
|
||||
" path: somepath/app.jar\n" +
|
||||
" random-route: true\n" +
|
||||
" services:\n" +
|
||||
" - instance_ABC\n" +
|
||||
" - instance_XYZ\n" +
|
||||
" stack: cflinuxfs2\n" +
|
||||
" timeout: 80\n" +
|
||||
" health-check-type: none\n"
|
||||
);
|
||||
|
||||
editor.assertIsHoverRegion("memory");
|
||||
editor.assertIsHoverRegion("inherit");
|
||||
editor.assertIsHoverRegion("applications");
|
||||
editor.assertIsHoverRegion("buildpack");
|
||||
editor.assertIsHoverRegion("domain");
|
||||
editor.assertIsHoverRegion("name");
|
||||
editor.assertIsHoverRegion("command");
|
||||
editor.assertIsHoverRegion("disk_quota");
|
||||
editor.assertIsHoverRegion("domains");
|
||||
editor.assertIsHoverRegion("env");
|
||||
editor.assertIsHoverRegion("host");
|
||||
editor.assertIsHoverRegion("hosts");
|
||||
editor.assertIsHoverRegion("instances");
|
||||
editor.assertIsHoverRegion("no-hostname");
|
||||
editor.assertIsHoverRegion("no-route");
|
||||
editor.assertIsHoverRegion("path");
|
||||
editor.assertIsHoverRegion("random-route");
|
||||
editor.assertIsHoverRegion("services");
|
||||
editor.assertIsHoverRegion("stack");
|
||||
editor.assertIsHoverRegion("timeout");
|
||||
editor.assertIsHoverRegion("health-check-type");
|
||||
|
||||
editor.assertHoverContains("memory", "Use the `memory` attribute to specify the memory limit");
|
||||
editor.assertHoverContains("1G", "Use the `memory` attribute to specify the memory limit");
|
||||
editor.assertHoverContains("inherit", "For example, every child of a parent manifest called `base-manifest.yml` begins like this");
|
||||
editor.assertHoverContains("buildpack", "use the `buildpack` attribute to specify its URL or name");
|
||||
editor.assertHoverContains("name", "The `name` attribute is the only required attribute for an application in a manifest file");
|
||||
editor.assertHoverContains("command", "On the command line, use the `-c` option to specify the custom start command as the following example shows");
|
||||
editor.assertHoverContains("disk_quota", "Use the `disk_quota` attribute to allocate the disk space for your app instance");
|
||||
editor.assertHoverContains("domain", "You can use the `domain` attribute when you want your application to be served");
|
||||
editor.assertHoverContains("domains", "Use the `domains` attribute to provide multiple domains");
|
||||
editor.assertHoverContains("env", "The `env` block consists of a heading, then one or more environment variable/value pairs");
|
||||
editor.assertHoverContains("host", "Use the `host` attribute to provide a hostname, or subdomain, in the form of a string");
|
||||
editor.assertHoverContains("hosts", "Use the `hosts` attribute to provide multiple hostnames, or subdomains");
|
||||
editor.assertHoverContains("instances", "Use the `instances` attribute to specify the number of app instances that you want to start upon push");
|
||||
editor.assertHoverContains("no-hostname", "By default, if you do not provide a hostname, the URL for the app takes the form of `APP-NAME.DOMAIN`");
|
||||
editor.assertHoverContains("no-route", "You can use the `no-route` attribute with a value of `true` to prevent a route from being created for your application");
|
||||
editor.assertHoverContains("path", "You can use the `path` attribute to tell Cloud Foundry where to find your application");
|
||||
editor.assertHoverContains("random-route", "Use the `random-route` attribute to create a URL that includes the app name and random words");
|
||||
editor.assertHoverContains("services", "The `services` block consists of a heading, then one or more service instance names");
|
||||
editor.assertHoverContains("stack", "Use the `stack` attribute to specify which stack to deploy your application to.");
|
||||
editor.assertHoverContains("timeout", "The `timeout` attribute defines the number of seconds Cloud Foundry allocates for starting your application");
|
||||
editor.assertHoverContains("health-check-type", "Use the `health-check-type` attribute to");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noHoverInfos() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"#comment\n" +
|
||||
"applications:\n" +
|
||||
"- buildpack: zbuildpack\n" +
|
||||
" name: foo\n" +
|
||||
" domains:\n" +
|
||||
" - pivotal.io\n" +
|
||||
" - otherdomain.org\n"
|
||||
|
||||
);
|
||||
editor.assertNoHover("comment");
|
||||
|
||||
// May fail in the future if hover support is added, but if hover support is added in the future,
|
||||
// it is expected that these should start to fail, as right now they have no hover
|
||||
editor.assertNoHover("pivotal.io");
|
||||
editor.assertNoHover("otherdomain.org");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void assertCompletions(String textBefore, String... textAfter) throws Exception {
|
||||
Editor editor = harness.newEditor(textBefore);
|
||||
editor.assertCompletions(textAfter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.TextDocumentSyncKind;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
|
||||
public class ManifestYamlLanguageServerTest {
|
||||
|
||||
public static File getTestResource(String name) throws URISyntaxException {
|
||||
return Paths.get(ManifestYamlLanguageServerTest.class.getResource(name).toURI()).toFile();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createAndInitializeServerWithWorkspace() throws Exception {
|
||||
LanguageServerHarness harness = new LanguageServerHarness(ManifestYamlLanguageServer::new);
|
||||
File workspaceRoot = getTestResource("/workspace/");
|
||||
assertExpectedInitResult(harness.intialize(workspaceRoot));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createAndInitializeServerWithoutWorkspace() throws Exception {
|
||||
File workspaceRoot = null;
|
||||
LanguageServerHarness harness = new LanguageServerHarness(ManifestYamlLanguageServer::new);
|
||||
assertExpectedInitResult(harness.intialize(workspaceRoot));
|
||||
}
|
||||
|
||||
// @Test public void completions() throws Exception {
|
||||
// LanguageServerHarness harness = new LanguageServerHarness(ManifestYamlLanguageServer::new);
|
||||
//
|
||||
// File workspaceRoot = getTestResource("/workspace/");
|
||||
// assertExpectedInitResult(harness.intialize(workspaceRoot));
|
||||
//
|
||||
// TextDocumentInfo doc = harness.openDocument(getTestResource("/workspace/testfile.yml"));
|
||||
//
|
||||
// CompletionList completions = harness.getCompletions(doc, doc.positionOf("foo"));
|
||||
// assertThat(completions.isIncomplete()).isFalse();
|
||||
// assertThat(completions.getItems())
|
||||
// .extracting(CompletionItem::getLabel)
|
||||
// .containsExactly("TypeScript", "JavaScript");
|
||||
//
|
||||
// List<CompletionItem> resolved = harness.resolveCompletions(completions);
|
||||
// assertThat(resolved)
|
||||
// .extracting(CompletionItem::getLabel)
|
||||
// .containsExactly("TypeScript", "JavaScript");
|
||||
//
|
||||
// assertThat(resolved)
|
||||
// .extracting(CompletionItem::getDetail)
|
||||
// .containsExactly("TypeScript details", "JavaScript details");
|
||||
//
|
||||
// assertThat(resolved)
|
||||
// .extracting(CompletionItem::getDocumentation)
|
||||
// .containsExactly("TypeScript docs", "JavaScript docs");
|
||||
// }
|
||||
|
||||
private void assertExpectedInitResult(InitializeResult initResult) {
|
||||
assertThat(initResult.getCapabilities().getCompletionProvider().getResolveProvider()).isFalse();
|
||||
assertThat(initResult.getCapabilities().getTextDocumentSync()).isEqualTo(TextDocumentSyncKind.Incremental);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
/*******************************************************************************
|
||||
* 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
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
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 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",
|
||||
// "host",
|
||||
// "hosts",
|
||||
"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<YTypedProperty> getNestedProps() {
|
||||
YSeqType applications = (YSeqType) schema.getTopLevelType().getPropertiesMap().get("applications").getType();
|
||||
YBeanType application = (YBeanType) applications.getDomainType();
|
||||
return application.getProperties();
|
||||
}
|
||||
|
||||
private void assertPropNames(List<YTypedProperty> properties, String... expectedNames) {
|
||||
assertEquals(ImmutableSet.copyOf(expectedNames), getNames(properties));
|
||||
}
|
||||
|
||||
private void assertPropNames(Map<String, YTypedProperty> propertiesMap, String[] toplevelPropNames) {
|
||||
assertEquals(ImmutableSet.copyOf(toplevelPropNames), ImmutableSet.copyOf(propertiesMap.keySet()));
|
||||
}
|
||||
|
||||
private ImmutableSet<String> getNames(Iterable<YTypedProperty> properties) {
|
||||
Builder<String> builder = ImmutableSet.builder();
|
||||
for (YTypedProperty p : properties) {
|
||||
builder.add(p.getName());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#Comment
|
||||
applications:
|
||||
- name: foo
|
||||
buildpack: something
|
||||
|
||||
4
vscode-extensions/vscode-concourse/test/examples/destroy-pipeline.sh
Executable file
4
vscode-extensions/vscode-concourse/test/examples/destroy-pipeline.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
branch=`git rev-parse --abbrev-ref HEAD`
|
||||
fly -t tools destroy-pipeline -p sts4-${branch}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
FROM ubuntu:16.04
|
||||
|
||||
ADD npmrc /root/.npmrc
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
gettext-base \
|
||||
git \
|
||||
jq \
|
||||
openjdk-8-jdk \
|
||||
maven \
|
||||
curl
|
||||
|
||||
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
|
||||
&& apt-get install -y nodejs
|
||||
|
||||
CMD /bin/bash
|
||||
@@ -0,0 +1 @@
|
||||
unsafe-perm=true
|
||||
116
vscode-extensions/vscode-concourse/test/examples/pipeline.yml
Normal file
116
vscode-extensions/vscode-concourse/test/examples/pipeline.yml
Normal file
@@ -0,0 +1,116 @@
|
||||
##########################################################
|
||||
resource_types:
|
||||
- name: s3-multi
|
||||
type: docker-image
|
||||
source:
|
||||
repository: kdvolder/s3-resource-simple
|
||||
- name: slack-notification
|
||||
type: docker-image
|
||||
source:
|
||||
repository: cfcommunity/slack-notification-resource
|
||||
tag: latest
|
||||
#########################################################
|
||||
resources:
|
||||
- name: docker-git
|
||||
type: git
|
||||
source:
|
||||
uri: git@github.com:spring-projects/sts4.git
|
||||
branch: {{branch}}
|
||||
username: kdvolder
|
||||
private_key: {{rsa_id}}
|
||||
paths:
|
||||
- concourse/docker
|
||||
- name: sts4
|
||||
type: git
|
||||
source:
|
||||
uri: git@github.com:spring-projects/sts4.git
|
||||
branch: {{branch}}
|
||||
private_key: {{rsa_id}}
|
||||
- name: s3-boot-properties-vsix
|
||||
type: s3
|
||||
source:
|
||||
bucket: {{s3_bucket}}
|
||||
access_key_id: {{s3_accesskey}}
|
||||
secret_access_key: {{s3_secretkey}}
|
||||
region_name: {{s3_region}}
|
||||
regexp: sts4/vscode-extensions/vscode-boot-properties-(.*).vsix
|
||||
- name: s3-manifest-yaml-vsix
|
||||
type: s3
|
||||
source:
|
||||
bucket: {{s3_bucket}}
|
||||
access_key_id: {{s3_accesskey}}
|
||||
secret_access_key: {{s3_secretkey}}
|
||||
region_name: {{s3_region}}
|
||||
regexp: sts4/vscode-extensions/vscode-manifest-yaml-(.*).vsix
|
||||
- name: website
|
||||
type: s3-multi
|
||||
source:
|
||||
bucket: {{s3_prod_bucket}}
|
||||
access_key_id: {{s3_prod_accesskey}}
|
||||
secret_access_key: {{s3_prod_secretkey}}
|
||||
region_name: {{s3_region}}
|
||||
path: snapshot/STS4/vscode-extensions
|
||||
options:
|
||||
- "--acl public-read"
|
||||
- name: slack-notification
|
||||
type: slack-notification
|
||||
source:
|
||||
url: https://hooks.slack.com/services/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
|
||||
- name: docker-image
|
||||
type: docker-image
|
||||
source:
|
||||
username: {{docker_hub_username}}
|
||||
email: {{docker_hub_email}}
|
||||
password: {{docker_hub_password}}
|
||||
repository: kdvolder/sts4-build-env
|
||||
########################################################################################
|
||||
jobs:
|
||||
- name: build-docker-image
|
||||
serial: true
|
||||
plan:
|
||||
- get: docker-git
|
||||
trigger: true
|
||||
- put: docker-image
|
||||
params:
|
||||
build: docker-git/concourse/docker
|
||||
get_params:
|
||||
skip_download: true
|
||||
- name: build-vsix
|
||||
plan:
|
||||
- get: sts4
|
||||
trigger: true
|
||||
- task: build-vscode-extensions
|
||||
file: sts4/concourse/tasks/build-vscode-extensions.yml
|
||||
on_success:
|
||||
aggregate:
|
||||
- put: s3-manifest-yaml-vsix
|
||||
params:
|
||||
file: vsix-files/vscode-manifest-yaml-*.vsix
|
||||
acl: public-read
|
||||
- put: s3-boot-properties-vsix
|
||||
params:
|
||||
file: vsix-files/vscode-boot-properties-*.vsix
|
||||
acl: public-read
|
||||
on_failure:
|
||||
put: slack-notification
|
||||
params:
|
||||
channel: "@kdvolder"
|
||||
text: |
|
||||
Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
|
||||
- name: build-website
|
||||
plan:
|
||||
- aggregate:
|
||||
- get: sts4
|
||||
- get: s3-manifest-yaml-vsix
|
||||
passed:
|
||||
- build-vsix
|
||||
trigger: true
|
||||
- get: s3-boot-properties-vsix
|
||||
passed:
|
||||
- build-vsix
|
||||
trigger: true
|
||||
- task: build-website
|
||||
file: sts4/concourse/tasks/build-website.yml
|
||||
- put: website
|
||||
params:
|
||||
path: website
|
||||
3
vscode-extensions/vscode-concourse/test/examples/set-pipeline.sh
Executable file
3
vscode-extensions/vscode-concourse/test/examples/set-pipeline.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
branch=`git rev-parse --abbrev-ref HEAD`
|
||||
fly -t tools set-pipeline --var "branch=${branch}" --load-vars-from ${HOME}/.sts4-concourse-credentials.yml -p sts4-${branch} -c pipeline.yml
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
workdir=`pwd`
|
||||
|
||||
cd sts4/vscode-extensions
|
||||
./build-all.sh
|
||||
|
||||
cd $workdir
|
||||
cp `find sts4/vscode-extensions -name "*.vsix"` vsix-files
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
inputs:
|
||||
- name: sts4
|
||||
outputs:
|
||||
- name: vsix-files
|
||||
platform: linux
|
||||
image_resource:
|
||||
type: docker-image
|
||||
source:
|
||||
repository: kdvolder/sts4-build-env
|
||||
run:
|
||||
path: "sts4/concourse/tasks/build-vscode-extensions.sh"
|
||||
43
vscode-extensions/vscode-concourse/test/examples/tasks/build-website.sh
Executable file
43
vscode-extensions/vscode-concourse/test/examples/tasks/build-website.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
workdir=`pwd`
|
||||
sources=$workdir/sts4/eclipse-distribution/common/html
|
||||
target=$workdir/website
|
||||
|
||||
#cp -r "${sources}/stylesheet.css" "$target"
|
||||
#cp -r ${sources}/*.js "$target"
|
||||
#cp s3-manifest-yaml-vsix/*.vsix "$target"
|
||||
#cp s3-boot-properties-vsix/*.vsix "$target"
|
||||
|
||||
export vscode_manifest_yaml=$(basename s3-manifest-yaml-vsix/*.vsix)
|
||||
echo "vscode_manifest_yaml=$vscode_manifest_yaml"
|
||||
export vscode_boot_properties=$(basename s3-boot-properties-vsix/*.vsix)
|
||||
echo "vscode_boot_properties=$vscode_boot_properties"
|
||||
|
||||
envsubst > "$target/vscode-extensions-snippet.html" << XXXXXX
|
||||
<ul>
|
||||
<li>Spring Boot Property Language Server:
|
||||
<a href="http://s3-test.spring.io/sts4/vscode-extensions/${vscode_boot_properties}">${vscode_boot_properties}</a>
|
||||
</li>
|
||||
<li>Cloud Foundry Manifest Language Server:
|
||||
<a href="http://s3-test.spring.io/sts4/vscode-extensions/${vscode_manifest_yaml}">${vscode_manifest_yaml}</a>
|
||||
</li>
|
||||
</ul>
|
||||
XXXXXX
|
||||
|
||||
export vscode_snippet=`cat "$target/vscode-extensions-snippet.html"`
|
||||
|
||||
envsubst > "$target/vscode-extensions.html" << XXXXXX
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>STS4 Vscode Extensions</h1>
|
||||
|
||||
$vscode_snippet
|
||||
|
||||
</body>
|
||||
</html>
|
||||
XXXXXX
|
||||
|
||||
cat $target/vscode-extensions.html
|
||||
@@ -0,0 +1,13 @@
|
||||
inputs:
|
||||
- name: sts4
|
||||
- name: s3-manifest-yaml-vsix
|
||||
- name: s3-boot-properties-vsix
|
||||
outputs:
|
||||
- name: website
|
||||
platform: linux
|
||||
image_resource:
|
||||
type: docker-image
|
||||
source:
|
||||
repository: kdvolder/sts4-build-env
|
||||
run:
|
||||
path: "sts4/concourse/tasks/build-website.sh"
|
||||
21
vscode-extensions/vscode-concourse/tsconfig.json
Normal file
21
vscode-extensions/vscode-concourse/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"declaration": true,
|
||||
"outDir": "out",
|
||||
"sourceMap": true,
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": [
|
||||
"typings/*.d.ts",
|
||||
"lib/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
12
vscode-extensions/vscode-concourse/tsd.json
Normal file
12
vscode-extensions/vscode-concourse/tsd.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": "v4",
|
||||
"repo": "borisyankov/DefinitelyTyped",
|
||||
"ref": "master",
|
||||
"path": "typings",
|
||||
"bundle": "typings/tsd.d.ts",
|
||||
"installed": {
|
||||
"node/node.d.ts": {
|
||||
"commit": "d22516f9f089de107d7e7d5938566377370631f6"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user