-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKubeFleet.cs
39 lines (34 loc) · 1.14 KB
/
KubeFleet.cs
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
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Snd.Sdk.Kubernetes.Base;
namespace Snd.Sdk.Kubernetes
{
/// <summary>
/// Generic Kube fleet implementation.
/// </summary>
public class KubeFleet : IKubeFleet
{
private ImmutableList<IKubeCluster> members = ImmutableList<IKubeCluster>.Empty;
/// <summary>
/// Creates an instance of <see cref="KubeFleet"/>.
/// </summary>
/// <returns></returns>
public KubeFleet() { }
/// <inheritdoc />
public void AddMember(IKubeCluster member)
{
if (this.members.Find(m => member.KubeApi.BaseUri.ToString() == m.KubeApi.BaseUri.ToString()) == null)
{
this.members = this.members.Add(member);
}
}
/// <inheritdoc />
public ImmutableList<IKubeCluster> GetAllMembers() => this.members;
/// <inheritdoc/>
public IKubeCluster GetMemberByName(string name)
{
return members.Find(m => m.ClusterName.Equals(name, System.StringComparison.InvariantCultureIgnoreCase));
}
}
}