Skip to content

Commit f313688

Browse files
author
Hovsep
committed
Merge pull request Azure#1502 from markcowl/cluoutput
Update outpiut format and list view processing for CLU commands
2 parents de09a71 + 8048231 commit f313688

File tree

5 files changed

+102
-19
lines changed

5 files changed

+102
-19
lines changed

src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public static class AzureEnvironmentConstants
372372

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

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

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

src/CLU/Commands.Common/Models/PSAzureContext.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,14 @@ public static implicit operator AzureContext(PSAzureContext context)
8686
public PSAzureTenant Tenant { get; set; }
8787

8888
public byte[] TokenCache { get; set; }
89+
90+
public override string ToString()
91+
{
92+
var account = Account != null ? Account.Id : string.Empty;
93+
var subscription = Subscription != null ? Subscription.SubscriptionId : string.Empty;
94+
var tenant = Tenant != null ? Tenant.TenantId : string.Empty;
95+
var environment = Environment != null ? Environment.Name : EnvironmentName.AzureCloud;
96+
return $"{{Account: {account}, Subscription: {subscription}, Tenant: {tenant}, Environment: {environment}}}";
97+
}
8998
}
9099
}

src/CLU/Commands.Common/Models/PSAzureProfile.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public IDictionary<string, PSAzureEnvironment> Environments
6464
get { return _env; }
6565
}
6666

67+
public string EnvironmentNames
68+
{
69+
get { return _env == null? null : $"{string.Join(", ", _env.Keys.ToArray())}"; }
70+
}
71+
6772
/// <summary>
6873
/// The current credentials and metadata for connecting with the current Azure cloud instance.
6974
/// </summary>

src/CLU/Microsoft.Azure.Commands.Profile/Microsoft.Azure.Commands.Profile.format.ps1xml

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,62 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<Configuration>
33
<ViewDefinitions>
4-
<View>
5-
<Name>Microsoft.Azure.Commands.Profile.Models.PSAzureProfile</Name>
4+
<View>
5+
<Name>Microsoft.Azure.Commands.Models.PSAzureProfile</Name>
66
<ViewSelectedBy>
7-
<TypeName>Microsoft.Azure.Commands.Profile.Models.PSAzureProfile</TypeName>
7+
<TypeName>Microsoft.Azure.Commands.Models.PSAzureProfile</TypeName>
88
</ViewSelectedBy>
99
<ListControl>
1010
<ListEntries>
1111
<ListEntry>
1212
<ListItems>
1313
<ListItem>
1414
<Label>Context</Label>
15-
1615
<Property>Context</Property>
1716
</ListItem>
18-
</ListItems>
17+
<ListItem>
18+
<Label>Environments</Label>
19+
<Property>EnvironmentNames</Property>
20+
</ListItem>
21+
</ListItems>
1922
</ListEntry>
2023
</ListEntries>
2124
</ListControl>
22-
</View>
25+
</View>-->
2326
<View>
24-
<Name>Microsoft.Azure.Commands.Profile.Models.PSAzureContext</Name>
27+
<Name>Microsoft.Azure.Commands.Models.PSAzureContext</Name>
2528
<ViewSelectedBy>
26-
<TypeName>Microsoft.Azure.Commands.Profile.Models.PSAzureContext</TypeName>
29+
<TypeName>Microsoft.Azure.Commands.Models.PSAzureContext</TypeName>
2730
</ViewSelectedBy>
2831
<ListControl>
2932
<ListEntries>
3033
<ListEntry>
3134
<ListItems>
3235
<ListItem>
36+
<Label>Environment</Label>
3337
<PropertyName>Environment</PropertyName>
3438
</ListItem>
3539
<ListItem>
40+
<Label>Account</Label>
3641
<PropertyName>Account</PropertyName>
3742
</ListItem>
3843
<ListItem>
3944
<Label>TenantId</Label>
40-
<Property>Tenant</Property>
45+
<PropertyName>Tenant</PropertyName>
4146
</ListItem>
4247
<ListItem>
4348
<Label>SubscriptionId</Label>
44-
<Property>Subscription</Property>
49+
<PropertyName>Subscription</PropertyName>
4550
</ListItem>
4651
</ListItems>
4752
</ListEntry>
4853
</ListEntries>
4954
</ListControl>
5055
</View>
5156
<View>
52-
<Name>Microsoft.Azure.Commands.Profile.Models.PSAzureSubscription</Name>
57+
<Name>Microsoft.Azure.Commands.Models.PSAzureSubscription</Name>
5358
<ViewSelectedBy>
54-
<TypeName>Microsoft.Azure.Commands.Profile.Models.PSAzureSubscription</TypeName>
59+
<TypeName>Microsoft.Azure.Commands.Models.PSAzureSubscription</TypeName>
5560
</ViewSelectedBy>
5661
<ListControl>
5762
<ListEntries>
@@ -75,9 +80,9 @@
7580
</ListControl>
7681
</View>
7782
<View>
78-
<Name>Microsoft.Azure.Commands.Profile.Models.PSAzureTenant</Name>
83+
<Name>Microsoft.Azure.Commands.Models.PSAzureTenant</Name>
7984
<ViewSelectedBy>
80-
<TypeName>Microsoft.Azure.Commands.Profile.Models.PSAzureTenant</TypeName>
85+
<TypeName>Microsoft.Azure.Commands.Models.PSAzureTenant</TypeName>
8186
</ViewSelectedBy>
8287
<ListControl>
8388
<ListEntries>
@@ -94,5 +99,58 @@
9499
</ListEntries>
95100
</ListControl>
96101
</View>
102+
<View>
103+
<Name>Microsoft.Azure.Commands.Models.PSAzureEnvironment</Name>
104+
<ViewSelectedBy>
105+
<TypeName>Microsoft.Azure.Commands.Models.PSAzureEnvironment</TypeName>
106+
</ViewSelectedBy>
107+
<ListControl>
108+
<ListEntries>
109+
<ListEntry>
110+
<ListItems>
111+
<ListItem>
112+
<PropertyName>Name</PropertyName>
113+
</ListItem>
114+
<ListItem>
115+
<Label>ActiveDirectory</Label>
116+
<Property>ActiveDirectoryAuthority</Property>
117+
</ListItem>
118+
<ListItem>
119+
<Label>ResourceManager</Label>
120+
<Property>ResourceManagerUrl</Property>
121+
</ListItem>
122+
<ListItem>
123+
<Label>Graph</Label>
124+
<Property>GraphUrl</Property>
125+
</ListItem>
126+
<ListItem>
127+
<Label>Gallery</Label>
128+
<Property>GalleryUrl</Property>
129+
</ListItem>
130+
<ListItem>
131+
<Label>DefaultTenant</Label>
132+
<Property>AdTenant</Property>
133+
</ListItem>
134+
<ListItem>
135+
<Label>TokenAudience</Label>
136+
<Property>ActiveDirectoryServiceEndpointResourceId</Property>
137+
</ListItem>
138+
<ListItem>
139+
<Label>KeyVaultAudience</Label>
140+
<Property>AzureKeyVaultServiceEndpointResourceId</Property>
141+
</ListItem>
142+
<ListItem>
143+
<Label>KeyVaultSuffix</Label>
144+
<Property>AzureKeyVaultDnsSuffix</Property>
145+
</ListItem>
146+
<ListItem>
147+
<Label>ADFS</Label>
148+
<Property>EnableAdfsAuthentication</Property>
149+
</ListItem>
150+
</ListItems>
151+
</ListEntry>
152+
</ListEntries>
153+
</ListControl>
154+
</View>
97155
</ViewDefinitions>
98156
</Configuration>

src/CLU/Microsoft.CLU/Helpers/FormatReader.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ private static void GetTableColumnItems(TableDescriptor table, XElement tableCon
136136
}
137137
}
138138

139-
private static void GetListItems(ListDescriptor list, XElement tableControl)
139+
private static void GetListItems(ListDescriptor list, XElement listControl)
140140
{
141-
var tableHeaders = GetChildrenMatching(tableControl, "ListEntries").FirstOrDefault();
141+
var listEntries = GetChildrenMatching(listControl, "ListEntries").FirstOrDefault();
142142

143-
if (tableHeaders != null)
143+
if (listEntries != null)
144144
{
145-
foreach (var entry in GetChildrenMatching(tableHeaders, "ListEntry"))
145+
foreach (var entry in GetChildrenMatching(listEntries, "ListEntry"))
146146
{
147147
foreach (var items in GetChildrenMatching(entry, "ListItems"))
148148
{
@@ -152,6 +152,7 @@ private static void GetListItems(ListDescriptor list, XElement tableControl)
152152

153153
var label = GetChildrenMatching(item, "Label").FirstOrDefault();
154154
var propertyName = GetChildrenMatching(item, "PropertyName").FirstOrDefault();
155+
var property = GetChildrenMatching(item, "Property").FirstOrDefault();
155156

156157
if (label != null && !string.IsNullOrEmpty(label.Value))
157158
{
@@ -160,6 +161,16 @@ private static void GetListItems(ListDescriptor list, XElement tableControl)
160161
if (propertyName != null && !string.IsNullOrEmpty(propertyName.Value))
161162
{
162163
column.ItemName = propertyName.Value;
164+
if (string.IsNullOrEmpty(column.Header))
165+
{
166+
column.Header = propertyName.Value;
167+
}
168+
}
169+
170+
if (property != null && !string.IsNullOrEmpty(property.Value) &&
171+
string.IsNullOrEmpty(column.ItemName))
172+
{
173+
column.ItemName = property.Value;
163174
}
164175

165176
if (!string.IsNullOrEmpty(column.ItemName) && !string.IsNullOrEmpty(column.Header))

0 commit comments

Comments
 (0)