Skip to content

Conversation

@arudell
Copy link
Member

@arudell arudell commented Dec 31, 2025

This pull request refactors the handling of SDN fabric infrastructure details across several modules, consolidating the definition of the SdnFabricInfrastructure class 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:

  • Defined the SdnFabricInfrastructure class in a new shared module src/classes/Common.psm1 and removed redundant class definitions from other modules, ensuring a single source of truth for SDN fabric details. [1] [2]
  • Updated all certificate-related functions (New-SdnNetworkControllerNodeCertificate, New-SdnMuxCertificate, New-SdnServerCertificate, etc.) and their callers to use [SdnFabricInfrastructure] instead of [System.Object] for the FabricDetails parameter, enforcing type safety and improving code readability. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Certificate distribution enhancements:

  • Added logic in certificate creation functions (New-SdnNetworkControllerNodeCertificate, New-SdnMuxCertificate, New-SdnServerCertificate) to automatically distribute newly created certificates to all relevant nodes in the SDN fabric if FabricDetails is provided, ensuring certificates are installed in the trusted root store across the infrastructure. [1] [2] [3]

Workflow and validation improvements:

  • Simplified and standardized environment validation in certificate rotation functions by replacing custom feature checks with explicit calls to Confirm-IsAdmin and role-specific validation functions (Confirm-IsNetworkController, Confirm-IsLoadBalancerMux), improving error messaging and maintainability. [1] [2]
  • Clarified parameter documentation for FabricDetails in multiple functions to reference "EnvironmentInfo derived from Get-SdnInfrastructureInfo," improving user understanding of expected input. [1] [2] [3]

Error handling and code clarity:

  • Refactored try/catch blocks in certificate rotation workflows to improve the placement of logging and error handling, ensuring that environment retrieval and validation steps are clearly separated from the main logic. [1] [2] [3] [4] [5]

Module imports and code organization:

  • Updated all relevant modules to import the shared Common.psm1 where the SdnFabricInfrastructure class is now defined, reducing duplication and improving maintainability. [1] [2] [3] [4] [5]

Change type

  • Bug fix (non-breaking change)
  • Code style update (formatting, local variables)
  • New Feature (non-breaking change that adds new functionality without impacting existing)
  • Breaking change (fix or feature that may cause functionality impact)
  • Other

Checklist:

  • My code follows the style and contribution guidelines of this project.
  • I have tested and validated my code changes.

@arudell arudell requested a review from a team as a code owner December 31, 2025 15:53
Copy link
Contributor

Copilot AI left a 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 SdnFabricInfrastructure class definition in the main module and updated all role modules to reference it via using module statements
  • 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>
@arudell arudell enabled auto-merge (squash) January 20, 2026 17:45
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

using module ..\SdnDiagnostics.psm1
Copy link

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using New-SdnMuxCertificate, it fails if FabricDetails not provided

3 participants