Skip to content

Commit eff4af5

Browse files
authored
chore(deps): updated k8s KubernetesClient to v18.0.5 (#976)
update KubernetesClient. Closes #967.
1 parent 1096ff9 commit eff4af5

24 files changed

+358
-187
lines changed

src/KubeOps.Abstractions/Entities/CustomKubernetesEntity{TSpec,TStatus}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information.
44

5-
using k8s;
5+
using k8s.Models;
66

77
namespace KubeOps.Abstractions.Entities;
88

src/KubeOps.Abstractions/Entities/CustomKubernetesEntity{TSpec}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information.
44

5-
using k8s;
5+
using k8s.Models;
66

77
namespace KubeOps.Abstractions.Entities;
88

src/KubeOps.Abstractions/Entities/KubernetesExtensions.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ public static TEntity WithOwnerReference<TEntity>(
8383
/// <param name="kubernetesObject">The object that should be translated.</param>
8484
/// <returns>The created <see cref="V1OwnerReference"/>.</returns>
8585
public static V1OwnerReference MakeOwnerReference(this IKubernetesObject<V1ObjectMeta> kubernetesObject)
86-
=> new(
87-
kubernetesObject.ApiVersion,
88-
kubernetesObject.Kind,
89-
kubernetesObject.Metadata.Name,
90-
kubernetesObject.Metadata.Uid);
86+
=> new()
87+
{
88+
ApiVersion = kubernetesObject.ApiVersion,
89+
Kind = kubernetesObject.Kind,
90+
Name = kubernetesObject.Metadata.Name,
91+
Uid = kubernetesObject.Metadata.Uid,
92+
};
9193

9294
private static IList<V1OwnerReference> EnsureOwnerReferences(this V1ObjectMeta meta) =>
9395
meta.OwnerReferences ??= new List<V1OwnerReference>();

src/KubeOps.Abstractions/KubeOps.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<ItemGroup>
1717
<PackageReference Include="JsonPatch.Net" Version="3.3.0" />
18-
<PackageReference Include="KubernetesClient" Version="17.0.14" />
18+
<PackageReference Include="KubernetesClient" Version="18.0.5" />
1919
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.10"/>
2020
<PackageReference Include="ZiggyCreatures.FusionCache" Version="2.4.0" />
2121
</ItemGroup>

src/KubeOps.Cli/Commands/Generator/OperatorGenerator.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.CommandLine;
6-
using System.CommandLine.Invocation;
76
using System.Text;
87

98
using k8s;
@@ -116,15 +115,15 @@ internal static async Task<int> Handler(IAnsiConsole console, ParseResult parseR
116115

117116
result.Add(
118117
$"namespace.{format.GetFileExtension()}",
119-
new V1Namespace(metadata: new(name: "system")).Initialize());
118+
new V1Namespace { Metadata = new() { Name = "system" } }.Initialize());
120119

121120
result.Add(
122121
$"kustomization.{format.GetFileExtension()}",
123122
new KustomizationConfig
124123
{
125124
NamePrefix = $"{name}-",
126125
Namespace = $"{name}-system",
127-
Labels = [new KustomizationCommonLabels(new Dictionary<string, string> { { "operator", name }, })],
126+
Labels = [new(new Dictionary<string, string> { { "operator", name }, })],
128127
Resources = result.DefaultFormatFiles.ToList(),
129128
Images =
130129
new List<KustomizationImage>

src/KubeOps.Cli/Generators/DeploymentGenerator.cs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,33 @@
99

1010
namespace KubeOps.Cli.Generators;
1111

12-
internal class DeploymentGenerator(OutputFormat format) : IConfigGenerator
12+
internal sealed class DeploymentGenerator(OutputFormat format) : IConfigGenerator
1313
{
1414
public void Generate(ResultOutput output)
1515
{
16-
var deployment = new V1Deployment(metadata: new V1ObjectMeta(
17-
labels: new Dictionary<string, string> { { "operator-deployment", "kubernetes-operator" } },
18-
name: "operator")).Initialize();
19-
deployment.Spec = new V1DeploymentSpec
16+
var deployment = new V1Deployment
17+
{
18+
Metadata = new()
19+
{
20+
Name = "operator",
21+
Labels = new Dictionary<string, string> { { "operator-deployment", "kubernetes-operator" } },
22+
},
23+
}.Initialize();
24+
deployment.Spec = new()
2025
{
2126
Replicas = 1,
2227
RevisionHistoryLimit = 0,
23-
Selector = new V1LabelSelector(
24-
matchLabels: new Dictionary<string, string> { { "operator-deployment", "kubernetes-operator" } }),
25-
Template = new V1PodTemplateSpec
28+
Selector = new()
2629
{
27-
Metadata = new V1ObjectMeta(
28-
labels: new Dictionary<string, string> { { "operator-deployment", "kubernetes-operator" } }),
29-
Spec = new V1PodSpec
30+
MatchLabels = new Dictionary<string, string> { { "operator-deployment", "kubernetes-operator" } },
31+
},
32+
Template = new()
33+
{
34+
Metadata = new()
35+
{
36+
Labels = new Dictionary<string, string> { { "operator-deployment", "kubernetes-operator" } },
37+
},
38+
Spec = new()
3039
{
3140
TerminationGracePeriodSeconds = 10,
3241
Containers = new List<V1Container>
@@ -41,26 +50,26 @@ public void Generate(ResultOutput output)
4150
{
4251
Name = "POD_NAMESPACE",
4352
ValueFrom =
44-
new V1EnvVarSource
53+
new()
4554
{
46-
FieldRef = new V1ObjectFieldSelector
55+
FieldRef = new()
4756
{
4857
FieldPath = "metadata.namespace",
4958
},
5059
},
5160
},
5261
},
53-
Resources = new V1ResourceRequirements
62+
Resources = new()
5463
{
5564
Requests = new Dictionary<string, ResourceQuantity>
5665
{
57-
{ "cpu", new ResourceQuantity("100m") },
58-
{ "memory", new ResourceQuantity("64Mi") },
66+
{ "cpu", new("100m") },
67+
{ "memory", new("64Mi") },
5968
},
6069
Limits = new Dictionary<string, ResourceQuantity>
6170
{
62-
{ "cpu", new ResourceQuantity("100m") },
63-
{ "memory", new ResourceQuantity("128Mi") },
71+
{ "cpu", new("100m") },
72+
{ "memory", new("128Mi") },
6473
},
6574
},
6675
},

src/KubeOps.Cli/Generators/MutationWebhookGenerator.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ public void Generate(ResultOutput output)
2020
return;
2121
}
2222

23-
var mutatorConfig = new V1MutatingWebhookConfiguration(
24-
metadata: new V1ObjectMeta(name: "mutators"),
25-
webhooks: new List<V1MutatingWebhook>()).Initialize();
23+
var mutatorConfig = new V1MutatingWebhookConfiguration
24+
{
25+
Metadata = new() { Name = "mutators" },
26+
Webhooks = new List<V1MutatingWebhook>(),
27+
}.Initialize();
2628

2729
foreach (var hook in webhooks)
2830
{
29-
mutatorConfig.Webhooks.Add(new V1MutatingWebhook
31+
mutatorConfig.Webhooks.Add(new()
3032
{
3133
Name = $"mutate.{hook.Metadata.SingularName}.{hook.Metadata.Group}.{hook.Metadata.Version}",
3234
MatchPolicy = "Exact",
@@ -42,10 +44,10 @@ public void Generate(ResultOutput output)
4244
ApiVersions = new[] { hook.Metadata.Version },
4345
},
4446
},
45-
ClientConfig = new Admissionregistrationv1WebhookClientConfig
47+
ClientConfig = new()
4648
{
4749
CaBundle = caBundle,
48-
Service = new Admissionregistrationv1ServiceReference
50+
Service = new()
4951
{
5052
Name = "operator",
5153
Path = hook.WebhookPath,

src/KubeOps.Cli/Generators/RbacGenerator.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
namespace KubeOps.Cli.Generators;
1616

17-
internal class RbacGenerator(MetadataLoadContext parser,
17+
internal sealed class RbacGenerator(
18+
MetadataLoadContext parser,
1819
OutputFormat outputFormat) : IConfigGenerator
1920
{
2021
public void Generate(ResultOutput output)
@@ -24,17 +25,29 @@ public void Generate(ResultOutput output)
2425
.Concat(parser.GetContextType<DefaultRbacAttributes>().GetCustomAttributesData<EntityRbacAttribute>())
2526
.ToList();
2627

27-
var role = new V1ClusterRole(rules: parser.Transpile(attributes).ToList()).Initialize();
28+
var role = new V1ClusterRole { Rules = parser.Transpile(attributes).ToList() }.Initialize();
2829
role.Metadata.Name = "operator-role";
2930
output.Add($"operator-role.{outputFormat.GetFileExtension()}", role);
3031

31-
var roleBinding = new V1ClusterRoleBinding(
32-
roleRef: new V1RoleRef(V1ClusterRole.KubeGroup, V1ClusterRole.KubeKind, "operator-role"),
33-
subjects: new List<Rbacv1Subject>
32+
var roleBinding = new V1ClusterRoleBinding
33+
{
34+
RoleRef = new()
35+
{
36+
ApiGroup = V1ClusterRole.KubeGroup,
37+
Kind = V1ClusterRole.KubeKind,
38+
Name = "operator-role",
39+
},
40+
Subjects = new List<Rbacv1Subject>
41+
{
42+
new()
3443
{
35-
new(V1ServiceAccount.KubeKind, "default", namespaceProperty: "system"),
36-
})
37-
.Initialize();
44+
Kind = V1ServiceAccount.KubeKind,
45+
Name = "default",
46+
NamespaceProperty = "system",
47+
},
48+
},
49+
}
50+
.Initialize();
3851
roleBinding.Metadata.Name = "operator-role-binding";
3952
output.Add($"operator-role-binding.{outputFormat.GetFileExtension()}", roleBinding);
4053
}

src/KubeOps.Cli/Generators/ValidationWebhookGenerator.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace KubeOps.Cli.Generators;
1212

13-
internal class ValidationWebhookGenerator
13+
internal sealed class ValidationWebhookGenerator
1414
(List<ValidationWebhook> webhooks, byte[] caBundle, OutputFormat format) : IConfigGenerator
1515
{
1616
public void Generate(ResultOutput output)
@@ -20,13 +20,15 @@ public void Generate(ResultOutput output)
2020
return;
2121
}
2222

23-
var validatorConfig = new V1ValidatingWebhookConfiguration(
24-
metadata: new V1ObjectMeta(name: "validators"),
25-
webhooks: new List<V1ValidatingWebhook>()).Initialize();
23+
var validatorConfig = new V1ValidatingWebhookConfiguration
24+
{
25+
Metadata = new() { Name = "validators" },
26+
Webhooks = new List<V1ValidatingWebhook>(),
27+
}.Initialize();
2628

2729
foreach (var hook in webhooks)
2830
{
29-
validatorConfig.Webhooks.Add(new V1ValidatingWebhook
31+
validatorConfig.Webhooks.Add(new()
3032
{
3133
Name = $"validate.{hook.Metadata.SingularName}.{hook.Metadata.Group}.{hook.Metadata.Version}",
3234
MatchPolicy = "Exact",
@@ -42,10 +44,10 @@ public void Generate(ResultOutput output)
4244
ApiVersions = new[] { hook.Metadata.Version },
4345
},
4446
},
45-
ClientConfig = new Admissionregistrationv1WebhookClientConfig
47+
ClientConfig = new()
4648
{
4749
CaBundle = caBundle,
48-
Service = new Admissionregistrationv1ServiceReference
50+
Service = new()
4951
{
5052
Name = "operator",
5153
Path = hook.WebhookPath,

0 commit comments

Comments
 (0)