Skip to content

Commit 2ea2299

Browse files
committed
Moved contents of KubernetesClient.Util into KubernetesClient project kubernetes-client#2 :(
1 parent 5fbb96b commit 2ea2299

File tree

19 files changed

+45
-69
lines changed

19 files changed

+45
-69
lines changed

kubernetes-client.sln

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkipTestLogger", "tests\Ski
4343
EndProject
4444
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "customResource", "examples\customResource\customResource.csproj", "{95672061-5799-4454-ACDB-D6D330DB1EC4}"
4545
EndProject
46-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "util", "util", "{B9F72EFC-551A-4A0C-B4DC-DBE5AF8F5FE8}"
47-
EndProject
48-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KubernetesClient.Util", "util\src\KubernetesClient.Util\KubernetesClient.Util.csproj", "{45B6236C-C57A-4622-A631-8AD3AA1DB768}"
49-
EndProject
50-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{96C503A9-4DF5-43FF-A80E-7E96F7C35CA8}"
51-
EndProject
52-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AEE9B8E6-7D40-46B2-A857-720CF03C47DA}"
53-
EndProject
54-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KubernetesClient.Util.Tests", "util\tests\KubernetesClient.Util.Tests\KubernetesClient.Util.Tests.csproj", "{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}"
55-
EndProject
5646
Global
5747
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5848
Debug|Any CPU = Debug|Any CPU
@@ -255,30 +245,6 @@ Global
255245
{95672061-5799-4454-ACDB-D6D330DB1EC4}.Release|x64.Build.0 = Release|Any CPU
256246
{95672061-5799-4454-ACDB-D6D330DB1EC4}.Release|x86.ActiveCfg = Release|Any CPU
257247
{95672061-5799-4454-ACDB-D6D330DB1EC4}.Release|x86.Build.0 = Release|Any CPU
258-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
259-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Debug|Any CPU.Build.0 = Debug|Any CPU
260-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Debug|x64.ActiveCfg = Debug|Any CPU
261-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Debug|x64.Build.0 = Debug|Any CPU
262-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Debug|x86.ActiveCfg = Debug|Any CPU
263-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Debug|x86.Build.0 = Debug|Any CPU
264-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Release|Any CPU.ActiveCfg = Release|Any CPU
265-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Release|Any CPU.Build.0 = Release|Any CPU
266-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Release|x64.ActiveCfg = Release|Any CPU
267-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Release|x64.Build.0 = Release|Any CPU
268-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Release|x86.ActiveCfg = Release|Any CPU
269-
{45B6236C-C57A-4622-A631-8AD3AA1DB768}.Release|x86.Build.0 = Release|Any CPU
270-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
271-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Debug|Any CPU.Build.0 = Debug|Any CPU
272-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Debug|x64.ActiveCfg = Debug|Any CPU
273-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Debug|x64.Build.0 = Debug|Any CPU
274-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Debug|x86.ActiveCfg = Debug|Any CPU
275-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Debug|x86.Build.0 = Debug|Any CPU
276-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Release|Any CPU.ActiveCfg = Release|Any CPU
277-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Release|Any CPU.Build.0 = Release|Any CPU
278-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Release|x64.ActiveCfg = Release|Any CPU
279-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Release|x64.Build.0 = Release|Any CPU
280-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Release|x86.ActiveCfg = Release|Any CPU
281-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319}.Release|x86.Build.0 = Release|Any CPU
282248
EndGlobalSection
283249
GlobalSection(SolutionProperties) = preSolution
284250
HideSolutionNode = FALSE
@@ -300,10 +266,6 @@ Global
300266
{5056C4A2-5E12-4C16-8DA7-8835DA58BFF2} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509}
301267
{4D2AE427-F856-49E5-B61D-EA6B17D89051} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509}
302268
{95672061-5799-4454-ACDB-D6D330DB1EC4} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40}
303-
{96C503A9-4DF5-43FF-A80E-7E96F7C35CA8} = {B9F72EFC-551A-4A0C-B4DC-DBE5AF8F5FE8}
304-
{45B6236C-C57A-4622-A631-8AD3AA1DB768} = {96C503A9-4DF5-43FF-A80E-7E96F7C35CA8}
305-
{AEE9B8E6-7D40-46B2-A857-720CF03C47DA} = {B9F72EFC-551A-4A0C-B4DC-DBE5AF8F5FE8}
306-
{9B55CB07-0FA9-4DB6-9388-36A1C3B5B319} = {AEE9B8E6-7D40-46B2-A857-720CF03C47DA}
307269
EndGlobalSection
308270
GlobalSection(ExtensibilityGlobals) = postSolution
309271
SolutionGuid = {049A763A-C891-4E8D-80CF-89DD3E22ADC7}

src/KubernetesClient/KubernetesClient.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@
4545
<PackageReference Include="IdentityModel.OidcClient" Version="3.1.2" />
4646
</ItemGroup>
4747

48+
<ItemGroup>
49+
<Folder Include="Util\Informer" />
50+
</ItemGroup>
51+
4852
</Project>

src/KubernetesClient/Util/Common/CallGeneratorParams.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// ReSharper disable once CheckNamespace
2-
3-
using System;
4-
5-
namespace k8s.Util.Utils
1+
namespace k8s.Util.Common
62
{
73
public class CallGeneratorParams
84
{

src/KubernetesClient/Util/Informer/Cache/Cache.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using k8s.Models;
5+
using k8s.Util.Common;
56

6-
namespace k8s.Util.Cache
7+
namespace k8s.Util.Informer.Cache
78
{
89
/// <summary>
910
/// Cache is a C# port of Java's Cache which is a port of k/client-go's ThreadSafeStore. It basically saves and indexes all the entries.
@@ -24,7 +25,7 @@ public class Cache<TApiType> : IIndexer<TApiType>
2425
/// The default label is "namespace". The default func is to look in the object's metadata and combine the
2526
/// namespace and name values, as namespace/name.
2627
/// </remarks>
27-
private readonly Dictionary<string, Func<TApiType, List<string>>> _indexers = new();
28+
private readonly Dictionary<string, Func<TApiType, List<string>>> _indexers = new Dictionary<string, Func<TApiType, List<string>>>();
2829

2930
/// <summary>
3031
/// indices stores objects' keys by their indices
@@ -34,21 +35,21 @@ public class Cache<TApiType> : IIndexer<TApiType>
3435
/// if the indexer func is to calculate the namespace and name values as namespace/name, then the indice HashSet
3536
/// holds those values.
3637
/// </remarks>
37-
private Dictionary<string, Dictionary<string, HashSet<string>>> _indices = new();
38+
private Dictionary<string, Dictionary<string, HashSet<string>>> _indices = new Dictionary<string, Dictionary<string, HashSet<string>>>();
3839

3940
/// <summary>
4041
/// items stores object instances
4142
/// </summary>
4243
/// <remarks>Indices hold the HashSet of calculated keys (namespace/name) for a given resource and items map each of
4344
/// those keys to actual K8s object that was originally returned.</remarks>
44-
private Dictionary<string, TApiType> _items = new();
45+
private Dictionary<string, TApiType> _items = new Dictionary<string, TApiType>();
4546

4647
/// <summary>
4748
/// object used to track locking
4849
/// </summary>
4950
/// <remarks>methods interacting with the store need to lock to secure the thread for race conditions,
5051
/// learn more: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/lock-statement</remarks>
51-
private readonly object _lock = new();
52+
private readonly object _lock = new object();
5253

5354
public Cache()
5455
: this(Caches.NamespaceIndex, Caches.MetaNamespaceIndexFunc, Caches.DeletionHandlingMetaNamespaceKeyFunc)
@@ -237,7 +238,7 @@ public IEnumerable<TApiType> Index(string indexName, TApiType obj)
237238
}
238239

239240
var returnKeySet = new HashSet<string>();
240-
foreach (var set in indexKeys.Select(indexKey => index.GetValueOrDefault(indexKey)).Where(set => set is not null && set.Count != 0))
241+
foreach (var set in indexKeys.Select(indexKey => index.GetValueOrDefault(indexKey)).Where(set => set != null && set.Count != 0))
241242
{
242243
returnKeySet.AddRange(set);
243244
}

src/KubernetesClient/Util/Informer/Cache/Caches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using k8s.Models;
44

5-
namespace k8s.Util.Cache
5+
namespace k8s.Util.Informer.Cache
66
{
77
/// <summary>
88
/// A set of helper utilities for constructing a cache.

src/KubernetesClient/Util/Informer/Cache/DeletedFinalStateUnknown.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using k8s.Models;
22

3-
namespace k8s.Util.Cache
3+
namespace k8s.Util.Informer.Cache
44
{
55
// DeletedFinalStateUnknown is placed into a DeltaFIFO in the case where
66
// an object was deleted but the watch deletion event was missed. In this

src/KubernetesClient/Util/Informer/Cache/DeltaType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace k8s.Util.Cache
1+
namespace k8s.Util.Informer.Cache
22
{
33
public enum DeltaType
44
{

src/KubernetesClient/Util/Informer/Cache/IIndexer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using k8s.Models;
44

5-
namespace k8s.Util.Cache
5+
namespace k8s.Util.Informer.Cache
66
{
77
public interface IIndexer<TApiType> : IStore<TApiType>
88
where TApiType : class, IKubernetesObject<V1ObjectMeta>

src/KubernetesClient/Util/Informer/Cache/IStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.Generic;
22
using k8s.Models;
33

4-
namespace k8s.Util.Cache
4+
namespace k8s.Util.Informer.Cache
55
{
66
public interface IStore<TApiType>
77
where TApiType : class, IKubernetesObject<V1ObjectMeta>

src/KubernetesClient/Util/Informer/Cache/Lister.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.Generic;
22
using k8s.Models;
33

4-
namespace k8s.Util.Cache
4+
namespace k8s.Util.Informer.Cache
55
{
66
/// <summary>
77
/// Lister interface is used to list cached items from a running informer.

src/KubernetesClient/Util/Informer/Cache/MutablePair.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33

4-
namespace k8s.Util.Cache
4+
namespace k8s.Util.Informer.Cache
55
{
66
public class MutablePair<TLeft, TRight>
77
{

tests/KubernetesClient.Tests/KubernetesClient.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11+
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.1.2" />
1112
<PackageReference Include="FluentAssertions" Version="5.10.3" />
1213
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
1314
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="13.2.33" />
@@ -41,4 +42,8 @@
4142
<ItemGroup>
4243
<ProjectReference Include="..\..\src\KubernetesClient\KubernetesClient.csproj" />
4344
</ItemGroup>
45+
46+
<ItemGroup>
47+
<Folder Include="Util\Common" />
48+
</ItemGroup>
4449
</Project>

tests/KubernetesClient.Tests/Util/Informer/Cache/CacheTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using FluentAssertions;
5-
using k8s.Util.Cache;
5+
using k8s.Util.Informer.Cache;
66
using k8s.Models;
77
using Xunit;
88

9-
namespace k8s.Util.Tests.Cache
9+
namespace k8s.Tests.Util.Informer.Cache
1010
{
1111
public class CacheTest
1212
{
@@ -243,12 +243,12 @@ public void AddNullIndexers()
243243
public void AddIndexersConflict()
244244
{
245245
var cache = new Cache<V1Pod>();
246-
Dictionary<string, Func<V1Pod, List<string>>> initialIndexers = new()
246+
Dictionary<string, Func<V1Pod, List<string>>> initialIndexers = new Dictionary<string, Func<V1Pod, List<string>>>()
247247
{
248248
{ "1", pod => new List<string>() },
249249
{ "2", pod => new List<string>() },
250250
};
251-
Dictionary<string, Func<V1Pod, List<string>>> conflictIndexers = new()
251+
Dictionary<string, Func<V1Pod, List<string>>> conflictIndexers = new Dictionary<string, Func<V1Pod, List<string>>>()
252252
{
253253
{ "1", pod => new List<string>() },
254254
};
@@ -261,7 +261,7 @@ public void AddIndexersConflict()
261261
public void AddIndexersSuccess()
262262
{
263263
var cache = new Cache<V1Pod>();
264-
Dictionary<string, Func<V1Pod, List<string>>> indexers = new()
264+
Dictionary<string, Func<V1Pod, List<string>>> indexers = new Dictionary<string, Func<V1Pod, List<string>>>()
265265
{
266266
{ "2", pod => new List<string>() { pod.Name() } },
267267
{ "3", pod => new List<string>() { pod.Name() } },

tests/KubernetesClient.Tests/Util/Informer/Cache/CachesTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
using FluentAssertions;
44
using k8s.Models;
55
using Xunit;
6-
using k8s.Util.Cache;
6+
using k8s.Util.Informer.Cache;
77

8-
namespace k8s.Util.Tests.Cache
8+
namespace k8s.Tests.Util.Informer.Cache
99
{
1010
public class CachesTest
1111
{

tests/KubernetesClient.Tests/Util/Informer/Cache/ListerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using FluentAssertions;
33
using k8s.Models;
44
using Xunit;
5-
using k8s.Util.Cache;
5+
using k8s.Util.Informer.Cache;
66

7-
namespace k8s.Util.Tests.Cache
7+
namespace k8s.Tests.Util.Informer.Cache
88
{
99
public class ListerTest
1010
{

tests/KubernetesClient.Tests/Util/Informer/Cache/ReflectorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using FluentAssertions;
22
using k8s.Models;
3-
using k8s.Util.Cache;
3+
using k8s.Util.Informer.Cache;
44
using Microsoft.Extensions.Logging;
55
using Xunit;
66
using Xunit.Abstractions;
77
using Xunit.Sdk;
88

9-
namespace k8s.Util.Tests.Cache
9+
namespace k8s.Tests.Util.Informer.Cache
1010
{
1111
public class ReflectorTest
1212
{

tests/KubernetesClient.Tests/Util/Informer/Cache/Util.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Linq;
44
using k8s.Models;
55

6-
namespace k8s.Util.Tests.Cache
6+
namespace k8s.Tests.Util.Informer.Cache
77
{
88
internal static class Util
99
{
@@ -30,7 +30,7 @@ internal static IEnumerable<V1Pod> CreatePods(int cnt)
3030

3131
internal static V1PodList CreatePostList(int cnt)
3232
{
33-
return new()
33+
return new V1PodList()
3434
{
3535
ApiVersion = "Pod/V1",
3636
Kind = "Pod",

util/src/KubernetesClient.Util/KubernetesClient.Util.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@
3535
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
3636
</ItemGroup>
3737

38+
<ItemGroup>
39+
<Folder Include="Utils" />
40+
</ItemGroup>
41+
3842
</Project>

util/tests/KubernetesClient.Util.Tests/KubernetesClient.Util.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@
2727
<ProjectReference Include="..\..\src\KubernetesClient.Util\KubernetesClient.Util.csproj" />
2828
</ItemGroup>
2929

30+
<ItemGroup>
31+
<Folder Include="Cache" />
32+
</ItemGroup>
33+
3034
</Project>

0 commit comments

Comments
 (0)