12
12
using Xunit ;
13
13
14
14
using static Microsoft . DotNet . Docker . Tests . ManifestHelper ;
15
+ using Microsoft . CodeAnalysis . CSharp . Syntax ;
15
16
16
17
#nullable enable
17
18
@@ -163,31 +164,17 @@ public void PlatformTag_TagExists(
163
164
[ MemberData ( nameof ( GetTagTestObjects ) , TestType . FloatingAlpine ) ]
164
165
public void FloatingAlpineTag_OnLatestVersion ( Repo repo , VersionType versionType , bool checkArchitecture )
165
166
{
166
- Dictionary < DockerfileInfo , List < string > > dockerfileTags = GetDockerfileTags ( repo ) ;
167
-
168
167
IEnumerable < KeyValuePair < DockerfileInfo , List < string > > > alpineDockerfileTags =
169
- dockerfileTags . Where ( p => p . Key . Os . Contains ( OS . Alpine ) ) ;
170
-
171
- Version ? latestAlpineVersion = alpineDockerfileTags
172
- . Select ( kvp => kvp . Key )
173
- . Select ( GetAlpineVersion )
174
- . OrderByDescending ( version => version )
175
- . FirstOrDefault ( ) ;
176
-
177
- if ( latestAlpineVersion is null )
178
- {
179
- // The repo doesn't have any alpine dockerfiles
180
- return ;
181
- }
182
-
183
- string latestAlpineOsVersion = OS . Alpine + latestAlpineVersion ;
168
+ GetDockerfileTags ( repo )
169
+ . Where ( p => p . Key . Os . Contains ( OS . Alpine ) ) ;
184
170
185
171
using ( new AssertionScope ( ) )
186
172
{
187
173
foreach ( ( DockerfileInfo dockerfileInfo , List < string > tags ) in alpineDockerfileTags )
188
174
{
175
+ string alpineFloatingTagVersion = GetAlpineFloatingTagVersion ( dockerfileInfo ) ;
189
176
Regex pattern = GetFloatingTagRegex ( dockerfileInfo ) ;
190
- if ( dockerfileInfo . Os == latestAlpineOsVersion )
177
+ if ( dockerfileInfo . Os == alpineFloatingTagVersion )
191
178
{
192
179
tags . Should ( ) . ContainSingle ( tag => pattern . IsMatch ( tag ) ,
193
180
because : $ "image { dockerfileInfo } should have an { OS . Alpine } floating tag") ;
@@ -200,6 +187,9 @@ public void FloatingAlpineTag_OnLatestVersion(Repo repo, VersionType versionType
200
187
}
201
188
}
202
189
190
+ string GetAlpineFloatingTagVersion ( DockerfileInfo info ) =>
191
+ Config . GetVariableValue ( $ "alpine|{ info . MajorMinor } |floating-tag-version") ;
192
+
203
193
Regex GetFloatingTagRegex ( DockerfileInfo info ) =>
204
194
GetTagRegex (
205
195
versionType ,
0 commit comments