File: commands.py

package info (click to toggle)
azure-devops-cli-extension 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,384 kB
  • sloc: python: 160,782; xml: 198; makefile: 56; sh: 51
file content (200 lines) | stat: -rw-r--r-- 11,563 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core.commands import CliCommandType
from azext_devops.dev.common.exception_handler import azure_devops_exception_handler
from ._format import (transform_build_table_output,
                      transform_builds_table_output,
                      transform_pipeline_run_table_output,
                      transform_pipeline_or_run_table_output,
                      transform_pipeline_runs_table_output,
                      transform_pipeline_table_output,
                      transform_pipelines_table_output,
                      transform_build_tags_output,
                      transform_definition_table_output,
                      transform_definitions_table_output,
                      transform_releases_table_output,
                      transform_release_table_output,
                      transform_release_definitions_table_output,
                      transform_release_definition_table_output,
                      transform_runs_artifact_table_output,
                      transform_pipelines_pools_table_output,
                      transform_pipelines_pool_table_output,
                      transform_pipelines_agents_table_output,
                      transform_pipelines_agent_table_output,
                      transform_pipelines_queues_table_output,
                      transform_pipelines_queue_table_output,
                      transform_pipelines_variable_groups_table_output,
                      transform_pipelines_variable_group_table_output,
                      transform_pipelines_variables_table_output,
                      transform_pipelines_var_group_variables_table_output,
                      transform_pipelines_folders_table_output,
                      transform_pipelines_folder_table_output)

buildOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.build#{}',
    exception_handler=azure_devops_exception_handler
)

buildDefOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.build_definition#{}',
    exception_handler=azure_devops_exception_handler
)

buildTaskOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.task#{}',
    exception_handler=azure_devops_exception_handler
)

releaseOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.release#{}',
    exception_handler=azure_devops_exception_handler
)

releaseDefinitionOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.release_definition#{}',
    exception_handler=azure_devops_exception_handler
)

pipelinesOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.pipeline#{}',
    exception_handler=azure_devops_exception_handler
)

pipelineCreateOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.pipeline_create#{}',
    exception_handler=azure_devops_exception_handler
)

pipelinesRunOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.pipeline_run#{}',
    exception_handler=azure_devops_exception_handler
)

pipelineRunArtifactsOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.runs_artifacts#{}',
    exception_handler=azure_devops_exception_handler
)

pipelineAgentPoolQueueOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.agent_pool_queue#{}',
    exception_handler=azure_devops_exception_handler
)

pipelineVariableGroupOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.variable_group#{}',
    exception_handler=azure_devops_exception_handler
)

pipelineVariablesOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.pipeline_variables#{}',
    exception_handler=azure_devops_exception_handler
)

pipelineFoldersOps = CliCommandType(
    operations_tmpl='azext_devops.dev.pipelines.pipeline_folders#{}',
    exception_handler=azure_devops_exception_handler
)


# pylint: disable=too-many-statements
def load_build_commands(self, _):
    with self.command_group('pipelines', command_type=pipelineCreateOps) as g:
        g.command('create', 'pipeline_create', table_transformer=transform_pipeline_or_run_table_output)
        g.command('update', 'pipeline_update', table_transformer=transform_pipeline_table_output)

    with self.command_group('pipelines', command_type=pipelinesOps) as g:
        g.command('list', 'pipeline_list', table_transformer=transform_pipelines_table_output)
        g.show_command('show', 'pipeline_show', table_transformer=transform_pipeline_table_output)
        g.command('delete', 'pipeline_delete', confirmation='Are you sure you want to delete this pipeline?')
        g.command('run', 'pipeline_run', table_transformer=transform_pipeline_run_table_output)

    with self.command_group('pipelines build', command_type=buildOps) as g:
        # basic build commands
        g.command('list', 'build_list', table_transformer=transform_builds_table_output)
        g.command('queue', 'build_queue', table_transformer=transform_build_table_output)
        g.show_command('show', 'build_show', table_transformer=transform_build_table_output)
        g.command('cancel', 'build_cancel', table_transformer=transform_build_table_output)

    with self.command_group('pipelines build tag', command_type=buildOps) as g:
        # basic build tag commands
        g.command('list', 'get_build_tags', table_transformer=transform_build_tags_output)
        g.command('add', 'add_build_tags', table_transformer=transform_build_tags_output)
        g.command('delete', 'delete_build_tag', table_transformer=transform_build_tags_output)

    with self.command_group('pipelines build definition', command_type=buildDefOps) as g:
        # basic build definition commands
        g.command('list', 'build_definition_list', table_transformer=transform_definitions_table_output)
        g.show_command('show', 'build_definition_show', table_transformer=transform_definition_table_output)

    with self.command_group('pipelines release', command_type=releaseOps) as g:
        # basic release commands
        g.command('list', 'release_list', table_transformer=transform_releases_table_output)
        g.command('create', 'release_create', table_transformer=transform_release_table_output)
        g.show_command('show', 'release_show', table_transformer=transform_release_table_output)

    with self.command_group('pipelines release definition', command_type=releaseDefinitionOps) as g:
        # basic release commands
        g.command('list', 'release_definition_list', table_transformer=transform_release_definitions_table_output)
        g.show_command('show', 'release_definition_show', table_transformer=transform_release_definition_table_output)

    with self.command_group('pipelines runs artifact', command_type=pipelineRunArtifactsOps) as g:
        g.command('download', 'run_artifact_download')
        g.command('list', 'run_artifact_list', table_transformer=transform_runs_artifact_table_output)
        g.command('upload', 'run_artifact_upload')

    with self.command_group('pipelines runs tag', command_type=pipelinesRunOps) as g:
        g.command('add', 'pipeline_run_add_tag', table_transformer=transform_build_tags_output)
        g.command('list', 'pipeline_run_get_tags', table_transformer=transform_build_tags_output)
        g.command('delete', 'pipeline_run_delete_tag', table_transformer=transform_build_tags_output)

    with self.command_group('pipelines runs', command_type=pipelinesRunOps) as g:
        g.command('list', 'pipeline_run_list', table_transformer=transform_pipeline_runs_table_output)
        g.show_command('show', 'pipeline_run_show', table_transformer=transform_pipeline_run_table_output)

    with self.command_group('pipelines pool', command_type=pipelineAgentPoolQueueOps) as g:
        g.command('list', 'list_pools', table_transformer=transform_pipelines_pools_table_output)
        g.show_command('show', 'show_pool', table_transformer=transform_pipelines_pool_table_output)

    with self.command_group('pipelines agent', command_type=pipelineAgentPoolQueueOps) as g:
        g.command('list', 'list_agents', table_transformer=transform_pipelines_agents_table_output)
        g.show_command('show', 'show_agent', table_transformer=transform_pipelines_agent_table_output)

    with self.command_group('pipelines queue', command_type=pipelineAgentPoolQueueOps) as g:
        g.command('list', 'list_queues', table_transformer=transform_pipelines_queues_table_output)
        g.show_command('show', 'show_queue', table_transformer=transform_pipelines_queue_table_output)

    with self.command_group('pipelines variable-group', command_type=pipelineVariableGroupOps) as g:
        g.command('create', 'variable_group_create', table_transformer=transform_pipelines_variable_group_table_output)
        g.show_command('show', 'variable_group_show', table_transformer=transform_pipelines_variable_group_table_output)
        g.command('list', 'variable_group_list', table_transformer=transform_pipelines_variable_groups_table_output)
        g.command('update', 'variable_group_update', table_transformer=transform_pipelines_variable_group_table_output)
        g.command('delete', 'variable_group_delete',
                  confirmation='Are you sure you want to delete this variable group?')

    with self.command_group('pipelines variable-group variable', command_type=pipelineVariableGroupOps) as g:
        g.command('create', 'variable_group_variable_add',
                  table_transformer=transform_pipelines_var_group_variables_table_output)
        g.command('list', 'variable_group_variable_list',
                  table_transformer=transform_pipelines_var_group_variables_table_output)
        g.command('update', 'variable_group_variable_update',
                  table_transformer=transform_pipelines_var_group_variables_table_output)
        g.command('delete', 'variable_group_variable_delete',
                  confirmation='Are you sure you want to delete this variable?')

    with self.command_group('pipelines variable', command_type=pipelineVariablesOps) as g:
        g.command('create', 'pipeline_variable_add', table_transformer=transform_pipelines_variables_table_output)
        g.command('update', 'pipeline_variable_update', table_transformer=transform_pipelines_variables_table_output)
        g.command('list', 'pipeline_variable_list', table_transformer=transform_pipelines_variables_table_output)
        g.command('delete', 'pipeline_variable_delete',
                  confirmation='Are you sure you want to delete this variable?')

    with self.command_group('pipelines folder', command_type=pipelineFoldersOps) as g:
        g.command('create', 'pipeline_folder_create', table_transformer=transform_pipelines_folder_table_output)
        g.command('delete', 'pipeline_folder_delete', table_transformer=transform_pipelines_folder_table_output,
                  confirmation='This will delete all pipelines in this folder. '
                               'Are you sure you want to delete this folder?')
        g.command('list', 'pipeline_folder_list', table_transformer=transform_pipelines_folders_table_output)
        g.command('update', 'pipeline_folder_update', table_transformer=transform_pipelines_folder_table_output)