forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP] Az.Ssh #2
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
Open
vthiebaut10
wants to merge
8
commits into
myTrack2
Choose a base branch
from
track2_sdk_08_01_22
base: myTrack2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[WIP] Az.Ssh #2
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
522e58b
Add SSH comdlets
vthiebaut10 d1c0f2e
Initial ssh
vthiebaut10 f9f6b0f
Address comments from code review
vthiebaut10 0982c82
Removed AzureIdUtilities, because Azure PowerShell already implemente…
vthiebaut10 1d7324c
Address comments from code review
vthiebaut10 5c44666
address some comments from code review
vthiebaut10 61246dd
update config entry
vthiebaut10 9df4c7a
base cmdlet changes
vthiebaut10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // ---------------------------------------------------------------------------------- | ||
| // | ||
| // 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 System; | ||
| using System.Linq; | ||
| using System.Text.RegularExpressions; | ||
|
|
||
| namespace Microsoft.Azure.Commands.Ssh | ||
| { | ||
| public static class AzureIdUtilities | ||
| { | ||
| private static Regex locationRegex = new Regex("/locations/(?<Location>.*?)/", RegexOptions.Compiled | RegexOptions.IgnoreCase); | ||
|
|
||
| private static Regex rgRegex = new Regex("/resourceGroups/(?<RG>.*?)/", RegexOptions.Compiled | RegexOptions.IgnoreCase); | ||
|
|
||
| private static Regex subscriptionRegex = new Regex("/subscriptions/(?<subscriptionId>.*?)/", RegexOptions.Compiled | RegexOptions.IgnoreCase); | ||
|
|
||
| private static Regex resourceProviderRegex = new Regex("/providers/(?<resourceProvider>.*/*?)/", RegexOptions.Compiled | RegexOptions.IgnoreCase); | ||
|
|
||
| public static string GetResourceName(string id) | ||
vthiebaut10 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| return id.Split('/').Last(); | ||
| } | ||
|
|
||
| public static string GetResourceLocation(string id) | ||
| { | ||
| var match = locationRegex.Match(id); | ||
|
|
||
| if (match.Success != true) | ||
| { | ||
| throw new ArgumentException("Invalid format of the resource identifier.", "id"); | ||
vthiebaut10 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return match.Groups["Location"].Value; | ||
| } | ||
|
|
||
| public static string GetResourceGroup(string id) | ||
| { | ||
| var match = rgRegex.Match(id); | ||
|
|
||
| if (match.Success != true) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| return match.Groups["RG"].Value; | ||
| } | ||
|
|
||
| public static string GetResourceSubscription(string id) | ||
| { | ||
| var match = subscriptionRegex.Match(id); | ||
|
|
||
| if (match.Success != true) | ||
| { | ||
| throw new ArgumentException("Invalid format of the resource identifier.", "id"); | ||
| } | ||
|
|
||
| return match.Groups["subscriptionId"].Value; | ||
| } | ||
|
|
||
| public static string GetResourceType(string id) | ||
| { | ||
| var match = resourceProviderRegex.Match(id); | ||
| if (match.Success != true) | ||
| { | ||
| throw new ArgumentException("Invalid format of the resource identifier.", "id"); | ||
| } | ||
|
|
||
| return match.Groups["resourceProvider"].Value; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <PsModuleName>Ssh</PsModuleName> | ||
| <OmitJsonPackage>true</OmitJsonPackage> | ||
| <AssemblyLoadContextEntryPoint>true</AssemblyLoadContextEntryPoint> | ||
| </PropertyGroup> | ||
|
|
||
| <Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" /> | ||
|
|
||
| <PropertyGroup> | ||
| <RootNamespace>$(LegacyAssemblyPrefix)$(PsModuleName)</RootNamespace> | ||
| <AssemblyName>$(LegacyAssemblyPrefix)$(PsModuleName).AlcWrapper</AssemblyName> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Azure.Management.Compute" Version="49.1.0" /> | ||
| <PackageReference Include="Microsoft.Azure.Management.Network" Version="20.6.0" /> | ||
| <PackageReference Include="Microsoft.Azure.Management.HybridCompute" Version="0.1.0-preview.2" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.