Skip to content

Commit a1f3da0

Browse files
committed
Concourse editor: support for semver driver 'gcs'
See #60
1 parent 0d4c3b8 commit a1f3da0

File tree

5 files changed

+82
-2
lines changed

5 files changed

+82
-2
lines changed

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,13 @@ private void initializeDefaultResourceTypes() {
605605
AbstractType swift_source = f.ybean("SwiftSemverSource");
606606
addProp(swift_source, "openstack", t_any).isPrimary(true);
607607

608+
AbstractType gcs_source = f.ybean("GcsSemverSource");
609+
addProp(gcs_source, "bucket", t_ne_string).isRequired(true);
610+
addProp(gcs_source, "key", t_ne_string).isRequired(true);
611+
addProp(gcs_source, "json_key", t_ne_string).isRequired(true);
612+
608613
AbstractType[] driverSpecificSources = {
609-
git_source, s3_source, swift_source
614+
git_source, s3_source, swift_source, gcs_source
610615
};
611616

612617
AbstractType source = f.contextAware("SemverSource", (dc) -> {
@@ -617,12 +622,14 @@ private void initializeDefaultResourceTypes() {
617622
return s3_source;
618623
case "swift":
619624
return swift_source;
625+
case "gcs":
626+
return gcs_source;
620627
default:
621628
return null;
622629
}
623630
}).treatAsBean();
624631
addProp(source, "initial_version", t_semver);
625-
addProp(source, "driver", f.yenum("SemverDriver", "git", "s3", "swift")).isPrimary(true, false);
632+
addProp(source, "driver", f.yenum("SemverDriver", "git", "s3", "swift", "gcs")).isPrimary(true, false);
626633
for (AbstractType s : driverSpecificSources) {
627634
for (YTypedProperty p : source.getProperties()) {
628635
s.addProperty(p);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*Required*. The name of the bucket.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*Required*. The contents of your GCP Account JSON Key. Example:
2+
3+
json_key: |
4+
{
5+
"private_key_id": "...",
6+
"private_key": "...",
7+
"client_email": "...",
8+
"client_id": "...",
9+
"type": "service_account"
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*Required*. The key to use for the object in the bucket tracking the version.

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

+61
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,20 @@ public void resourceAttributeHovers() throws Exception {
21432143
"version|Unused",
21442144
"source|'openstack' is required"
21452145
);
2146+
2147+
//required props for gcs driver
2148+
editor = harness.newEditor(
2149+
"resources:\n" +
2150+
"- name: version\n" +
2151+
" type: semver\n" +
2152+
" check_every: 1h \n" +
2153+
" source:\n" +
2154+
" driver: gcs"
2155+
);
2156+
editor.assertProblems(
2157+
"version|Unused",
2158+
"source|Properties [bucket, json_key, key] are required"
2159+
);
21462160
}
21472161

21482162
@Test public void semverResourceSourceBadDriver() throws Exception {
@@ -2159,6 +2173,53 @@ public void resourceAttributeHovers() throws Exception {
21592173
);
21602174
}
21612175

2176+
@Test public void semverGcsResourceSourceContentAssist() throws Exception {
2177+
assertContextualCompletions(PLAIN_COMPLETION,
2178+
"resources:\n" +
2179+
"- name: version\n" +
2180+
" type: semver\n" +
2181+
" source:\n" +
2182+
" driver: gcs\n" +
2183+
" <*>"
2184+
, // ===========
2185+
"<*>"
2186+
, // ==>
2187+
"bucket: $1\n" +
2188+
" key: $2\n" +
2189+
" json_key: $3<*>"
2190+
, // --
2191+
"bucket: <*>",
2192+
"json_key: <*>",
2193+
"key: <*>"
2194+
);
2195+
}
2196+
2197+
@Test public void semverGcsResourceReconcileAndHover() throws Exception {
2198+
Editor editor;
2199+
2200+
// required props for git driver
2201+
editor = harness.newEditor(
2202+
"resources:\n" +
2203+
"- name: version\n" +
2204+
" type: semver\n" +
2205+
" source:\n" +
2206+
" driver: gcs\n" +
2207+
" bucket: some-bucket\n" +
2208+
" key: some-key\n" +
2209+
" json_key: some-json-key-string\n" +
2210+
" bogus: bad"
2211+
);
2212+
editor.assertProblems(
2213+
"version|Unused",
2214+
"bogus|Unknown property"
2215+
);
2216+
2217+
editor.assertHoverContains("driver", "The driver to use");
2218+
editor.assertHoverContains("bucket", "The name of the bucket");
2219+
editor.assertHoverContains("key", "key to use for the object in the bucket tracking the version");
2220+
editor.assertHoverContains("json_key", "contents of your GCP Account JSON Key");
2221+
}
2222+
21622223
@Test public void semverGitResourceSourceContentAssist() throws Exception {
21632224
assertContextualCompletions(PLAIN_COMPLETION,
21642225
"resources:\n" +

0 commit comments

Comments
 (0)