Skip to content

Commit

Permalink
enable custom headers (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
weinong authored and fengzhou-msft committed Dec 10, 2019
1 parent e8244ae commit c9b33f4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Release History
===============
0.4.24
+++++
* added custom header support

0.4.23
+++++
* Enable GA support of apiserver authorized IP ranges via paramater `--api-server-authorized-ip-ranges` in `az aks create` and `az aks update`
Expand Down
3 changes: 3 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
- name: --api-server-authorized-ip-ranges
type: string
short-summary: Comma seperated list of authorized apiserver IP ranges. Set to 0.0.0.0/32 to restrict apiserver traffic to node pools.
- name: --aks-custom-headers
type: string
short-summary: Send custom headers. When specified, format should be Key1=Value1,Key2=Value2
examples:
- name: Create a Kubernetes cluster with an existing SSH public key.
text: az aks create -g MyResourceGroup -n MyManagedCluster --ssh-key-value /path/to/publickey
Expand Down
1 change: 1 addition & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def load_arguments(self, _):
c.argument('node_resource_group')
c.argument('attach_acr', acr_arg_type, validator=validate_acr)
c.argument('api_server_authorized_ip_ranges', type=str, validator=validate_ip_ranges)
c.argument('aks_custom_headers')
c.argument('enable_private_cluster', action='store_true')
c.argument('enable_managed_identity', action='store_true')

Expand Down
16 changes: 15 additions & 1 deletion src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ def aks_create(cmd, client, resource_group_name, name, ssh_key_value, # pylint:
enable_private_cluster=False,
enable_managed_identity=False,
api_server_authorized_ip_ranges=None,
aks_custom_headers=None,
no_wait=False):
if not no_ssh_key:
try:
Expand Down Expand Up @@ -867,13 +868,26 @@ def aks_create(cmd, client, resource_group_name, name, ssh_key_value, # pylint:
enable_private_cluster=True
)

headers = {}
if aks_custom_headers is not None:
if aks_custom_headers != "":
for pair in aks_custom_headers.split(','):
parts = pair.split('=')
if len(parts) != 2:
raise CLIError('custom headers format is incorrect')

headers[parts[0]] = parts[1]

# Due to SPN replication latency, we do a few retries here
max_retry = 30
retry_exception = Exception(None)
for _ in range(0, max_retry):
try:
return sdk_no_wait(no_wait, client.create_or_update,
resource_group_name=resource_group_name, resource_name=name, parameters=mc)
resource_group_name=resource_group_name,
resource_name=name,
parameters=mc,
custom_headers=headers)
except CloudError as ex:
retry_exception = ex
if 'not found in Active Directory tenant' in ex.message:
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open as open1
from setuptools import setup, find_packages

VERSION = "0.4.23"
VERSION = "0.4.24"
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down
8 changes: 4 additions & 4 deletions src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
],
"aks-preview": [
{
"downloadUrl": "https://azurecliaks.blob.core.windows.net/azure-cli-extension/aks_preview-0.4.23-py2.py3-none-any.whl",
"filename": "aks_preview-0.4.23-py2.py3-none-any.whl",
"downloadUrl": "https://azurecliaks.blob.core.windows.net/azure-cli-extension/aks_preview-0.4.24-py2.py3-none-any.whl",
"filename": "aks_preview-0.4.24-py2.py3-none-any.whl",
"metadata": {
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.0.49",
Expand Down Expand Up @@ -88,9 +88,9 @@
"metadata_version": "2.0",
"name": "aks-preview",
"summary": "Provides a preview for upcoming AKS features",
"version": "0.4.23"
"version": "0.4.24"
},
"sha256Digest": "14bdac2c162d9ac63aa53259601398407fa22f94f5c80c0172bb242591790630"
"sha256Digest": "93e70b30da3620975b52b5fe8ae8b97064ce8ba9922d4fbd33dcdaf68a2c861f"
}
],
"alias": [
Expand Down

0 comments on commit c9b33f4

Please sign in to comment.