Skip to content
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

[AutoPR devops] Adding new api version to devops RP #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions src/devops/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

0.1.0
++++++
* Initial release.
39 changes: 39 additions & 0 deletions src/devops/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Azure CLI devops Extension #
This is the extension for devops

### How to use ###
Install this extension using the below CLI command
```
az extension add --name devops
```

### Included Features ###
#### devops pipeline-template-definition ####
##### List #####
```
az devops pipeline-template-definition list
```
#### devops pipeline ####
##### Create #####
```
az devops pipeline create --location "South India" \
--bootstrap-configuration-repository-properties bootstrapConfiguration={"template":{"id":"ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp","parameters":{"appInsightLocation":"South India","appServicePlan":"S1 Standard","azureAuth":"{\\"scheme\\":\\"ServicePrincipal\\",\\"parameters\\":{\\"tenantid\\":\\"{subscriptionTenantId}\\",\\"objectid\\":\\"{appObjectId}\\",\\"serviceprincipalid\\":\\"{appId}\\",\\"serviceprincipalkey\\":\\"{appSecret}\\"}}","location":"South India","resourceGroup":"myAspNetWebAppPipeline-rg","subscriptionId":"{subscriptionId}","webAppName":"myAspNetWebApp"}}} organization={"name":"myAspNetWebAppPipeline-org"} project={"name":"myAspNetWebAppPipeline-project"} \
--name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg"
```
##### Show #####
```
az devops pipeline show --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg"
```
##### List #####
```
az devops pipeline list --resource-group "myAspNetWebAppPipeline-rg"
```
##### Update #####
```
az devops pipeline update --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" \
--tags tagKey="tagvalue"
```
##### Delete #####
```
az devops pipeline delete --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg"
```
50 changes: 50 additions & 0 deletions src/devops/azext_devops/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_devops.generated._help import helps # pylint: disable=unused-import
try:
from azext_devops.manual._help import helps # pylint: disable=reimported
except ImportError:
pass


class AzureDevOpsCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_devops.generated._client_factory import cf_devops_cl
devops_custom = CliCommandType(
operations_tmpl='azext_devops.custom#{}',
client_factory=cf_devops_cl)
parent = super(AzureDevOpsCommandsLoader, self)
parent.__init__(cli_ctx=cli_ctx, custom_command_type=devops_custom)

def load_command_table(self, args):
from azext_devops.generated.commands import load_command_table
load_command_table(self, args)
try:
from azext_devops.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass
return self.command_table

def load_arguments(self, command):
from azext_devops.generated._params import load_arguments
load_arguments(self, command)
try:
from azext_devops.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass


COMMAND_LOADER_CLS = AzureDevOpsCommandsLoader
17 changes: 17 additions & 0 deletions src/devops/azext_devops/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError:
pass
4 changes: 4 additions & 0 deletions src/devops/azext_devops/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.11.0"
}
17 changes: 17 additions & 0 deletions src/devops/azext_devops/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError:
pass
12 changes: 12 additions & 0 deletions src/devops/azext_devops/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

__path__ = __import__('pkgutil').extend_path(__path__, __name__)
24 changes: 24 additions & 0 deletions src/devops/azext_devops/generated/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------


def cf_devops_cl(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from ..vendored_sdks.devops import AzureDevOps
return get_mgmt_service_client(cli_ctx,
AzureDevOps)


def cf_pipeline_template_definition(cli_ctx, *_):
return cf_devops_cl(cli_ctx).pipeline_template_definition


def cf_pipeline(cli_ctx, *_):
return cf_devops_cl(cli_ctx).pipeline
99 changes: 99 additions & 0 deletions src/devops/azext_devops/generated/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=too-many-lines

from knack.help_files import helps


helps['devops pipeline-template-definition'] = """
type: group
short-summary: devops pipeline-template-definition
"""

helps['devops pipeline-template-definition list'] = """
type: command
short-summary: "Lists all pipeline templates which can be used to configure an Azure Pipeline."
examples:
- name: Get the list of pipeline template definitions
text: |-
az devops pipeline-template-definition list
"""

helps['devops pipeline'] = """
type: group
short-summary: devops pipeline
"""

helps['devops pipeline list'] = """
type: command
short-summary: "Lists all Azure Pipelines under the specified resource group. And Lists all Azure Pipelines under \
the specified subscription."
examples:
- name: List all Azure Pipelines under the specified resource group
text: |-
az devops pipeline list --resource-group "myAspNetWebAppPipeline-rg"
- name: List all Azure pipelines under the specified subscription
text: |-
az devops pipeline list
"""

helps['devops pipeline show'] = """
type: command
short-summary: "Gets an existing Azure Pipeline."
examples:
- name: Get an existing Azure pipeline
text: |-
az devops pipeline show --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg"
"""

helps['devops pipeline create'] = """
type: command
short-summary: "Create an Azure Pipeline."
examples:
- name: Create an Azure pipeline to deploy a sample ASP.Net application to Azure web-app
text: |-
az devops pipeline create --location "South India" --bootstrap-configuration-repository-properties \
bootstrapConfiguration={"template":{"id":"ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp","paramete\
rs":{"appInsightLocation":"South India","appServicePlan":"S1 Standard","azureAuth":"{\\"scheme\\":\\"ServicePrincipal\\\
",\\"parameters\\":{\\"tenantid\\":\\"{subscriptionTenantId}\\",\\"objectid\\":\\"{appObjectId}\\",\\"serviceprincipali\
d\\":\\"{appId}\\",\\"serviceprincipalkey\\":\\"{appSecret}\\"}}","location":"South India","resourceGroup":"myAspNetWeb\
AppPipeline-rg","subscriptionId":"{subscriptionId}","webAppName":"myAspNetWebApp"}}} organization={"name":"myAspNetWebA\
ppPipeline-org"} project={"name":"myAspNetWebAppPipeline-project"} --name "myAspNetWebAppPipeline" --resource-group \
"myAspNetWebAppPipeline-rg"
"""

helps['devops pipeline update'] = """
type: command
short-summary: "Updates the properties of an Azure Pipeline. Currently, only tags can be updated."
examples:
- name: Get an existing Azure pipeline
text: |-
az devops pipeline update --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" \
--tags tagKey="tagvalue"
"""

helps['devops pipeline delete'] = """
type: command
short-summary: "Deletes an Azure Pipeline."
examples:
- name: Get an existing Azure pipeline
text: |-
az devops pipeline delete --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg"
"""

helps['devops pipeline wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of the devops pipeline is met.
examples:
- name: Pause executing next line of CLI script until the devops pipeline is successfully created.
text: |-
az devops pipeline wait --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" \
--created
"""
71 changes: 71 additions & 0 deletions src/devops/azext_devops/generated/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=too-many-lines
# pylint: disable=too-many-statements

from azure.cli.core.commands.parameters import (
tags_type,
get_enum_type,
resource_group_name_type,
get_location_type
)
from azure.cli.core.commands.validators import get_default_location_from_resource_group
from azext_devops.action import (
AddBootstrapConfigurationTemplateParameters,
AddBootstrapConfigurationRepositoryProperties
)


def load_arguments(self, _):

with self.argument_context('devops pipeline list') as c:
c.argument('resource_group_name', resource_group_name_type)

with self.argument_context('devops pipeline show') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('pipeline_name', options_list=['--name', '-n', '--pipeline-name'], type=str, help='The name of the '
'Azure Pipeline resource in ARM.', id_part='name')

with self.argument_context('devops pipeline create') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('pipeline_name', options_list=['--name', '-n', '--pipeline-name'], type=str, help='The name of the '
'Azure Pipeline resource in ARM.')
c.argument('tags', tags_type)
c.argument('location', arg_type=get_location_type(self.cli_ctx),
validator=get_default_location_from_resource_group)
c.argument('bootstrap_configuration_template_id', type=str,
help='Unique identifier of the pipeline template.')
c.argument('bootstrap_configuration_template_parameters', action=AddBootstrapConfigurationTemplateParameters,
nargs='*', help='Dictionary of input parameters used in the pipeline template. Expect value: '
'KEY1=VALUE1 KEY2=VALUE2 ...')
c.argument('bootstrap_configuration_repository_repository_type', arg_type=get_enum_type(['gitHub', 'vstsGit']),
help='Type of code repository.')
c.argument('bootstrap_configuration_repository_default_branch', type=str, help='Default branch used to '
'configure Continuous Integration (CI) in the pipeline.')
c.argument('bootstrap_configuration_repository_properties',
action=AddBootstrapConfigurationRepositoryProperties, nargs='*', help='Repository-specific '
'properties. Expect value: KEY1=VALUE1 KEY2=VALUE2 ...')
c.argument('project_name', type=str, help='Name of the Azure DevOps Project.')

with self.argument_context('devops pipeline update') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('pipeline_name', options_list=['--name', '-n', '--pipeline-name'], type=str, help='The name of the '
'Azure Pipeline resource.', id_part='name')
c.argument('tags', tags_type)

with self.argument_context('devops pipeline delete') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('pipeline_name', options_list=['--name', '-n', '--pipeline-name'], type=str, help='The name of the '
'Azure Pipeline resource.', id_part='name')

with self.argument_context('devops pipeline wait') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('pipeline_name', options_list=['--name', '-n', '--pipeline-name'], type=str, help='The name of the '
'Azure Pipeline resource in ARM.', id_part='name')
9 changes: 9 additions & 0 deletions src/devops/azext_devops/generated/_validators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
Loading