Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add display property to pipeline schema #607

Merged
merged 2 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.yaml.snakeyaml.nodes.Node;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;

/**
* @author Kris De Volder
Expand Down Expand Up @@ -456,6 +455,12 @@ public PipelineYmlSchema(ConcourseModel models, GithubInfoProvider github) {
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);
Expand All @@ -464,12 +469,14 @@ public PipelineYmlSchema(ConcourseModel models, GithubInfoProvider github) {
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"),
Expand All @@ -482,7 +489,9 @@ public PipelineYmlSchema(ConcourseModel models, GithubInfoProvider github) {
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"+
Expand Down Expand Up @@ -493,6 +505,17 @@ public void getStepHovers() throws Exception {
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(
Expand Down Expand Up @@ -819,6 +842,9 @@ public void toplevelCompletions() throws Exception {
Editor editor;
editor = harness.newEditor(CURSOR);
editor.assertCompletions(
"display:\n"+
" background_image: <*>"
, // ---------------
"groups:\n" +
"- name: <*>"
, // --------------
Expand Down Expand Up @@ -890,6 +916,8 @@ public void valueCompletions() throws Exception {
@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" +
Expand Down Expand Up @@ -924,6 +952,7 @@ public void topLevelHoverInfos() throws Exception {
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
Expand Down Expand Up @@ -4003,11 +4032,12 @@ public void taskWithYamlParams() throws Exception {
//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"
);

Expand Down Expand Up @@ -4255,6 +4285,7 @@ public void taskWithYamlParams() throws Exception {
"- try",
"- aggregate",
//Dedented completions
"← display",
"← groups",
"← resource_types",
"← resources",
Expand Down Expand Up @@ -4711,6 +4742,7 @@ public void taskWithYamlParams() throws Exception {
"<*>"
);
editor.assertCompletionLabels(
"display",
"groups",
"jobs",
"resource_types",
Expand Down