File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -131,4 +131,40 @@ Describe 'Tests for the secret() function and extensions' {
131
131
$errorMessage = Get-Content - Raw - Path $TestDrive / error.log
132
132
$errorMessage | Should -Match " Extension 'Test/Secret2' returned multiple lines which is not supported for secrets"
133
133
}
134
+
135
+ It ' Allows to pass in secret() through parameters' {
136
+ $configYaml = @'
137
+ $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
138
+ parameters:
139
+ myString:
140
+ type: secureString
141
+ defaultValue: "[secret('MySecret')]"
142
+ resources:
143
+ - name: Database Connection
144
+ type: Microsoft.DSC.Debug/Echo
145
+ properties:
146
+ output: "[parameters('myString')]"
147
+ '@
148
+ $out = dsc - l trace config get - i $configYaml 2> $TestDrive / error.log | ConvertFrom-Json
149
+ $LASTEXITCODE | Should - Be 0
150
+ $out.results.Count | Should - Be 1
151
+ $out.results [0 ].result.actualState.Output | Should - BeExactly ' Hello'
152
+ }
153
+
154
+ It ' Allows to pass in secret() through variables' {
155
+ $configYaml = @'
156
+ $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
157
+ variables:
158
+ myString: "[secret('MySecret')]"
159
+ resources:
160
+ - name: Database Connection
161
+ type: Microsoft.DSC.Debug/Echo
162
+ properties:
163
+ output: "[variables('myString')]"
164
+ '@
165
+ $out = dsc - l trace config get - i $configYaml 2> $TestDrive / error.log | ConvertFrom-Json
166
+ $LASTEXITCODE | Should - Be 0
167
+ $out.results.Count | Should - Be 1
168
+ $out.results [0 ].result.actualState.Output | Should - BeExactly ' Hello'
169
+ }
134
170
}
Original file line number Diff line number Diff line change @@ -699,9 +699,10 @@ impl Configurator {
699
699
/// This function will return an error if the parameters are invalid.
700
700
pub fn set_context ( & mut self , parameters_input : Option < & Value > ) -> Result < ( ) , DscError > {
701
701
let config = serde_json:: from_str :: < Configuration > ( self . json . as_str ( ) ) ?;
702
+
703
+ self . context . extensions = self . discovery . extensions . values ( ) . cloned ( ) . collect ( ) ;
702
704
self . set_parameters ( parameters_input, & config) ?;
703
705
self . set_variables ( & config) ?;
704
- self . context . extensions = self . discovery . extensions . values ( ) . cloned ( ) . collect ( ) ;
705
706
Ok ( ( ) )
706
707
}
707
708
You can’t perform that action at this time.
0 commit comments