Adds option for partial matches of kube node names.

This commit is contained in:
benbierens 2023-09-25 09:19:29 +02:00
parent 10697f1047
commit 3a24a77803
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
1 changed files with 7 additions and 2 deletions

View File

@ -12,7 +12,7 @@
/// <summary> /// <summary>
/// Returns the location object for a specific kubernetes node. Throws if it doesn't exist. /// Returns the location object for a specific kubernetes node. Throws if it doesn't exist.
/// </summary> /// </summary>
ILocation Get(string kubeNodeName); ILocation Get(string kubeNodeName, bool allowPartialMatches = false);
} }
public class KnownLocations : IKnownLocations public class KnownLocations : IKnownLocations
@ -34,8 +34,13 @@
return locations[index]; return locations[index];
} }
public ILocation Get(string kubeNodeName) public ILocation Get(string kubeNodeName, bool allowPartialMatches = false)
{ {
if (allowPartialMatches)
{
return locations.Single(l => l.NodeLabel != null && l.NodeLabel.Value.Contains(kubeNodeName));
}
return locations.Single(l => l.NodeLabel != null && l.NodeLabel.Value == kubeNodeName); return locations.Single(l => l.NodeLabel != null && l.NodeLabel.Value == kubeNodeName);
} }
} }