Skip to content

Commit 47b8330

Browse files
committed
Refactor client constructors to use Kubernetes type instead of IKubernetes
1 parent 1347826 commit 47b8330

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

examples/clientset/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal class Program
1010
private static async Task Main(string[] args)
1111
{
1212
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
13-
IKubernetes client = new Kubernetes(config);
13+
var client = new Kubernetes(config);
1414

1515
ClientSet clientSet = new ClientSet(client);
1616
var list = await clientSet.CoreV1.Pods.ListAsync("default").ConfigureAwait(false);

src/KubernetesClient/ClientSets/ResourceClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ namespace k8s.ClientSets;
33
public abstract class ResourceClient
44
{
55
protected Kubernetes Client { get; }
6-
public ResourceClient(IKubernetes kubernetes)
6+
public ResourceClient(Kubernetes kubernetes)
77
{
8-
Client = (Kubernetes)kubernetes;
8+
Client = kubernetes;
99
}
1010
}

src/LibKubernetesGenerator/GeneralNameHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void RegisterHelper(ScriptObject scriptObject)
2222
{
2323
scriptObject.Import(nameof(GetInterfaceName), new Func<JsonSchema, string>(GetInterfaceName));
2424
scriptObject.Import(nameof(GetMethodName), new Func<OpenApiOperation, string, string>(GetMethodName));
25-
scriptObject.Import(nameof(GetActionName), new Func<OpenApiOperationDescription, string, string, string>(GetActionName));
25+
scriptObject.Import(nameof(GetActionTypeName), new Func<OpenApiOperationDescription, string, string, string>(GetActionTypeName));
2626
scriptObject.Import(nameof(GetDotNetName), new Func<string, string, string>(GetDotNetName));
2727
scriptObject.Import(nameof(GetDotNetNameOpenApiParameter), new Func<OpenApiParameter, string, string>(GetDotNetNameOpenApiParameter));
2828
}
@@ -164,7 +164,7 @@ public static string GetMethodName(OpenApiOperation watchOperation, string suffi
164164
return methodName;
165165
}
166166

167-
public static string GetActionName(OpenApiOperationDescription apiOperation, string resource, string suffix)
167+
public static string GetActionTypeName(OpenApiOperationDescription apiOperation, string resource, string suffix)
168168
{
169169
var actionType = apiOperation.Operation?.ExtensionData?["x-kubernetes-action"] as string;
170170

src/LibKubernetesGenerator/templates/Client.cs.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace k8s.ClientSets;
1212
/// </summary>
1313
public partial class {{name}}Client : ResourceClient
1414
{
15-
public {{name}}Client(IKubernetes kubernetes) : base(kubernetes)
15+
public {{name}}Client(Kubernetes kubernetes) : base(kubernetes)
1616
{
1717
}
1818

@@ -28,7 +28,7 @@ public partial class {{name}}Client : ResourceClient
2828
/// <param name="cancellationToken">
2929
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
3030
/// </param>
31-
public async Task{{GetReturnType api.operation "<>"}} {{GetActionName api name "Async"}}(
31+
public async Task{{GetReturnType api.operation "<>"}} {{GetActionTypeName api name "Async"}}(
3232
{{ for parameter in api.operation.parameters}}
3333
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "true"}},
3434
{{ end }}
@@ -79,7 +79,7 @@ public partial class {{name}}Client : ResourceClient
7979
/// <param name="cancellationToken">
8080
/// A <see cref="CancellationToken"/> which can be used to cancel the asynchronous operation.
8181
/// </param>
82-
public async Task<T> {{GetActionName api name "Async"}}<T>(
82+
public async Task<T> {{GetActionTypeName api name "Async"}}<T>(
8383
{{ for parameter in api.operation.parameters}}
8484
{{GetDotNetTypeOpenApiParameter parameter}} {{GetDotNetNameOpenApiParameter parameter "false"}},
8585
{{ end }}

src/LibKubernetesGenerator/templates/ClientSet.cs.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace k8s.ClientSets;
1111
public partial class ClientSet
1212
{
1313
{{for group in groups}}
14-
public {{group}}GroupClient {{group}};
14+
public {{group}}GroupClient {{group}} { get; }
1515
{{end}}
1616

17-
public ClientSet(IKubernetes kubernetes)
17+
public ClientSet(Kubernetes kubernetes)
1818
{
1919
{{for group in groups}}
2020
{{group}} = new {{group}}GroupClient(kubernetes);

src/LibKubernetesGenerator/templates/GroupClient.cs.template

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ namespace k8s.ClientSets;
1111
/// </summary>
1212
public partial class {{name}}GroupClient
1313
{
14+
1415
{{for client in clients}}
15-
public {{client}}Client {{client}};
16+
public {{client}}Client {{client}} { get; }
1617
{{end}}
1718

18-
public {{name}}GroupClient(IKubernetes kubernetes)
19+
public {{name}}GroupClient(Kubernetes kubernetes)
1920
{
2021
{{for client in clients}}
2122
{{client}} = new {{client}}Client(kubernetes);

0 commit comments

Comments
 (0)