Skip to content

Commit 0877710

Browse files
committed
refactor: update WatcherExt class to internal and remove obsolete attributes; improve example method signature in Program.cs
1 parent 85d7011 commit 0877710

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

examples/clientset/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private static async Task Main(string[] args)
2323
System.Console.WriteLine(pod?.Metadata?.Name);
2424

2525
var watch = clientSet.CoreV1.Pod.WatchListAsync("default");
26-
await foreach (var (_, item)in watch.ConfigureAwait(false))
26+
await foreach (var (_, item) in watch.ConfigureAwait(false))
2727
{
2828
System.Console.WriteLine(item.Metadata.Name);
2929
}

src/KubernetesClient/WatcherExt.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace k8s
44
{
5-
public static class WatcherExt
5+
internal static class WatcherExt
66
{
77
/// <summary>
88
/// create a watch object from a call to api server with watch=true
@@ -16,7 +16,6 @@ public static class WatcherExt
1616
/// The action to invoke when the server closes the connection.
1717
/// </param>
1818
/// <returns>a watch object</returns>
19-
[Obsolete("This method will be deprecated in future versions.")]
2019
public static Watcher<T> Watch<T, L>(
2120
this Task<HttpOperationResponse<L>> responseTask,
2221
Action<WatchEventType, T> onEvent,
@@ -53,7 +52,6 @@ private static Func<Task<TextReader>> MakeStreamReaderCreator<T, L>(Task<HttpOpe
5352
/// The action to invoke when the server closes the connection.
5453
/// </param>
5554
/// <returns>a watch object</returns>
56-
[Obsolete("This method will be deprecated in future versions.")]
5755
public static Watcher<T> Watch<T, L>(
5856
this HttpOperationResponse<L> response,
5957
Action<WatchEventType, T> onEvent,
@@ -73,7 +71,6 @@ public static Watcher<T> Watch<T, L>(
7371
/// <param name="onError">a callback when any exception was caught during watching</param>
7472
/// <param name="cancellationToken">cancellation token</param>
7573
/// <returns>IAsyncEnumerable of watch events</returns>
76-
[Obsolete("This method will be deprecated in future versions.")]
7774
public static IAsyncEnumerable<(WatchEventType, T)> WatchAsync<T, L>(
7875
this Task<HttpOperationResponse<L>> responseTask,
7976
Action<Exception> onError = null,

src/LibKubernetesGenerator/TypeHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ private string GetDotNetType(JsonSchema schema, JsonSchemaProperty parent)
122122
return $"IDictionary<string, {GetDotNetType(schema.AdditionalPropertiesSchema, parent)}>";
123123
}
124124

125-
126125
if (schema?.Reference != null)
127126
{
128127
return classNameHelper.GetClassNameForSchemaDefinition(schema.Reference);
@@ -306,7 +305,7 @@ private string TryGetItemTypeFromSchema(OpenApiResponse response)
306305
{
307306
return classNameHelper.GetClassNameForSchemaDefinition(itemsProperty.Reference);
308307
}
309-
308+
310309
if (itemsProperty.Item?.Reference != null)
311310
{
312311
return classNameHelper.GetClassNameForSchemaDefinition(itemsProperty.Item.Reference);

tests/KubernetesClient.Tests/WatchTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
732732
}
733733

734734
[Fact]
735-
public void MustHttp2VersionSet()
735+
public async Task MustHttp2VersionSet()
736736
{
737737
var server = new MockKubeApiServer(testOutput, async httpContext =>
738738
{
@@ -747,6 +747,7 @@ public void MustHttp2VersionSet()
747747
Assert.Null(handler.Version);
748748
using var watcher = client.CoreV1.WatchListNamespacedPod("default", onEvent: (type, item) => { });
749749
Assert.Equal(HttpVersion.Version20, handler.Version);
750+
await Task.CompletedTask.ConfigureAwait(true);
750751
}
751752

752753
[Fact]

0 commit comments

Comments
 (0)