forked from dotnet/dotnet-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageVersion.cs
More file actions
54 lines (43 loc) · 2.09 KB
/
Copy pathImageVersion.cs
File metadata and controls
54 lines (43 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace Microsoft.DotNet.Docker.Tests
{
public readonly record struct ImageVersion
{
private readonly Version _version;
public static readonly ImageVersion V8_0 = new(new Version(8, 0), isPreview: false);
public static readonly ImageVersion V8_1 = new(new Version(8, 1), isPreview: false);
public static readonly ImageVersion V9_0 = new(new Version(9, 0), isPreview: false);
public static readonly ImageVersion V9_1 = new(new Version(9, 1), isPreview: false);
public static readonly ImageVersion V13_2 = new(new Version(13, 2), isPreview: false);
public static readonly ImageVersion V13_3 = new(new Version(13, 3), isPreview: false);
public static readonly ImageVersion V9_2_Preview = new(new Version(9, 2), isPreview: true);
public static readonly ImageVersion V10_0 = new(new Version(10, 0), isPreview: false);
public static readonly ImageVersion V11_0 = new(new Version(11, 0), isPreview: true);
public ImageVersion(Version version, bool isPreview)
{
_version = version;
IsPreview = isPreview;
}
public int Major => _version.Major;
public bool IsPreview { get; }
public override string ToString() => _version.ToString();
public string GetTagName() => ToString() + (IsPreview ? "-preview" : string.Empty);
public static string TrimBuildVersionForRelease(string buildVersion)
{
int servicingIndex = buildVersion.IndexOf("-servicing.");
if (servicingIndex != -1)
{
buildVersion = buildVersion.Substring(0, servicingIndex);
}
int rtmIndex = buildVersion.IndexOf("-rtm.");
if (rtmIndex != -1)
{
buildVersion = buildVersion.Substring(0, rtmIndex);
}
return buildVersion;
}
}
}