Skip to content

Commit

Permalink
Revert "[k8s-extension] create new cli release - v1.4.3 (#250)" (#251)
Browse files Browse the repository at this point in the history
This reverts commit 584815d.
  • Loading branch information
bavneetsingh16 authored Aug 23, 2023
1 parent 584815d commit aa77ff2
Show file tree
Hide file tree
Showing 1,560 changed files with 146,751 additions and 342,952 deletions.
4 changes: 1 addition & 3 deletions .github/policies/resourceManagement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ configuration:
- or:
- payloadType: Issues
- isAction:
action: Labeled
action: Opened
then:
- if:
- hasLabel:
Expand Down Expand Up @@ -4591,8 +4591,6 @@ configuration:
reviewer: Juliehzl
- requestReview:
reviewer: jijohn14
- requestReview:
reviewer: Greedygre
description: '[container app] Auto assign labels and reviewers based on PR title/description.'
- if:
- payloadType: Issues
Expand Down
32 changes: 13 additions & 19 deletions linter_exclusions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2170,11 +2170,6 @@ networkcloud kubernetescluster agentpool wait:
kubernetes_cluster_name:
rule_exclusions:
- option_length_too_long
networkfabric acl create:
parameters:
dynamic_match_configurations:
rule_exclusions:
- option_length_too_long
networkfabric controller create:
parameters:
workload_er_connections:
Expand Down Expand Up @@ -2279,6 +2274,18 @@ networkfabric internetgateway update:
internet_gateway_rule_id:
rule_exclusions:
- option_length_too_long
networkfabric internetgatewayrule create:
rule_exclusions:
- missing_command_test_coverage
networkfabric internetgatewayrule delete:
rule_exclusions:
- missing_command_test_coverage
networkfabric internetgatewayrule list:
rule_exclusions:
- missing_command_test_coverage
networkfabric internetgatewayrule show:
rule_exclusions:
- missing_command_test_coverage
networkfabric internetgatewayrule update:
rule_exclusions:
- missing_command_test_coverage
Expand All @@ -2290,22 +2297,9 @@ networkfabric ipextendedcommunity create:
ip_extended_community_rules:
rule_exclusions:
- option_length_too_long
networkfabric tap update:
networkfabric npb show:
rule_exclusions:
- missing_command_test_coverage
networkfabric taprule create:
parameters:
dynamic_match_configurations:
rule_exclusions:
- option_length_too_long
polling_interval_in_seconds:
rule_exclusions:
- option_length_too_long
networkfabric taprule update:
parameters:
dynamic_match_configurations:
rule_exclusions:
- option_length_too_long
notification-hub authorization-rule create:
parameters:
notification_hub_name:
Expand Down
10 changes: 9 additions & 1 deletion scripts/ci/build_ext_cmd_tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ export AZURE_EXTENSION_INDEX_URL=https://raw.githubusercontent.com/Azure/azure-c
output=$(az extension list-available --query [].name -otsv)
# azure-cli-ml is replaced by ml
# disable alias which relies on Jinja2 2.10
blocklist=("azure-cli-ml" "alias")
# -----------------------------------------------
# When two extensions have the same command, the following error will be reported:
# `Exception: Key: show already exists in containerapp. 2 extensions cannot have the same command!`
# Temporarily skip the containerapp-preview extension,
# Which will cause the containerapp-preview extension to be unable to use the dynamic load function.
# That is, when using the unique command of containerapp-preview, the extension cannot be automatically prompted to install.
# TODO: remove this after support for building dependencies in command index between extensions
# -----------------------------------------------
blocklist=("azure-cli-ml" "alias" "containerapp-preview")

rm -f ~/.azure/extCmdTreeToUpload.json

Expand Down
15 changes: 13 additions & 2 deletions scripts/ci/index_ref_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,35 @@
class TestIndexRefDocsMeta(type):
def __new__(mcs, name, bases, _dict):

def gen_test(ext_name, ext_url, filename):
def gen_test(ext_name, ext_url, filename, dep_url):
def test(self):
if dep_url.get(ext_name):
dep_file = get_whl_from_url(dep_url[ext_name][0], dep_url[ext_name][1], self.whl_dir)
else:
dep_file = None
ext_file = get_whl_from_url(ext_url, filename, self.whl_dir)
ref_doc_out_dir = os.path.join(REF_DOC_OUT_DIR, ext_name)
if not os.path.isdir(ref_doc_out_dir):
os.mkdir(ref_doc_out_dir)
script_args = [sys.executable, REF_GEN_SCRIPT, '--extension-file', ext_file, '--output-dir',
ref_doc_out_dir]
if dep_file:
script_args.extend(['--dependent-file', dep_file])
try:
check_call(script_args)
except CalledProcessError as e:
traceback.print_exc()
raise e
return test

dep_url = {}
for ext_name, ext_url, filename in ALL_TESTS:
test_name = "test_ref_doc_%s" % ext_name
_dict[test_name] = gen_test(ext_name, ext_url, filename)
# The containerapp-preview extension is a special case,
# it must depend on the continerapp extension and cannot run independently.
if ext_name == 'containerapp':
dep_url['containerapp-preview'] = [ext_url, filename]
_dict[test_name] = gen_test(ext_name, ext_url, filename, dep_url)
return type.__new__(mcs, name, bases, _dict)


Expand Down
8 changes: 8 additions & 0 deletions scripts/ci/verify_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,17 @@ def _cmd(cmd):
check_call(cmd, shell=True)

def add_from_code(self):
# The containerapp-preview extension is a special case,
# it must depend on the continerapp extension and cannot run independently.
if self.extension_name == 'containerapp-preview':
self._cmd('azdev extension add containerapp')
self._cmd('azdev extension add {}'.format(self.extension_name))

def remove(self):
# The containerapp-preview extension is a special case,
# it must depend on the continerapp extension and cannot run independently.
if self.extension_name == 'containerapp-preview':
self._cmd('azdev extension remove containerapp')
self._cmd('azdev extension remove {}'.format(self.extension_name))

def linter(self):
Expand Down
13 changes: 10 additions & 3 deletions scripts/refdoc/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ def print_status(msg=''):
print('-- '+msg)


def generate(ext_file, output_dir):
def generate(ext_file, output_dir, dep_file):
# Verify sphinx installed in environment before we get started
check_call(['sphinx-build', '--version'])
if not output_dir:
output_dir = tempfile.mkdtemp(prefix='ref-doc-out-', dir=os.getcwd())
print_status('Using output directory {}'.format(output_dir))
temp_extension_dir = tempfile.mkdtemp()
try:
if dep_file:
pip_cmd = [sys.executable, '-m', 'pip', 'install', '--target',
os.path.join(temp_extension_dir, 'extension'),
dep_file, '--disable-pip-version-check', '--no-cache-dir']
print_status('Executing "{}"'.format(' '.join(pip_cmd)))
check_call(pip_cmd)
pip_cmd = [sys.executable, '-m', 'pip', 'install', '--target', os.path.join(temp_extension_dir, 'extension'),
ext_file, '--disable-pip-version-check', '--no-cache-dir']
print_status('Executing "{}"'.format(' '.join(pip_cmd)))
Expand Down Expand Up @@ -75,6 +81,7 @@ def _type_path(val):
help='Path to the extension .whl file.', required=True, type=_type_ext_file)
parser.add_argument('-o', '--output-dir', dest='output_dir',
help='Path to place the generated documentation. By default, a temporary directory will be created.', required=False, type=_type_path)

parser.add_argument('-d', '--dependent-file', dest='dep_file',
help='Path to the dependent extension .whl file.', required=False, type=str)
args = parser.parse_args()
generate(args.ext_file, args.output_dir)
generate(args.ext_file, args.output_dir, args.dep_file)
5 changes: 0 additions & 5 deletions src/acrquery/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
Release History
===============
1.0.1
++++++
* Add: New mock files to validate query request.
* Bug fix: Omit login server endpoint suffix.

1.0.0
++++++
* Initial release.
4 changes: 1 addition & 3 deletions src/acrquery/azext_acrquery/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.command_modules.acr._validators import validate_registry_name


def load_arguments(self, _):

with self.argument_context('acr query') as c:
c.argument('registry_name', options_list=['--name', '-n'], validator=validate_registry_name, help='The name of the container registry that the query is run against.')
c.argument('registry_name', options_list=['--name', '-n'], help='The name of the container registry that the query is run against.')
c.argument('repository', help='The repository that the query is run against. If no repository is provided, the query is run at the registry level.')
c.argument('kql_query', options_list=['--kql-query', '-q'], help='The KQL query to execute.')
c.argument('skip_token', help='Skip token to get the next page of the query if applicable.')
Expand Down
101 changes: 101 additions & 0 deletions src/acrquery/azext_acrquery/tests/latest/mock_test_acr_query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import unittest
from unittest import mock
import json

from azext_acrquery.query import (
create_query
)

from azure.cli.command_modules.acr._docker_utils import (
EMPTY_GUID,
get_authorization_header,
)

from azure.cli.core.mock import DummyCli


class AcrQueryCommandsTests(unittest.TestCase):

@mock.patch('azext_acrquery.query.get_access_credentials', autospec=True)
@mock.patch('requests.request', autospec=True)
def test_acrquery(self, mock_requests_get, mock_get_access_credentials):
cmd = self._setup_cmd()

response = mock.MagicMock()
response.headers = {}
response.status_code = 200
response.content = json.dumps({'repositories': ['testrepo1', 'testrepo2']}).encode()
mock_requests_get.return_value = response

# Basic auth
mock_get_access_credentials.return_value = 'testregistry.azurecr.io', 'username', 'password'
create_query(cmd, 'testregistry', 'get')
mock_requests_get.assert_called_with(
method='post',
url='https://testregistry.azurecr.io/acr/v1/_metadata/_query',
headers=get_authorization_header('username', 'password'),
params=None,
json={
'query': 'get'
},
timeout=300,
verify=mock.ANY)

# Bearer auth
mock_get_access_credentials.return_value = 'testregistry.azurecr.io', EMPTY_GUID, 'password'
create_query(cmd, 'testregistry', 'get')
mock_requests_get.assert_called_with(
method='post',
url='https://testregistry.azurecr.io/acr/v1/_metadata/_query',
headers=get_authorization_header(EMPTY_GUID, 'password'),
params=None,
json={
'query': 'get'
},
timeout=300,
verify=mock.ANY)

# Filter by repository
mock_get_access_credentials.return_value = 'testregistry.azurecr.io', EMPTY_GUID, 'password'
create_query(cmd, 'testregistry', 'get', repository='repository')
mock_requests_get.assert_called_with(
method='post',
url='https://testregistry.azurecr.io/acr/v1/repository/_metadata/_query',
headers=get_authorization_header(EMPTY_GUID, 'password'),
params=None,
json={
'query': 'get'
},
timeout=300,
verify=mock.ANY)

# Request with skip token
mock_get_access_credentials.return_value = 'testregistry.azurecr.io', EMPTY_GUID, 'password'
create_query(cmd, 'testregistry', 'get', skip_token='12345678')
mock_requests_get.assert_called_with(
method='post',
url='https://testregistry.azurecr.io/acr/v1/repository/_metadata/_query',
headers=get_authorization_header(EMPTY_GUID, 'password'),
params=None,
json={
'query': 'get',
'options': {
'$skipToken': '12345678'
}
},
timeout=300,
verify=mock.ANY)

def _setup_cmd(self):
cmd = mock.MagicMock()
cmd.cli_ctx = DummyCli()
mock_sku = mock.MagicMock()
mock_sku.classic.value = 'Classic'
mock_sku.basic.value = 'Basic'
cmd.get_models.return_value = mock_sku
return cmd
Loading

0 comments on commit aa77ff2

Please sign in to comment.