Merge pull request #607 from jghiloni/add-display-support

Add display property to pipeline schema
This commit is contained in:
Kris De Volder
2021-03-05 08:24:16 -08:00
committed by GitHub
4 changed files with 54 additions and 4 deletions

View File

@@ -58,7 +58,6 @@ import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.nodes.Node;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
/**
* @author Kris De Volder
@@ -456,6 +455,12 @@ public class PipelineYmlSchema implements YamlSchema {
addProp(group, "resources", f.yseq(t_resource_name));
addProp(group, "jobs", f.yseq(t_job_name));
YType t_background_image_def = f.yatomic("Background Image")
.parseWith(ValueParsers.NE_STRING);
AbstractType t_display = f.ybean("Display");
addProp(t_display, "background_image", t_background_image_def).isRequired(true);
YSeqType t_resources = f.yseq(t_resource);
YSeqType t_jobs = f.yseq(job);
YSeqType t_resourceTypes = f.yseq(resourceType);
@@ -464,12 +469,14 @@ public class PipelineYmlSchema implements YamlSchema {
addProp(TOPLEVEL_TYPE, "jobs", t_jobs);
addProp(TOPLEVEL_TYPE, "resource_types", t_resourceTypes);
addProp(TOPLEVEL_TYPE, "groups", t_groups);
addProp(TOPLEVEL_TYPE, "display", t_display);
definitionTypes = ImmutableList.of(
jobNameDef,
resourceTypeNameDef,
t_resource_name_def,
t_group_name_def
t_group_name_def,
t_background_image_def
);
hierarchicDefinitions = ImmutableList.of(
new HierarchicalDefType(t_resources, null, SymbolKind.File, "Resources"),
@@ -482,7 +489,9 @@ public class PipelineYmlSchema implements YamlSchema {
new HierarchicalDefType(resourceType, YamlPath.fromSimpleProperty("name"), SymbolKind.Interface, "Resource Type"),
new HierarchicalDefType(t_groups, null, SymbolKind.Package, "Groups"),
new HierarchicalDefType(group, YamlPath.fromSimpleProperty("name"), SymbolKind.Package, "Groups")
new HierarchicalDefType(group, YamlPath.fromSimpleProperty("name"), SymbolKind.Package, "Groups"),
new HierarchicalDefType(t_display, null, SymbolKind.Package, "Display Settings")
);
initializeDefaultResourceTypes();

View File

@@ -0,0 +1 @@
Allow users to specify a custom background image which is put at 30% opacity, grayscaled and blended into existing background. Must be an http, https, or relative URL.

View File

@@ -0,0 +1,8 @@
Visual configurations for personalizing your pipeline (Concourse 6.6+ only)
You may use this optional section to set a background image on your pipeline.
A simple example looks like this:
display:
background_image: https://avatars1.githubusercontent.com/u/7809479?s=400&v=4

View File

@@ -184,6 +184,18 @@ public class ConcourseEditorTest {
);
}
@Test public void reconcileDisplayType() throws Exception {
Editor editor;
editor = harness.newEditor(
"display:\n" +
" background_image: # <- bad\n"
);
editor.assertProblems(
"^ # <- bad|String should not be empty"
);
}
@Test public void testReconcileCatchesParseError() throws Exception {
Editor editor = harness.newEditor(
"somemap: val\n"+
@@ -493,6 +505,17 @@ public class ConcourseEditorTest {
editor.assertHoverContains("ensure", "a second step to execute regardless of the result of the parent step");
}
@Test public void displayHovers() throws Exception {
Editor editor;
editor = harness.newEditor(
"display:\n" +
" background_image: http://google.com/myimage.png\n"
);
editor.assertHoverContains("background_image", "custom background image");
}
@Test
public void groupHovers() throws Exception {
Editor editor = harness.newEditor(
@@ -819,6 +842,9 @@ public class ConcourseEditorTest {
Editor editor;
editor = harness.newEditor(CURSOR);
editor.assertCompletions(
"display:\n"+
" background_image: <*>"
, // ---------------
"groups:\n" +
"- name: <*>"
, // --------------
@@ -890,6 +916,8 @@ public class ConcourseEditorTest {
@Test
public void topLevelHoverInfos() throws Exception {
Editor editor = harness.newEditor(
"display:\n" +
" background_image: http://example.com/fakeimage.png\n" +
"resource_types:\n" +
"- name: s3-multi\n" +
" type: docker-image\n" +
@@ -924,6 +952,7 @@ public class ConcourseEditorTest {
editor.assertHoverContains("resources", "A resource is any entity that can be checked for new versions");
editor.assertHoverContains("jobs", "At a high level, a job describes some actions to perform");
editor.assertHoverContains("groups", "A pipeline may optionally contain a section called `groups`");
editor.assertHoverContains("display", "set a background image on your pipeline");
}
@Test
@@ -4003,11 +4032,12 @@ public class ConcourseEditorTest {
//For the nested context:
"→ uri",
// For the top-level context:
"← display",
"← groups",
"← jobs",
"← resource_types",
"← - Resource Snippet",
// For the 'next job' context:
// For the 'next job' context
"← - name"
);
@@ -4255,6 +4285,7 @@ public class ConcourseEditorTest {
"- try",
"- aggregate",
//Dedented completions
"← display",
"← groups",
"← resource_types",
"← resources",
@@ -4711,6 +4742,7 @@ public class ConcourseEditorTest {
"<*>"
);
editor.assertCompletionLabels(
"display",
"groups",
"jobs",
"resource_types",