From 9b647d6b25f03a49726b59f129bebf121c4426e0 Mon Sep 17 00:00:00 2001 From: Remy Suen Date: Sun, 10 Sep 2023 17:28:53 -0400 Subject: [PATCH] Fix #120 Correct link range if image has a tag and digest This was fixed in 0.11.0 but no regression test was added so one will be added now. CHANGELOG.md is also retroactively being corrected to include this as one of the fixes included in 0.11.0. Note that the Git tag itself of course will not change and will continue to point at a7e1c23255004f7273062390d3427f76979efe9d which was what was used to release 0.11.0 to npm. Signed-off-by: Remy Suen --- CHANGELOG.md | 3 +++ test/dockerLinks.test.ts | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 576cf9e..5e4d1e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ All notable changes to this project will be documented in this file. - flag empty tag specified with a digest in FROM instructions as an error ([rcjsuen/dockerfile-utils#118](https://github.com/rcjsuen/dockerfile-utils/issues/118)) - ignore predefined platform ARG variables if they are used as a base image ([rcjsuen/dockerfile-utils#119](https://github.com/rcjsuen/dockerfile-utils/issues/119)) +### Fixed +- correct link range calculation if tag provided with a digest ([#120](https://github.com/rcjsuen/dockerfile-language-service/issues/120)) + ## [0.10.2] - 2023-06-01 ### Fixed - ignore quotes in comments if it's within an embedded argument with CRLF used as a newline delimiter ([#113](https://github.com/rcjsuen/dockerfile-language-service/issues/113)) diff --git a/test/dockerLinks.test.ts b/test/dockerLinks.test.ts index b09558f..f451de9 100644 --- a/test/dockerLinks.test.ts +++ b/test/dockerLinks.test.ts @@ -72,6 +72,14 @@ describe("Dockerfile links", function () { links[0] = service.resolveLink(links[0]); assertLink(links[0], "https://hub.docker.com/r/microsoft/dotnet/", "r/microsoft/dotnet/", 0, 5, 0, 21); }); + + it("FROM microsoft/dotnet:non-existent-tag@sha256:5483e2b609c0f66c3ebd96666de7b0a74537613b43565879ecb0d0a73e845d7d", () => { + const links = service.computeLinks("FROM microsoft/dotnet:non-existent-tag@sha256:5483e2b609c0f66c3ebd96666de7b0a74537613b43565879ecb0d0a73e845d7d"); + assert.strictEqual(links.length, 1); + assertLink(links[0], undefined, "r/microsoft/dotnet/", 0, 5, 0, 21); + links[0] = service.resolveLink(links[0]); + assertLink(links[0], "https://hub.docker.com/r/microsoft/dotnet/", "r/microsoft/dotnet/", 0, 5, 0, 21); + }); }); describe("build stages", function () {