Skip to content

feat: implement flat universal parameters for CUT-5149 custom attributes#746

Open
junioralmeida-82 wants to merge 6 commits into
v3.3.0_pwshModulefrom
feature/CUT-5149-system-attributes-csv
Open

feat: implement flat universal parameters for CUT-5149 custom attributes#746
junioralmeida-82 wants to merge 6 commits into
v3.3.0_pwshModulefrom
feature/CUT-5149-system-attributes-csv

Conversation

@junioralmeida-82
Copy link
Copy Markdown
Contributor

@junioralmeida-82 junioralmeida-82 commented May 28, 2026

Issues

  • CUT-5149 - Implement Custom Attributes and CSV Management for Systems

What does this solve?

  • Set-JCSystem Optimization: Refactored the core function signature to a completely flat parameter structure, removing conflicting ParameterSetName tags to resolve binding intersections.
  • DynamicParam macOS Fix: Fixed a native PowerShell Core binding issue on macOS where the dynamic parameter block threw ParameterBindingException by ensuring the method returns a validated object dictionary instead of a raw $null when processing exclusions.
  • New Utility Features: Implemented Update-JCSystemFromCSV and New-JCImportSystemTemplate focused entirely on system infrastructure profiles rather than legacy user nomenclature.
  • Manifest Alignment: Registered both utility functions into FunctionsToExport inside JumpCloud.psd1.

Is there anything particularly tricky?

  • Manually verified via local cleanup and search (Cmd+F) that all environment credentials, actual Org IDs, and API keys are completely stripped from the committed codebase files.

How should this be tested?

Execute the official orchestrator targeting the task tag:
& "./Tests/InvokePester.ps1" -JumpCloudApiKey $ApiKey -IncludeTagList "CUT-5149"

Screenshots

Captura de Tela 2026-05-28 às 16 38 02 Captura de Tela 2026-05-28 às 16 38 29

Note

Medium Risk
Changes a core cmdlet (Set-JCSystem) and live API PUT behavior for attributes; mistakes could overwrite or drop existing system custom attributes, though merge logic and tests mitigate this.

Overview
Bumps the JumpCloud module to 3.3.0 and extends system management with custom attributes (CUT-5149), aligned with the existing user attribute pattern (NumberOfCustomAttributes + dynamic AttributeN_name / AttributeN_value).

Set-JCSystem gains flat parameters for add/update/remove of custom attributes: it loads current attributes via Get-JCSystem, merges or removes by name, and sends the full attributes array on PUT. A DynamicParam block exposes AttributeN_* when NumberOfCustomAttributes is set, always returning a parameter dictionary (fixes macOS binding when no dynamic params are needed). The API URL now uses $global:JCUrlBasePath.

New-JCDeviceUpdateTemplate accepts NumberOfCustomAttributes (CLI or interactive) to add AttributeN_name / AttributeN_value columns to device update CSVs. Update-JCDeviceFromCSV adds alias Update-JCSystemFromCSV, counts populated attribute columns per row, and passes NumberOfCustomAttributes into Set-JCSystem. New Pester coverage exercises add, merge, and selective remove of system custom attributes.

Reviewed by Cursor Bugbot for commit c38ecb6. Bugbot is set up for automated code reviews on this repo. Configure here.

@junioralmeida-82 junioralmeida-82 self-assigned this May 28, 2026
@junioralmeida-82 junioralmeida-82 requested a review from a team as a code owner May 28, 2026 19:42
@junioralmeida-82 junioralmeida-82 added enhancement minor minor version release PowerShell Module Release for JumpCloud PowerShell Module labels May 28, 2026
@jworkmanjc jworkmanjc changed the base branch from master to v3.3.0_pwshModule May 29, 2026 13:40
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

There are 4 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 1f3e90c. Configure here.

Comment thread PowerShell/JumpCloud Module/JumpCloud.psd1 Outdated
Comment thread PowerShell/JumpCloud Module/JumpCloud.psd1 Outdated
@jworkmanjc jworkmanjc requested a review from gweinjc June 3, 2026 14:20
Copy link
Copy Markdown
Contributor

@gweinjc gweinjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Results:
Tested the changes locally, was able to add/remove/update custom attributes on devices.

To-Do:

  • Docs for each of the changed functions need to be updated to include the new params and examples of how to use them. See the following script to generate the helpfiles: PowerShell/Deploy/Build-HelpFiles.ps1
  • Missing tests for Update-JCDeviceFromCsv and New-JCDeviceUpdateTemplate
  • See other in-line comments

[Alias('_id', 'id')]
$SystemID,

[Parameter(ValueFromPipelineByPropertyName = $true, HelpMessage = 'The system displayName. The displayName is set to the hostname of the system during agent installation. When the system hostname updates the displayName does not update.')]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove all of the HelpMessages from the params?

[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowMultiFactorAuthentication,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowPublicKeyAuthentication,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$systemInsights,
[Parameter(ValueFromPipelineByPropertyName = $false)]$primarySystemUser,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing HelpMessage

[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowSshRootLogin,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowMultiFactorAuthentication,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowPublicKeyAuthentication,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$systemInsights,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing HelpMessage

[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowSshPasswordAuthentication,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowSshRootLogin,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowMultiFactorAuthentication,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowPublicKeyAuthentication,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing HelpMessage

[Parameter(ValueFromPipelineByPropertyName = $true)][string]$description,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowSshPasswordAuthentication,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowSshRootLogin,
[Parameter(ValueFromPipelineByPropertyName = $true)][bool]$allowMultiFactorAuthentication,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing HelpMessage


begin {
DynamicParam {
# Inicializa o dicionário nativo para evitar falhas de compilação no macOS
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to remove comments

$dict.Add("Attribute$ParamNumber`_value", $param1)
}
}
# Sempre retorna o objeto (preenchido ou vazio), neutralizando o bug de binding do Mac
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to remove comments

$Force
$Force,

# CUT-5149: Universal parameter to define the number of custom attributes via CLI.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to remove comments

elseif ($ConfirmPrimarySystemUser -eq 'N') {
}

# CUT-5149: Assistente interativo por perguntas para incluir colunas de Custom Attributes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to remove comments

}
}

# Injection for CUT-5149: Dynamically calculates the number of Custom Attributes in the current line's CSV.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need to remove comments

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

Labels

enhancement minor minor version release PowerShell Module Release for JumpCloud PowerShell Module

Development

Successfully merging this pull request may close these issues.

3 participants