From 3b0a2656fe1717cc8a8b297dec268216d9a42c76 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Wed, 7 Sep 2022 10:29:27 -0700 Subject: [PATCH] Fix https://github.com/spring-projects/sts4/issues/831 docker-image resource source `registry_mirror` property schema should allow for just a url rather than host/user/pass object. --- .../vscode/concourse/PipelineYmlSchema.java | 2 +- .../desc/DockerImageSource/registry_mirror.md | 6 +++- .../vscode/concourse/ConcourseEditorTest.java | 28 +++++++++++++------ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java b/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java index 5c79030bb..44a2bb887 100644 --- a/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java +++ b/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/PipelineYmlSchema.java @@ -649,7 +649,7 @@ public class PipelineYmlSchema implements YamlSchema { addProp(source, "aws_secret_access_key", t_ne_string); addProp(source, "aws_session_token", t_ne_string); addProp(source, "insecure_registries", t_strings); - addProp(source, "registry_mirror", registry_mirror); + addProp(source, "registry_mirror", t_ne_string); addProp(source, "ca_certs", f.yseq(f.ybean("CaCertsEntry", f.yprop("domain", t_ne_string), f.yprop("cert", t_ne_string) diff --git a/headless-services/concourse-language-server/src/main/resources/desc/DockerImageSource/registry_mirror.md b/headless-services/concourse-language-server/src/main/resources/desc/DockerImageSource/registry_mirror.md index 92d86c170..912523661 100644 --- a/headless-services/concourse-language-server/src/main/resources/desc/DockerImageSource/registry_mirror.md +++ b/headless-services/concourse-language-server/src/main/resources/desc/DockerImageSource/registry_mirror.md @@ -1 +1,5 @@ -*Optional.* Hostname and credentials pointing to a docker registry mirror service. +*Optional.* A URL pointing to a docker registry mirror service. + +Note: `registry_mirror` is ignored if `repository` contains an explicitly-declared +registry-hostname-prefixed value, such as `my-registry.com/foo/bar`, in which case +the registry cited in the `repository` value is used instead of the `registry_mirror`. \ No newline at end of file diff --git a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java index c4abd5d57..ea37deaf4 100644 --- a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java +++ b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java @@ -23,7 +23,6 @@ import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.concurrent.CompletableFuture; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -159,6 +158,22 @@ public class ConcourseEditorTest { " source:\n" + " repository: alpine\n" + " tag: latest\n" + + " registry_mirror: https://my-registry.com\n" + + "run:\n" + + " path: sh\n" + + " args:\n" + + " - -exc\n" + + " - sleep 60\n" + ); + editor.assertProblems(/*NONE*/); + + editor = harness.newEditor(LanguageId.CONCOURSE_TASK, + "platform: linux\n" + + "image_resource:\n" + + " type: registry-image\n" + + " source:\n" + + " repository: alpine\n" + + " tag: latest\n" + " registry_mirror:\n" + " host: my-registry.com\n" + " username: myuser\n" + @@ -171,6 +186,7 @@ public class ConcourseEditorTest { " - sleep 60\n" ); editor.assertProblems("bad|Unknown"); + } @Test public void GH_639_globStar() throws Exception { @@ -2455,10 +2471,7 @@ public class ConcourseEditorTest { " aws_secret_access_key: {{aws_secret_key}}\n" + " aws_session_token: ((aws_token))\n" + " insecure_registries: no-list\n" + - " registry_mirror:\n" + - " host: dockermirror.com\n" + - " username: mirroruser\n" + - " password: ((mirror_pass))\n" + + " registry_mirror: https://some.registry.host\n" + " max_concurrent_downloads: num-down\n" + " max_concurrent_uploads: num-up\n" + " ca_certs:\n" + @@ -2497,10 +2510,7 @@ public class ConcourseEditorTest { editor.assertHoverContains("aws_secret_access_key", "AWS secret key to use"); editor.assertHoverContains("aws_session_token", "AWS session token (assumed role)"); editor.assertHoverContains("insecure_registries", "array of CIDRs"); - editor.assertHoverContains("registry_mirror", "Hostname and credentials pointing to a docker registry mirror service"); - editor.assertHoverContains("host", "hostname pointing to a Docker registry mirror service"); - editor.assertHoverContains("username", 2, "username to use when authenticating to the mirror"); - editor.assertHoverContains("password", 2, "password to use when authenticating to the mirror"); + editor.assertHoverContains("registry_mirror", "URL pointing to a docker registry mirror service"); editor.assertHoverContains("ca_certs", "Each entry specifies the x509 CA certificate for"); editor.assertHoverContains("client_certs", "Each entry specifies the x509 certificate and key");