-
Couldn't load subscription status.
- Fork 304
feat: enhance Kubernetes client with watch functionality #1667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
80b46b7
6979dd5
136b103
f9a3d9c
201be85
942a645
9ac1f9c
4d752ed
5e47c09
6de5558
c6bda21
85d7011
0877710
09a7717
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ public static class WatcherExt | |
| /// The action to invoke when the server closes the connection. | ||
| /// </param> | ||
| /// <returns>a watch object</returns> | ||
| [Obsolete("This method will be deprecated in future versions.")] | ||
| public static Watcher<T> Watch<T, L>( | ||
| this Task<HttpOperationResponse<L>> responseTask, | ||
| Action<WatchEventType, T> onEvent, | ||
|
|
@@ -52,6 +53,7 @@ private static Func<Task<TextReader>> MakeStreamReaderCreator<T, L>(Task<HttpOpe | |
| /// The action to invoke when the server closes the connection. | ||
| /// </param> | ||
| /// <returns>a watch object</returns> | ||
| [Obsolete("This method will be deprecated in future versions.")] | ||
| public static Watcher<T> Watch<T, L>( | ||
| this HttpOperationResponse<L> response, | ||
| Action<WatchEventType, T> onEvent, | ||
|
|
@@ -71,6 +73,7 @@ public static Watcher<T> Watch<T, L>( | |
| /// <param name="onError">a callback when any exception was caught during watching</param> | ||
| /// <param name="cancellationToken">cancellation token</param> | ||
| /// <returns>IAsyncEnumerable of watch events</returns> | ||
| [Obsolete("This method will be deprecated in future versions.")] | ||
| public static IAsyncEnumerable<(WatchEventType, T)> WatchAsync<T, L>( | ||
| this Task<HttpOperationResponse<L>> responseTask, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we should not filter so what do you think, make those There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's best to just change it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @brendanburns for ideas There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It seems that @ is wrong. It should be @brendandburns There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping @brendandburns There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to keep it compatible for one version to give people a chance to migrate and then we can remove/update. Does that work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restored, thanks |
||
| Action<Exception> onError = null, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -245,6 +245,16 @@ | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| case "T": | ||||||||||||||||||||||||||||||||
| var itemType = TryGetItemTypeFromSchema(response); | ||||||||||||||||||||||||||||||||
tg123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
| if (itemType != null) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| return itemType; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||
| case "TList": | ||||||||||||||||||||||||||||||||
| return t; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return t; | ||||||||||||||||||||||||||||||||
|
|
@@ -283,5 +293,26 @@ | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| private string TryGetItemTypeFromSchema(OpenApiResponse response) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| var listSchema = response?.Schema?.Reference; | ||||||||||||||||||||||||||||||||
| if (listSchema?.Properties?.TryGetValue("items", out var itemsProperty) != true) | ||||||||||||||||||||||||||||||||
|
Comment on lines
+298
to
+299
|
||||||||||||||||||||||||||||||||
| var listSchema = response?.Schema?.Reference; | |
| if (listSchema?.Properties?.TryGetValue("items", out var itemsProperty) != true) | |
| // Resolve the schema reference to the actual schema object | |
| var referencedSchema = response?.Schema?.ActualSchema; | |
| if (referencedSchema?.Properties?.TryGetValue("items", out var itemsProperty) != true) |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method attempts to access Properties on a JsonReference object, but JsonReference doesn't have a Properties property. This will always return null. You should resolve the reference first to get the actual schema.
| var listSchema = response?.Schema?.Reference; | |
| if (listSchema?.Properties?.TryGetValue("items", out var itemsProperty) != true) | |
| { | |
| return null; | |
| } | |
| // Resolve the reference to the actual schema before accessing Properties | |
| var referencedSchema = response?.Schema?.Reference as JsonSchema; | |
| if (referencedSchema == null) | |
| { | |
| return null; | |
| } | |
| if (!referencedSchema.Properties.TryGetValue("items", out var itemsProperty)) | |
| { | |
| return null; | |
| } |
Check warning on line 309 in src/LibKubernetesGenerator/TypeHelper.cs
GitHub Actions / MSBuild build
Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)
Check warning on line 309 in src/LibKubernetesGenerator/TypeHelper.cs
GitHub Actions / Dotnet build (ubuntu-latest)
Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)
Check warning on line 309 in src/LibKubernetesGenerator/TypeHelper.cs
GitHub Actions / Dotnet build (macOS-latest)
Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)
Check warning on line 309 in src/LibKubernetesGenerator/TypeHelper.cs
GitHub Actions / Dotnet build (windows-latest)
Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)
Check warning on line 309 in src/LibKubernetesGenerator/TypeHelper.cs
GitHub Actions / e2e
Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)
Check warning on line 309 in src/LibKubernetesGenerator/TypeHelper.cs
GitHub Actions / Analyze (csharp)
Code should not contain trailing whitespace (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md)
Uh oh!
There was an error while loading. Please reload this page.