Skip to content

Clu #253

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

Merged
merged 20 commits into from
Dec 17, 2015
Merged

Clu #253

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
901ad2d
Xunit test infra for CLU
markcowl Dec 15, 2015
9f244ff
dependency and rename fixes
markcowl Dec 15, 2015
5068aa1
Merge branch 'clu' of github.com:Azure/azure-powershell into cluoutput
markcowl Dec 15, 2015
4d51229
[#109999746] Removed "AzureDirectoryName" from Authentication resources.
Dec 15, 2015
d9d36b4
[#110124884] Investigate PSObject removal from resource cmdlets.
Dec 15, 2015
dc34da6
Removed PSObject from Resource Lock cmdlets.
Dec 16, 2015
29d5dc0
Removed PSObject from PolicyAssignment, PolicyDefinition and Resource…
Dec 16, 2015
fce7376
Updating output format for Profile cmdlets
markcowl Dec 16, 2015
8048231
Merging cmdlet rename changes from upstream
markcowl Dec 16, 2015
c86c954
Merge pull request #1500 from huangpf/clu
markcowl Dec 16, 2015
4492a39
Removed powershell test.
Dec 16, 2015
de09a71
Merge pull request #1498 from hovsepm/clu
Dec 16, 2015
30ff134
use recommenedd coreconsole from https://github.com/dotnet/cli
yugangw-msft Dec 16, 2015
2f307a9
merge with the latest clu
yugangw-msft Dec 16, 2015
f313688
Merge pull request #1502 from markcowl/cluoutput
Dec 16, 2015
5eac2fc
remove unused azure file, rathe the nix version azure.sh is fine to r…
yugangw-msft Dec 16, 2015
f39bc05
remove no longer used consolehost package
yugangw-msft Dec 16, 2015
3a15637
Merge pull request #1509 from yugangw-msft/corehost
Dec 16, 2015
053deb6
replace build with dnu restore to improve build perf
yugangw-msft Dec 16, 2015
a3d1ee9
Merge pull request #1510 from yugangw-msft/forCI
yugangw-msft Dec 16, 2015
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using System;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;
using System;
using System.Collections.Generic;
using System.Security;
using System.Security.Cryptography.X509Certificates;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
using Microsoft.Rest;
using System;
using System.Runtime.InteropServices;
using Commands.Common.Authentication.Properties;
using Microsoft.Rest.Azure.Authentication;
using System.Management.Automation;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,11 +16,10 @@
using System;
using System.Linq;
using System.Management.Automation;
using System.Security;
using Commands.Common.Authentication.Properties;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Rest;
using Microsoft.Rest.Azure.Authentication;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Factories
{
Expand Down
3 changes: 1 addition & 2 deletions src/CLU/Commands.Common.Authentication/ClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Management.Automation;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Factories
{
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Commands.Common.Authentication/JsonUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using System;
using System.Collections.Generic;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Models
{
Expand Down Expand Up @@ -372,7 +372,7 @@ public static class AzureEnvironmentConstants

public const string USGovernmentSqlDatabaseDnsSuffix = ".database.usgovcloudapi.net";

public const string AzureActiveDirectoryEndpoint = "https://login.windows.net/";
public const string AzureActiveDirectoryEndpoint = "https://login.microsoftonline.com/";

public const string ChinaActiveDirectoryEndpoint = "https://login.chinacloudapi.cn/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using Microsoft.Rest;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Models
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication.Models
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@
<data name="AccountNeedsToBeSpecified" xml:space="preserve">
<value>Account needs to be specified</value>
</data>
<data name="AzureDirectoryName" xml:space="preserve">
<value>Windows Azure Powershell</value>
</data>
<data name="CertificateNotFoundInStore" xml:space="preserve">
<value>No certificate was found in the certificate store with thumbprint {0}</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion src/CLU/Commands.Common.Authentication/Validate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Commands.Common.Authentication.Properties;
using System;
using System.IO;
using System.Linq;
using Commands.Common.Authentication.Properties;

namespace Microsoft.Azure.Commands.Common.Authentication
{
Expand Down
12 changes: 3 additions & 9 deletions src/CLU/Commands.Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,11 @@ protected virtual void WriteExceptionError(Exception ex)
WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.CloseError, null));
}

protected PSObject ConstructPSObject(string typeName, params object[] args)
protected PSObject ConstructPSObject(params object[] args)
{
return PowerShellUtilities.ConstructPSObject(typeName, args);
return PowerShellUtilities.ConstructPSObject(args);
}

protected void SafeWriteOutputPSObject(string typeName, params object[] args)
{
PSObject customObject = this.ConstructPSObject(typeName, args);
WriteObject(customObject);
}


private void FlushDebugMessages(bool record = false)
{
if (record)
Expand Down
9 changes: 9 additions & 0 deletions src/CLU/Commands.Common/Models/PSAzureContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,14 @@ public static implicit operator AzureContext(PSAzureContext context)
public PSAzureTenant Tenant { get; set; }

public byte[] TokenCache { get; set; }

public override string ToString()
{
var account = Account != null ? Account.Id : string.Empty;
var subscription = Subscription != null ? Subscription.SubscriptionId : string.Empty;
var tenant = Tenant != null ? Tenant.TenantId : string.Empty;
var environment = Environment != null ? Environment.Name : EnvironmentName.AzureCloud;
return $"{{Account: {account}, Subscription: {subscription}, Tenant: {tenant}, Environment: {environment}}}";
}
}
}
5 changes: 5 additions & 0 deletions src/CLU/Commands.Common/Models/PSAzureProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public IDictionary<string, PSAzureEnvironment> Environments
get { return _env; }
}

public string EnvironmentNames
{
get { return _env == null? null : $"{string.Join(", ", _env.Keys.ToArray())}"; }
}

/// <summary>
/// The current credentials and metadata for connecting with the current Azure cloud instance.
/// </summary>
Expand Down
9 changes: 2 additions & 7 deletions src/CLU/Commands.Common/PowerShellUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,12 @@ private static void ChangeForTargetEnvironment(Func<IEnumerable<string>, IEnumer
}
}

public static PSObject ConstructPSObject(string typeName, params object[] args)
public static PSObject ConstructPSObject(params object[] args)
{
Debug.Assert(args.Length % 2 == 0, "The parameter args length must be even number");

PSObject outputObject = new PSObject();

if (!string.IsNullOrEmpty(typeName))
{
outputObject.TypeNames.Add(typeName);
}


for (int i = 0, j = 0; i < args.Length / 2; i++, j += 2)
{
outputObject.Properties.Add(new PSNoteProperty(args[j].ToString(), args[j + 1]));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Newtonsoft.Json;

namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources
{
public class ResourceLock<TProperties> : Resource<TProperties>
{
public ResourceLock(Resource<TProperties> r)
: base(r)
{
}

/// <summary>
/// Gets or sets the lock id for the resource.
/// </summary>
[JsonProperty(Required = Required.Default)]
public string LockId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources;
using Newtonsoft.Json;

namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
{
public class ResourcePolicyAssignment<TProperties> : Resource<TProperties>
{
public ResourcePolicyAssignment(Resource<TProperties> r)
: base(r)
{
}

/// <summary>
/// Gets or sets the policy assignment id for the resource.
/// </summary>
[JsonProperty(Required = Required.Default)]
public string PolicyAssignmentId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources;
using Newtonsoft.Json;

namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
{
public class ResourcePolicyDefinition<TProperties> : Resource<TProperties>
{
public ResourcePolicyDefinition(Resource<TProperties> r)
: base(r)
{
}

/// <summary>
/// Gets or sets the policy definition id for the resource.
/// </summary>
[JsonProperty(Required = Required.Default)]
public string PolicyDefinitionId { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources
/// </summary>
public class Resource<TProperties>
{
public Resource()
{

}

public Resource(Resource<TProperties> r)
{
this.ChangedTime = r.ChangedTime;
this.CreatedTime = r.CreatedTime;
this.ETag = r.ETag;
this.Id = r.Id;
this.Kind = r.Kind;
this.Location = r.Location;
this.Name = r.Name;
this.Plan = r.Plan;
this.Properties = r.Properties;
this.Sku = r.Sku;
this.Tags = r.Tags;
this.Type = r.Type;
}

/// <summary>
/// Gets or sets the properties.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal static class JTokenExtensions
/// </summary>
/// <param name="jtoken">The <see cref="JObject"/></param>
/// <param name="objectType">The type of the object.</param>
internal static PSObject ToPsObject(this JToken jtoken, string objectType = null)
internal static PSObject ToPsObject(this JToken jtoken)
{
if (jtoken == null)
{
Expand All @@ -63,12 +63,7 @@ internal static PSObject ToPsObject(this JToken jtoken, string objectType = null

var jobject = (JObject)jtoken;
var psObject = new PSObject();

if (!string.IsNullOrWhiteSpace(objectType))
{
psObject.TypeNames.Add(objectType);
}


foreach (var property in jobject.Properties())
{
psObject.Properties.Add(new PSNoteProperty(
Expand Down
Loading