forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Move Travis CI job "syncing available extensions to Microsoft/az…
…ure-docs-cli" to ADO (Azure#1314)
- Loading branch information
Jianhui Harold
authored
Feb 25, 2020
1 parent
c1837fd
commit 4dab494
Showing
5 changed files
with
108 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This scripts is used in a Pipeline named **Azure CLI Extensions Sync** of Azure DevOps. | ||
|
||
It's for syncing available extensions list to Microsoft/azure-cli-docs. |
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,26 @@ | ||
--- | ||
title: Available extensions for the Azure CLI | ||
description: A complete list of the officially supported extensions for the Azure CLI. | ||
author: haroldrandom | ||
ms.author: jianzen | ||
manager: yonzhan,yungezz | ||
ms.date: {{ date }} | ||
ms.topic: article | ||
ms.prod: azure | ||
ms.technology: azure-cli | ||
ms.devlang: azure-cli | ||
--- | ||
|
||
# Available extensions for the Azure CLI | ||
|
||
This article is a complete list of the available extensions for the Azure CLI which are supported by Microsoft. | ||
|
||
The list of extensions is also available from the CLI. To get it, run [az extension list-available](/cli/azure/extension?view=azure-cli-latest#az-extension-list-available): | ||
|
||
```azurecli-interactive | ||
az extension list-available --output table | ||
``` | ||
|
||
| Name | Version | Summary | Preview | | ||
|------|---------|---------|---------|{% for extension in extensions %} | ||
| [{{ extension.name }}]({{ extension.project_url }}) | {{ extension.version }} | {{ extension.desc }} | {{ extension.preview }} |{% endfor %} |
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,2 @@ | ||
Jinja2~=2.10.1 | ||
wheel==0.31.1 |
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,63 @@ | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
""" | ||
This script must be run at the root of repo folder, which is azure-cli-extensions/ | ||
It's used to update a file "azure-cli-extensions-list.md" of MicrosoftDocs/azure-cli-docs. | ||
The file content is list of all available latest extensions. | ||
""" | ||
|
||
import os | ||
import sys | ||
|
||
import collections | ||
import datetime | ||
from pkg_resources import parse_version | ||
|
||
from jinja2 import Template # pylint: disable=import-error | ||
|
||
|
||
SCRIPTS_LOCATION = os.path.abspath(os.path.join('.', 'scripts')) | ||
|
||
AZURE_DOCS_CLI_REPO_PATH = os.path.join('.', 'azure-docs-cli') | ||
AVAILABLE_EXTENSIONS_DOC = os.path.join(AZURE_DOCS_CLI_REPO_PATH, 'docs-ref-conceptual', 'azure-cli-extensions-list.md') | ||
TEMPLATE_FILE = os.path.join(SCRIPTS_LOCATION, "ci", "avail-ext-doc", "list-template.md") | ||
|
||
sys.path.insert(0, SCRIPTS_LOCATION) | ||
from ci.util import get_index_data, INDEX_PATH | ||
|
||
|
||
def get_extensions(): | ||
extensions = [] | ||
index_extensions = collections.OrderedDict(sorted(get_index_data()['extensions'].items())) | ||
for _, exts in index_extensions.items(): | ||
# Get latest version | ||
exts = sorted(exts, key=lambda c: parse_version(c['metadata']['version']), reverse=True) | ||
extensions.append({ | ||
'name': exts[0]['metadata']['name'], | ||
'desc': exts[0]['metadata']['summary'], | ||
'version': exts[0]['metadata']['version'], | ||
'project_url': exts[0]['metadata']['extensions']['python.details']['project_urls']['Home'], | ||
'preview': 'Yes' if exts[0]['metadata'].get('azext.isPreview') else '' | ||
}) | ||
return extensions | ||
|
||
|
||
def update_extensions_list(output_file): | ||
with open(TEMPLATE_FILE, 'r') as doc_template: | ||
template = Template(doc_template.read()) | ||
if template is None: | ||
raise RuntimeError("Failed to read template file {}".format(TEMPLATE_FILE)) | ||
with open(output_file, 'w') as output: | ||
output.write(template.render(extensions=get_extensions(), date=datetime.date.today().strftime("%m/%d/%Y"))) | ||
|
||
|
||
def main(): | ||
update_extensions_list(AVAILABLE_EXTENSIONS_DOC) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |