Skip to content

Commit

Permalink
Fix latest label logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ptr727 committed Mar 24, 2024
1 parent b53fbae commit d674fe9
Show file tree
Hide file tree
Showing 14 changed files with 248 additions and 63 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,5 @@ fabric.properties
.idea

*.DotSettings

.mono
33 changes: 19 additions & 14 deletions CreateMatrix/ProductInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,28 @@ private void AddLabel(VersionInfo versionInfo, VersionInfo.LabelType label)
if (versionInfo.CompareTo(existingVersion) <= 0)
return;

Log.Logger.Information("{Product}: Replacing {Label} from {ExistingVersion} to {NewVersion}", Product, label, existingVersion.Version, versionInfo.Version);
Log.Logger.Warning("{Product}: Replacing {Label} from {ExistingVersion} to {NewVersion}", Product, label, existingVersion.Version, versionInfo.Version);

// Remove from other version
// Remove from other version and add to this version
existingVersion.Labels.Remove(label);
// Add to this version
versionInfo.Labels.Add(label);
}

private VersionInfo? FindMissingLabel(VersionInfo.LabelType targetLabel, List<VersionInfo.LabelType> sourceLabels)
{
foreach (var label in sourceLabels)
{
// Find last matching item, must be sorted
var version = Versions.FindLast(item => item.Labels.Contains(label));
if (version != default(VersionInfo))
{
Log.Logger.Warning("{Product}: Using {SourceLabel} for {TargetLabel}", Product, label, targetLabel);
return version;
}
}
return default;
}

private void VerifyLabels()
{
// Sort by version number
Expand All @@ -158,25 +172,16 @@ private void VerifyLabels()
// If no Latest label is set, use Stable or RC or Beta as Latest
if (!Versions.Any(item => item.Labels.Contains(VersionInfo.LabelType.Latest)))
{
// Find Stable or RC or Beta to use as Latest
// Versions are ordered so highest version will be used
var latest = Versions.FindLast(item => item.Labels.Contains(VersionInfo.LabelType.Stable));
latest ??= Versions.FindLast(item => item.Labels.Contains(VersionInfo.LabelType.RC));
latest ??= Versions.FindLast(item => item.Labels.Contains(VersionInfo.LabelType.Beta));
var latest = FindMissingLabel(VersionInfo.LabelType.Latest, [VersionInfo.LabelType.Stable, VersionInfo.LabelType.RC, VersionInfo.LabelType.Beta]);
Debug.Assert(latest != default(VersionInfo));

// Add latest
latest.Labels.Add(VersionInfo.LabelType.Latest);
}

// If no Stable label is set, use Latest as stable
if (!Versions.Any(item => item.Labels.Contains(VersionInfo.LabelType.Stable)))
{
// Find latest
var stable = Versions.Find(item => item.Labels.Contains(VersionInfo.LabelType.Latest));
var stable = FindMissingLabel(VersionInfo.LabelType.Stable, [VersionInfo.LabelType.Latest]);
Debug.Assert(stable != default(VersionInfo));

// Add the stable label
stable.Labels.Add(VersionInfo.LabelType.Stable);
}

Expand Down
3 changes: 2 additions & 1 deletion CreateMatrix/ReleasesJsonSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ internal VersionInfo.LabelType GetLabel()
// Determine the equivalent label
return PublicationType switch
{
"release" => IsPublished() ? VersionInfo.LabelType.Stable : VersionInfo.LabelType.None,
// Use Stable or Latest based on if published or not
"release" => IsPublished() ? VersionInfo.LabelType.Stable : VersionInfo.LabelType.Latest,
"rc" => VersionInfo.LabelType.RC,
"beta" => VersionInfo.LabelType.Beta,
_ => throw new InvalidEnumArgumentException($"Unknown PublicationType: {PublicationType}")
Expand Down
6 changes: 3 additions & 3 deletions Docker/DWSpectrum-LSIO.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ARG LABEL_DESCRIPTION="DW Spectrum IPVMS Docker based on LinuxServer"

# Download URL and version
# Current values are defined by the build pipeline
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/digitalwatchdog/37996/dwspectrum-server_update-5.1.2.37996-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/digitalwatchdog/37996/dwspectrum-server_update-5.1.2.37996-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.2.37996"
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/digitalwatchdog/38363/dwspectrum-server_update-5.1.3.38363-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/digitalwatchdog/38363/dwspectrum-server_update-5.1.3.38363-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.3.38363"

# NxWitness (networkoptix) or DWSpectrum (digitalwatchdog) or NxMeta (networkoptix-metavms)
ARG RUNTIME_NAME="digitalwatchdog"
Expand Down
6 changes: 3 additions & 3 deletions Docker/DWSpectrum.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ARG LABEL_DESCRIPTION="DW Spectrum IPVMS Docker"

# Download URL and version
# Current values are defined by the build pipeline
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/digitalwatchdog/37996/dwspectrum-server_update-5.1.2.37996-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/digitalwatchdog/37996/dwspectrum-server_update-5.1.2.37996-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.2.37996"
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/digitalwatchdog/38363/dwspectrum-server_update-5.1.3.38363-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/digitalwatchdog/38363/dwspectrum-server_update-5.1.3.38363-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.3.38363"

# NxWitness (networkoptix) or DWSpectrum (digitalwatchdog) or NxMeta (networkoptix-metavms)
ARG RUNTIME_NAME="digitalwatchdog"
Expand Down
6 changes: 3 additions & 3 deletions Docker/NxMeta-LSIO.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ARG LABEL_DESCRIPTION="Nx Meta VMS Docker based on LinuxServer"

# Download URL and version
# Current values are defined by the build pipeline
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/metavms/37996/metavms-server_update-5.1.2.37996-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/metavms/37996/metavms-server_update-5.1.2.37996-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.2.37996"
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/metavms/38363/metavms-server_update-5.1.3.38363-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/metavms/38363/metavms-server_update-5.1.3.38363-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.3.38363"

# NxWitness (networkoptix) or DWSpectrum (digitalwatchdog) or NxMeta (networkoptix-metavms)
ARG RUNTIME_NAME="networkoptix-metavms"
Expand Down
6 changes: 3 additions & 3 deletions Docker/NxMeta.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ARG LABEL_DESCRIPTION="Nx Meta VMS Docker"

# Download URL and version
# Current values are defined by the build pipeline
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/metavms/37996/metavms-server_update-5.1.2.37996-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/metavms/37996/metavms-server_update-5.1.2.37996-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.2.37996"
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/metavms/38363/metavms-server_update-5.1.3.38363-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/metavms/38363/metavms-server_update-5.1.3.38363-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.3.38363"

# NxWitness (networkoptix) or DWSpectrum (digitalwatchdog) or NxMeta (networkoptix-metavms)
ARG RUNTIME_NAME="networkoptix-metavms"
Expand Down
6 changes: 3 additions & 3 deletions Docker/NxWitness-LSIO.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ARG LABEL_DESCRIPTION="Nx Witness VMS Docker based on LinuxServer"

# Download URL and version
# Current values are defined by the build pipeline
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/default/37996/nxwitness-server_update-5.1.2.37996-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/default/37996/nxwitness-server_update-5.1.2.37996-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.2.37996"
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/default/38363/nxwitness-server_update-5.1.3.38363-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/default/38363/nxwitness-server_update-5.1.3.38363-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.3.38363"

# NxWitness (networkoptix) or DWSpectrum (digitalwatchdog) or NxMeta (networkoptix-metavms)
ARG RUNTIME_NAME="networkoptix"
Expand Down
6 changes: 3 additions & 3 deletions Docker/NxWitness.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ARG LABEL_DESCRIPTION="Nx Witness VMS Docker"

# Download URL and version
# Current values are defined by the build pipeline
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/default/37996/nxwitness-server_update-5.1.2.37996-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/default/37996/nxwitness-server_update-5.1.2.37996-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.2.37996"
ARG DOWNLOAD_X64_URL="https://updates.networkoptix.com/default/38363/nxwitness-server_update-5.1.3.38363-linux_x64.zip"
ARG DOWNLOAD_ARM64_URL="https://updates.networkoptix.com/default/38363/nxwitness-server_update-5.1.3.38363-linux_arm64.zip"
ARG DOWNLOAD_VERSION="5.1.3.38363"

# NxWitness (networkoptix) or DWSpectrum (digitalwatchdog) or NxMeta (networkoptix-metavms)
ARG RUNTIME_NAME="networkoptix"
Expand Down
Loading

0 comments on commit d674fe9

Please sign in to comment.