-
Notifications
You must be signed in to change notification settings - Fork 4
update FabricDetails to use class object for consistency #526
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This pull request refactors SDN fabric infrastructure handling by introducing a centralized SdnFabricInfrastructure class and using it as a strongly-typed parameter across certificate management functions. The changes improve code maintainability, type safety, and consistency while automating certificate distribution across SDN fabric nodes.
Changes:
- Centralized the
SdnFabricInfrastructureclass definition in the main module and updated all role modules to reference it viausing modulestatements - Replaced generic
[System.Object]parameter types with strongly-typed[SdnFabricInfrastructure]across certificate creation and rotation functions - Enhanced certificate functions to conditionally distribute generated certificates to all fabric nodes when FabricDetails is provided
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/SdnDiagnostics.psm1 | Added centralized SdnFabricInfrastructure class definition and updated parameter type in certificate rotation scriptblock |
| src/modules/SdnDiag.NetworkController.psm1 | Removed duplicate class definition, added using statement, updated parameter types, improved role validation, and added conditional certificate distribution |
| src/modules/SdnDiag.LoadBalancerMux.psm1 | Added using statement, updated parameter types, replaced feature checks with Confirm-IsLoadBalancerMux, and added conditional certificate distribution |
| src/modules/SdnDiag.Server.psm1 | Added using statement, updated parameter types and documentation, and added conditional certificate distribution |
| src/modules/SdnDiag.Common.psm1 | Added using statement and updated parameter types for certificate distribution functions |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…to make-fabricdetails-required
…osoft/SdnDiagnostics into make-fabricdetails-required
src/modules/SdnDiag.Common.psm1
Outdated
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| using module ..\SdnDiagnostics.psm1 |
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.
Is it possible to use an absolute path here (same with all the other instances)?
This pull request refactors the handling of SDN fabric infrastructure details across several modules, consolidating the definition of the
SdnFabricInfrastructureclass and updating all relevant functions to use this strongly-typed class instead of generic objects. Additionally, certificate creation and rotation functions now consistently distribute certificates to the SDN fabric, improving reliability and code clarity. The changes also streamline environment validation and error handling in certificate rotation workflows.Type improvements and code consistency:
SdnFabricInfrastructureclass in a new shared modulesrc/classes/Common.psm1and removed redundant class definitions from other modules, ensuring a single source of truth for SDN fabric details. [1] [2]New-SdnNetworkControllerNodeCertificate,New-SdnMuxCertificate,New-SdnServerCertificate, etc.) and their callers to use[SdnFabricInfrastructure]instead of[System.Object]for theFabricDetailsparameter, enforcing type safety and improving code readability. [1] [2] [3] [4] [5] [6] [7] [8] [9]Certificate distribution enhancements:
New-SdnNetworkControllerNodeCertificate,New-SdnMuxCertificate,New-SdnServerCertificate) to automatically distribute newly created certificates to all relevant nodes in the SDN fabric ifFabricDetailsis provided, ensuring certificates are installed in the trusted root store across the infrastructure. [1] [2] [3]Workflow and validation improvements:
Confirm-IsAdminand role-specific validation functions (Confirm-IsNetworkController,Confirm-IsLoadBalancerMux), improving error messaging and maintainability. [1] [2]FabricDetailsin multiple functions to reference "EnvironmentInfo derived from Get-SdnInfrastructureInfo," improving user understanding of expected input. [1] [2] [3]Error handling and code clarity:
Module imports and code organization:
Common.psm1where theSdnFabricInfrastructureclass is now defined, reducing duplication and improving maintainability. [1] [2] [3] [4] [5]Change type
Checklist: