Skip to content

Commit 8e23d94

Browse files
committed
Added simple generation code for FunctionsToExport and used it
1 parent e91a0e3 commit 8e23d94

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

Contrib/CODE_GENERATION.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Notes about generating code for the module
2+
3+
## History
4+
5+
Our first shot a generating code for the module was to create an ad-hoc string interpolation based generator : `New-GetCmdlet.ps1`.
6+
7+
The actual generation process where we tell the cmdlet what to generate is defined
8+
in `New-GetCmdlets.ps1`
9+
10+
However, this approach is very cumbersome and leads to a very hard do maintain
11+
generator. The preferred approach now is to use a template base generator. The generator is still a work in progress but you can take a look at https://github.com/dbroeglin/Forge.Netscaler if you are interested.
12+
13+
## Updating FunctionsToExport
14+
15+
$list = (Get-ChildItem ./NetScaler/Public/ |
16+
Sort-Object Name |
17+
ForEach-Object {
18+
$_.name -replace '(.*).ps1', " '`$1'"
19+
}) -join ",`r`n"
20+
[System.IO.File]::WriteAllText(
21+
"./Netscaler/Netscaler.psd1", (
22+
(
23+
Get-Content -Encoding UTF8 ./NetScaler/NetScaler.psd1 -Raw
24+
) -replace "(?smi)(FunctionsToExport *= *@\()[^)]*(\))",
25+
"`$1`r`n$list`r`n`$2"))
26+
27+
28+

NetScaler/NetScaler.psd1

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ FunctionsToExport = @(
9292
'Disable-NSLBVirtualServer',
9393
'Disable-NSMode',
9494
'Disconnect-NetScaler',
95-
'Enable-NSHighAvailability',
9695
'Enable-NSFeature',
96+
'Enable-NSHighAvailability',
9797
'Enable-NSLBMonitor',
9898
'Enable-NSLBServer',
9999
'Enable-NSLBVirtualServer',
@@ -115,8 +115,8 @@ FunctionsToExport = @(
115115
'Get-NSFeature',
116116
'Get-NSHardware',
117117
'Get-NSHostname',
118-
'Get-NSIPResource',
119118
'Get-NSIP6Resource',
119+
'Get-NSIPResource',
120120
'Get-NSKCDAccount',
121121
'Get-NSLBMonitor',
122122
'Get-NSLBServer',
@@ -134,18 +134,18 @@ FunctionsToExport = @(
134134
'Get-NSLBVirtualServerTrafficPolicyBinding',
135135
'Get-NSLDAPAuthenticationPolicy',
136136
'Get-NSLDAPAuthenticationServer',
137+
'Get-NSMode',
138+
'Get-NSNTPServer',
137139
'Get-NSResponderAction',
138140
'Get-NSResponderPolicy',
139141
'Get-NSRewriteAction',
140142
'Get-NSRewritePolicy',
141-
'Get-NSStat',
142-
'Get-NSMode',
143-
'Get-NSNTPServer',
144143
'Get-NSSAMLAuthenticationPolicy',
145144
'Get-NSSAMLAuthenticationServer',
146145
'Get-NSSSLCertificate',
147146
'Get-NSSSLCertificateLink',
148147
'Get-NSSSLProfile',
148+
'Get-NSStat',
149149
'Get-NSSystemFile',
150150
'Get-NSTimeZone',
151151
'Get-NSVersion',
@@ -173,7 +173,6 @@ FunctionsToExport = @(
173173
'New-NSResponderPolicy',
174174
'New-NSRewriteAction',
175175
'New-NSRewritePolicy',
176-
'New-NSNTPServer',
177176
'New-NSSSLProfile',
178177
'New-NSVPNSessionPolicy',
179178
'New-NSVPNSessionProfile',
@@ -184,9 +183,9 @@ FunctionsToExport = @(
184183
'Remove-NSLBServer',
185184
'Remove-NSLBServiceGroup',
186185
'Remove-NSLBServiceGroupMonitorBinding',
186+
'Remove-NSLBSSLVirtualServerProfile',
187187
'Remove-NSLBVirtualServer',
188188
'Remove-NSLBVirtualServerBinding',
189-
'Remove-NSLBSSLVirtualServerProfile',
190189
'Remove-NSLDAPAuthenticationPolicy',
191190
'Remove-NSLDAPAuthenticationServer',
192191
'Remove-NSResponderAction',
@@ -266,3 +265,5 @@ PrivateData = @{
266265

267266
}
268267

268+
269+

0 commit comments

Comments
 (0)