-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synapse] Add support for workspace Repository Configuration (#15660)
* Update change log * Support CICD * Add PSWorkspaceRepositoryConfiguration * Revert gen3 changes * link to git repo when create a workspace * add help docs * redesign git repo related cmdlets * update New-AzSynapseWorkspace.md * update changelog * fix for ci test Co-authored-by: Dongwei Wang <[email protected]> Co-authored-by: Wan Yang <[email protected]>
- Loading branch information
1 parent
2ce9bcc
commit 4eeda23
Showing
17 changed files
with
481 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
78 changes: 78 additions & 0 deletions
78
...napse/Synapse/Commands/ManagementCommands/Workspace/NewAzureSynapseGitRepositoryConfig.cs
This file contains 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,78 @@ | ||
using Microsoft.Azure.Commands.Synapse.Common; | ||
using Microsoft.Azure.Commands.Synapse.Models; | ||
using Microsoft.Azure.Commands.Synapse.Properties; | ||
using Microsoft.Azure.Management.Synapse.Models; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
using System; | ||
using System.Management.Automation; | ||
|
||
namespace Microsoft.Azure.Commands.Synapse.Commands | ||
{ | ||
[Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.GitRepositoryConfig)] | ||
[OutputType(typeof(PSWorkspaceRepositoryConfiguration))] | ||
public class NewAzureSynapseGitRepositoryConfig : SynapseManagementCmdletBase | ||
{ | ||
[Parameter(Mandatory = true, HelpMessage = HelpMessages.RepositoryType)] | ||
[ValidateSet(SynapseConstants.RepositoryType.GitHub, SynapseConstants.RepositoryType.AzureDevOpsGit, IgnoreCase = false)] | ||
[ValidateNotNullOrEmpty] | ||
public string RepositoryType { get; set; } | ||
|
||
[Parameter(Mandatory = false, HelpMessage = HelpMessages.HostName)] | ||
[ValidateNotNullOrEmpty] | ||
public string HostName { get; set; } | ||
|
||
[Parameter(Mandatory = true, HelpMessage = HelpMessages.AccountName)] | ||
[ValidateNotNullOrEmpty] | ||
public string AccountName { get; set; } | ||
|
||
[Parameter(Mandatory = false, HelpMessage = HelpMessages.ProjectName)] | ||
[ValidateNotNullOrEmpty] | ||
public string ProjectName { get; set; } | ||
|
||
[Parameter(Mandatory = true, HelpMessage = HelpMessages.RepositoryName)] | ||
[ValidateNotNullOrEmpty] | ||
public string RepositoryName { get; set; } | ||
|
||
[Parameter(Mandatory = true, HelpMessage = HelpMessages.CollaborationBranch)] | ||
[ValidateNotNullOrEmpty] | ||
public string CollaborationBranch { get; set; } | ||
|
||
[Parameter(Mandatory = false, HelpMessage = HelpMessages.RootFolder)] | ||
[ValidateNotNullOrEmpty] | ||
public string RootFolder { get; set; } = "/"; | ||
|
||
[Parameter(Mandatory = false, HelpMessage = HelpMessages.TenantId)] | ||
[ValidateNotNullOrEmpty] | ||
public Guid TenantId { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
if (this.RepositoryType == SynapseConstants.RepositoryType.AzureDevOpsGit && this.ProjectName == null) | ||
{ | ||
throw new PSArgumentException(string.Format(Resources.WorkspaceGitRepoParameterException, "ProjectName"), "ProjectName"); | ||
} | ||
|
||
if (this.RepositoryType == SynapseConstants.RepositoryType.AzureDevOpsGit) | ||
{ | ||
if (!this.IsParameterBound(c => c.TenantId)) | ||
{ | ||
this.TenantId = SynapseAnalyticsClient.GetTenantId(); | ||
} | ||
} | ||
|
||
var settings = new WorkspaceRepositoryConfiguration | ||
{ | ||
Type = this.RepositoryType == SynapseConstants.RepositoryType.AzureDevOpsGit ? SynapseConstants.RepositoryType.WorkspaceVSTSConfiguration : SynapseConstants.RepositoryType.WorkspaceGitHubConfiguration, | ||
HostName = this.RepositoryType == SynapseConstants.RepositoryType.GitHub ? this.HostName : null, | ||
AccountName = this.AccountName, | ||
ProjectName = this.RepositoryType == SynapseConstants.RepositoryType.AzureDevOpsGit ? this.ProjectName : null, | ||
RepositoryName = this.RepositoryName, | ||
CollaborationBranch = this.CollaborationBranch, | ||
TenantId = this.TenantId, | ||
RootFolder = this.RootFolder | ||
}; | ||
|
||
WriteObject(new PSWorkspaceRepositoryConfiguration(settings)); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
83 changes: 83 additions & 0 deletions
83
src/Synapse/Synapse/Models/PSWorkspaceRepositoryConfiguration.cs
This file contains 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 @@ | ||
using Microsoft.Azure.Management.Synapse.Models; | ||
|
||
namespace Microsoft.Azure.Commands.Synapse.Models | ||
{ | ||
public class PSWorkspaceRepositoryConfiguration | ||
{ | ||
private WorkspaceRepositoryConfiguration workspaceRepositoryConfiguration; | ||
|
||
public PSWorkspaceRepositoryConfiguration(WorkspaceRepositoryConfiguration workspaceRepositoryConfiguration) | ||
{ | ||
this.workspaceRepositoryConfiguration = workspaceRepositoryConfiguration; | ||
this.Type = workspaceRepositoryConfiguration.Type; | ||
this.HostName = workspaceRepositoryConfiguration.HostName; | ||
this.AccountName = workspaceRepositoryConfiguration.AccountName; | ||
this.ProjectName = workspaceRepositoryConfiguration.ProjectName; | ||
this.RepositoryName = workspaceRepositoryConfiguration.RepositoryName; | ||
this.CollaborationBranch = workspaceRepositoryConfiguration.CollaborationBranch; | ||
this.RootFolder = workspaceRepositoryConfiguration.RootFolder; | ||
this.LastCommitId = workspaceRepositoryConfiguration.LastCommitId; | ||
this.TenantId = workspaceRepositoryConfiguration.TenantId; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets type of workspace repositoryID configuration. Example | ||
/// WorkspaceVSTSConfiguration, WorkspaceGitHubConfiguration | ||
/// </summary> | ||
public string Type { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets gitHub Enterprise host name. For example: | ||
/// https://github.mydomain.com | ||
/// </summary> | ||
public string HostName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets account name | ||
/// </summary> | ||
public string AccountName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets VSTS project name | ||
/// </summary> | ||
public string ProjectName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets repository name | ||
/// </summary> | ||
public string RepositoryName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets collaboration branch | ||
/// </summary> | ||
public string CollaborationBranch { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets root folder to use in the repository | ||
/// </summary> | ||
public string RootFolder { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the last commit ID | ||
/// </summary> | ||
public string LastCommitId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the VSTS tenant ID | ||
/// </summary> | ||
public System.Guid? TenantId { get; set; } | ||
|
||
public WorkspaceRepositoryConfiguration ToSdkObject() | ||
{ | ||
return new WorkspaceRepositoryConfiguration | ||
{ | ||
Type = this.Type, | ||
AccountName = this.AccountName, | ||
ProjectName = this.ProjectName, | ||
RepositoryName = this.RepositoryName, | ||
CollaborationBranch = this.CollaborationBranch, | ||
RootFolder = this.RootFolder | ||
}; | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Oops, something went wrong.