Skip to content

Add azdo provider - #743

Merged
vhvb1989 merged 74 commits into
Azure:mainfrom
kaizentm:add-azdo-provider
Sep 27, 2022
Merged

Add azdo provider#743
vhvb1989 merged 74 commits into
Azure:mainfrom
kaizentm:add-azdo-provider

Conversation

@vhvb1989

@vhvb1989 vhvb1989 commented Sep 23, 2022

Copy link
Copy Markdown
Member

fix #737
fix #750
This PR fixes #101, #708, #699 and #702 and adds support for Azure DevOps an SCM and CI provider.

This new workflow enables the following:

  • Pipeline named providers for GitHub github and Azure DevOps azdo

  • The provider can be specified in two ways:

    • via azure.yaml by defining the following section:
      pipelines:
         - provider: azdo
      This providers a permanent mechanism for switcing to Azure DevOps as a pipeline provider.
    • Via the --provider flag
       azd pipeline config --provider azdo
      This method updates the provider for only this command invocation. Subsequent pipeline config commands will default to github, unless --provider is passed in.
  • Detection of provider based on .azdo or .github in the template augments the above behavior.

    • If only a .github folder exists, it is assumed the provider is github if azdo is set as a provider value, this will result in an error
    • If only a .azdo folder exists, it is assume the provider is azdo. If github is set as the provider value, this will result in an error.
    • If both .azdo and .github folder exists, github is selected by default if --provider argument is not set and/or if there's not an pipeline: provider entry in azure.yaml
    • When pipeline:provider is set in azure.yaml and --provider argument is also used for running azd pipeline config. The --provider argument overrides the settings from azure.yaml
  • AzDo provider supports using an existing project.

  • AzDo provider supports creating a new project.

  • AzDo provider supports using an existing repo.

  • AzDo provider supports creating a new repo in a project.

  • PAT authentication is used to push to the new repo, and the tool checks for credential helper and offers to set it to store to make subsequent pushes easier.

  • If a PAT is not provided, the tool will ask the user for a PAT and ask the user if they would like to store it.

  • If an organization name is not provided via an Environment Variable, the user will be prompted for an organization name and it will be stored in the environment file.

  • AzDo provider creates a build policy to ensure pushes to default branch are disabled and require a successful pipeline invocation.

  • Deployment Pipeline is created

  • Service Connection is created to allow the pipeline to deploy to azure.

  • Initial pipeline deployment is queued to follow the github behavior.

This was tested with a full deployment of todo-python-mongo using an Azure DevOps Pipeline.
image

image

image

hattan and others added 30 commits September 13, 2022 07:45
Co-authored-by: Hadwa Gaber <hadwaa@microsoft.com>
Co-authored-by: Hadwa Gaber <hadwaa@microsoft.com>
Co-authored-by: Hadwa Gaber <hadwaa@microsoft.com>
Co-authored-by: Hadwa Gaber <hadwaa@microsoft.com>
Co-authored-by: Hadwa Gaber <hadwaa@microsoft.com>
* Refactor to introduce new azdo package

* refactor azdo code to multiple files in azdo package

* Added azdo connection test and refactored provider

* Added azdo provider initial tests

* added more azdo provider tests

* Adding test to verify save env config in azdo provider

* Updating displayed urls to aka.ms
Comment thread cli/azd/pkg/azdo/project.go

@wbreza wbreza left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Added a few more comments but nothing blocking at this point.

Comment thread cli/azd/pkg/azdo/azdo.go
Comment thread cli/azd/pkg/azdo/pipeline.go
Comment thread cli/azd/pkg/azdo/project.go
Comment thread cli/azd/pkg/azdo/project.go
Comment thread cli/azd/pkg/azdo/service_connection.go
Comment thread cli/azd/pkg/azdo/utils.go
Comment thread cli/azd/pkg/commands/pipeline/pipeline.go
Comment thread schemas/v1.0/azure.yaml.json Outdated

@ellismg ellismg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the hard work here, @vhvb1989.

One stylistic comment, there's a bunch of places where we set a bunch of locals, then construct an args parameter (which we also set to a local) and then make a call passing in the args object. It might be easier to read if we instead just creatied the options object at the call site. I think that combined with adding some helper which basically looks like refOf[T any](value T) *T would let us collapse the number of locals we have and move values closer to where they end up being used.

I personally like this style because when reading code if we assign something to a local my mind starts to track it, whereas when we just create a value inside the argument list of a function, we are calling I sort of know "okay, this stuff is just specific to this call" and my mind spends less time lingering on it.

Comment thread .vscode/cspell.global.yaml
Comment thread cli/azd/pkg/azdo/pipeline.go
Comment thread cli/azd/pkg/azdo/pipeline.go
Comment thread cli/azd/pkg/azdo/pipeline.go
Comment thread cli/azd/pkg/azdo/pipeline.go Outdated
Comment thread cli/azd/pkg/commands/pipeline/azdo_provider_test.go
Comment thread cli/azd/pkg/commands/pipeline/pipeline.go
Comment thread cli/azd/pkg/commands/pipeline/pipeline.go
Comment thread cli/azd/pkg/commands/pipeline/pipeline.go
Comment thread schemas/v1.0/azure.yaml.json Outdated
@azure-sdk

Copy link
Copy Markdown
Collaborator

Repoman Generation Results

Repoman pushed changes to remotes for the following projects:

Project: todo-csharp-cosmos-sql

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-csharp-cosmos-sql -b pr/743

View Changes | Compare Changes


Project: todo-csharp-sql

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-csharp-sql -b pr/743

View Changes | Compare Changes


Project: todo-nodejs-mongo-aca

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-nodejs-mongo-aca -b pr/743

View Changes | Compare Changes


Project: todo-nodejs-mongo-swa-func

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-nodejs-mongo-swa-func -b pr/743

View Changes | Compare Changes


Project: todo-nodejs-mongo

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-nodejs-mongo -b pr/743

View Changes | Compare Changes


Project: todo-nodejs-mongo-terraform

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-nodejs-mongo-terraform -b pr/743

View Changes | Compare Changes


Project: todo-python-mongo-aca

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-python-mongo-aca -b pr/743

View Changes | Compare Changes


Project: todo-python-mongo-swa-func

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-python-mongo-swa-func -b pr/743

View Changes | Compare Changes


Project: todo-python-mongo

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-python-mongo -b pr/743

View Changes | Compare Changes


Project: todo-python-mongo-terraform

Remote: azure-samples-staging

Branch: pr/743

You can initialize this project with:

azd init -t Azure-Samples/todo-python-mongo-terraform -b pr/743

View Changes | Compare Changes


@azure-sdk

Copy link
Copy Markdown
Collaborator

Azure Dev CLI Install Instructions

Install scripts

MacOS/Linux

May elevate using sudo on some platforms and configurations

bash:

curl -fsSL https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/743/uninstall-azd.sh | bash;
curl -fsSL https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/743/install-azd.sh | bash -s -- --base-url https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/743 --version '' --verbose

pwsh:

Invoke-RestMethod 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/743/uninstall-azd.ps1' -OutFile uninstall-azd.ps1; ./uninstall-azd.ps1
Invoke-RestMethod 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/743/install-azd.ps1' -OutFile install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/743' -Version '' -Verbose

Windows

powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/743/uninstall-azd.ps1' > uninstall-azd.ps1; ./uninstall-azd.ps1;"
powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/743/install-azd.ps1' > install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/743' -Version '' -Verbose;"

Standalone Binary

Container

docker run -it azdevcliextacr.azurecr.io/azure-dev:pr-743

@vhvb1989
vhvb1989 merged commit 6291854 into Azure:main Sep 27, 2022
@vhvb1989
vhvb1989 deleted the add-azdo-provider branch September 27, 2022 20:43
@vhvb1989
vhvb1989 restored the add-azdo-provider branch September 27, 2022 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

6 participants