Concourse editor: support for semver driver 'gcs'
See https://github.com/spring-projects/sts4/issues/60
This commit is contained in:
@@ -605,8 +605,13 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
AbstractType swift_source = f.ybean("SwiftSemverSource");
|
||||
addProp(swift_source, "openstack", t_any).isPrimary(true);
|
||||
|
||||
AbstractType gcs_source = f.ybean("GcsSemverSource");
|
||||
addProp(gcs_source, "bucket", t_ne_string).isRequired(true);
|
||||
addProp(gcs_source, "key", t_ne_string).isRequired(true);
|
||||
addProp(gcs_source, "json_key", t_ne_string).isRequired(true);
|
||||
|
||||
AbstractType[] driverSpecificSources = {
|
||||
git_source, s3_source, swift_source
|
||||
git_source, s3_source, swift_source, gcs_source
|
||||
};
|
||||
|
||||
AbstractType source = f.contextAware("SemverSource", (dc) -> {
|
||||
@@ -617,12 +622,14 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
return s3_source;
|
||||
case "swift":
|
||||
return swift_source;
|
||||
case "gcs":
|
||||
return gcs_source;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}).treatAsBean();
|
||||
addProp(source, "initial_version", t_semver);
|
||||
addProp(source, "driver", f.yenum("SemverDriver", "git", "s3", "swift")).isPrimary(true, false);
|
||||
addProp(source, "driver", f.yenum("SemverDriver", "git", "s3", "swift", "gcs")).isPrimary(true, false);
|
||||
for (AbstractType s : driverSpecificSources) {
|
||||
for (YTypedProperty p : source.getProperties()) {
|
||||
s.addProperty(p);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
*Required*. The name of the bucket.
|
||||
@@ -0,0 +1,10 @@
|
||||
*Required*. The contents of your GCP Account JSON Key. Example:
|
||||
|
||||
json_key: |
|
||||
{
|
||||
"private_key_id": "...",
|
||||
"private_key": "...",
|
||||
"client_email": "...",
|
||||
"client_id": "...",
|
||||
"type": "service_account"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
*Required*. The key to use for the object in the bucket tracking the version.
|
||||
@@ -2143,6 +2143,20 @@ public class ConcourseEditorTest {
|
||||
"version|Unused",
|
||||
"source|'openstack' is required"
|
||||
);
|
||||
|
||||
//required props for gcs driver
|
||||
editor = harness.newEditor(
|
||||
"resources:\n" +
|
||||
"- name: version\n" +
|
||||
" type: semver\n" +
|
||||
" check_every: 1h \n" +
|
||||
" source:\n" +
|
||||
" driver: gcs"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"version|Unused",
|
||||
"source|Properties [bucket, json_key, key] are required"
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void semverResourceSourceBadDriver() throws Exception {
|
||||
@@ -2159,6 +2173,53 @@ public class ConcourseEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void semverGcsResourceSourceContentAssist() throws Exception {
|
||||
assertContextualCompletions(PLAIN_COMPLETION,
|
||||
"resources:\n" +
|
||||
"- name: version\n" +
|
||||
" type: semver\n" +
|
||||
" source:\n" +
|
||||
" driver: gcs\n" +
|
||||
" <*>"
|
||||
, // ===========
|
||||
"<*>"
|
||||
, // ==>
|
||||
"bucket: $1\n" +
|
||||
" key: $2\n" +
|
||||
" json_key: $3<*>"
|
||||
, // --
|
||||
"bucket: <*>",
|
||||
"json_key: <*>",
|
||||
"key: <*>"
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void semverGcsResourceReconcileAndHover() throws Exception {
|
||||
Editor editor;
|
||||
|
||||
// required props for git driver
|
||||
editor = harness.newEditor(
|
||||
"resources:\n" +
|
||||
"- name: version\n" +
|
||||
" type: semver\n" +
|
||||
" source:\n" +
|
||||
" driver: gcs\n" +
|
||||
" bucket: some-bucket\n" +
|
||||
" key: some-key\n" +
|
||||
" json_key: some-json-key-string\n" +
|
||||
" bogus: bad"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"version|Unused",
|
||||
"bogus|Unknown property"
|
||||
);
|
||||
|
||||
editor.assertHoverContains("driver", "The driver to use");
|
||||
editor.assertHoverContains("bucket", "The name of the bucket");
|
||||
editor.assertHoverContains("key", "key to use for the object in the bucket tracking the version");
|
||||
editor.assertHoverContains("json_key", "contents of your GCP Account JSON Key");
|
||||
}
|
||||
|
||||
@Test public void semverGitResourceSourceContentAssist() throws Exception {
|
||||
assertContextualCompletions(PLAIN_COMPLETION,
|
||||
"resources:\n" +
|
||||
|
||||
Reference in New Issue
Block a user