Skip to content

Commit 2644482

Browse files
committed
Print warning for short base image names.
1 parent 3d3b442 commit 2644482

File tree

18 files changed

+107
-24
lines changed

18 files changed

+107
-24
lines changed

src/Containers/Microsoft.NET.Build.Containers/ContainerHelpers.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static class ContainerHelpers
3131
/// DockerRegistry is the default registry used when no registry is specified.
3232
/// </summary>
3333
private const string DockerRegistry = "registry-1.docker.io";
34-
private const string DockerRegistryAlias = "docker.io";
34+
internal const string DockerRegistryAlias = "docker.io";
3535

3636
/// <summary>
3737
/// Matches if the string is not lowercase or numeric, or ., _, or -.
@@ -196,7 +196,8 @@ internal static bool TryParseFullyQualifiedContainerName(string fullyQualifiedCo
196196
[NotNullWhen(true)] out string? containerRegistry,
197197
[NotNullWhen(true)] out string? containerName,
198198
out string? containerTag, // tag is always optional - we can't guarantee anything here
199-
out string? containerDigest // digest is always optional - we can't guarantee anything here
199+
out string? containerDigest, // digest is always optional - we can't guarantee anything here
200+
out bool isRegistrySpecified
200201
)
201202
{
202203

@@ -208,6 +209,7 @@ out string? containerDigest // digest is always optional - we can't guarantee an
208209
containerName = null;
209210
containerTag = null;
210211
containerDigest = null;
212+
isRegistrySpecified = false;
211213
return false;
212214
}
213215

@@ -228,14 +230,9 @@ out string? containerDigest // digest is always optional - we can't guarantee an
228230

229231
// safely discover the registry
230232
var registryPortion = nameMatch.Groups[1];
231-
if (registryPortion.Success)
232-
{
233-
containerRegistry = registryPortion.Value;
234-
}
235-
else
236-
{
237-
containerRegistry = DockerRegistryAlias;
238-
}
233+
isRegistrySpecified = registryPortion.Success;
234+
containerRegistry = isRegistrySpecified ? registryPortion.Value
235+
: DockerRegistryAlias;
239236

240237
// direct access to the name portion is safe because the regex matched
241238
var imageNamePortion = nameMatch.Groups[2];
@@ -259,6 +256,7 @@ out string? containerDigest // digest is always optional - we can't guarantee an
259256
containerName = null;
260257
containerTag = null;
261258
containerDigest = null;
259+
isRegistrySpecified = false;
262260
return false;
263261
}
264262

src/Containers/Microsoft.NET.Build.Containers/Resources/Strings.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Containers/Microsoft.NET.Build.Containers/Resources/Strings.resx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@
133133
<value>CONTAINER2013: {0} had spaces in it, replacing with dashes.</value>
134134
<comment>{StrBegin="CONTAINER2013: "}</comment>
135135
</data>
136+
<data name="BaseImageNameRegistryFallback" xml:space="preserve">
137+
<value>CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</value>
138+
<comment>{StrBegin="CONTAINER2020: "}</comment>
139+
</data>
136140
<data name="BaseImageNotFound" xml:space="preserve">
137141
<value>CONTAINER1011: Couldn't find matching base image for {0} that matches RuntimeIdentifier {1}.</value>
138142
<comment>{StrBegin="CONTAINER1011: "}</comment>

src/Containers/Microsoft.NET.Build.Containers/Resources/xlf/Strings.cs.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<target state="translated">CONTAINER2009: Nelze analyzovat {0}: {1}</target>
1818
<note>{StrBegin="CONTAINER2009: "}</note>
1919
</trans-unit>
20+
<trans-unit id="BaseImageNameRegistryFallback">
21+
<source>CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</source>
22+
<target state="new">CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</target>
23+
<note>{StrBegin="CONTAINER2020: "}</note>
24+
</trans-unit>
2025
<trans-unit id="BaseImageNameWithSpaces">
2126
<source>CONTAINER2013: {0} had spaces in it, replacing with dashes.</source>
2227
<target state="translated">CONTAINER2013: {0} obsahoval mezery, které se nahradily pomlčkami.</target>

src/Containers/Microsoft.NET.Build.Containers/Resources/xlf/Strings.de.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<target state="translated">CONTAINER2009: {0} konnte nicht analysiert werden: {1}</target>
1818
<note>{StrBegin="CONTAINER2009: "}</note>
1919
</trans-unit>
20+
<trans-unit id="BaseImageNameRegistryFallback">
21+
<source>CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</source>
22+
<target state="new">CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</target>
23+
<note>{StrBegin="CONTAINER2020: "}</note>
24+
</trans-unit>
2025
<trans-unit id="BaseImageNameWithSpaces">
2126
<source>CONTAINER2013: {0} had spaces in it, replacing with dashes.</source>
2227
<target state="translated">CONTAINER2013: {0} enthielt Leerzeichen. Diese werden durch Bindestriche ersetzt.</target>

src/Containers/Microsoft.NET.Build.Containers/Resources/xlf/Strings.es.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<target state="translated">CONTAINER2009: No se pudo analizar {0}: {1}</target>
1818
<note>{StrBegin="CONTAINER2009: "}</note>
1919
</trans-unit>
20+
<trans-unit id="BaseImageNameRegistryFallback">
21+
<source>CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</source>
22+
<target state="new">CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</target>
23+
<note>{StrBegin="CONTAINER2020: "}</note>
24+
</trans-unit>
2025
<trans-unit id="BaseImageNameWithSpaces">
2126
<source>CONTAINER2013: {0} had spaces in it, replacing with dashes.</source>
2227
<target state="translated">CONTAINER2013: {0} tenía espacios, reemplazando por guiones.</target>

src/Containers/Microsoft.NET.Build.Containers/Resources/xlf/Strings.fr.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<target state="translated">CONTAINER2009: impossible d’analyser {0} : {1}</target>
1818
<note>{StrBegin="CONTAINER2009: "}</note>
1919
</trans-unit>
20+
<trans-unit id="BaseImageNameRegistryFallback">
21+
<source>CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</source>
22+
<target state="new">CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</target>
23+
<note>{StrBegin="CONTAINER2020: "}</note>
24+
</trans-unit>
2025
<trans-unit id="BaseImageNameWithSpaces">
2126
<source>CONTAINER2013: {0} had spaces in it, replacing with dashes.</source>
2227
<target state="translated">CONTAINER2013: {0} contenait des espaces, remplacés par des tirets.</target>

src/Containers/Microsoft.NET.Build.Containers/Resources/xlf/Strings.it.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<target state="translated">CONTAINER2009: non è stato possibile analizzare {0}: {1}</target>
1818
<note>{StrBegin="CONTAINER2009: "}</note>
1919
</trans-unit>
20+
<trans-unit id="BaseImageNameRegistryFallback">
21+
<source>CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</source>
22+
<target state="new">CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</target>
23+
<note>{StrBegin="CONTAINER2020: "}</note>
24+
</trans-unit>
2025
<trans-unit id="BaseImageNameWithSpaces">
2126
<source>CONTAINER2013: {0} had spaces in it, replacing with dashes.</source>
2227
<target state="translated">CONTAINER2013: {0} conteneva spazi, che verranno sostituiti con trattini.</target>

src/Containers/Microsoft.NET.Build.Containers/Resources/xlf/Strings.ja.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<target state="translated">CONTAINER2009: {0} を解析できませんでした: {1}</target>
1818
<note>{StrBegin="CONTAINER2009: "}</note>
1919
</trans-unit>
20+
<trans-unit id="BaseImageNameRegistryFallback">
21+
<source>CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</source>
22+
<target state="new">CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</target>
23+
<note>{StrBegin="CONTAINER2020: "}</note>
24+
</trans-unit>
2025
<trans-unit id="BaseImageNameWithSpaces">
2126
<source>CONTAINER2013: {0} had spaces in it, replacing with dashes.</source>
2227
<target state="translated">CONTAINER2013: {0} にスペースが含まれており、ダッシュに置き換えています。</target>

src/Containers/Microsoft.NET.Build.Containers/Resources/xlf/Strings.ko.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<target state="translated">CONTAINER2009: {0}을(를) 구문 분석할 수 없습니다: {1}</target>
1818
<note>{StrBegin="CONTAINER2009: "}</note>
1919
</trans-unit>
20+
<trans-unit id="BaseImageNameRegistryFallback">
21+
<source>CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</source>
22+
<target state="new">CONTAINER2020: {0} does not specify a registry and will be pulled from Docker Hub. Please prefix the name with the image registry, for example: '{1}/&lt;image&gt;'.</target>
23+
<note>{StrBegin="CONTAINER2020: "}</note>
24+
</trans-unit>
2025
<trans-unit id="BaseImageNameWithSpaces">
2126
<source>CONTAINER2013: {0} had spaces in it, replacing with dashes.</source>
2227
<target state="translated">CONTAINER2013: {0}에 공백이 있었고 대시로 대체되었습니다.</target>

0 commit comments

Comments
 (0)