Skip to content

Commit f0541b7

Browse files
Copy #18193 and fix CI issue on generation branch (#18195)
* Build from the main branch * Write a warning message when setting values for parameters that are not provided * Update tests * try fix ci issue by sync Az.props and shared Co-authored-by: Francisco-Gamino <[email protected]>
1 parent 6cee52d commit f0541b7

File tree

6 files changed

+46
-9
lines changed

6 files changed

+46
-9
lines changed

src/Az.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
<AutoGen>true</AutoGen>
3535
<DependentUpon>Resources.resx</DependentUpon>
3636
</Compile>
37+
<!-- include shared source code -->
38+
<Compile Include="$(MSBuildThisFileDirectory)shared\*.cs" />
3739
</ItemGroup>
3840

3941
<ItemGroup>
@@ -47,6 +49,7 @@
4749
<ItemGroup>
4850
<None Update="Az.$(PsModuleName).psd1" CopyToOutputDirectory="PreserveNewest" />
4951
<None Update="help\*.md" CopyToOutputDirectory="PreserveNewest" />
52+
<None Update="help\About\*.help.txt" CopyToOutputDirectory="PreserveNewest" />
5053
<None Update="*.ps1xml" CopyToOutputDirectory="PreserveNewest" />
5154
</ItemGroup>
5255

src/Functions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ directive:
6565
```
6666
6767
``` yaml
68-
branch: powershell-function
68+
branch: main
6969
require:
7070
- $(this-folder)/../readme.azure.noprofile.md
7171
input-file:

src/Functions/custom/HelperFunctions.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ $constants["FunctionsNoV2Version"] = @(
4242
"USSec East"
4343
)
4444

45+
$constants["SetDefaultValueParameterWarningMessage"] = "This default value is subject to change over time. Please set this value explicitly to ensure the behavior is not accidentally impacted by future changes."
46+
4547
foreach ($variableName in $constants.Keys)
4648
{
4749
if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
@@ -1018,7 +1020,7 @@ function GetRuntimeJsonDefinition
10181020
$RuntimeVersion = $latestVersion.ToString()
10191021
}
10201022

1021-
Write-Verbose "RuntimeVersion not specified. Setting default runtime version for '$Runtime' to '$RuntimeVersion'." -Verbose
1023+
Write-Warning "RuntimeVersion not specified. Setting default value to '$RuntimeVersion'. $SetDefaultValueParameterWarningMessage"
10221024
}
10231025

10241026
# Get the RuntimeJsonDefinition

src/Functions/custom/New-AzFunctionApp.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ function New-AzFunctionApp {
266266
}
267267

268268
$FunctionsVersion = $DefaultFunctionsVersion
269-
Write-Verbose "FunctionsVersion not specified. Setting default FunctionsVersion to '$FunctionsVersion'." -Verbose
269+
Write-Warning "FunctionsVersion not specified. Setting default value to '$FunctionsVersion'. $SetDefaultValueParameterWarningMessage"
270270
}
271271

272272
ValidateFunctionsVersion -FunctionsVersion $FunctionsVersion
@@ -284,7 +284,7 @@ function New-AzFunctionApp {
284284
if (-not $OSType)
285285
{
286286
$OSType = GetDefaultOSType -Runtime $Runtime
287-
Write-Verbose "OSType for $Runtime is '$OSType'." -Verbose
287+
Write-Warning "OSType not specified. Setting default value to '$OSType'. $SetDefaultValueParameterWarningMessage"
288288
}
289289

290290
$runtimeJsonDefintion = GetRuntimeJsonDefinition -FunctionsVersion $FunctionsVersion -Runtime $Runtime -RuntimeVersion $RuntimeVersion -OSType $OSType

src/Functions/test/New-AzFunctionApp.Tests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ Describe 'New-AzFunctionApp' {
128128
-FunctionsVersion $functionsVersion `
129129
-WhatIf
130130

131-
} 4>&1 2>&1 > $filePath
131+
} 3>&1 2>&1 > $filePath
132132

133133
$logFileContent = Get-Content -Path $filePath -Raw
134134
$expectectedRuntimeVersion = $expectedDefaultRuntimeVersion[$OSType][$functionsVersion][$runtime]
135-
$expectedMessage = "RuntimeVersion not specified. Setting default runtime version for '$runtime' to '$expectectedRuntimeVersion'."
135+
$expectedMessage = "RuntimeVersion not specified. Setting default value to '$expectectedRuntimeVersion'."
136136
$logFileContent | Should Match $expectedMessage
137137
}
138138
finally
@@ -234,12 +234,12 @@ Describe 'New-AzFunctionApp' {
234234
-RuntimeVersion $runtimeVersion `
235235
-WhatIf
236236

237-
} 4>&1 2>&1 > $filePath
237+
} 3>&1 2>&1 > $filePath
238238

239239
$logFileContent = Get-Content -Path $filePath -Raw
240240

241-
$expectectedFunctionsVersionWarning = "FunctionsVersion not specified. Setting default FunctionsVersion to '$expectedFunctionsVersion'."
242-
$expectectedOSTypeWarning = "OSType for $runtime is '$expectedOSType'."
241+
$expectectedFunctionsVersionWarning = "FunctionsVersion not specified. Setting default value to '$expectedFunctionsVersion'."
242+
$expectectedOSTypeWarning = "OSType not specified. Setting default value to '$expectedOSType'."
243243

244244
$logFileContent | Should Match $expectectedFunctionsVersionWarning
245245
$logFileContent | Should Match $expectectedOSTypeWarning

src/shared/ConfigKeys.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Shared.Config
16+
{
17+
/// <summary>
18+
/// This class stores keys of all the pre-defined configs.
19+
/// </summary>
20+
/// <remarks>
21+
/// All keys should be defined here.
22+
/// If the key is used in Azure/azure-powershell-common repo, duplicate it in ConfigKeysForCommon class.
23+
/// Keys defined here should NEVER be removed or changed to prevent breaking change.
24+
/// </remarks>
25+
internal static class ConfigKeys
26+
{
27+
public const string EnableInterceptSurvey = "EnableInterceptSurvey";
28+
public const string DisplayBreakingChangeWarning = "DisplayBreakingChangeWarning";
29+
public const string DefaultSubscriptionForLogin = "DefaultSubscriptionForLogin";
30+
public const string EnableDataCollection = "EnableDataCollection";
31+
}
32+
}

0 commit comments

Comments
 (0)