Skip to content

Commit 1d38a7c

Browse files
committed
Merge remote-tracking branch 'upstream/clu' into clu
2 parents d2aae3f + 853e0d5 commit 1d38a7c

File tree

12 files changed

+51
-19
lines changed

12 files changed

+51
-19
lines changed

examples/lib/loginUser.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/bin/bash
2-
echo "Logging in as user"
32
azure account add -u "$azureUser" -p "$password" -s "$subscription"

examples/lib/testrunner.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export location="westus"
66
export CmdletSessionID=1010
77
export MSYS_NO_PATHCONV=1
88

9+
echo "Logging in as user"
910
. $BASEDIR/loginUser.sh
1011

1112
for d in $( ls $BASEDIR/.. --ignore=lib ); do

src/CLU/Commands.Common.ScenarioTest/ExampleScriptRunner.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ public class ExampleScriptRunner
3939
ResourceManagementClient _client;
4040
const string DefaultLocation = "westus";
4141
const string ResourceGroupNameKey = "groupName";
42-
const string locationKey = "location";
42+
const string LocationKey = "location";
43+
const string BaseDir = "BASEDIR";
4344
const string SessionKey = "CmdletSessionID";
44-
const string storageAccountTypeKey = "storageAccountType";
45-
const string storageAccountNameKey = "storageAccountName";
45+
const string StorageAccountTypeKey = "storageAccountType";
46+
const string StorageAccountNameKey = "storageAccountName";
4647
const string DefaultStorageAccountType = "Standard_GRS";
4748

4849
public ExampleScriptRunner(string sessionId) : this(new Random(), sessionId)
@@ -106,11 +107,12 @@ public string RunScript(string testName)
106107
DeployTemplate(deploymentTemplatePath, _resourceGroupName);
107108
}
108109

110+
process.EnvironmentVariables[BaseDir] = testDirectory;
109111
process.EnvironmentVariables[SessionKey] = _sessionId;
110112
process.EnvironmentVariables[ResourceGroupNameKey] = _resourceGroupName;
111-
process.EnvironmentVariables[locationKey] = DefaultLocation;
112-
process.EnvironmentVariables[storageAccountTypeKey] = DefaultStorageAccountType;
113-
process.EnvironmentVariables[storageAccountNameKey] = _storageAccountName;
113+
process.EnvironmentVariables[LocationKey] = DefaultLocation;
114+
process.EnvironmentVariables[StorageAccountTypeKey] = DefaultStorageAccountType;
115+
process.EnvironmentVariables[StorageAccountNameKey] = _storageAccountName;
114116
foreach (var helper in _context.EnvironmentHelpers)
115117
{
116118
helper.TrySetupScriptEnvironment(_context, _clientFactory, process.EnvironmentVariables);

src/CLU/Commands.Common.ScenarioTest/ProcessHelper.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,16 @@ private void SetEnvironmentVariables(ProcessStartInfo startInfo)
173173

174174
private void ProcessError(object sender, DataReceivedEventArgs e)
175175
{
176-
Logger.Instance.WriteError(e.Data);
176+
if (e.Data != null)
177+
{
178+
Logger.Instance.WriteError(e.Data);
179+
}
177180
}
178181

179182
private void ProcessOutput(object sender, DataReceivedEventArgs e)
180183
{
181-
Logger.Instance.WriteMessage(e.Data);
182184
_processOutput.Append(e.Data);
185+
Logger.Instance.WriteMessage(e.Data);
183186
}
184187

185188
private void EndProcess()

src/CLU/Commands.Common.ScenarioTest/ScenarioTestFixture.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using Microsoft.Azure.Commands.Common.Authentication.Models;
1717
using Microsoft.Azure.Commands.Common.ScenarioTest;
1818
using Microsoft.Azure.Commands.Models;
19-
using Moq.Protected;
2019
using Newtonsoft.Json;
2120

2221
namespace Microsoft.Azure.Commands.Common.ScenarioTest
@@ -34,6 +33,10 @@ public ScenarioTestFixture()
3433
var helper = GetRunner("lib");
3534
var profileText = helper.RunScript(credentials.LoginScriptName);
3635
var profile = JsonConvert.DeserializeObject<PSAzureProfile>(profileText);
36+
if (profile == null)
37+
{
38+
throw new ArgumentOutOfRangeException(nameof(profile), $"Deserialized profile is null: `{profileText}`");
39+
}
3740
AzureContext = (AzureContext) (profile.Context);
3841
}
3942

src/CLU/Commands.Common.ScenarioTest/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"Commands.Common": "",
2121
"Commands.Common.Authentication": "",
2222
"Commands.ResourceManager.Common": "",
23-
"Commands.ScenarioTests.ResourceManager.Common": "",
2423
"Microsoft.Azure.Commands.Profile": "",
2524
"Microsoft.Azure.Management.Resources": "3.3.0-preview",
2625
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",

src/CLU/Microsoft.CLU/CommandBinder/CmdletBinderAndCommand.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,18 @@ private void BindDynamicParameters()
342342
// If Cmdlet instance support dynamic parameters then rerun the parser to bind dynamic parameters.
343343
_dynamicParameterBindInProgress = true;
344344
this.ParserSeekBeginAndRun();
345+
var psCmdlet = _cmdlet as PSCmdlet;
346+
if (psCmdlet != null)
347+
{
348+
// We need to add all dynamic parameters that were bound
349+
foreach (var boundParam in _cmdletMetadata.Instance.Parameters)
350+
{
351+
if (boundParam.Value.IsBound && boundParam.Value.IsDynamic && !psCmdlet.MyInvocation.BoundParameters.ContainsKey(boundParam.Value.Name))
352+
{
353+
psCmdlet.MyInvocation.BoundParameters[boundParam.Value.Name] = boundParam.Value;
354+
}
355+
}
356+
}
345357
_dynamicParameterBindInProgress = false;
346358
}
347359
}

src/CLU/Microsoft.CLU/Metadata/CmdletMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class CmdletMetadata
1717
/// <summary>
1818
/// The metadata information of the cmdlet instance.
1919
/// </summary>
20-
public InstanceMetadata Instance { get; set; }
20+
public InstanceMetadata Instance { get; private set; }
2121

2222
/// <summary>
2323
/// Creates an instance of CmdletMetadata.

src/CLU/Microsoft.CLU/Metadata/InstanceMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public ReadOnlyCollection<CommandParameterSetInfo> ParameterSets
5151
}
5252
}
5353

54-
Dictionary<string, ParameterMetadata> _dynamicParameters;
54+
Dictionary<string, ParameterMetadata> _dynamicParameters = new Dictionary<string, ParameterMetadata>();
5555
/// <summary>
5656
/// Get dynamic parameter metadata dictionary. The key is name of the dynamic
5757
/// parameter and value is the dynamic parameter metadata.

src/CLU/Microsoft.CLU/System.Management.Automation/CmdletInfo.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using System.Collections.ObjectModel;
1+
using Microsoft.CLU.Metadata;
2+
using System.Collections.ObjectModel;
23
using System.Linq;
34
using System.Reflection;
5+
using System.Collections.Generic;
46

57
namespace System.Management.Automation
68
{
@@ -25,6 +27,9 @@ internal CmdletInfo(Type cmdlet, PSModuleInfo module, ICommandRuntime runtime, s
2527
cmdlet.GetTypeInfo().GetCustomAttributes(typeof(OutputTypeAttribute), true)
2628
.Select(a => a as OutputTypeAttribute)
2729
.SelectMany(ot => ot.Type).ToList());
30+
31+
_typeMetadata = new TypeMetadata(cmdlet);
32+
_typeMetadata.Load();
2833
}
2934

3035
public string Noun
@@ -37,6 +42,13 @@ public string Verb
3742
get; private set;
3843
}
3944

45+
public override Dictionary<string, ParameterMetadata> Parameters
46+
{
47+
get
48+
{
49+
return _typeMetadata.Parameters;
50+
}
51+
}
4052
public override ReadOnlyCollection<PSTypeName> OutputType
4153
{
4254
get
@@ -67,6 +79,7 @@ public override string ToString()
6779
return Name;
6880
}
6981

82+
private TypeMetadata _typeMetadata;
7083
private ReadOnlyCollection<PSTypeName> _outputTypes;
7184
}
7285
}

src/CLU/Microsoft.CLU/System.Management.Automation/CommandInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ public abstract class CommandInfo
88
public CommandTypes CommandType { get { return CommandTypes.Cmdlet; } }
99
public string Name { get; protected set; }
1010
public abstract ReadOnlyCollection<PSTypeName> OutputType { get; }
11-
public virtual Dictionary<string, ParameterMetadata> Parameters { get; private set; }
12-
public ReadOnlyCollection<CommandParameterSetInfo> ParameterSets { get; protected set; }
11+
public virtual Dictionary<string, ParameterMetadata> Parameters { get; }
12+
public ReadOnlyCollection<CommandParameterSetInfo> ParameterSets { get; }
1313
public PSModuleInfo Module { get; protected set; }
1414
public string ModuleName { get { return Module.Name; } }
1515

tools/CLU/BuildAndInstallClu.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ copy /Y %root%\drop\clurun\win7-x64\azure.lx %root%\drop\clurun\osx.10.10-x64
4242
copy /Y %root%\drop\clurun\win7-x64\msclu.cfg %root%\drop\clurun\osx.10.10-x64
4343

4444
REM: copy over the pre-cooked azure.sh and ensure correct line endings
45-
copy /Y %~dp0\azure.sh %root%\drop\clurun\osx.10.10-x64
46-
set azuresh=%root%\drop\clurun\osx.10.10-x64\azure.sh
45+
copy /Y %~dp0\azure.sh %root%\drop\clurun\osx.10.10-x64\azure
46+
set azuresh=%root%\drop\clurun\osx.10.10-x64\azure
4747
echo Get-ChildItem %azuresh% ^| ForEach-Object { > %temp%\fixLineEndings.ps1
4848
echo $contents = [IO.File]::ReadAllText($_) -replace "`r`n?", "`n" >> %temp%\fixLineEndings.ps1
4949
echo [IO.File]::WriteAllText($_, $contents) >> %temp%\fixLineEndings.ps1
@@ -53,7 +53,7 @@ echo } >> %temp%\fixLineEndings.ps1
5353
xcopy %root%\drop\clurun\win7-x64\pkgs %root%\drop\clurun\ubuntu.14.04-x64\pkgs /S /Q /I /Y
5454
copy /Y %root%\drop\clurun\win7-x64\azure.lx %root%\drop\clurun\ubuntu.14.04-x64
5555
copy /Y %root%\drop\clurun\win7-x64\msclu.cfg %root%\drop\clurun\ubuntu.14.04-x64
56-
copy /Y %azuresh% %root%\drop\clurun\ubuntu.14.04-x64
56+
copy /Y %azuresh% %root%\drop\clurun\ubuntu.14.04-x64\azure
5757

5858
REM, windows version also needs it for bash based testing
5959
copy /Y %~dp0\azure.win.sh %root%\drop\clurun\win7-x64\azure

0 commit comments

Comments
 (0)