-
Notifications
You must be signed in to change notification settings - Fork 1
Make Property Conditionaly (#55) #56
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
Conversation
WalkthroughThe changes update the project’s documentation, dependencies, and test configurations. The README now includes instructions for using an operator-specific application builder, adding a new controller with a finalizer, and configuring custom launch profiles for installation. Package versions are updated in both source and test configuration files. Additionally, the testing framework has switched assertion libraries in some areas and added detailed package reference settings in test project files. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant Builder as OperatorHost
participant Controller as ProjectController
participant Installer as Install Process
App->>Builder: CreateOperatorApplicationBuilder(args)
Builder->>Controller: AddController(ProjectController).WithFinalizer("project.local.finalizer")
Builder->>App: Build Application (app = builder.Build())
App->>Installer: Execute AddInstall() to generate install.yaml
Installer->>App: Return installation configuration
App->>App: RunAsync()
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
test/K8sOperator.NET.Tests/ControllerTests.cs (1)
83-84: Consider using FluentAssertions consistentlyThese lines correctly use FluentAssertions syntax, but other tests in this file still use the traditional
Assert.True(true)pattern. For consistency, consider using FluentAssertions throughout all tests.- Assert.True(true); + true.Should().BeTrue();README.md (1)
112-117: Grammar issue in installation instructionsThe sentence structure in line 112 is incorrect.
-By running the `Install` profile will create the install.yaml file in the root of the project. +Running the `Install` profile will create the install.yaml file in the root of the project.or:
-By running the `Install` profile will create the install.yaml file in the root of the project. +By running the `Install` profile, you will create the install.yaml file in the root of the project.🧰 Tools
🪛 LanguageTool
[grammar] ~112-~112: The word ‘install’ is not a noun.
Context: ...g theInstallprofile will create the install.yaml file in the root of the project. T...(A_INSTALL)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
README.md(3 hunks)src/Directory.Packages.props(1 hunks)test/Directory.Build.props(2 hunks)test/Directory.Packages.props(1 hunks)test/K8sOperator.NET.Generators.Tests/K8sOperator.NET.Generators.Tests.csproj(1 hunks)test/K8sOperator.NET.Tests/ControllerTests.cs(1 hunks)test/K8sOperator.NET.Tests/K8sOperator.NET.Tests.csproj(1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md
[grammar] ~112-~112: The word ‘install’ is not a noun.
Context: ...g the Install profile will create the install.yaml file in the root of the project. T...
(A_INSTALL)
🔇 Additional comments (15)
test/K8sOperator.NET.Tests/K8sOperator.NET.Tests.csproj (1)
9-18: LGTM! Package references consistently configuredThe package configurations align with best practices by specifying private assets and include assets correctly for these test dependencies.
test/K8sOperator.NET.Generators.Tests/K8sOperator.NET.Generators.Tests.csproj (1)
2-11: LGTM! Package references consistently configuredThe package configurations align with best practices by specifying private assets and include assets correctly for these test dependencies, matching the approach in other test projects.
src/Directory.Packages.props (3)
8-8: LGTM! Updated AspNetCore.Http.Abstractions packageThe minor version update from 2.2.0 to 2.3.0 shouldn't introduce breaking changes.
12-12: LGTM! Updated static analysis toolUpgrading SonarAnalyzer.CSharp might introduce new or updated rules. This is good for maintaining code quality standards.
7-7:Details
❓ Verification inconclusive
Verify compatibility with KubernetesClient major version upgrade
Upgrading from 15.0.1 to 16.0.2 is a major version change that might include breaking changes. Ensure your codebase is compatible with this new version.
🏁 Script executed:
#!/bin/bash # Check for KubernetesClient API usage that might be affected by the upgrade rg "kubernetes|k8s|KubernetesClient" --type csharp -A 2 -B 2Length of output: 21253
Action: Confirm compatibility with KubernetesClient V16.0.2
The upgrade from version 15.0.1 to 16.0.2 introduces a major version change that may include breaking API changes. Our repository shows widespread usage of Kubernetes-related types (e.g., instances of
IKubernetes,Kubernetes, and client implementations in both production and test files). Although no immediate incompatibilities are evident from the static search, please ensure that:
- All client implementations in files such as
src/K8sOperator.NET/KubernetesClient.cs,src/K8sOperator.NET/Builder/EventWatcherBuilder.cs, and related builders properly work with the updated API.- Test cases (notably in
test/K8sOperator.NET.Tests/*) that instantiate or substitute KubernetesClient components continue to pass without issues.- Integration tests are executed to catch any subtle behavioral changes due to the upgrade.
Once these areas have been verified, you can confidently proceed with the upgrade.
test/Directory.Build.props (2)
28-28: Global using directive updated to match package referenceThe global using directive has been correctly updated to match the new AwesomeAssertions package reference.
15-15:Details
❓ Verification inconclusive
Package reference switched from FluentAssertions to AwesomeAssertions
The testing framework is now using AwesomeAssertions instead of FluentAssertions. This is a significant change that should be carefully managed.
🏁 Script executed:
#!/bin/bash # Verify if any test files still use FluentAssertions syntax that may need updating rg -l "Should\(\)" --type cs --glob "test/**/*.cs" | head -n 5 # Check if AwesomeAssertions is publicly available curl -s "https://api.nuget.org/v3-flatcontainer/awesomeassertions/index.json" | jqLength of output: 508
Attention: Verify Assertion Syntax Compatibility
The package reference in
test/Directory.Build.propsnow points to AwesomeAssertions instead of FluentAssertions. However, our verification shows that several test files (e.g.,test/K8sOperator.NET.Tests/EntityScope.cs,ControllerTests.cs,ChangeTrackerTests.cs, andControllerDatasourceTests.cs) still contain calls toShould(). Although AwesomeAssertions is publicly available (versions ranging from 7.0.0 to 8.0.2) and might support this syntax as a drop-in replacement, please confirm that theseShould()assertions work as expected with AwesomeAssertions. If there are any discrepancies in behavior or if the new package requires syntax adjustments, update the tests accordingly.test/Directory.Packages.props (4)
12-13: Minor updates to testing packagesUpdates to Microsoft.NET.Test.Sdk (17.11.1 → 17.13.0) and NSubstitute (5.1.0 → 5.3.0) are minor updates that should not introduce breaking changes.
7-8:Details
✅ Verification successful
Updated dependencies including major assertion library change
Package updates include:
- Minor update to coverlet.collector (6.0.2 → 6.0.4)
- Complete replacement of FluentAssertions with AwesomeAssertions 8.0.2
The switch to AwesomeAssertions is a major change that may require test code updates.
🌐 Web query:
Is AwesomeAssertions a real .NET testing library?💡 Result:
AwesomeAssertions is a real .NET testing library designed to enhance unit testing with intuitive assertion methods and detailed failure messages. Originally forked from Fluent Assertions by Dennis Doomen and Jonas Nyrup, it continues under the Apache-2 license and supports modern .NET platforms like .NET 6+, .NET Framework 4.7+, and .NET Standard 2.0+[1][3][5].
Key Features:
- Expressive Syntax: Enables chaining assertions (e.g.,
actual.Should().StartWith("AB").And.EndWith("HI")) for readability[2][3].- Diagnostic Clarity: Provides failure messages that highlight mismatches (e.g.,
Expected "1234567890" to be "0987654321"with contextual details)[1][2].- Cross-Platform Support: Integrates with MSTest V2, xUnit, NUnit, MSpec, and TUnit[1][3].
- Extensibility: Offers custom assertion methods and stack trace analysis to improve test reporting[2].
Example Usage:
string accountNumber = "1234567890"; accountNumber.Should().Be("0987654321");If this assertion fails, it outputs:
Expected accountNumber to be “0987654321”, but “1234567890” differs near “123” (index 0)[1]The library is actively maintained, with analyzers and community extensions available on GitHub to enforce best practices[9]. Its documentation and compatibility with major .NET test frameworks confirm its status as a legitimate testing tool[3][8].
Citations:
- 1: https://awesomeassertions.org/about/
- 2: https://awesomeassertions.org/introduction
- 3: https://awesomeassertions.org
- 4: https://www.lambdatest.com/blog/c-sharp-testing-frameworks/
- 5: https://www.fluentassertions.com
- 6: https://dev.to/tipsy_dev/testing-library-writing-better-async-tests-c67
- 7: https://blog.safnet.com/archive/2018/12/03/assertion-comparisons/
- 8: https://github.com/ilya-chumakov/awesome-dotnet-testing
- 9: https://github.com/AwesomeAssertions/AwesomeAssertions.analyzers
Dependency Update Verification – Approved
The dependency changes in
test/Directory.Packages.propshave been verified. The version bump forcoverlet.collector(6.0.2 → 6.0.4) is correct, and the switch from FluentAssertions to the legitimate AwesomeAssertions 8.0.2 is confirmed. Note that the major change to AwesomeAssertions might necessitate corresponding updates in test code.
16-17:Details
❓ Verification inconclusive
Updated xUnit packages including major version change
The xunit package is updated from 2.9.2 to 2.9.3 (minor), but xunit.runner.visualstudio is updated from 2.8.2 to 3.0.2 (major version change).
🌐 Web query:
What are the breaking changes in xunit.runner.visualstudio 3.0.2 compared to 2.8.2?💡 Result:
The transition from
xunit.runner.visualstudio2.8.2 to 3.0.2 introduces several breaking changes and critical updates:Compatibility Changes
- Requirement for v3 Test Execution: Version 3.x.y of the Visual Studio adapter is mandatory for running xUnit.net v3 tests. The 2.x.y releases no longer support v3 tests and are now superseded, though 3.x.y can still run v1/v2 tests[2][4].
- Platform Support:
- Adjusted Runtime Dependencies: The 3.0.2 runner no longer supports .NET Framework versions below 4.6.2 or non-Windows platforms using Mono for .NET Framework tests. Linux/macOS users must ensure tests are updated to .NET 6+ or use platform-compatible frameworks[4][8].
Configuration and Execution
- New RunSettings Options:
Option Purpose CultureSpecifies the culture for test execution ExplicitControls inclusion of tests marked as [Explicit]FailWarnsTreats warnings as errors SeedSets randomization seed for theories These options override xunit.runner.jsonsettings if both are present[4][6].- Explicit Test Handling: Tests marked with
Explicitnow adhere strictly to theExplicitRunSetting, and skipped tests are reported as "not run" instead of ignored[4][7].Diagnostics and Reporting
- Test Execution Metadata: Start/end timestamps (
StartTime,EndTime) are now reported to VSTest, resolving timing inaccuracies indotnet testsummaries[4].- Source Information Fixes: Inherited tests now correctly report file/line numbers, reducing ambiguity in test origins[4].
Deprecated Features
- Legacy Configuration: The
xunit.runner.jsonfile might be bypassed in favor of RunSettings, leading to potential misconfigurations if migration isn't performed[4][6].- Cancellation Workflow: The 3.0.2 runner uses
TestContext.Current.CancellationTokenfor immediate test cancellation, replacing older message-based cancellation systems. Tests relying on delayed cancellation behavior may fail unexpectedly[10].Known Upgrade Issues
- NullReferenceException: Some users report exceptions after upgrading, particularly in CI environments (e.g., Linux runners). Workarounds involve ensuring all dependencies align with v3 requirements[8][9].
- Debugging in VSCode: Debugger launches previously failing in VSCode were fixed, but custom debug configurations might require updates[4].
For projects using v2 tests, ensure runner configurations explicitly target v2 frameworks to avoid unintended behavior[5]. Migrating to .NET 6+ or .NET Framework 4.7.2+ is strongly advised for full compatibility[1][10].
Citations:
- 1: https://www.nuget.org/packages/xunit.runner.visualstudio
- 2: https://xunit.net/releases/v3/0.2.0-pre.69
- 3: https://github.com/xunit/visualstudio.xunit
- 4: https://xunit.net/releases/visualstudio/3.0.0
- 5: https://xunit.net
- 6: https://xunit.net/docs/runsettings
- 7: https://xunit.net/docs/getting-started/v3/whats-new
- 8: xunit/xunit#3125
- 9: xunit/xunit#3145
- 10: https://xunit.net/releases/v3/2.0.0
Action Required: Verify xUnit Runner Configuration
The xunit package has been updated from 2.9.2 to 2.9.3—a minor change that shouldn’t affect compatibility. However, the xunit.runner.visualstudio update from 2.8.2 to 3.0.2 is a major leap that introduces several breaking changes. Notable points include:
- Test Execution Requirements: Version 3 requires using xUnit.net v3 tests; the 2.x runner no longer supports v3 tests.
- Platform and Runtime Dependencies: The 3.0.2 runner drops support for .NET Framework versions below 4.6.2 (and has limited support on non-Windows platforms for legacy frameworks), so verify your target framework is compatible.
- Configuration Changes: New RunSettings options and changes in test cancellation/reporting may necessitate updates to your test configuration files (e.g., transitioning from
xunit.runner.jsonto RunSettings).Please verify that these changes align with your project’s testing infrastructure and update any relevant configurations accordingly.
File:
test/Directory.Packages.props(Lines 16-17)<PackageVersion Include="xunit" Version="2.9.3" /> <PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
9-10:Details
❓ Verification inconclusive
Microsoft.AspNetCore packages updated to version 2.3.0
Both Microsoft.AspNetCore and Microsoft.AspNetCore.Hosting.Abstractions have been updated from version 2.2.0 to 2.3.0. This is a potentially significant update.
🌐 Web query:
What are the breaking changes between Microsoft.AspNetCore 2.2.0 and 2.3.0?💡 Result:
To transition from ASP.NET Core 2.2.0 to 2.3.0, you'll encounter breaking changes due to Microsoft re-versioning ASP.NET Core 2.1 as 2.3.0 to extend support for .NET Framework users[1][2]. This means upgrading from 2.2.x to 2.3.x functionally downgrades your application to 2.1.x code, requiring removal of all dependencies on ASP.NET Core 2.2-specific features[1][2].
Key breaking changes include:
Feature/Capability ASP.NET Core 2.2 ASP.NET Core 2.3 (≈ 2.1) Required Action Endpoint Routing Introduced new endpoint routing system ( UseEndpoints)Reverts to pre-2.2 routing Rewrite routing logic using older MVC routing patterns[3][7]. OpenAPI Analyzers Native OpenAPI support via conventions/analyzers Removed Replace with third-party tools like NSwag/Swashbuckle[3]. ProblemDetails Responses Automatic RFC 7807 ProblemDetailsfor 4xx errorsDisabled Manual implementation required[3]. In-Process IIS Hosting Supported via AspNetCoreHostingModelNot available Revert to out-of-process hosting[3]. Health Checks Service Built-in health checks middleware Absent Remove dependency or backport logic[3]. SignalR Java Client Native Java client support Unavailable Downgrade to community alternatives[3]. CORS Policy Matching Strict header validation for CORS policies Relaxed pre-2.2 behavior Adjust CORS configuration[3]. Upgrade implications:
- Library Compatibility: NuGet packages requiring ASP.NET Core 2.2 will fail to resolve dependencies in 2.3.x projects[1][2].
- Security Risks: ASP.NET Core 2.2 has been unsupported since 2019[1][2], so continuing on 2.2 exposes applications to vulnerabilities.
- Migration Path: For supported .NET Framework scenarios, rewrite 2.2-specific code. For modern .NET Core, upgrade to LTS versions like .NET 8[1][2][5].
Steps to mitigate breaking changes:
- Audit Dependencies: Remove any direct references to ASP.NET Core 2.2 packages[1][9].
- Downgrade Features: Strip out 2.2-specific features (e.g., endpoint routing)[3][7].
- Test Thoroughly: Validate API responses, routing, and third-party integrations[1].
This re-versioning strategy prioritizes security updates for legacy .NET Framework deployments over backward compatibility[1][2]. For long-term support, Microsoft recommends migrating to .NET 8[1][5].
Citations:
- 1: https://devblogs.microsoft.com/dotnet/servicing-release-advisory-aspnetcore-23/
- 2: dotnet/announcements#331
- 3: https://learn.microsoft.com/en-us/aspnet/core/release-notes/aspnetcore-2.2?view=aspnetcore-9.0
- 4: https://learn.microsoft.com/en-us/dotnet/core/compatibility/aspnetcore
- 5: https://www.hanselman.com/blog/updating-an-aspnet-core-22-web-site-to-net-core-31-lts
- 6: https://abp.io/docs/latest/release-info/migration-guides/abp-8-0
- 7: https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-9.0
- 8: https://github.com/dotnet/core/blob/master/release-notes/2.2/2.2.3/2.2.3.md
- 9: https://www.nuget.org/packages/Microsoft.AspNetCore/
- 10: https://github.com/microsoft/ApplicationInsights-dotnet/blob/main/CHANGELOG.md
ACTION: Confirm compatibility and update dependent code for re-versioned ASP.NET Core packages
File:
test/Directory.Packages.props(Lines 9-10)
Snippet:<PackageVersion Include="Microsoft.AspNetCore" Version="2.3.0" /> <PackageVersion Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.3.0" />Comment:
BothMicrosoft.AspNetCoreandMicrosoft.AspNetCore.Hosting.Abstractionshave been updated from version 2.2.0 to 2.3.0. Note that this update is not a conventional upgrade; it re-versions ASP.NET Core 2.1 as 2.3.0 to support .NET Framework scenarios. This effectively means that features introduced in 2.2.0 may now be absent or altered, which can lead to breaking changes. Key differences to be aware of include:
- Endpoint Routing: Changes may revert to pre-2.2 routing patterns, potentially impacting your existing routing logic.
- OpenAPI Analyzers & ProblemDetails: Native support and automatic behaviors available in 2.2.0 might now be removed, requiring manual handling or alternative tools.
- In-Process IIS Hosting & Health Checks: Adjustments or removals could affect hosting and middleware functionality.
Next Steps:
- Audit application code: Verify that no dependencies or features rely on ASP.NET Core 2.2-specific behaviors.
- Test thoroughly: Validate routing, API error handling, and hosting implementations under the new version.
- Plan for potential refactoring: Adjust code where necessary to align with the functionalities of ASP.NET Core 2.1.
README.md (4)
34-34: Added K8sOperator.NET.Generators package referenceThe documentation now includes the K8sOperator.NET.Generators package in both the installation command and manual .csproj configuration. This is a good documentation update that aligns with the new functionality.
Also applies to: 41-41
53-62: Updated application initialization patternThe example has been updated to show the operator-specific application builder pattern:
- Using
OperatorHost.CreateOperatorApplicationBuilderinstead ofWebApplication.CreateBuilder- Adding a controller with a finalizer
- Adding installation support with
app.AddInstall()- Using async await pattern for application run
This provides a clearer, more concise example for Kubernetes operator development.
66-106: New section for launchSettings.json configurationAdded comprehensive documentation for configuring different launch profiles:
- Operator mode - For running the operator
- Install mode - For generating installation YAML
- Help and Version modes - For accessing built-in commands
This addition significantly improves the developer experience by providing ready-to-use configurations.
132-132:Details
✅ Verification successful
Updated license file reference
The license link has been updated from LICENSE to LICENSE.md.
🏁 Script executed:
#!/bin/bash # Check if LICENSE.md exists in the repository if [ -f LICENSE.md ]; then echo "LICENSE.md exists" else echo "LICENSE.md does not exist - verify if this is the correct filename" if [ -f LICENSE ]; then echo "However, LICENSE file exists" fi fiLength of output: 68
License File Reference Verified
The LICENSE file link in the README has been correctly updated to point to
LICENSE.mdas confirmed by our verification. No further changes are necessary.
| @@ -1,4 +1,6 @@ | |||
| namespace K8sOperator.NET.Tests; | |||
| using FluentAssertions; | |||
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.
💡 Verification agent
🧩 Analysis chain
Consider standardizing assertion libraries across test projects
You've added FluentAssertions here, but according to the summary, other parts of the project are moving to AwesomeAssertions. This might lead to inconsistent assertion styles across the codebase.
🏁 Script executed:
#!/bin/bash
# Check which assertion libraries are being used across test projects
rg -l "using .*Assertions;" --type csharpLength of output: 145
Action Required: Align Assertion Library Usage
The ControllerTests.cs file currently imports and uses FluentAssertions, while evidence from ControllerDatasourceTests.cs shows a shift toward AwesomeAssertions. To ensure consistency across test projects, please standardize on AwesomeAssertions by updating the import and any affected test assertions accordingly.
Summary by CodeRabbit
New Features
Documentation
Dependency Updates
FluentAssertionstoAwesomeAssertionsfor enhanced testing capabilities.