-
Notifications
You must be signed in to change notification settings - Fork 9
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
(#240) Parameterize setup #284
base: main
Are you sure you want to change the base?
Conversation
c2d1bb6
to
78f53cf
Compare
c1f8e77
to
86402af
Compare
This script adds parameterization to the ClientSetup.ps1 script that is hosted within the Nexus repository. It also adds parameterization to the registration script that is executed on a client so you can customize the installation.
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.
There's a lot of single-character variables that I think could be expanded to have helpful names, to ease legibility and maintainability in the future, but I haven't made suggestions as they generally spanned a fair number of lines and got muddled with other comments.
$ProxyCredential, | ||
|
||
#Install the Chocolatey Licensed Extension with right-click context menus available |
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.
#Install the Chocolatey Licensed Extension with right-click context menus available | |
# Install the Chocolatey Licensed Extension with right-click context menus available. |
Matching the format of the other param comments.
|
||
|
||
Write-Host "Applying user supplied configuration" -ForegroundColor Cyan | ||
#How we call choco from here changes as we need to be more dynamic with thingsii . |
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.
#How we call choco from here changes as we need to be more dynamic with thingsii . | |
# How we call choco from here changes as we need to be more dynamic with things. |
@@ -158,3 +187,128 @@ if ($ServiceSalt) { | |||
} | |||
choco feature enable --name="'useChocolateyCentralManagement'" | |||
choco feature enable --name="'useChocolateyCentralManagementDeployments'" | |||
|
|||
|
|||
Write-Host "Applying user supplied configuration" -ForegroundColor Cyan |
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.
Write-Host "Applying user supplied configuration" -ForegroundColor Cyan | |
if ($AdditionalConfiguration -or $AdditionalFeatures -or $AdditionalSources -or AdditionalPackages) { | |
Write-Host "Applying user supplied configuration" -ForegroundColor Cyan | |
} |
$package.ContainsKey('Pin') { $c.Add('--pin') } | ||
} | ||
|
||
#Ensure packages install and they don't flood the console output |
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.
#Ensure packages install and they don't flood the console output | |
# Ensure packages install and they don't flood the console output |
scripts/Register-C4bEndpoint.ps1
Outdated
|
||
$PSBoundParameters.ContainsKey('IncludePackageTools') { | ||
$params.Add('IncludePackageTools',$IncludePackageTools) |
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.
$params.Add('IncludePackageTools',$IncludePackageTools) | |
$params.Add('IncludePackageTools', $IncludePackageTools) |
#> | ||
Foreach ($a in $AdditionalSources) { | ||
$c = [System.Collections.Generic.List[string]]::new() | ||
#Required items |
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.
#Required items | |
# Required items |
CertificatePassword = 's0mepa$$' | ||
} | ||
#> | ||
Foreach ($a in $AdditionalSources) { |
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.
Foreach ($a in $AdditionalSources) { | |
foreach ($a in $AdditionalSources) { |
choco source add --name="'ChocolateyInternal'" --source="'$RepositoryUrl'" --allow-self-service --priority=1 | ||
} | ||
|
||
#Environment base Source configuration |
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.
#Environment base Source configuration | |
# Environment base source configuration |
Credential = $RepositoryCredential | ||
ClientSalt = $ClientCommunicationSalt | ||
ServiceSalt = $ServiceCommunicationSalt | ||
RepositoryUrl = $RepositoryUrl | ||
} | ||
|
||
switch ($true) { | ||
$PSBoundParameters.ContainsKey('AdditionalConfiguration') { | ||
$params.Add('AdditionalConfiguration', $AdditionalConfiguration) | ||
} | ||
$PSBoundParameters.ContainsKey('AdditionalFeatures') { | ||
$params.add('AdditionalFeatures', $AdditionalFeatures) | ||
} | ||
|
||
$PSBoundParameters.ContainsKey('AdditionalPackages') { | ||
$params.Add('AdditionalPackages', $AdditionalPackages) | ||
} | ||
|
||
$PSBoundParameters.ContainsKey('AdditionalSources') { | ||
$params.Add('AdditionalSources', $AdditionalSources) | ||
} | ||
|
||
$PSBoundParameters.ContainsKey('IncludePackageTools') { | ||
$params.Add('IncludePackageTools', $IncludePackageTools) | ||
} | ||
} |
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.
Instead of all this, given we control the params, is it worth literally just parsing and passing PSBoundParams? I think the only thing that would need changing is FQDN/RepositoryUrl.
$params = @{ | |
Credential = $RepositoryCredential | |
ClientSalt = $ClientCommunicationSalt | |
ServiceSalt = $ServiceCommunicationSalt | |
RepositoryUrl = $RepositoryUrl | |
} | |
switch ($true) { | |
$PSBoundParameters.ContainsKey('AdditionalConfiguration') { | |
$params.Add('AdditionalConfiguration', $AdditionalConfiguration) | |
} | |
$PSBoundParameters.ContainsKey('AdditionalFeatures') { | |
$params.add('AdditionalFeatures', $AdditionalFeatures) | |
} | |
$PSBoundParameters.ContainsKey('AdditionalPackages') { | |
$params.Add('AdditionalPackages', $AdditionalPackages) | |
} | |
$PSBoundParameters.ContainsKey('AdditionalSources') { | |
$params.Add('AdditionalSources', $AdditionalSources) | |
} | |
$PSBoundParameters.ContainsKey('IncludePackageTools') { | |
$params.Add('IncludePackageTools', $IncludePackageTools) | |
} | |
} | |
$params = $PSBoundParameters | |
foreach ($Parameter in @("FQDN", "TrustCertificate")) { | |
$null = $params.Remove($Parameter) | |
} | |
$params += @{ | |
RepositoryUrl = $RepositoryUrl | |
} |
Please note, I've not tested this (and there's probably more properties to nuke), but it seems like there's less code to maintain with this approach.
$c.Add("--name='$($a.Name)'") | ||
$c.Add("--source='$($a.Source)'") | ||
|
||
#Add credentials if source has them |
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.
#Add credentials if source has them | |
# Add credentials if source has them |
Description Of Changes
Adds parameterization to both
ClientSetup.ps1
andRegister-C4bEndpoint.ps1
to allow an end user to customize the installation of Chocolatey For Business on an endpoint.Motivation and Context
An opinionated approach is nice, but allowing some level of customization that is easy for the end user is a nice added touch to really improve the overall experience with our tooling.
Testing
Operating Systems Testing
Change Types Made
Change Checklist
Related Issue
Fixes #240