Skip to content

Commit bd0ad52

Browse files
authored
Merge pull request #607 from jghiloni/add-display-support
Add display property to pipeline schema
2 parents a33dc1e + 6e51ca9 commit bd0ad52

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import org.yaml.snakeyaml.nodes.Node;
5959

6060
import com.google.common.collect.ImmutableList;
61-
import com.google.common.collect.ImmutableSet;
6261

6362
/**
6463
* @author Kris De Volder
@@ -456,6 +455,12 @@ public PipelineYmlSchema(ConcourseModel models, GithubInfoProvider github) {
456455
addProp(group, "resources", f.yseq(t_resource_name));
457456
addProp(group, "jobs", f.yseq(t_job_name));
458457

458+
YType t_background_image_def = f.yatomic("Background Image")
459+
.parseWith(ValueParsers.NE_STRING);
460+
461+
AbstractType t_display = f.ybean("Display");
462+
addProp(t_display, "background_image", t_background_image_def).isRequired(true);
463+
459464
YSeqType t_resources = f.yseq(t_resource);
460465
YSeqType t_jobs = f.yseq(job);
461466
YSeqType t_resourceTypes = f.yseq(resourceType);
@@ -464,12 +469,14 @@ public PipelineYmlSchema(ConcourseModel models, GithubInfoProvider github) {
464469
addProp(TOPLEVEL_TYPE, "jobs", t_jobs);
465470
addProp(TOPLEVEL_TYPE, "resource_types", t_resourceTypes);
466471
addProp(TOPLEVEL_TYPE, "groups", t_groups);
472+
addProp(TOPLEVEL_TYPE, "display", t_display);
467473

468474
definitionTypes = ImmutableList.of(
469475
jobNameDef,
470476
resourceTypeNameDef,
471477
t_resource_name_def,
472-
t_group_name_def
478+
t_group_name_def,
479+
t_background_image_def
473480
);
474481
hierarchicDefinitions = ImmutableList.of(
475482
new HierarchicalDefType(t_resources, null, SymbolKind.File, "Resources"),
@@ -482,7 +489,9 @@ public PipelineYmlSchema(ConcourseModel models, GithubInfoProvider github) {
482489
new HierarchicalDefType(resourceType, YamlPath.fromSimpleProperty("name"), SymbolKind.Interface, "Resource Type"),
483490

484491
new HierarchicalDefType(t_groups, null, SymbolKind.Package, "Groups"),
485-
new HierarchicalDefType(group, YamlPath.fromSimpleProperty("name"), SymbolKind.Package, "Groups")
492+
new HierarchicalDefType(group, YamlPath.fromSimpleProperty("name"), SymbolKind.Package, "Groups"),
493+
494+
new HierarchicalDefType(t_display, null, SymbolKind.Package, "Display Settings")
486495
);
487496

488497
initializeDefaultResourceTypes();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Visual configurations for personalizing your pipeline (Concourse 6.6+ only)
2+
3+
You may use this optional section to set a background image on your pipeline.
4+
5+
A simple example looks like this:
6+
7+
display:
8+
background_image: https://avatars1.githubusercontent.com/u/7809479?s=400&v=4

headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java

+33-1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ public class ConcourseEditorTest {
184184
);
185185
}
186186

187+
@Test public void reconcileDisplayType() throws Exception {
188+
Editor editor;
189+
editor = harness.newEditor(
190+
"display:\n" +
191+
" background_image: # <- bad\n"
192+
);
193+
194+
editor.assertProblems(
195+
"^ # <- bad|String should not be empty"
196+
);
197+
}
198+
187199
@Test public void testReconcileCatchesParseError() throws Exception {
188200
Editor editor = harness.newEditor(
189201
"somemap: val\n"+
@@ -493,6 +505,17 @@ public void getStepHovers() throws Exception {
493505
editor.assertHoverContains("ensure", "a second step to execute regardless of the result of the parent step");
494506
}
495507

508+
@Test public void displayHovers() throws Exception {
509+
Editor editor;
510+
editor = harness.newEditor(
511+
"display:\n" +
512+
" background_image: http://google.com/myimage.png\n"
513+
);
514+
515+
editor.assertHoverContains("background_image", "custom background image");
516+
}
517+
518+
496519
@Test
497520
public void groupHovers() throws Exception {
498521
Editor editor = harness.newEditor(
@@ -819,6 +842,9 @@ public void toplevelCompletions() throws Exception {
819842
Editor editor;
820843
editor = harness.newEditor(CURSOR);
821844
editor.assertCompletions(
845+
"display:\n"+
846+
" background_image: <*>"
847+
, // ---------------
822848
"groups:\n" +
823849
"- name: <*>"
824850
, // --------------
@@ -890,6 +916,8 @@ public void valueCompletions() throws Exception {
890916
@Test
891917
public void topLevelHoverInfos() throws Exception {
892918
Editor editor = harness.newEditor(
919+
"display:\n" +
920+
" background_image: http://example.com/fakeimage.png\n" +
893921
"resource_types:\n" +
894922
"- name: s3-multi\n" +
895923
" type: docker-image\n" +
@@ -924,6 +952,7 @@ public void topLevelHoverInfos() throws Exception {
924952
editor.assertHoverContains("resources", "A resource is any entity that can be checked for new versions");
925953
editor.assertHoverContains("jobs", "At a high level, a job describes some actions to perform");
926954
editor.assertHoverContains("groups", "A pipeline may optionally contain a section called `groups`");
955+
editor.assertHoverContains("display", "set a background image on your pipeline");
927956
}
928957

929958
@Test
@@ -4003,11 +4032,12 @@ public void taskWithYamlParams() throws Exception {
40034032
//For the nested context:
40044033
"→ uri",
40054034
// For the top-level context:
4035+
"← display",
40064036
"← groups",
40074037
"← jobs",
40084038
"← resource_types",
40094039
"← - Resource Snippet",
4010-
// For the 'next job' context:
4040+
// For the 'next job' context
40114041
"← - name"
40124042
);
40134043

@@ -4255,6 +4285,7 @@ public void taskWithYamlParams() throws Exception {
42554285
"- try",
42564286
"- aggregate",
42574287
//Dedented completions
4288+
"← display",
42584289
"← groups",
42594290
"← resource_types",
42604291
"← resources",
@@ -4711,6 +4742,7 @@ public void taskWithYamlParams() throws Exception {
47114742
"<*>"
47124743
);
47134744
editor.assertCompletionLabels(
4745+
"display",
47144746
"groups",
47154747
"jobs",
47164748
"resource_types",

0 commit comments

Comments
 (0)