Skip to content

Update outpiut format and list view processing for CLU commands #1502

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 5 commits into from
Dec 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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
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
Original file line number Diff line number Diff line change
@@ -1,57 +1,62 @@
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>Microsoft.Azure.Commands.Profile.Models.PSAzureProfile</Name>
<View>
<Name>Microsoft.Azure.Commands.Models.PSAzureProfile</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.Commands.Profile.Models.PSAzureProfile</TypeName>
<TypeName>Microsoft.Azure.Commands.Models.PSAzureProfile</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<Label>Context</Label>

<Property>Context</Property>
</ListItem>
</ListItems>
<ListItem>
<Label>Environments</Label>
<Property>EnvironmentNames</Property>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
</View>-->
<View>
<Name>Microsoft.Azure.Commands.Profile.Models.PSAzureContext</Name>
<Name>Microsoft.Azure.Commands.Models.PSAzureContext</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.Commands.Profile.Models.PSAzureContext</TypeName>
<TypeName>Microsoft.Azure.Commands.Models.PSAzureContext</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<Label>Environment</Label>
<PropertyName>Environment</PropertyName>
</ListItem>
<ListItem>
<Label>Account</Label>
<PropertyName>Account</PropertyName>
</ListItem>
<ListItem>
<Label>TenantId</Label>
<Property>Tenant</Property>
<PropertyName>Tenant</PropertyName>
</ListItem>
<ListItem>
<Label>SubscriptionId</Label>
<Property>Subscription</Property>
<PropertyName>Subscription</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
<View>
<Name>Microsoft.Azure.Commands.Profile.Models.PSAzureSubscription</Name>
<Name>Microsoft.Azure.Commands.Models.PSAzureSubscription</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.Commands.Profile.Models.PSAzureSubscription</TypeName>
<TypeName>Microsoft.Azure.Commands.Models.PSAzureSubscription</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
Expand All @@ -75,9 +80,9 @@
</ListControl>
</View>
<View>
<Name>Microsoft.Azure.Commands.Profile.Models.PSAzureTenant</Name>
<Name>Microsoft.Azure.Commands.Models.PSAzureTenant</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.Commands.Profile.Models.PSAzureTenant</TypeName>
<TypeName>Microsoft.Azure.Commands.Models.PSAzureTenant</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
Expand All @@ -94,5 +99,58 @@
</ListEntries>
</ListControl>
</View>
<View>
<Name>Microsoft.Azure.Commands.Models.PSAzureEnvironment</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.Commands.Models.PSAzureEnvironment</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<PropertyName>Name</PropertyName>
</ListItem>
<ListItem>
<Label>ActiveDirectory</Label>
<Property>ActiveDirectoryAuthority</Property>
</ListItem>
<ListItem>
<Label>ResourceManager</Label>
<Property>ResourceManagerUrl</Property>
</ListItem>
<ListItem>
<Label>Graph</Label>
<Property>GraphUrl</Property>
</ListItem>
<ListItem>
<Label>Gallery</Label>
<Property>GalleryUrl</Property>
</ListItem>
<ListItem>
<Label>DefaultTenant</Label>
<Property>AdTenant</Property>
</ListItem>
<ListItem>
<Label>TokenAudience</Label>
<Property>ActiveDirectoryServiceEndpointResourceId</Property>
</ListItem>
<ListItem>
<Label>KeyVaultAudience</Label>
<Property>AzureKeyVaultServiceEndpointResourceId</Property>
</ListItem>
<ListItem>
<Label>KeyVaultSuffix</Label>
<Property>AzureKeyVaultDnsSuffix</Property>
</ListItem>
<ListItem>
<Label>ADFS</Label>
<Property>EnableAdfsAuthentication</Property>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
</ViewDefinitions>
</Configuration>
19 changes: 15 additions & 4 deletions src/CLU/Microsoft.CLU/Helpers/FormatReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ private static void GetTableColumnItems(TableDescriptor table, XElement tableCon
}
}

private static void GetListItems(ListDescriptor list, XElement tableControl)
private static void GetListItems(ListDescriptor list, XElement listControl)
{
var tableHeaders = GetChildrenMatching(tableControl, "ListEntries").FirstOrDefault();
var listEntries = GetChildrenMatching(listControl, "ListEntries").FirstOrDefault();

if (tableHeaders != null)
if (listEntries != null)
{
foreach (var entry in GetChildrenMatching(tableHeaders, "ListEntry"))
foreach (var entry in GetChildrenMatching(listEntries, "ListEntry"))
{
foreach (var items in GetChildrenMatching(entry, "ListItems"))
{
Expand All @@ -152,6 +152,7 @@ private static void GetListItems(ListDescriptor list, XElement tableControl)

var label = GetChildrenMatching(item, "Label").FirstOrDefault();
var propertyName = GetChildrenMatching(item, "PropertyName").FirstOrDefault();
var property = GetChildrenMatching(item, "Property").FirstOrDefault();

if (label != null && !string.IsNullOrEmpty(label.Value))
{
Expand All @@ -160,6 +161,16 @@ private static void GetListItems(ListDescriptor list, XElement tableControl)
if (propertyName != null && !string.IsNullOrEmpty(propertyName.Value))
{
column.ItemName = propertyName.Value;
if (string.IsNullOrEmpty(column.Header))
{
column.Header = propertyName.Value;
}
}

if (property != null && !string.IsNullOrEmpty(property.Value) &&
string.IsNullOrEmpty(column.ItemName))
{
column.ItemName = property.Value;
}

if (!string.IsNullOrEmpty(column.ItemName) && !string.IsNullOrEmpty(column.Header))
Expand Down