Skip to content
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

(CONT-257) Add PDKTemplateRef parameter #231

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2016, windows-2019]
os: [windows-2019, windows-2022]
tag: [General, Unit]
include:
- tag: General
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2016, windows-2019]
os: [windows-2019, windows-2022]
tag: [Basic, MultiModule]
pwshlib_source: [forge, git]
include:
Expand Down
7 changes: 5 additions & 2 deletions src/functions/New-PuppetDscModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Function New-PuppetDscModule {
.PARAMETER Repository
Specifies a non-default PSRepository.
If left blank, will default to PSGallery.
.PARAMETER PDKTemplateRef
Specifies the template git branch or tag to use when creating new moudles or classes.
.EXAMPLE
New-PuppetDscModule -PowerShellModuleName PowerShellGet -PowerShellModuleVersion 2.2.3 -Repository PSGallery

Expand All @@ -58,7 +60,8 @@ Function New-PuppetDscModule {
[string]$OutputDirectory,
[switch]$AllowPrerelease,
[switch]$PassThru,
[string]$Repository
[string]$Repository,
[string]$PDKTemplateRef = '2.5.0'
)

Begin {
Expand Down Expand Up @@ -110,7 +113,7 @@ Function New-PuppetDscModule {
$ErrorActionPreference = 'Stop'
# Scaffold the module via the PDK
Write-PSFMessage -Message 'Initializing the Puppet Module'
Initialize-PuppetModule -OutputFolderPath $OutputDirectory -PuppetModuleName $PuppetModuleName -verbose
Initialize-PuppetModule -OutputFolderPath $OutputDirectory -PuppetModuleName $PuppetModuleName -PDKTemplateRef $PDKTemplateRef -verbose

# Vendor the PowerShell module and all of its dependencies
Write-PSFMessage -Message 'Vendoring the DSC Resources'
Expand Down
10 changes: 9 additions & 1 deletion src/internal/functions/Initialize-PuppetModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function Initialize-PuppetModule {
The path, relative or literal, to the Puppet module's root folder.
.PARAMETER PuppetModuleName
The name of the Puppet module to create.
.PARAMETER PDKTemplateRef
Specifies the template git branch or tag to use when creating new moudles or classes.
.PARAMETER Confirm
Prompts for confirmation before overwriting the file
.PARAMETER WhatIf
Expand All @@ -22,11 +24,17 @@ function Initialize-PuppetModule {
[Parameter(Mandatory = $True)]
[string]$OutputFolderPath,
[Parameter(Mandatory = $True)]
[string]$PuppetModuleName
[string]$PuppetModuleName,
[Parameter(Mandatory = $False)]
[string]$PDKTemplateRef
)

begin {
$Command = "pdk new module $PuppetModuleName --skip-interview --template-url https://github.com/puppetlabs/pdk-templates"
if ($PSBoundParameters.ContainsKey('PDKTemplateRef')) {
$Command = "$Command --template-ref $PDKTemplateRef"
}

$ModuleFolderPath = Join-Path -Path $OutputFolderPath -ChildPath $PuppetModuleName
$TemplateFolder = Join-Path -Path (Split-Path -Path $MyInvocation.MyCommand.Module.Path -Parent) -ChildPath 'internal/templates/static'
}
Expand Down