From 828f9d3321effe01fbe74b754a9a1f61fab65f71 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Wed, 10 Mar 2021 13:25:37 -0800 Subject: [PATCH 01/31] Create pull.yml --- .github/pull.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/pull.yml diff --git a/.github/pull.yml b/.github/pull.yml new file mode 100644 index 00000000000..7201bb6d18b --- /dev/null +++ b/.github/pull.yml @@ -0,0 +1,12 @@ +version: "1" +rules: # Array of rules + - base: master # Required. Target branch + upstream: wei:master # Required. Must be in the same fork network. + mergeMethod: hardreset # Optional, one of [none, merge, squash, rebase, hardreset], Default: none. + mergeUnstable: false # Optional, merge pull request even when the mergeable_state is not clean. Default: false + - base: k8s-configuration + upstream: master # Required. Can be a branch in the same forked repo. + - base: k8s-extension/private-preview + upstream: master # Required. Can be a branch in the same forked repo. + - base: k8s-extension/public-preview + upstream: master # Required. Can be a branch in the same forked repo. From 1436bfc8859e33ea69b06e0b746cbd9ef5fe7825 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Wed, 10 Mar 2021 14:00:34 -0800 Subject: [PATCH 02/31] Update pull.yml --- .github/pull.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/pull.yml b/.github/pull.yml index 7201bb6d18b..8f65923a382 100644 --- a/.github/pull.yml +++ b/.github/pull.yml @@ -10,3 +10,5 @@ rules: # Array of rules upstream: master # Required. Can be a branch in the same forked repo. - base: k8s-extension/public-preview upstream: master # Required. Can be a branch in the same forked repo. + - base: release + upstream: master # Required. Can be a branch in the same forked repo. From 6cffd965b4061d66bad7e637a4a55bb93c9440d1 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Wed, 10 Mar 2021 14:15:10 -0800 Subject: [PATCH 03/31] Update azure-pipelines.yml --- azure-pipelines.yml | 405 ++++++++++++++++++++++++++++---------------- 1 file changed, 259 insertions(+), 146 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d43ef5102f0..77ff718d967 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,128 +1,157 @@ resources: -- repo: self + repositories: + - repository: K8sPartnerExtensionTest + type: git + endpoint: AzureReposConnection + name: One/compute-HybridMgmt-K8sPartnerExtensionTest trigger: batch: true branches: include: - - '*' - + - k8s-extension/public-preview + - k8s-extension/private-preview pr: branches: include: - - '*' - -jobs: -- job: CredScan - displayName: "Credential Scan" - pool: - vmImage: "windows-2019" - steps: - - task: ms-codeanalysis.vss-microsoft-security-code-analysis-devops.build-task-credscan.CredScan@2 - displayName: 'Run Credential Scanner' - inputs: - toolMajorVersion: V2 - suppressionsFile: './scripts/ci/credscan/CredScanSuppressions.json' - - task: ms-codeanalysis.vss-microsoft-security-code-analysis-devops.build-task-postanalysis.PostAnalysis@1 - displayName: 'Post Analysis' - inputs: - AllTools: false - BinSkim: false - CredScan: true - RoslynAnalyzers: false - TSLint: false - ToolLogsNotFoundAction: 'Standard' - -- job: CheckLicenseHeader - displayName: "Check License" - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.6' - inputs: - versionSpec: 3.6 - - bash: | - set -ev - - # prepare and activate virtualenv - python -m venv env/ - - chmod +x ./env/bin/activate - source ./env/bin/activate - - # clone azure-cli - git clone -q --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli - - pip install -q azdev - - azdev setup -c ../azure-cli -r ./ - - azdev --version - az --version - - azdev verify license - -- job: StaticAnalysis - displayName: "Static Analysis" - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.6' - inputs: - versionSpec: 3.6 - - bash: pip install wheel==0.30.0 pylint==1.9.5 flake8==3.5.0 requests - displayName: 'Install wheel, pylint, flake8, requests' - - bash: python scripts/ci/source_code_static_analysis.py - displayName: "Static Analysis" - -- job: IndexVerify - displayName: "Verify Extensions Index" - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.7' - inputs: - versionSpec: 3.7 - - bash: | - #!/usr/bin/env bash - set -ev - pip install wheel==0.30.0 requests packaging - export CI="ADO" - python ./scripts/ci/test_index.py -v - displayName: "Verify Extensions Index" + - k8s-extension/public-preview + - k8s-extension/private-preview -- job: SourceTests - displayName: "Integration Tests, Build Tests" - pool: - vmImage: 'ubuntu-16.04' - strategy: - matrix: - Python36: - python.version: '3.6' - Python38: - python.version: '3.8' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python $(python.version)' - inputs: - versionSpec: '$(python.version)' - - bash: pip install wheel==0.30.0 - displayName: 'Install wheel==0.30.0' - - bash: ./scripts/ci/test_source.sh - displayName: 'Run integration test and build test' - env: - ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) - ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) - -- job: LintModifiedExtensions - displayName: "CLI Linter on Modified Extensions" - condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) - pool: - vmImage: 'ubuntu-16.04' - steps: +stages: +- stage: K8sExtensionTestSuite + displayName: "K8s-Extension Test Suite" + variables: + K8S_EXTENSION_REPO_PATH: $(Agent.BuildDirectory)/s/compute-HybridMgmt-K8sPartnerExtensionTest + CLI_REPO_PATH: $(Agent.BuildDirectory)/s/azure-cli-extensions-pr + EXTENSION_NAME: "k8s-extension" + EXTENSION_FILE_NAME: "k8s_extension" + SUBSCRIPTION_ID: "15c06b1b-01d6-407b-bb21-740b8617dea3" + RESOURCE_GROUP: "K8sPartnerExtensionTest" + BASE_CLUSTER_NAME: "k8s-extension-cluster" + jobs: + - job: K8sExtensionTestSuite + displayName: "Run the Test Suite" + pool: + vmImage: 'ubuntu-16.04' + steps: + - checkout: self + - checkout: K8sPartnerExtensionTest + + - bash: | + echo "Installing helm3" + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + + echo "Installing kubectl" + curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" + chmod +x ./kubectl + sudo mv ./kubectl /usr/local/bin/kubectl + kubectl version --client + displayName: "Setup the VM with helm3 and kubectl" + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: | + set -ev + + # prepare and activate virtualenv + pip install virtualenv + python3 -m venv env/ + source env/bin/activate + + # clone azure-cli + pip install azdev + + ls $(CLI_REPO_PATH) + + azdev --version + azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME) + azdev extension build $(EXTENSION_NAME) + + workingDirectory: $(CLI_REPO_PATH) + displayName: "Setup and Build $(EXTENSION_NAME) with azdev" + + - bash: | + K8S_EXTENSION_VERSION=$(ls ${EXTENSION_FILE_NAME}* | cut -d "-" -f2) + echo "##vso[task.setvariable variable=K8S_EXTENSION_VERSION]$K8S_EXTENSION_VERSION" + cp * $(K8S_EXTENSION_REPO_PATH)/extensions + workingDirectory: $(CLI_REPO_PATH)/dist + displayName: "Copy the Built .whl to Extension Test Path" + + - bash: | + RAND_STR=$RANDOM + AKS_CLUSTER_NAME="${BASE_CLUSTER_NAME}-${RAND_STR}-aks" + ARC_CLUSTER_NAME="${BASE_CLUSTER_NAME}-${RAND_STR}-arc" + + JSON_STRING=$(jq -n \ + --arg SUB_ID "$SUBSCRIPTION_ID" \ + --arg RG "$RESOURCE_GROUP" \ + --arg AKS_CLUSTER_NAME "$AKS_CLUSTER_NAME" \ + --arg ARC_CLUSTER_NAME "$ARC_CLUSTER_NAME" \ + --arg K8S_EXTENSION_VERSION "$K8S_EXTENSION_VERSION" \ + '{subscriptionId: $SUB_ID, resourceGroup: $RG, aksClusterName: $AKS_CLUSTER_NAME, arcClusterName: $ARC_CLUSTER_NAME, extensionVersion: {"k8s-extension": $K8S_EXTENSION_VERSION, connectedk8s: "1.0.0"}}') + echo $JSON_STRING > settings.json + cat settings.json + workingDirectory: $(K8S_EXTENSION_REPO_PATH) + displayName: "Generate a settings.json file" + + - bash : | + echo "Downloading the kind script" + curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-linux-amd64 + chmod +x ./kind + ./kind create cluster + displayName: "Create and Start the Kind cluster" + + - task: AzureCLI@2 + displayName: Bootstrap + inputs: + azureSubscription: AzureResourceConnection + scriptType: pscore + scriptLocation: inlineScript + inlineScript: | + .\Bootstrap.ps1 -CI + workingDirectory: $(K8S_EXTENSION_REPO_PATH) + + - task: AzureCLI@2 + displayName: Run the Test Suite + inputs: + azureSubscription: AzureResourceConnection + scriptType: pscore + scriptLocation: inlineScript + inlineScript: | + .\Test.ps1 -CI + workingDirectory: $(K8S_EXTENSION_REPO_PATH) + continueOnError: true + + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: '**/TestResults.xml' + failTaskOnFailedTests: true + condition: succeededOrFailed() + + - task: AzureCLI@2 + displayName: Cleanup + inputs: + azureSubscription: AzureResourceConnection + scriptType: pscore + scriptLocation: inlineScript + inlineScript: | + .\Cleanup.ps1 -CI + workingDirectory: $(K8S_EXTENSION_REPO_PATH) + condition: succeededOrFailed() + +- stage: AzureCLIOfficial + displayName: "Azure Official CLI Code Checks" + dependsOn: [] + jobs: + - job: CheckLicenseHeader + displayName: "Check License" + pool: + vmImage: 'ubuntu-16.04' + steps: - task: UsePythonVersion@0 displayName: 'Use Python 3.6' inputs: @@ -131,41 +160,125 @@ jobs: set -ev # prepare and activate virtualenv - pip install virtualenv - python -m virtualenv venv/ - source ./venv/bin/activate + python -m venv env/ + + chmod +x ./env/bin/activate + source ./env/bin/activate # clone azure-cli - git clone --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli + git clone -q --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli - pip install azdev + pip install -q azdev + + azdev setup -c ../azure-cli -r ./ azdev --version + az --version - azdev setup -c ../azure-cli -r ./ + azdev verify license + + - job: StaticAnalysis + displayName: "Static Analysis" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: pip install wheel==0.30.0 pylint==1.9.5 flake8==3.5.0 requests + displayName: 'Install wheel, pylint, flake8, requests' + - bash: python scripts/ci/source_code_static_analysis.py + displayName: "Static Analysis" + + - job: IndexVerify + displayName: "Verify Extensions Index" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.7' + inputs: + versionSpec: 3.7 + - bash: | + #!/usr/bin/env bash + set -ev + pip install wheel==0.30.0 requests packaging + export CI="ADO" + python ./scripts/ci/test_index.py -v + displayName: "Verify Extensions Index" + + - job: SourceTests + displayName: "Integration Tests, Build Tests" + pool: + vmImage: 'ubuntu-16.04' + strategy: + matrix: + Python36: + python.version: '3.6' + Python38: + python.version: '3.8' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python $(python.version)' + inputs: + versionSpec: '$(python.version)' + - bash: pip install wheel==0.30.0 + displayName: 'Install wheel==0.30.0' + - bash: ./scripts/ci/test_source.sh + displayName: 'Run integration test and build test' + env: + ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) + ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) + + - job: LintModifiedExtensions + displayName: "CLI Linter on Modified Extensions" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: | + set -ev - # overwrite the default AZURE_EXTENSION_DIR set by ADO - AZURE_EXTENSION_DIR=~/.azure/cliextensions az --version - - AZURE_EXTENSION_DIR=~/.azure/cliextensions python scripts/ci/verify_linter.py - displayName: "CLI Linter on Modified Extension" - env: - ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) - ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) - -- job: IndexRefDocVerify - displayName: "Verify Ref Docs" - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.7' - inputs: - versionSpec: 3.7 - - bash: pip install wheel==0.30.0 - displayName: 'Install wheel==0.30.0' - - task: Bash@3 - displayName: "Verify Extension Ref Docs" - inputs: - targetType: 'filePath' - filePath: scripts/ci/test_index_ref_doc.sh + # prepare and activate virtualenv + pip install virtualenv + python -m virtualenv venv/ + source ./venv/bin/activate + + # clone azure-cli + git clone --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli + + pip install azdev + + azdev --version + + azdev setup -c ../azure-cli -r ./ -e k8s-extension + + # overwrite the default AZURE_EXTENSION_DIR set by ADO + AZURE_EXTENSION_DIR=~/.azure/cliextensions az --version + + AZURE_EXTENSION_DIR=~/.azure/cliextensions azdev linter --include-whl-extensions k8s-extension + displayName: "CLI Linter on Modified Extension" + env: + ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) + ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) + + - job: IndexRefDocVerify + displayName: "Verify Ref Docs" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.7' + inputs: + versionSpec: 3.7 + - bash: pip install wheel==0.30.0 + displayName: 'Install wheel==0.30.0' + - task: Bash@3 + displayName: "Verify Extension Ref Docs" + inputs: + targetType: 'filePath' + filePath: scripts/ci/test_index_ref_doc.sh From db0f4bd7b188c2aa1388ed9366994e5508061483 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Wed, 10 Mar 2021 14:19:45 -0800 Subject: [PATCH 04/31] Initial commit of k8s-extension --- src/k8s-extension/HISTORY.rst | 83 +++ src/k8s-extension/README.rst | 5 + .../azext_k8s_extension/__init__.py | 32 + .../azext_k8s_extension/_client_factory.py | 31 + .../azext_k8s_extension/_help.py | 38 ++ .../azext_k8s_extension/_params.py | 73 +++ .../azext_k8s_extension/_validators.py | 21 + .../azext_k8s_extension/action.py | 37 ++ .../azext_k8s_extension/azext_metadata.json | 4 + .../azext_k8s_extension/commands.py | 24 + .../azext_k8s_extension/custom.py | 275 ++++++++ .../partner_extensions/AzureDefender.py | 73 +++ .../partner_extensions/ContainerInsights.py | 460 ++++++++++++++ .../partner_extensions/DefaultExtension.py | 62 ++ .../partner_extensions/OpenServiceMesh.py | 95 +++ .../PartnerExtensionModel.py | 19 + .../partner_extensions/__init__.py | 0 .../azext_k8s_extension/tests/__init__.py | 5 + .../tests/latest/__init__.py | 5 + .../latest/recordings/test_k8s_extension.yaml | 270 ++++++++ .../latest/test_k8s_extension_scenario.py | 67 ++ .../vendored_sdks/__init__.py | 19 + .../vendored_sdks/_configuration.py | 49 ++ .../vendored_sdks/_k8s_extension_client.py | 50 ++ .../vendored_sdks/models/__init__.py | 70 +++ .../models/_k8s_extension_client_enums.py | 68 ++ .../vendored_sdks/models/_models.py | 587 ++++++++++++++++++ .../vendored_sdks/models/_models_py3.py | 587 ++++++++++++++++++ .../vendored_sdks/models/_paged_models.py | 40 ++ .../vendored_sdks/operations/__init__.py | 16 + .../operations/_k8s_extensions_operations.py | 452 ++++++++++++++ .../vendored_sdks/version.py | 13 + src/k8s-extension/setup.cfg | 2 + src/k8s-extension/setup.py | 58 ++ 34 files changed, 3690 insertions(+) create mode 100644 src/k8s-extension/HISTORY.rst create mode 100644 src/k8s-extension/README.rst create mode 100644 src/k8s-extension/azext_k8s_extension/__init__.py create mode 100644 src/k8s-extension/azext_k8s_extension/_client_factory.py create mode 100644 src/k8s-extension/azext_k8s_extension/_help.py create mode 100644 src/k8s-extension/azext_k8s_extension/_params.py create mode 100644 src/k8s-extension/azext_k8s_extension/_validators.py create mode 100644 src/k8s-extension/azext_k8s_extension/action.py create mode 100644 src/k8s-extension/azext_k8s_extension/azext_metadata.json create mode 100644 src/k8s-extension/azext_k8s_extension/commands.py create mode 100644 src/k8s-extension/azext_k8s_extension/custom.py create mode 100644 src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py create mode 100644 src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py create mode 100644 src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py create mode 100644 src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py create mode 100644 src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py create mode 100644 src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py create mode 100644 src/k8s-extension/azext_k8s_extension/tests/__init__.py create mode 100644 src/k8s-extension/azext_k8s_extension/tests/latest/__init__.py create mode 100644 src/k8s-extension/azext_k8s_extension/tests/latest/recordings/test_k8s_extension.yaml create mode 100644 src/k8s-extension/azext_k8s_extension/tests/latest/test_k8s_extension_scenario.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/__init__.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/_configuration.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/_k8s_extension_client.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/models/__init__.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_k8s_extension_client_enums.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_paged_models.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/__init__.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_k8s_extensions_operations.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/version.py create mode 100644 src/k8s-extension/setup.cfg create mode 100644 src/k8s-extension/setup.py diff --git a/src/k8s-extension/HISTORY.rst b/src/k8s-extension/HISTORY.rst new file mode 100644 index 00000000000..695f549b1a2 --- /dev/null +++ b/src/k8s-extension/HISTORY.rst @@ -0,0 +1,83 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++++++++++++++ +* Initial release. + +0.1.1 +++++++++++++++++++ +* Add support for microsoft-azure-defender extension type + +0.1.2 +++++++++++++++++++ + +* Add support for Arc Appliance cluster type + +0.1.3 +++++++++++++++++++ + +* Customization for microsoft.openservicemesh + +0.1PP.4 +++++++++++++++++++ + +* Refactor for clear separation of extension-type specific customizations +* Introduce new versioning scheme to allow Preview releases by Partners + +0.1PP.5 +++++++++++++++++++ + +* OpenServiceMesh customization. +* If Version is passed in, accept None for AutoUpgradeMinorVersion, and not require it to be False. + +0.1PP.6 +++++++++++++++++++ + +* OpenServiceMesh customization. +* Scope is always cluster. Version is mandatory for staging and pilot release-trains. + +0.1PP.7 +++++++++++++++++++ + +* Fix clusterType of Microsoft.ResourceConnector resource + +0.1PP.8 +++++++++++++++++++ + +* Update clusterType validation to allow 'appliances' +* Update identity creation to use the appropriate parent resource's type and api-version +* Throw error if cluster type is not one of the 3 supported types + +0.1PP.9 +++++++++++++++++++ + +* Rename azuremonitor-containers extension type to microsoft.azuremonitor.containers + +0.1PP.10 +++++++++++++++++++ + +* Add azuremonitor-containers back with alternative microsoft.azuremonitor.containers + +0.1PP.11 +++++++++++++++++++ + +* Add shorter aliases for long parameter names + +0.1PP.12 +++++++++++++++++++ + +* Remove support for azuremonitor-containers extension type naming + +0.1PP.13 +++++++++++++++++++ + +* Move CLI errors to non-deprecated error types +* Remove support for update + +0.1PP.14 +++++++++++++++++++ + +* Update help text, group CLI arguments diff --git a/src/k8s-extension/README.rst b/src/k8s-extension/README.rst new file mode 100644 index 00000000000..e91e1b13229 --- /dev/null +++ b/src/k8s-extension/README.rst @@ -0,0 +1,5 @@ +Microsoft Azure CLI 'k8s-extension' Extension +============================================= + +This package is for the 'k8s-extension' extension. +i.e. 'az k8s-extension' diff --git a/src/k8s-extension/azext_k8s_extension/__init__.py b/src/k8s-extension/azext_k8s_extension/__init__.py new file mode 100644 index 00000000000..e2301227d45 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/__init__.py @@ -0,0 +1,32 @@ +# -------------------------------------------------------------------------------------------- +# 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 import AzCommandsLoader + +from azext_k8s_extension._help import helps # pylint: disable=unused-import + + +class K8sExtensionCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_k8s_extension._client_factory import cf_k8s_extension + k8s_extension_custom = CliCommandType( + operations_tmpl='azext_k8s_extension.custom#{}', + client_factory=cf_k8s_extension) + super(K8sExtensionCommandsLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=k8s_extension_custom) + + def load_command_table(self, args): + from azext_k8s_extension.commands import load_command_table + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_k8s_extension._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = K8sExtensionCommandsLoader diff --git a/src/k8s-extension/azext_k8s_extension/_client_factory.py b/src/k8s-extension/azext_k8s_extension/_client_factory.py new file mode 100644 index 00000000000..a4ec83ee0cb --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/_client_factory.py @@ -0,0 +1,31 @@ +# -------------------------------------------------------------------------------------------- +# 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.client_factory import get_mgmt_service_client +from azure.cli.core.profiles import ResourceType + + +def cf_k8s_extension(cli_ctx, *_): + from azext_k8s_extension.vendored_sdks import K8sExtensionClient + return get_mgmt_service_client(cli_ctx, K8sExtensionClient) + + +def cf_k8s_extension_operation(cli_ctx, _): + return cf_k8s_extension(cli_ctx).k8s_extensions + + +def cf_resource_groups(cli_ctx, subscription_id=None): + return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, + subscription_id=subscription_id).resource_groups + + +def cf_resources(cli_ctx, subscription_id=None): + return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, + subscription_id=subscription_id).resources + + +def cf_log_analytics(cli_ctx, subscription_id=None): + from azure.mgmt.loganalytics import LogAnalyticsManagementClient # pylint: disable=no-name-in-module + return get_mgmt_service_client(cli_ctx, LogAnalyticsManagementClient, subscription_id=subscription_id) diff --git a/src/k8s-extension/azext_k8s_extension/_help.py b/src/k8s-extension/azext_k8s_extension/_help.py new file mode 100644 index 00000000000..69011bb9d92 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/_help.py @@ -0,0 +1,38 @@ +# 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. +# -------------------------------------------------------------------------------------------- + +from knack.help_files import helps # pylint: disable=unused-import + + +helps['k8s-extension'] = """ + type: group + short-summary: Commands to manage K8s-extensions. +""" + +helps['k8s-extension create'] = """ + type: command + short-summary: Create a K8s-extension. +""" + +helps['k8s-extension list'] = """ + type: command + short-summary: List K8s-extensions. +""" + +helps['k8s-extension delete'] = """ + type: command + short-summary: Delete a K8s-extension. +""" + +helps['k8s-extension show'] = """ + type: command + short-summary: Show details of a K8s-extension. +""" + +helps['k8s-extension update'] = """ + type: command + short-summary: Update a K8s-extension. +""" diff --git a/src/k8s-extension/azext_k8s_extension/_params.py b/src/k8s-extension/azext_k8s_extension/_params.py new file mode 100644 index 00000000000..0e870204887 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/_params.py @@ -0,0 +1,73 @@ +# -------------------------------------------------------------------------------------------- +# 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.parameters import ( + get_enum_type, + get_three_state_flag, + tags_type +) +from azure.cli.core.commands.validators import get_default_location_from_resource_group + +from azext_k8s_extension.action import ( + AddConfigurationSettings, + AddConfigurationProtectedSettings +) + + +def load_arguments(self, _): + with self.argument_context('k8s-extension') as c: + c.argument('tags', tags_type) + c.argument('location', + validator=get_default_location_from_resource_group) + c.argument('name', + options_list=['--name', '-n'], + help='Name of the extension instance') + c.argument('extension_type', + help='Name of the extension type.') + c.argument('cluster_name', + options_list=['--cluster-name', '-c'], + help='Name of the Kubernetes cluster') + c.argument('cluster_type', + arg_type=get_enum_type(['connectedClusters', 'managedClusters', 'appliances']), + help='Specify Arc clusters or AKS managed clusters or Arc appliances.') + c.argument('scope', + arg_type=get_enum_type(['cluster', 'namespace']), + help='Specify the extension scope.') + c.argument('auto_upgrade_minor_version', + arg_group="Version", + options_list=['--auto-upgrade-minor-version', '--auto-upgrade'], + arg_type=get_three_state_flag(), + help='Automatically upgrade minor version of the extension instance.') + c.argument('version', + arg_group="Version", + help='Specify the version to install for the extension instance if' + ' --auto-upgrade-minor-version is not enabled.') + c.argument('configuration_settings', + arg_group="Configuration", + options_list=['--configuration-settings', '--config'], + action=AddConfigurationSettings, + nargs='+', + help='Configuration Settings as key=value pair. Repeat parameter for each setting') + c.argument('configuration_protected_settings', + arg_group="Configuration", + options_list=['--configuration-protected-settings', '--config-protected'], + action=AddConfigurationProtectedSettings, + nargs='+', + help='Configuration Protected Settings as key=value pair. Repeat parameter for each setting') + c.argument('configuration_settings_file', + arg_group="Configuration", + options_list=['--configuration-settings-file', '--config-file'], + help='JSON file path for configuration-settings') + c.argument('configuration_protected_settings_file', + arg_group="Configuration", + options_list=['--configuration-protected-settings-file', '--config-protected-file'], + help='JSON file path for configuration-protected-settings') + c.argument('release_namespace', + help='Specify the namespace to install the extension release.') + c.argument('release_train', + help='Specify the release train for the extension type.') + c.argument('target_namespace', + help='Specify the target namespace to install to for the extension instance. This' + ' parameter is required if extension scope is set to \'namespace\'') diff --git a/src/k8s-extension/azext_k8s_extension/_validators.py b/src/k8s-extension/azext_k8s_extension/_validators.py new file mode 100644 index 00000000000..72270dab104 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/_validators.py @@ -0,0 +1,21 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def example_name_or_id_validator(cmd, namespace): + # Example of a storage account name or ID validator. + # See: https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#supporting-name-or-id-parameters # pylint: disable=line-too-long + + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + if namespace.storage_account: + if not is_valid_resource_id(namespace.RESOURCE): + namespace.storage_account = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=namespace.resource_group_name, + namespace='Microsoft.Storage', + type='storageAccounts', + name=namespace.storage_account + ) diff --git a/src/k8s-extension/azext_k8s_extension/action.py b/src/k8s-extension/azext_k8s_extension/action.py new file mode 100644 index 00000000000..4afbbbcd611 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/action.py @@ -0,0 +1,37 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import argparse +from azure.cli.core.azclierror import ArgumentUsageError + + +# pylint: disable=protected-access, too-few-public-methods +class AddConfigurationSettings(argparse._AppendAction): + + def __call__(self, parser, namespace, values, option_string=None): + settings = {} + for item in values: + try: + key, value = item.split('=', 1) + settings[key] = value + except ValueError: + raise ArgumentUsageError('Usage error: {} configuration_setting_key=configuration_setting_value'. + format(option_string)) + super(AddConfigurationSettings, self).__call__(parser, namespace, settings, option_string) + + +# pylint: disable=protected-access, too-few-public-methods +class AddConfigurationProtectedSettings(argparse._AppendAction): + + def __call__(self, parser, namespace, values, option_string=None): + prot_settings = {} + for item in values: + try: + key, value = item.split('=', 1) + prot_settings[key] = value + except ValueError: + raise ArgumentUsageError('Usage error: {} configuration_protected_setting_key=' + 'configuration_protected_setting_value'.format(option_string)) + super(AddConfigurationProtectedSettings, self).__call__(parser, namespace, prot_settings, option_string) diff --git a/src/k8s-extension/azext_k8s_extension/azext_metadata.json b/src/k8s-extension/azext_k8s_extension/azext_metadata.json new file mode 100644 index 00000000000..30fdaf614ee --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.15.0" +} \ No newline at end of file diff --git a/src/k8s-extension/azext_k8s_extension/commands.py b/src/k8s-extension/azext_k8s_extension/commands.py new file mode 100644 index 00000000000..63fe78f7d2a --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/commands.py @@ -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. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +from azure.cli.core.commands import CliCommandType +from azext_k8s_extension._client_factory import (cf_k8s_extension, cf_k8s_extension_operation) + + +def load_command_table(self, _): + + k8s_extension_sdk = CliCommandType( + operations_tmpl='azext_k8s_extension.vendored_sdks.operations#K8sExtensionsOperations.{}', + client_factory=cf_k8s_extension) + + with self.command_group('k8s-extension', k8s_extension_sdk, client_factory=cf_k8s_extension_operation, + is_preview=True) \ + as g: + g.custom_command('create', 'create_k8s_extension') + g.custom_command('update', 'update_k8s_extension') + g.custom_command('delete', 'delete_k8s_extension', confirmation=True) + g.custom_command('list', 'list_k8s_extension') + g.custom_show_command('show', 'show_k8s_extension') diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py new file mode 100644 index 00000000000..469b4059dee --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -0,0 +1,275 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=unused-argument,too-many-locals + +import json +from knack.log import get_logger + +from msrestazure.azure_exceptions import CloudError + +from azure.cli.core.azclierror import ResourceNotFoundError, MutuallyExclusiveArgumentError, \ + InvalidArgumentValueError, CommandNotFoundError +from azure.cli.core.commands.client_factory import get_subscription_id +from azext_k8s_extension.vendored_sdks.models import ConfigurationIdentity +# from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate +from azext_k8s_extension.vendored_sdks.models import ErrorResponseException + +from .partner_extensions.ContainerInsights import ContainerInsights +from .partner_extensions.AzureDefender import AzureDefender +from .partner_extensions.OpenServiceMesh import OpenServiceMesh +from .partner_extensions.DefaultExtension import DefaultExtension + +from ._client_factory import cf_resources + +logger = get_logger(__name__) + + +# A factory method to return the correct extension class based off of the extension name +def ExtensionFactory(extension_name): + extension_map = { + 'microsoft.azuremonitor.containers': ContainerInsights, + 'microsoft.azuredefender.kubernetes': AzureDefender, + 'microsoft.openservicemesh': OpenServiceMesh, + } + + # Return the extension if we find it in the map, else return the default + return extension_map.get(extension_name, DefaultExtension)() + + +def show_k8s_extension(client, resource_group_name, cluster_name, name, cluster_type): + """Get an existing K8s Extension. + + """ + # Determine ClusterRP + cluster_rp = __get_cluster_rp(cluster_type) + + try: + extension = client.get(resource_group_name, + cluster_rp, cluster_type, cluster_name, name) + return extension + except ErrorResponseException as ex: + # Customize the error message for resources not found + if ex.response.status_code == 404: + # If Cluster not found + if ex.message.__contains__("(ResourceNotFound)"): + message = "{0} Verify that the cluster-type is correct and the resource exists.".format( + ex.message) + # If Configuration not found + elif ex.message.__contains__("Operation returned an invalid status code 'Not Found'"): + message = "(ExtensionNotFound) The Resource {0}/{1}/{2}/Microsoft.KubernetesConfiguration/" \ + "extensions/{3} could not be found!".format( + cluster_rp, cluster_type, cluster_name, name) + else: + message = ex.message + raise ResourceNotFoundError(message) + + +def create_k8s_extension(cmd, client, resource_group_name, cluster_name, name, cluster_type, + extension_type, scope='cluster', auto_upgrade_minor_version=None, release_train=None, + version=None, target_namespace=None, release_namespace=None, configuration_settings=None, + configuration_protected_settings=None, configuration_settings_file=None, + configuration_protected_settings_file=None, tags=None): + """Create a new Extension Instance. + + """ + extension_type_lower = extension_type.lower() + + # Determine ClusterRP + cluster_rp = __get_cluster_rp(cluster_type) + + # Configuration Settings & Configuration Protected Settings + if configuration_settings is not None and configuration_settings_file is not None: + raise MutuallyExclusiveArgumentError( + 'Error! Both configuration-settings and configuration-settings-file cannot be provided.' + ) + + if configuration_protected_settings is not None and configuration_protected_settings_file is not None: + raise MutuallyExclusiveArgumentError( + 'Error! Both configuration-protected-settings and configuration-protected-settings-file ' + 'cannot be provided.' + ) + + config_settings = {} + config_protected_settings = {} + # Get Configuration Settings from file + if configuration_settings_file is not None: + config_settings = __get_config_settings_from_file(configuration_settings_file) + + if configuration_settings is not None: + for dicts in configuration_settings: + for key, value in dicts.items(): + config_settings[key] = value + + # Get Configuration Protected Settings from file + if configuration_protected_settings_file is not None: + config_protected_settings = __get_config_settings_from_file(configuration_protected_settings_file) + + if configuration_protected_settings is not None: + for dicts in configuration_protected_settings: + for key, value in dicts.items(): + config_protected_settings[key] = value + + # Identity is not created by default. Extension type must specify if identity is required. + create_identity = False + + extension_instance = None + + # Scope & Namespace validation - common to all extension-types + __validate_scope_and_namespace(scope, release_namespace, target_namespace) + + # Give Partners a chance to their extensionType specific validations and to set value over-rides. + + # Get the extension class based on the extension name + extension_class = ExtensionFactory(extension_type_lower) + extension_instance, name, create_identity = extension_class.Create( + cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type_lower, scope, + auto_upgrade_minor_version, release_train, version, target_namespace, release_namespace, config_settings, + config_protected_settings, configuration_settings_file, configuration_protected_settings_file) + + # Common validations + __validate_version_and_auto_upgrade(extension_instance.version, extension_instance.auto_upgrade_minor_version) + + # Create identity, if required + if create_identity: + extension_instance.identity, extension_instance.location = \ + __create_identity(cmd, resource_group_name, cluster_name, cluster_type, cluster_rp) + + # Try to create the resource + return client.create(resource_group_name, cluster_rp, cluster_type, cluster_name, name, extension_instance) + + +def list_k8s_extension(client, resource_group_name, cluster_name, cluster_type): + cluster_rp = __get_cluster_rp(cluster_type) + return client.list(resource_group_name, cluster_rp, cluster_type, cluster_name) + + +def update_k8s_extension(client, resource_group_name, cluster_type, cluster_name, name, + auto_upgrade_minor_version='', release_train='', version='', tags=None): + + """Patch an existing Extension Instance. + + """ + + # TODO: Remove this after we eventually get PATCH implemented for update and uncomment + raise CommandNotFoundError( + "\"k8s-extension update\" currently is not available. " + "Use \"k8s-extension create\" to update a previously created extension instance." + ) + + # # Ensure some values are provided for update + # if auto_upgrade_minor_version is None and release_train is None and version is None: + # message = "Error! No values provided for update. Provide new value(s) for one or more of these properties:" \ + # " auto-upgrade-minor-version, release-train or version." + # raise RequiredArgumentMissingError(message) + + # # Determine ClusterRP + # cluster_rp = __get_cluster_rp(cluster_type) + + # # Get the existing extensionInstance + # extension = client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name) + + # extension_type_lower = extension.extension_type.lower() + + # # Get the extension class based on the extension name + # extension_class = ExtensionFactory(extension_type_lower) + # upd_extension = extension_class.Update(extension, auto_upgrade_minor_version, release_train, version) + + # __validate_version_and_auto_upgrade(version, auto_upgrade_minor_version) + + # upd_extension = ExtensionInstanceUpdate(auto_upgrade_minor_version=auto_upgrade_minor_version, + # release_train=release_train, version=version) + + # return client.update(resource_group_name, cluster_rp, cluster_type, cluster_name, name, upd_extension) + + +def delete_k8s_extension(client, resource_group_name, cluster_name, name, cluster_type): + """Delete an existing Kubernetes Extension. + + """ + # Determine ClusterRP + cluster_rp = __get_cluster_rp(cluster_type) + + k8s_extension_instance_name = name + + return client.delete(resource_group_name, cluster_rp, cluster_type, cluster_name, k8s_extension_instance_name) + + +def __create_identity(cmd, resource_group_name, cluster_name, cluster_type, cluster_rp): + subscription_id = get_subscription_id(cmd.cli_ctx) + resources = cf_resources(cmd.cli_ctx, subscription_id) + + cluster_resource_id = '/subscriptions/{0}/resourceGroups/{1}/providers/{2}/{3}/{4}'.format(subscription_id, + resource_group_name, + cluster_rp, + cluster_type, + cluster_name) + + if cluster_rp == 'Microsoft.Kubernetes': + parent_api_version = '2020-01-01-preview' + elif cluster_rp == 'Microsoft.ResourceConnector': + parent_api_version = '2020-09-15-privatepreview' + elif cluster_rp == 'Microsoft.ContainerService': + parent_api_version = '2017-07-01' + else: + raise InvalidArgumentValueError( + "Error! Cluster type '{}' is not supported for extension identity".format(cluster_type) + ) + + try: + resource = resources.get_by_id(cluster_resource_id, parent_api_version) + location = str(resource.location.lower()) + except CloudError as ex: + raise ex + identity_type = "SystemAssigned" + + return ConfigurationIdentity(type=identity_type), location + + +def __get_cluster_rp(cluster_type): + rp = "" + if cluster_type.lower() == 'connectedclusters': + rp = 'Microsoft.Kubernetes' + elif cluster_type.lower() == 'appliances': + rp = 'Microsoft.ResourceConnector' + elif cluster_type.lower() == '': + rp = 'Microsoft.ContainerService' + else: + raise InvalidArgumentValueError("Error! Cluster type '{}' is not supported".format(cluster_type)) + return rp + + +def __validate_scope_and_namespace(scope, release_namespace, target_namespace): + if scope == 'cluster': + if target_namespace is not None: + message = "When Scope is 'cluster', target-namespace must not be given." + raise MutuallyExclusiveArgumentError(message) + else: + if release_namespace is not None: + message = "When Scope is 'namespace', release-namespace must not be given." + raise MutuallyExclusiveArgumentError(message) + + +def __validate_version_and_auto_upgrade(version, auto_upgrade_minor_version): + if version is not None: + if auto_upgrade_minor_version: + message = "To pin to specific version, auto-upgrade-minor-version must be set to 'false'." + raise MutuallyExclusiveArgumentError(message) + + auto_upgrade_minor_version = False + + +def __get_config_settings_from_file(file_path): + try: + config_file = open(file_path,) + settings = json.load(config_file) + except ValueError: + raise Exception("File {} is not a valid JSON file".format(file_path)) + + files = len(settings) + if files == 0: + raise Exception("File {} is empty".format(file_path)) + + return settings diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py new file mode 100644 index 00000000000..172662f4e57 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py @@ -0,0 +1,73 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=unused-argument + +from knack.log import get_logger + +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate +from azext_k8s_extension.vendored_sdks.models import ScopeCluster +from azext_k8s_extension.vendored_sdks.models import Scope + +from .PartnerExtensionModel import PartnerExtensionModel +from .ContainerInsights import _get_container_insights_settings + +logger = get_logger(__name__) + + +class AzureDefender(PartnerExtensionModel): + def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, + scope, auto_upgrade_minor_version, release_train, version, target_namespace, + release_namespace, configuration_settings, configuration_protected_settings, + configuration_settings_file, configuration_protected_settings_file): + + """ExtensionType 'microsoft.azuredefender.kubernetes' specific validations & defaults for Create + Must create and return a valid 'ExtensionInstanceForCreate' object. + + """ + # NOTE-1: Replace default scope creation with your customization! + ext_scope = None + # Hardcoding name, release_namespace and scope since ci only supports one instance and cluster scope + # and platform doesnt have support yet extension specific constraints like this + name = extension_type.lower() + release_namespace = "azuredefender" + # Scope is always cluster + scope_cluster = ScopeCluster(release_namespace=release_namespace) + ext_scope = Scope(cluster=scope_cluster, namespace=None) + + is_ci_extension_type = False + + logger.warning('Ignoring name, release-namespace and scope parameters since %s ' + 'only supports cluster scope and single instance of this extension', extension_type) + + _get_container_insights_settings(cmd, resource_group_name, cluster_name, configuration_settings, + configuration_protected_settings, is_ci_extension_type) + + # NOTE-2: Return a valid ExtensionInstanceForCreate object, Instance name and flag for Identity + create_identity = True + extension_instance = ExtensionInstanceForCreate( + extension_type=extension_type, + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version, + scope=ext_scope, + configuration_settings=configuration_settings, + configuration_protected_settings=configuration_protected_settings, + identity=None, + location="" + ) + return extension_instance, name, create_identity + + def Update(self, extension, auto_upgrade_minor_version, release_train, version): + """ExtensionType 'microsoft.azuredefender.kubernetes' specific validations & defaults for Update + Must create and return a valid 'ExtensionInstanceUpdate' object. + + """ + return ExtensionInstanceUpdate( + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version + ) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py new file mode 100644 index 00000000000..ada94d985a9 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py @@ -0,0 +1,460 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=unused-argument + +import datetime +import json + +from knack.log import get_logger + +from azure.cli.core.azclierror import InvalidArgumentValueError +from azure.cli.core.commands import LongRunningOperation +from azure.cli.core.commands.client_factory import get_mgmt_service_client, get_subscription_id +from azure.cli.core.util import sdk_no_wait +from msrestazure.azure_exceptions import CloudError +from msrestazure.tools import parse_resource_id, is_valid_resource_id + +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate +from azext_k8s_extension.vendored_sdks.models import ScopeCluster +from azext_k8s_extension.vendored_sdks.models import Scope + +from .PartnerExtensionModel import PartnerExtensionModel + +from .._client_factory import ( + cf_resources, cf_resource_groups, cf_log_analytics) + +logger = get_logger(__name__) + + +class ContainerInsights(PartnerExtensionModel): + def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, + scope, auto_upgrade_minor_version, release_train, version, target_namespace, + release_namespace, configuration_settings, configuration_protected_settings, + configuration_settings_file, configuration_protected_settings_file): + + """ExtensionType 'microsoft.azuremonitor.containers' specific validations & defaults for Create + Must create and return a valid 'ExtensionInstanceForCreate' object. + + """ + # NOTE-1: Replace default scope creation with your customization! + ext_scope = None + # Hardcoding name, release_namespace and scope since container-insights only supports one instance and cluster + # scope and platform doesnt have support yet extension specific constraints like this + name = 'azuremonitor-containers' + release_namespace = 'azuremonitor-containers' + # Scope is always cluster + scope_cluster = ScopeCluster(release_namespace=release_namespace) + ext_scope = Scope(cluster=scope_cluster, namespace=None) + + is_ci_extension_type = True + + logger.warning('Ignoring name, release-namespace and scope parameters since %s ' + 'only supports cluster scope and single instance of this extension', extension_type) + + _get_container_insights_settings(cmd, resource_group_name, cluster_name, configuration_settings, + configuration_protected_settings, is_ci_extension_type) + + # NOTE-2: Return a valid ExtensionInstanceForCreate object, Instance name and flag for Identity + create_identity = True + extension_instance = ExtensionInstanceForCreate( + extension_type=extension_type, + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version, + scope=ext_scope, + configuration_settings=configuration_settings, + configuration_protected_settings=configuration_protected_settings, + identity=None, + location="" + ) + return extension_instance, name, create_identity + + def Update(self, extension, auto_upgrade_minor_version, release_train, version): + """ExtensionType 'microsoft.azuremonitor.containers' specific validations & defaults for Update + Must create and return a valid 'ExtensionInstanceUpdate' object. + + """ + return ExtensionInstanceUpdate( + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version + ) + + +# Custom Validation Logic for Container Insights + +def _invoke_deployment(cmd, resource_group_name, deployment_name, template, parameters, validate, no_wait, + subscription_id=None): + from azure.cli.core.profiles import ResourceType + deployment_properties = cmd.get_models('DeploymentProperties', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) + properties = deployment_properties(template=template, parameters=parameters, mode='incremental') + smc = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, + subscription_id=subscription_id).deployments + if validate: + logger.info('==== BEGIN TEMPLATE ====') + logger.info(json.dumps(template, indent=2)) + logger.info('==== END TEMPLATE ====') + + if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES): + deployment_temp = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) + deployment = deployment_temp(properties=properties) + + if validate: + validation_poller = smc.validate(resource_group_name, deployment_name, deployment) + return LongRunningOperation(cmd.cli_ctx)(validation_poller) + return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, deployment) + + if validate: + return smc.validate(resource_group_name, deployment_name, properties) + return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, properties) + + +def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id, + cluster_resource_group_name, cluster_name): + # mapping for azure public cloud + # log analytics workspaces cannot be created in WCUS region due to capacity limits + # so mapped to EUS per discussion with log analytics team + # pylint: disable=too-many-locals,too-many-statements + + azurecloud_location_to_oms_region_code_map = { + "australiasoutheast": "ASE", + "australiaeast": "EAU", + "australiacentral": "CAU", + "canadacentral": "CCA", + "centralindia": "CIN", + "centralus": "CUS", + "eastasia": "EA", + "eastus": "EUS", + "eastus2": "EUS2", + "eastus2euap": "EAP", + "francecentral": "PAR", + "japaneast": "EJP", + "koreacentral": "SE", + "northeurope": "NEU", + "southcentralus": "SCUS", + "southeastasia": "SEA", + "uksouth": "SUK", + "usgovvirginia": "USGV", + "westcentralus": "EUS", + "westeurope": "WEU", + "westus": "WUS", + "westus2": "WUS2" + } + azurecloud_region_to_oms_region_map = { + "australiacentral": "australiacentral", + "australiacentral2": "australiacentral", + "australiaeast": "australiaeast", + "australiasoutheast": "australiasoutheast", + "brazilsouth": "southcentralus", + "canadacentral": "canadacentral", + "canadaeast": "canadacentral", + "centralus": "centralus", + "centralindia": "centralindia", + "eastasia": "eastasia", + "eastus": "eastus", + "eastus2": "eastus2", + "francecentral": "francecentral", + "francesouth": "francecentral", + "japaneast": "japaneast", + "japanwest": "japaneast", + "koreacentral": "koreacentral", + "koreasouth": "koreacentral", + "northcentralus": "eastus", + "northeurope": "northeurope", + "southafricanorth": "westeurope", + "southafricawest": "westeurope", + "southcentralus": "southcentralus", + "southeastasia": "southeastasia", + "southindia": "centralindia", + "uksouth": "uksouth", + "ukwest": "uksouth", + "westcentralus": "eastus", + "westeurope": "westeurope", + "westindia": "centralindia", + "westus": "westus", + "westus2": "westus2" + } + + # mapping for azure china cloud + # currently log analytics supported only China East 2 region + azurechina_location_to_oms_region_code_map = { + "chinaeast": "EAST2", + "chinaeast2": "EAST2", + "chinanorth": "EAST2", + "chinanorth2": "EAST2" + } + azurechina_region_to_oms_region_map = { + "chinaeast": "chinaeast2", + "chinaeast2": "chinaeast2", + "chinanorth": "chinaeast2", + "chinanorth2": "chinaeast2" + } + + # mapping for azure us governmner cloud + azurefairfax_location_to_oms_region_code_map = { + "usgovvirginia": "USGV" + } + azurefairfax_region_to_oms_region_map = { + "usgovvirginia": "usgovvirginia" + } + + cluster_location = '' + resources = cf_resources(cmd.cli_ctx, subscription_id) + + cluster_resource_id = '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Kubernetes' \ + '/connectedClusters/{2}'.format(subscription_id, cluster_resource_group_name, cluster_name) + try: + resource = resources.get_by_id(cluster_resource_id, '2020-01-01-preview') + cluster_location = resource.location.lower() + except CloudError as ex: + raise ex + + cloud_name = cmd.cli_ctx.cloud.name.lower() + workspace_region = "eastus" + workspace_region_code = "EUS" + + # sanity check that locations and clouds match. + if ((cloud_name == 'azurecloud' and azurechina_region_to_oms_region_map.get(cluster_location, False)) or + (cloud_name == 'azurecloud' and azurefairfax_region_to_oms_region_map.get(cluster_location, False))): + raise InvalidArgumentValueError( + 'Wrong cloud (azurecloud) setting for region {}, please use "az cloud set ..."' + .format(cluster_location) + ) + + if ((cloud_name == 'azurechinacloud' and azurecloud_region_to_oms_region_map.get(cluster_location, False)) or + (cloud_name == 'azurechinacloud' and azurefairfax_region_to_oms_region_map.get(cluster_location, False))): + raise InvalidArgumentValueError( + 'Wrong cloud (azurechinacloud) setting for region {}, please use "az cloud set ..."' + .format(cluster_location) + ) + + if ((cloud_name == 'azureusgovernment' and azurecloud_region_to_oms_region_map.get(cluster_location, False)) or + (cloud_name == 'azureusgovernment' and azurechina_region_to_oms_region_map.get(cluster_location, False))): + raise InvalidArgumentValueError( + 'Wrong cloud (azureusgovernment) setting for region {}, please use "az cloud set ..."' + .format(cluster_location) + ) + + if cloud_name == 'azurecloud': + workspace_region = azurecloud_region_to_oms_region_map.get(cluster_location, "eastus") + workspace_region_code = azurecloud_location_to_oms_region_code_map.get(workspace_region, "EUS") + elif cloud_name == 'azurechinacloud': + workspace_region = azurechina_region_to_oms_region_map.get(cluster_location, "chinaeast2") + workspace_region_code = azurechina_location_to_oms_region_code_map.get(workspace_region, "EAST2") + elif cloud_name == 'azureusgovernment': + workspace_region = azurefairfax_region_to_oms_region_map.get(cluster_location, "usgovvirginia") + workspace_region_code = azurefairfax_location_to_oms_region_code_map.get(workspace_region, "USGV") + else: + logger.error("AKS Monitoring addon not supported in cloud : %s", cloud_name) + + default_workspace_resource_group = 'DefaultResourceGroup-' + workspace_region_code + default_workspace_name = 'DefaultWorkspace-{0}-{1}'.format(subscription_id, workspace_region_code) + default_workspace_resource_id = '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.OperationalInsights' \ + '/workspaces/{2}'.format(subscription_id, default_workspace_resource_group, default_workspace_name) + resource_groups = cf_resource_groups(cmd.cli_ctx, subscription_id) + + # check if default RG exists + if resource_groups.check_existence(default_workspace_resource_group): + try: + resource = resources.get_by_id(default_workspace_resource_id, '2015-11-01-preview') + return resource.id + except CloudError as ex: + if ex.status_code != 404: + raise ex + else: + resource_groups.create_or_update(default_workspace_resource_group, { + 'location': workspace_region}) + + default_workspace_params = { + 'location': workspace_region, + 'properties': { + 'sku': { + 'name': 'standalone' + } + } + } + async_poller = resources.create_or_update_by_id(default_workspace_resource_id, '2015-11-01-preview', + default_workspace_params) + + ws_resource_id = '' + while True: + result = async_poller.result(15) + if async_poller.done(): + ws_resource_id = result.id + break + + return ws_resource_id + + +def _ensure_container_insights_for_monitoring(cmd, workspace_resource_id): + # extract subscription ID and resource group from workspace_resource_id URL + parsed = parse_resource_id(workspace_resource_id) + subscription_id, resource_group = parsed["subscription"], parsed["resource_group"] + + resources = cf_resources(cmd.cli_ctx, subscription_id) + try: + resource = resources.get_by_id(workspace_resource_id, '2015-11-01-preview') + location = resource.location + except CloudError as ex: + raise ex + + unix_time_in_millis = int( + (datetime.datetime.utcnow() - datetime.datetime.utcfromtimestamp(0)).total_seconds() * 1000.0) + + solution_deployment_name = 'ContainerInsights-{}'.format(unix_time_in_millis) + + # pylint: disable=line-too-long + template = { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "workspaceResourceId": { + "type": "string", + "metadata": { + "description": "Azure Monitor Log Analytics Resource ID" + } + }, + "workspaceRegion": { + "type": "string", + "metadata": { + "description": "Azure Monitor Log Analytics workspace region" + } + }, + "solutionDeploymentName": { + "type": "string", + "metadata": { + "description": "Name of the solution deployment" + } + } + }, + "resources": [ + { + "type": "Microsoft.Resources/deployments", + "name": "[parameters('solutionDeploymentName')]", + "apiVersion": "2017-05-10", + "subscriptionId": "[split(parameters('workspaceResourceId'),'/')[2]]", + "resourceGroup": "[split(parameters('workspaceResourceId'),'/')[4]]", + "properties": { + "mode": "Incremental", + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": {}, + "variables": {}, + "resources": [ + { + "apiVersion": "2015-11-01-preview", + "type": "Microsoft.OperationsManagement/solutions", + "location": "[parameters('workspaceRegion')]", + "name": "[Concat('ContainerInsights', '(', split(parameters('workspaceResourceId'),'/')" + "[8], ')')]", + "properties": { + "workspaceResourceId": "[parameters('workspaceResourceId')]" + }, + "plan": { + "name": "[Concat('ContainerInsights', '(', split(parameters('workspaceResourceId')," + "'/')[8], ')')]", + "product": "[Concat('OMSGallery/', 'ContainerInsights')]", + "promotionCode": "", + "publisher": "Microsoft" + } + } + ] + }, + "parameters": {} + } + } + ] + } + + params = { + "workspaceResourceId": { + "value": workspace_resource_id + }, + "workspaceRegion": { + "value": location + }, + "solutionDeploymentName": { + "value": solution_deployment_name + } + } + + deployment_name = 'arc-k8s-monitoring-{}'.format(unix_time_in_millis) + # publish the Container Insights solution to the Log Analytics workspace + return _invoke_deployment(cmd, resource_group, deployment_name, template, params, + validate=False, no_wait=False, subscription_id=subscription_id) + + +def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_name, configuration_settings, + configuration_protected_settings, is_ci_extension_type): + + subscription_id = get_subscription_id(cmd.cli_ctx) + workspace_resource_id = '' + + if configuration_settings is not None: + if 'loganalyticsworkspaceresourceid' in configuration_settings: + configuration_settings['logAnalyticsWorkspaceResourceID'] = \ + configuration_settings.pop('loganalyticsworkspaceresourceid') + + if 'logAnalyticsWorkspaceResourceID' in configuration_settings: + workspace_resource_id = configuration_settings['logAnalyticsWorkspaceResourceID'] + + workspace_resource_id = workspace_resource_id.strip() + + if configuration_protected_settings is not None: + if 'proxyEndpoint' in configuration_protected_settings: + # current supported format for proxy endpoint is http(s)://:@: + # do some basic validation since the ci agent does the complete validation + proxy = configuration_protected_settings['proxyEndpoint'].strip().lower() + proxy_parts = proxy.split('://') + if (not proxy) or (not proxy.startswith('http://') and not proxy.startswith('https://')) or \ + (len(proxy_parts) != 2): + raise InvalidArgumentValueError( + 'proxyEndpoint url should in this format http(s)://:@:' + ) + logger.info("successfully validated proxyEndpoint url hence passing proxy endpoint to extension") + configuration_protected_settings['omsagent.proxy'] = configuration_protected_settings['proxyEndpoint'] + + if not workspace_resource_id: + workspace_resource_id = _ensure_default_log_analytics_workspace_for_monitoring( + cmd, subscription_id, cluster_resource_group_name, cluster_name) + else: + if not is_valid_resource_id(workspace_resource_id): + raise InvalidArgumentValueError('{} is not a valid Azure resource ID.'.format(workspace_resource_id)) + + if is_ci_extension_type: + _ensure_container_insights_for_monitoring(cmd, workspace_resource_id).result() + + # extract subscription ID and resource group from workspace_resource_id URL + parsed = parse_resource_id(workspace_resource_id) + workspace_sub_id, workspace_rg_name, workspace_name = \ + parsed["subscription"], parsed["resource_group"], parsed["name"] + + log_analytics_client = cf_log_analytics(cmd.cli_ctx, workspace_sub_id) + log_analytics_workspace = log_analytics_client.workspaces.get(workspace_rg_name, workspace_name) + if not log_analytics_workspace: + raise InvalidArgumentValueError( + 'Fails to retrieve workspace by {}'.format(workspace_name)) + + shared_keys = log_analytics_client.shared_keys.get_shared_keys( + workspace_rg_name, workspace_name) + if not shared_keys: + raise InvalidArgumentValueError('Fails to retrieve shared key for workspace {}'.format( + log_analytics_workspace)) + configuration_protected_settings['omsagent.secret.wsid'] = log_analytics_workspace.customer_id + configuration_settings['logAnalyticsWorkspaceResourceID'] = workspace_resource_id + configuration_protected_settings['omsagent.secret.key'] = shared_keys.primary_shared_key + # set the domain for the ci agent for non azure public clouds + cloud_name = cmd.cli_ctx.cloud.name + if cloud_name.lower() == 'azurechinacloud': + configuration_settings['omsagent.domain'] = 'opinsights.azure.cn' + elif cloud_name.lower() == 'azureusgovernment': + configuration_settings['omsagent.domain'] = 'opinsights.azure.us' + elif cloud_name.lower() == 'usnat': + configuration_settings['omsagent.domain'] = 'opinsights.azure.eaglex.ic.gov' + elif cloud_name.lower() == 'ussec': + configuration_settings['omsagent.domain'] = 'opinsights.azure.microsoft.scloud' diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py new file mode 100644 index 00000000000..243371e47b7 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py @@ -0,0 +1,62 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=unused-argument + +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate +from azext_k8s_extension.vendored_sdks.models import ScopeCluster +from azext_k8s_extension.vendored_sdks.models import ScopeNamespace +from azext_k8s_extension.vendored_sdks.models import Scope + +from .PartnerExtensionModel import PartnerExtensionModel + + +class DefaultExtension(PartnerExtensionModel): + def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, + scope, auto_upgrade_minor_version, release_train, version, target_namespace, + release_namespace, configuration_settings, configuration_protected_settings, + configuration_settings_file, configuration_protected_settings_file): + + """Default validations & defaults for Create + Must create and return a valid 'ExtensionInstanceForCreate' object. + + """ + ext_scope = None + if scope is None or scope.lower() == 'cluster': + scope_cluster = ScopeCluster(release_namespace=release_namespace) + ext_scope = Scope(cluster=scope_cluster, namespace=None) + else: + scope_namespace = ScopeNamespace(target_namespace=target_namespace) + ext_scope = Scope(namespace=scope_namespace, cluster=None) + + # If release-train is not input, set it to 'stable' + if release_train is None: + release_train = 'stable' + + create_identity = False + extension_instance = ExtensionInstanceForCreate( + extension_type=extension_type, + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version, + scope=ext_scope, + configuration_settings=configuration_settings, + configuration_protected_settings=configuration_protected_settings, + identity=None, + location="" + ) + return extension_instance, name, create_identity + + def Update(self, extension, auto_upgrade_minor_version, release_train, version): + """Default validations & defaults for Update + Must create and return a valid 'ExtensionInstanceUpdate' object. + + """ + return ExtensionInstanceUpdate( + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version + ) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py new file mode 100644 index 00000000000..b9e530877dc --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py @@ -0,0 +1,95 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=unused-argument + +from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError +from knack.log import get_logger + +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate +from azext_k8s_extension.vendored_sdks.models import ScopeCluster +from azext_k8s_extension.vendored_sdks.models import Scope + +from .PartnerExtensionModel import PartnerExtensionModel + +logger = get_logger(__name__) + + +class OpenServiceMesh(PartnerExtensionModel): + def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, + scope, auto_upgrade_minor_version, release_train, version, target_namespace, + release_namespace, configuration_settings, configuration_protected_settings, + configuration_settings_file, configuration_protected_settings_file): + + """ExtensionType 'microsoft.openservicemesh' specific validations & defaults for Create + Must create and return a valid 'ExtensionInstanceForCreate' object. + + """ + # NOTE-1: Replace default scope creation with your customization, if required + # Scope must always be cluster + ext_scope = None + if scope == 'namespace': + raise InvalidArgumentValueError("Invalid scope '{}'. This extension can be installed " + "only at 'cluster' scope.".format(scope)) + + scope_cluster = ScopeCluster(release_namespace=release_namespace) + ext_scope = Scope(cluster=scope_cluster, namespace=None) + + valid_release_trains = ['staging', 'pilot'] + # If release-train is not input, set it to 'stable' + if release_train is None: + raise RequiredArgumentMissingError( + "A release-train must be provided. Valid values are 'staging', 'pilot'." + ) + + if release_train.lower() in valid_release_trains: + # version is a mandatory if release-train is staging or pilot + if version is None: + raise RequiredArgumentMissingError( + "A version must be provided for release-train {}.".format(release_train) + ) + # If the release-train is 'staging' or 'pilot' then auto-upgrade-minor-version MUST be set to False + if auto_upgrade_minor_version or auto_upgrade_minor_version is None: + auto_upgrade_minor_version = False + logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train) + else: + raise InvalidArgumentValueError( + "Invalid release-train '{}'. Valid values are 'staging', 'pilot'.".format(release_train) + ) + + # NOTE-2: Return a valid ExtensionInstanceForCreate object, Instance name and flag for Identity + create_identity = False + extension_instance = ExtensionInstanceForCreate( + extension_type=extension_type, + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version, + scope=ext_scope, + configuration_settings=configuration_settings, + configuration_protected_settings=configuration_protected_settings, + identity=None, + location="" + ) + return extension_instance, name, create_identity + + def Update(self, extension, auto_upgrade_minor_version, release_train, version): + """ExtensionType 'microsoft.openservicemesh' specific validations & defaults for Update + Must create and return a valid 'ExtensionInstanceUpdate' object. + + """ + # auto-upgrade-minor-version MUST be set to False if release_train is staging or pilot + if release_train.lower() in 'staging' 'pilot': + if auto_upgrade_minor_version or auto_upgrade_minor_version is None: + auto_upgrade_minor_version = False + # Set version to None to always get the latest version - user cannot override + version = None + logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train) + + return ExtensionInstanceUpdate( + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version + ) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py new file mode 100644 index 00000000000..c863a8d3833 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from abc import ABC, abstractmethod + + +class PartnerExtensionModel(ABC): + @abstractmethod + def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, + scope, auto_upgrade_minor_version, release_train, version, target_namespace, + release_namespace, configuration_settings, configuration_protected_settings, + configuration_settings_file, configuration_protected_settings_file): + pass + + @abstractmethod + def Update(self, extension, auto_upgrade_minor_version, release_train, version): + pass diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/k8s-extension/azext_k8s_extension/tests/__init__.py b/src/k8s-extension/azext_k8s_extension/tests/__init__.py new file mode 100644 index 00000000000..99c0f28cd71 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/tests/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- diff --git a/src/k8s-extension/azext_k8s_extension/tests/latest/__init__.py b/src/k8s-extension/azext_k8s_extension/tests/latest/__init__.py new file mode 100644 index 00000000000..99c0f28cd71 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/tests/latest/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- diff --git a/src/k8s-extension/azext_k8s_extension/tests/latest/recordings/test_k8s_extension.yaml b/src/k8s-extension/azext_k8s_extension/tests/latest/recordings/test_k8s_extension.yaml new file mode 100644 index 00000000000..127b21ac873 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/tests/latest/recordings/test_k8s_extension.yaml @@ -0,0 +1,270 @@ +interactions: +- request: + body: '{"properties": {"extensionType": "microsoft.openservicemesh", "autoUpgradeMinorVersion": + false, "releaseTrain": "staging", "version": "0.1.0", "scope": {"cluster": {}}, + "configurationSettings": {}, "configurationProtectedSettings": {}}, "location": + ""}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - k8s-extension create + Connection: + - keep-alive + Content-Length: + - '252' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n -c --cluster-type --extension-type --release-train --version + User-Agent: + - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 + azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh?api-version=2020-07-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh","name":"openservice-mesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"configurationSettings":{},"statuses":[],"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"staging","version":"0.1.0","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-03-08T23:14:12.4010326+00:00","lastModifiedTime":"2021-03-08T23:14:12.4010327+00:00"}}' + headers: + api-supported-versions: + - 2020-07-01-Preview + cache-control: + - no-cache + content-length: + - '708' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 08 Mar 2021 23:14:11 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - openresty/1.15.8.2 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - k8s-extension list + Connection: + - keep-alive + ParameterSetName: + - -c -g --cluster-type + User-Agent: + - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 + azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions?api-version=2020-07-01-preview + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh","name":"openservice-mesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"staging","version":"0.1.0","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-03-08T23:14:12.4010326+00:00","lastModifiedTime":"2021-03-08T23:14:12.4010327+00:00"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/hci22jan21","name":"hci22jan21","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"extensionType":"microsoft.azstackhci.operator","autoUpgradeMinorVersion":true,"releaseTrain":"stable","version":"1.0.0","scope":{"cluster":{"releaseNamespace":null}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-01-22T20:49:34.3336157+00:00","lastModifiedTime":"2021-01-22T20:49:34.3336249+00:00"}}],"nextLink":null}' + headers: + api-supported-versions: + - 2020-07-01-Preview + cache-control: + - no-cache + content-length: + - '1341' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 08 Mar 2021 23:14:13 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - openresty/1.15.8.2 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - k8s-extension show + Connection: + - keep-alive + ParameterSetName: + - -c -g -n --cluster-type + User-Agent: + - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 + azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh?api-version=2020-07-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh","name":"openservice-mesh","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"configurationSettings":{},"statuses":[],"extensionType":"microsoft.openservicemesh","autoUpgradeMinorVersion":false,"releaseTrain":"staging","version":"0.1.0","scope":{"cluster":{"releaseNamespace":"arc-osm-system"}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-03-08T23:14:12.4010326+00:00","lastModifiedTime":"2021-03-08T23:14:12.4010327+00:00"}}' + headers: + api-supported-versions: + - 2020-07-01-Preview + cache-control: + - no-cache + content-length: + - '708' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 08 Mar 2021 23:14:14 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - openresty/1.15.8.2 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - k8s-extension delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -c -n --cluster-type -y + User-Agent: + - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 + azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + accept-language: + - en-US + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/openservice-mesh?api-version=2020-07-01-preview + response: + body: + string: '{"content":null,"statusCode":200,"headers":[],"version":"1.1","reasonPhrase":"OK","trailingHeaders":[],"requestMessage":null,"isSuccessStatusCode":true}' + headers: + api-supported-versions: + - 2020-07-01-Preview + cache-control: + - no-cache + content-length: + - '152' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 08 Mar 2021 23:14:14 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - openresty/1.15.8.2 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - k8s-extension list + Connection: + - keep-alive + ParameterSetName: + - -c -g --cluster-type + User-Agent: + - python/3.9.0 (Windows-10-10.0.19041-SP0) msrest/0.6.21 msrest_azure/0.6.4 + azure-mgmt-kubernetesconfiguration/0.1.0 Azure-SDK-For-Python AZURECLI/2.19.1 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions?api-version=2020-07-01-preview + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nanthirg0923/providers/Microsoft.Kubernetes/connectedClusters/nanthicluster0923/providers/Microsoft.KubernetesConfiguration/extensions/hci22jan21","name":"hci22jan21","type":"Microsoft.KubernetesConfiguration/extensions","properties":{"extensionType":"microsoft.azstackhci.operator","autoUpgradeMinorVersion":true,"releaseTrain":"stable","version":"1.0.0","scope":{"cluster":{"releaseNamespace":null}},"installState":"Pending","lastStatusTime":null,"errorInfo":{},"creationTime":"2021-01-22T20:49:34.3336157+00:00","lastModifiedTime":"2021-01-22T20:49:34.3336249+00:00"}}],"nextLink":null}' + headers: + api-supported-versions: + - 2020-07-01-Preview + cache-control: + - no-cache + content-length: + - '673' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 08 Mar 2021 23:14:16 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - openresty/1.15.8.2 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/k8s-extension/azext_k8s_extension/tests/latest/test_k8s_extension_scenario.py b/src/k8s-extension/azext_k8s_extension/tests/latest/test_k8s_extension_scenario.py new file mode 100644 index 00000000000..0e53c9e6691 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/tests/latest/test_k8s_extension_scenario.py @@ -0,0 +1,67 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +import unittest + +from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, record_only) + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +class K8sExtensionScenarioTest(ScenarioTest): + @record_only() + @ResourceGroupPreparer(name_prefix='cli_test_k8s_extension') + def test_k8s_extension(self): + resource_type = 'microsoft.openservicemesh' + self.kwargs.update({ + 'name': 'openservice-mesh', + 'rg': 'nanthirg0923', + 'cluster_name': 'nanthicluster0923', + 'cluster_type': 'connectedClusters', + 'extension_type': resource_type, + 'release_train': 'staging', + 'version': '0.1.0' + }) + + self.cmd('k8s-extension create -g {rg} -n {name} -c {cluster_name} --cluster-type {cluster_type} --extension-type {extension_type} --release-train {release_train} --version {version}', checks=[ + self.check('name', '{name}'), + self.check('releaseTrain', '{release_train}'), + self.check('version', '{version}'), + self.check('resourceGroup', '{rg}'), + self.check('extensionType', '{extension_type}') + ]) + + # Update is disabled for now + # self.cmd('k8s-extension update -g {rg} -n {name} --tags foo=boo', checks=[ + # self.check('tags.foo', 'boo') + # ]) + + installed_exts = self.cmd('k8s-extension list -c {cluster_name} -g {rg} --cluster-type {cluster_type}').get_output_in_json() + found_extension = False + for item in installed_exts: + if item['extensionType'] == resource_type: + found_extension = True + break + self.assertTrue(found_extension) + + self.cmd('k8s-extension show -c {cluster_name} -g {rg} -n {name} --cluster-type {cluster_type}', checks=[ + self.check('name', '{name}'), + self.check('releaseTrain', '{release_train}'), + self.check('version', '{version}'), + self.check('resourceGroup', '{rg}'), + self.check('extensionType', '{extension_type}') + ]) + + self.cmd('k8s-extension delete -g {rg} -c {cluster_name} -n {name} --cluster-type {cluster_type} -y') + + installed_exts = self.cmd('k8s-extension list -c {cluster_name} -g {rg} --cluster-type {cluster_type}').get_output_in_json() + found_extension = False + for item in installed_exts: + if item['extensionType'] == resource_type: + found_extension = True + break + self.assertFalse(found_extension) diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/__init__.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/__init__.py new file mode 100644 index 00000000000..d94dccac4c2 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/__init__.py @@ -0,0 +1,19 @@ +# 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. +# -------------------------------------------------------------------------- + +from ._configuration import K8sExtensionClientConfiguration +from ._k8s_extension_client import K8sExtensionClient +__all__ = ['K8sExtensionClient', 'K8sExtensionClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/_configuration.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/_configuration.py new file mode 100644 index 00000000000..48080b2ee7d --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/_configuration.py @@ -0,0 +1,49 @@ +# 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. +# -------------------------------------------------------------------------- +from msrestazure import AzureConfiguration + +from .version import VERSION + + +class K8sExtensionClientConfiguration(AzureConfiguration): + """Configuration for K8sExtensionClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The Azure subscription ID. This is a + GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(K8sExtensionClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-mgmt-kubernetesconfiguration/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/_k8s_extension_client.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/_k8s_extension_client.py new file mode 100644 index 00000000000..1b63ebfd1ac --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/_k8s_extension_client.py @@ -0,0 +1,50 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import K8sExtensionClientConfiguration +from .operations import K8sExtensionsOperations +from . import models + + +class K8sExtensionClient(SDKClient): + """K8sExtension Client + + :ivar config: Configuration for client. + :vartype config: K8sExtensionClientConfiguration + + :ivar k8s_extensions: K8sExtensions operations + :vartype k8s_extensions: azure.mgmt.kubernetesconfiguration.operations.K8sExtensionsOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The Azure subscription ID. This is a + GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = K8sExtensionClientConfiguration(credentials, subscription_id, base_url) + super(K8sExtensionClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2020-07-01-preview' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.k8s_extensions = K8sExtensionsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/__init__.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/__init__.py new file mode 100644 index 00000000000..166f80c01ea --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/__init__.py @@ -0,0 +1,70 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import ErrorDefinition + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ExtensionInstance + from ._models_py3 import ExtensionInstanceForCreate + from ._models_py3 import ExtensionInstanceForList + from ._models_py3 import ExtensionInstanceUpdate + from ._models_py3 import ExtensionStatus + from ._models_py3 import ProxyResource + from ._models_py3 import Resource + from ._models_py3 import Result + from ._models_py3 import Scope + from ._models_py3 import ScopeCluster + from ._models_py3 import ScopeNamespace + from ._models_py3 import ConfigurationIdentity +except (SyntaxError, ImportError): + from ._models import ErrorDefinition + from ._models import ErrorResponse, ErrorResponseException + from ._models import ExtensionInstance + from ._models import ExtensionInstanceForCreate + from ._models import ExtensionInstanceForList + from ._models import ExtensionInstanceUpdate + from ._models import ExtensionStatus + from ._models import ProxyResource + from ._models import Resource + from ._models import Result + from ._models import Scope + from ._models import ScopeCluster + from ._models import ScopeNamespace + from ._models import ConfigurationIdentity +from ._paged_models import ExtensionInstanceForListPaged +from ._k8s_extension_client_enums import ( + MessageLevelType, + InstallStateType, + LevelType, + ResourceIdentityType, +) + +__all__ = [ + 'ErrorDefinition', + 'ErrorResponse', 'ErrorResponseException', + 'ExtensionInstance', + 'ExtensionInstanceForCreate', + 'ExtensionInstanceForList', + 'ConfigurationIdentity', + 'ExtensionInstanceUpdate', + 'ExtensionStatus', + 'ProxyResource', + 'Resource', + 'Result', + 'Scope', + 'ScopeCluster', + 'ScopeNamespace', + 'ExtensionInstanceForListPaged', + 'MessageLevelType', + 'InstallStateType', + 'LevelType', + 'ResourceIdentityType', +] diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_k8s_extension_client_enums.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_k8s_extension_client_enums.py new file mode 100644 index 00000000000..7be14a4b085 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_k8s_extension_client_enums.py @@ -0,0 +1,68 @@ +# 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. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class ComplianceStateType(str, Enum): + + pending = "Pending" + compliant = "Compliant" + noncompliant = "Noncompliant" + installed = "Installed" + failed = "Failed" + + +class MessageLevelType(str, Enum): + + error = "Error" + warning = "Warning" + information = "Information" + + +class OperatorType(str, Enum): + + flux = "Flux" + + +class OperatorScopeType(str, Enum): + + cluster = "cluster" + namespace = "namespace" + + +class ProvisioningStateType(str, Enum): + + accepted = "Accepted" + deleting = "Deleting" + running = "Running" + succeeded = "Succeeded" + failed = "Failed" + + +class InstallStateType(str, Enum): + + pending = "Pending" + installed = "Installed" + failed = "Failed" + + +class LevelType(str, Enum): + + error = "Error" + warning = "Warning" + information = "Information" + + +class ResourceIdentityType(str, Enum): + + system_assigned = "SystemAssigned" + none = "None" diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py new file mode 100644 index 00000000000..0a11097a24f --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py @@ -0,0 +1,587 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + +class ConfigurationIdentity(Model): + """Identity for the managed cluster. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar principal_id: The principal id of the system assigned identity which + is used by the configuration. + :vartype principal_id: str + :ivar tenant_id: The tenant id of the system assigned identity which is + used by the configuration. + :vartype tenant_id: str + :param type: The type of identity used for the configuration. Type + 'SystemAssigned' will use an implicitly created identity. Type 'None' will + not use Managed Identity for the configuration. Possible values include: + 'SystemAssigned', 'None' + :type type: str or + ~azure.mgmt.kubernetesconfiguration.models.ResourceIdentityType + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + } + + def __init__(self, **kwargs): + super(ConfigurationIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = kwargs.get('type', None) + + +class ErrorDefinition(Model): + """Error definition. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. Service specific error code which serves as the + substatus for the HTTP error code. + :type code: str + :param message: Required. Description of the error. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ErrorDefinition, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class ErrorResponse(Model): + """Error response. + + :param error: Error definition. + :type error: ~azure.mgmt.kubernetesconfiguration.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class Resource(Model): + """The Resource model definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """ARM proxy resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ProxyResource, self).__init__(**kwargs) + + +class ExtensionInstance(ProxyResource): + """The Extension Instance object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param extension_type: Type of the Extension, of which this resource is an + instance of. It must be one of the Extension Types registered with + Microsoft.KubernetesConfiguration by the Extension publisher. + :type extension_type: str + :param auto_upgrade_minor_version: Flag to note if this instance + participates in auto upgrade of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension instance participates in + for auto-upgrade (e.g. Stable, Preview, etc.) - only if + autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension instance, if + it is 'pinned' to a specific version. autoUpgradeMinorVersion must be + 'false'. + :type version: str + :param scope: Scope at which the extension instance is installed. + :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope + :param configuration_settings: Configuration settings, as name-value pairs + for configuring this instance of the extension. + :type configuration_settings: dict[str, str] + :param install_state: Status of installation of this instance of the + extension. Possible values include: 'Pending', 'Installed', 'Failed' + :type install_state: str or + ~azure.mgmt.kubernetesconfiguration.models.InstallStateType + :param statuses: Status from this instance of the extension. + :type statuses: + list[~azure.mgmt.kubernetesconfiguration.models.ExtensionStatus] + :ivar creation_time: DateLiteral (per ISO8601) noting the time the + resource was created by the client (user). + :vartype creation_time: str + :ivar last_modified_time: DateLiteral (per ISO8601) noting the time the + resource was modified by the client (user). + :vartype last_modified_time: str + :ivar last_status_time: DateLiteral (per ISO8601) noting the time of last + status from the agent. + :vartype last_status_time: str + :ivar error_info: Error information from the Agent - e.g. errors during + installation. + :vartype error_info: + ~azure.mgmt.kubernetesconfiguration.models.ErrorDefinition + :param identity: The identity of the configuration. + :type identity: + ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'creation_time': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'last_status_time': {'readonly': True}, + 'error_info': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'Scope'}, + 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'install_state': {'key': 'properties.installState', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, + 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, + 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, + 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, + } + + def __init__(self, **kwargs): + super(ExtensionInstance, self).__init__(**kwargs) + self.extension_type = kwargs.get('extension_type', None) + self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) + self.release_train = kwargs.get('release_train', None) + self.version = kwargs.get('version', None) + self.scope = kwargs.get('scope', None) + self.configuration_settings = kwargs.get('configuration_settings', None) + self.install_state = kwargs.get('install_state', None) + self.statuses = kwargs.get('statuses', None) + self.creation_time = None + self.last_modified_time = None + self.last_status_time = None + self.error_info = None + self.identity = kwargs.get('identity', None) + + +class ExtensionInstanceForCreate(ProxyResource): + """Object to create a new Extension Instance. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param extension_type: Type of the Extension, of which this resource is an + instance of. It must be one of the Extension Types registered with + Microsoft.KubernetesConfiguration by the Extension publisher. + :type extension_type: str + :param auto_upgrade_minor_version: Flag to note if this instance + participates in auto upgrade of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension instance participates in + for auto-upgrade (e.g. Stable, Preview, etc.) - only if + autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension instance, if + it is 'pinned' to a specific version. autoUpgradeMinorVersion must be + 'false'. + :type version: str + :param scope: Scope at which the extension instance is installed. + :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope + :param configuration_settings: Configuration settings, as name-value pairs + for configuring this instance of the extension. + :type configuration_settings: dict[str, str] + :param configuration_protected_settings: Configuration settings that are + sensitive, as name-value pairs for configuring this instance of the + extension. + :type configuration_protected_settings: dict[str, str] + :param identity: The identity of the configuration. + :type identity: + ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'Scope'}, + 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ExtensionInstanceForCreate, self).__init__(**kwargs) + self.extension_type = kwargs.get('extension_type', None) + self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) + self.release_train = kwargs.get('release_train', None) + self.version = kwargs.get('version', None) + self.scope = kwargs.get('scope', None) + self.configuration_settings = kwargs.get('configuration_settings', None) + self.configuration_protected_settings = kwargs.get('configuration_protected_settings', None) + self.identity = kwargs.get('identity', None) + self.location = kwargs.get('location', None) + + +class ExtensionInstanceForList(ProxyResource): + """The Extension Instance object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param extension_type: Type of the Extension, of which this resource is an + instance of. It must be one of the Extension Types registered with + Microsoft.KubernetesConfiguration by the Extension publisher. + :type extension_type: str + :param auto_upgrade_minor_version: Flag to note if this instance + participates in auto upgrade of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension instance participates in + for auto-upgrade (e.g. Stable, Preview, etc.) - only if + autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension instance, if + it is 'pinned' to a specific version. + :type version: str + :param scope: Scope at which the extension instance is installed. + :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope + :param install_state: Status of installation of this instance of the + extension. Possible values include: 'Pending', 'Installed', 'Failed' + :type install_state: str or + ~azure.mgmt.kubernetesconfiguration.models.InstallStateType + :ivar creation_time: DateLiteral (per ISO8601) noting the time the + resource was created by the client (user). + :vartype creation_time: str + :ivar last_modified_time: DateLiteral (per ISO8601) noting the time the + resource was modified by the client (user). + :vartype last_modified_time: str + :ivar last_status_time: DateLiteral (per ISO8601) noting the time of last + status from the agent. + :vartype last_status_time: str + :ivar error_info: Error information from the Agent - e.g. errors during + installation. + :vartype error_info: + ~azure.mgmt.kubernetesconfiguration.models.ErrorDefinition + :param identity: The identity of the configuration. + :type identity: + ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'creation_time': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'last_status_time': {'readonly': True}, + 'error_info': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'Scope'}, + 'install_state': {'key': 'properties.installState', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, + 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, + 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, + 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, + } + + def __init__(self, **kwargs): + super(ExtensionInstanceForList, self).__init__(**kwargs) + self.extension_type = kwargs.get('extension_type', None) + self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) + self.release_train = kwargs.get('release_train', None) + self.version = kwargs.get('version', None) + self.scope = kwargs.get('scope', None) + self.install_state = kwargs.get('install_state', None) + self.creation_time = None + self.last_modified_time = None + self.last_status_time = None + self.error_info = None + self.identity = kwargs.get('identity', None) + + +class ExtensionInstanceUpdate(Model): + """Update Extension Instance request object. + + :param auto_upgrade_minor_version: Flag to note if this instance + participates in Extension Lifecycle Management or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension instance participates in + for auto-upgrade (e.g. Stable, Preview, etc.) - only if + autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version number of extension, to 'pin' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :type version: str + """ + + _attribute_map = { + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ExtensionInstanceUpdate, self).__init__(**kwargs) + self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) + self.release_train = kwargs.get('release_train', None) + self.version = kwargs.get('version', None) + + +class ExtensionStatus(Model): + """Status from this instance of the extension. + + :param code: Status code provided by the Extension + :type code: str + :param display_status: Short description of status of this instance of the + extension. + :type display_status: str + :param level: Level of the status. Possible values include: 'Error', + 'Warning', 'Information'. Default value: "Information" . + :type level: str or ~azure.mgmt.kubernetesconfiguration.models.LevelType + :param message: Detailed message of the status from the Extension + instance. + :type message: str + :param time: DateLiteral (per ISO8601) noting the time of installation + status. + :type time: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'display_status': {'key': 'displayStatus', 'type': 'str'}, + 'level': {'key': 'level', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'time': {'key': 'time', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ExtensionStatus, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.display_status = kwargs.get('display_status', None) + self.level = kwargs.get('level', "Information") + self.message = kwargs.get('message', None) + self.time = kwargs.get('time', None) + + +class Result(Model): + """Sample result definition. + + :param sample_property: Sample property of type string + :type sample_property: str + """ + + _attribute_map = { + 'sample_property': {'key': 'sampleProperty', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Result, self).__init__(**kwargs) + self.sample_property = kwargs.get('sample_property', None) + + +class Scope(Model): + """Scope of the extensionInstance. It can be either Cluster or Namespace; but + not both. + + :param cluster: Specifies that the scope of the extensionInstance is + Cluster + :type cluster: ~azure.mgmt.kubernetesconfiguration.models.ScopeCluster + :param namespace: Specifies that the scope of the extensionInstance is + Namespace + :type namespace: ~azure.mgmt.kubernetesconfiguration.models.ScopeNamespace + """ + + _attribute_map = { + 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, + 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + } + + def __init__(self, **kwargs): + super(Scope, self).__init__(**kwargs) + self.cluster = kwargs.get('cluster', None) + self.namespace = kwargs.get('namespace', None) + + +class ScopeCluster(Model): + """Specifies that the scope of the extensionInstance is Cluster. + + :param release_namespace: Namespace where the extension Release must be + placed, for a Cluster scoped extensionInstance. If this namespace does + not exist, it will be created + :type release_namespace: str + """ + + _attribute_map = { + 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ScopeCluster, self).__init__(**kwargs) + self.release_namespace = kwargs.get('release_namespace', None) + + +class ScopeNamespace(Model): + """Specifies that the scope of the extensionInstance is Namespace. + + :param target_namespace: Namespace where the extensionInstance will be + created for an Namespace scoped extensionInstance. If this namespace does + not exist, it will be created + :type target_namespace: str + """ + + _attribute_map = { + 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ScopeNamespace, self).__init__(**kwargs) + self.target_namespace = kwargs.get('target_namespace', None) diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py new file mode 100644 index 00000000000..16b408963ab --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py @@ -0,0 +1,587 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + +class ConfigurationIdentity(Model): + """Identity for the managed cluster. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar principal_id: The principal id of the system assigned identity which + is used by the configuration. + :vartype principal_id: str + :ivar tenant_id: The tenant id of the system assigned identity which is + used by the configuration. + :vartype tenant_id: str + :param type: The type of identity used for the configuration. Type + 'SystemAssigned' will use an implicitly created identity. Type 'None' will + not use Managed Identity for the configuration. Possible values include: + 'SystemAssigned', 'None' + :type type: str or + ~azure.mgmt.kubernetesconfiguration.models.ResourceIdentityType + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + } + + def __init__(self, *, type=None, **kwargs) -> None: + super(ConfigurationIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class ErrorDefinition(Model): + """Error definition. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. Service specific error code which serves as the + substatus for the HTTP error code. + :type code: str + :param message: Required. Description of the error. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code: str, message: str, **kwargs) -> None: + super(ErrorDefinition, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ErrorResponse(Model): + """Error response. + + :param error: Error definition. + :type error: ~azure.mgmt.kubernetesconfiguration.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__(self, *, error=None, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class Resource(Model): + """The Resource model definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """ARM proxy resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(ProxyResource, self).__init__(**kwargs) + + +class ExtensionInstance(ProxyResource): + """The Extension Instance object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param extension_type: Type of the Extension, of which this resource is an + instance of. It must be one of the Extension Types registered with + Microsoft.KubernetesConfiguration by the Extension publisher. + :type extension_type: str + :param auto_upgrade_minor_version: Flag to note if this instance + participates in auto upgrade of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension instance participates in + for auto-upgrade (e.g. Stable, Preview, etc.) - only if + autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension instance, if + it is 'pinned' to a specific version. autoUpgradeMinorVersion must be + 'false'. + :type version: str + :param scope: Scope at which the extension instance is installed. + :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope + :param configuration_settings: Configuration settings, as name-value pairs + for configuring this instance of the extension. + :type configuration_settings: dict[str, str] + :param install_state: Status of installation of this instance of the + extension. Possible values include: 'Pending', 'Installed', 'Failed' + :type install_state: str or + ~azure.mgmt.kubernetesconfiguration.models.InstallStateType + :param statuses: Status from this instance of the extension. + :type statuses: + list[~azure.mgmt.kubernetesconfiguration.models.ExtensionStatus] + :ivar creation_time: DateLiteral (per ISO8601) noting the time the + resource was created by the client (user). + :vartype creation_time: str + :ivar last_modified_time: DateLiteral (per ISO8601) noting the time the + resource was modified by the client (user). + :vartype last_modified_time: str + :ivar last_status_time: DateLiteral (per ISO8601) noting the time of last + status from the agent. + :vartype last_status_time: str + :ivar error_info: Error information from the Agent - e.g. errors during + installation. + :vartype error_info: + ~azure.mgmt.kubernetesconfiguration.models.ErrorDefinition + :param identity: The identity of the configuration. + :type identity: + ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'creation_time': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'last_status_time': {'readonly': True}, + 'error_info': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'Scope'}, + 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'install_state': {'key': 'properties.installState', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, + 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, + 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, + 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, + } + + def __init__(self, *, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, configuration_settings=None, install_state=None, statuses=None, identity=None, **kwargs) -> None: + super(ExtensionInstance, self).__init__(**kwargs) + self.extension_type = extension_type + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.scope = scope + self.configuration_settings = configuration_settings + self.install_state = install_state + self.statuses = statuses + self.creation_time = None + self.last_modified_time = None + self.last_status_time = None + self.error_info = None + self.identity = identity + + +class ExtensionInstanceForCreate(ProxyResource): + """Object to create a new Extension Instance. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param extension_type: Type of the Extension, of which this resource is an + instance of. It must be one of the Extension Types registered with + Microsoft.KubernetesConfiguration by the Extension publisher. + :type extension_type: str + :param auto_upgrade_minor_version: Flag to note if this instance + participates in auto upgrade of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension instance participates in + for auto-upgrade (e.g. Stable, Preview, etc.) - only if + autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension instance, if + it is 'pinned' to a specific version. autoUpgradeMinorVersion must be + 'false'. + :type version: str + :param scope: Scope at which the extension instance is installed. + :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope + :param configuration_settings: Configuration settings, as name-value pairs + for configuring this instance of the extension. + :type configuration_settings: dict[str, str] + :param configuration_protected_settings: Configuration settings that are + sensitive, as name-value pairs for configuring this instance of the + extension. + :type configuration_protected_settings: dict[str, str] + :param identity: The identity of the configuration. + :type identity: + ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'Scope'}, + 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__(self, *, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, configuration_settings=None, configuration_protected_settings=None, identity=None, location=None, **kwargs) -> None: + super(ExtensionInstanceForCreate, self).__init__(location=location,**kwargs) + self.extension_type = extension_type + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.scope = scope + self.configuration_settings = configuration_settings + self.configuration_protected_settings = configuration_protected_settings + self.identity = identity + self.location = location + + +class ExtensionInstanceForList(ProxyResource): + """The Extension Instance object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param extension_type: Type of the Extension, of which this resource is an + instance of. It must be one of the Extension Types registered with + Microsoft.KubernetesConfiguration by the Extension publisher. + :type extension_type: str + :param auto_upgrade_minor_version: Flag to note if this instance + participates in auto upgrade of minor version, or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension instance participates in + for auto-upgrade (e.g. Stable, Preview, etc.) - only if + autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version of the extension for this extension instance, if + it is 'pinned' to a specific version. + :type version: str + :param scope: Scope at which the extension instance is installed. + :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope + :param install_state: Status of installation of this instance of the + extension. Possible values include: 'Pending', 'Installed', 'Failed' + :type install_state: str or + ~azure.mgmt.kubernetesconfiguration.models.InstallStateType + :ivar creation_time: DateLiteral (per ISO8601) noting the time the + resource was created by the client (user). + :vartype creation_time: str + :ivar last_modified_time: DateLiteral (per ISO8601) noting the time the + resource was modified by the client (user). + :vartype last_modified_time: str + :ivar last_status_time: DateLiteral (per ISO8601) noting the time of last + status from the agent. + :vartype last_status_time: str + :ivar error_info: Error information from the Agent - e.g. errors during + installation. + :vartype error_info: + ~azure.mgmt.kubernetesconfiguration.models.ErrorDefinition + :param identity: The identity of the configuration. + :type identity: + ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'creation_time': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'last_status_time': {'readonly': True}, + 'error_info': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'Scope'}, + 'install_state': {'key': 'properties.installState', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, + 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, + 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, + 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, + } + + def __init__(self, *, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, install_state=None, identity=None, **kwargs) -> None: + super(ExtensionInstanceForList, self).__init__(**kwargs) + self.extension_type = extension_type + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + self.scope = scope + self.install_state = install_state + self.creation_time = None + self.last_modified_time = None + self.last_status_time = None + self.error_info = None + self.identity = identity + + +class ExtensionInstanceUpdate(Model): + """Update Extension Instance request object. + + :param auto_upgrade_minor_version: Flag to note if this instance + participates in Extension Lifecycle Management or not. + :type auto_upgrade_minor_version: bool + :param release_train: ReleaseTrain this extension instance participates in + for auto-upgrade (e.g. Stable, Preview, etc.) - only if + autoUpgradeMinorVersion is 'true'. + :type release_train: str + :param version: Version number of extension, to 'pin' to a specific + version. autoUpgradeMinorVersion must be 'false'. + :type version: str + """ + + _attribute_map = { + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + } + + def __init__(self, *, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, **kwargs) -> None: + super(ExtensionInstanceUpdate, self).__init__(**kwargs) + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.release_train = release_train + self.version = version + + +class ExtensionStatus(Model): + """Status from this instance of the extension. + + :param code: Status code provided by the Extension + :type code: str + :param display_status: Short description of status of this instance of the + extension. + :type display_status: str + :param level: Level of the status. Possible values include: 'Error', + 'Warning', 'Information'. Default value: "Information" . + :type level: str or ~azure.mgmt.kubernetesconfiguration.models.LevelType + :param message: Detailed message of the status from the Extension + instance. + :type message: str + :param time: DateLiteral (per ISO8601) noting the time of installation + status. + :type time: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'display_status': {'key': 'displayStatus', 'type': 'str'}, + 'level': {'key': 'level', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'time': {'key': 'time', 'type': 'str'}, + } + + def __init__(self, *, code: str=None, display_status: str=None, level="Information", message: str=None, time: str=None, **kwargs) -> None: + super(ExtensionStatus, self).__init__(**kwargs) + self.code = code + self.display_status = display_status + self.level = level + self.message = message + self.time = time + + +class Result(Model): + """Sample result definition. + + :param sample_property: Sample property of type string + :type sample_property: str + """ + + _attribute_map = { + 'sample_property': {'key': 'sampleProperty', 'type': 'str'}, + } + + def __init__(self, *, sample_property: str=None, **kwargs) -> None: + super(Result, self).__init__(**kwargs) + self.sample_property = sample_property + + +class Scope(Model): + """Scope of the extensionInstance. It can be either Cluster or Namespace; but + not both. + + :param cluster: Specifies that the scope of the extensionInstance is + Cluster + :type cluster: ~azure.mgmt.kubernetesconfiguration.models.ScopeCluster + :param namespace: Specifies that the scope of the extensionInstance is + Namespace + :type namespace: ~azure.mgmt.kubernetesconfiguration.models.ScopeNamespace + """ + + _attribute_map = { + 'cluster': {'key': 'cluster', 'type': 'ScopeCluster'}, + 'namespace': {'key': 'namespace', 'type': 'ScopeNamespace'}, + } + + def __init__(self, *, cluster=None, namespace=None, **kwargs) -> None: + super(Scope, self).__init__(**kwargs) + self.cluster = cluster + self.namespace = namespace + + +class ScopeCluster(Model): + """Specifies that the scope of the extensionInstance is Cluster. + + :param release_namespace: Namespace where the extension Release must be + placed, for a Cluster scoped extensionInstance. If this namespace does + not exist, it will be created + :type release_namespace: str + """ + + _attribute_map = { + 'release_namespace': {'key': 'releaseNamespace', 'type': 'str'}, + } + + def __init__(self, *, release_namespace: str=None, **kwargs) -> None: + super(ScopeCluster, self).__init__(**kwargs) + self.release_namespace = release_namespace + + +class ScopeNamespace(Model): + """Specifies that the scope of the extensionInstance is Namespace. + + :param target_namespace: Namespace where the extensionInstance will be + created for an Namespace scoped extensionInstance. If this namespace does + not exist, it will be created + :type target_namespace: str + """ + + _attribute_map = { + 'target_namespace': {'key': 'targetNamespace', 'type': 'str'}, + } + + def __init__(self, *, target_namespace: str=None, **kwargs) -> None: + super(ScopeNamespace, self).__init__(**kwargs) + self.target_namespace = target_namespace diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_paged_models.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_paged_models.py new file mode 100644 index 00000000000..8f2e7eca24e --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_paged_models.py @@ -0,0 +1,40 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class ResourceProviderOperationPaged(Paged): + """ + A paging container for iterating over a list of :class:`ResourceProviderOperation ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ResourceProviderOperation]'} + } + + def __init__(self, *args, **kwargs): + + super(ResourceProviderOperationPaged, self).__init__(*args, **kwargs) +class ExtensionInstanceForListPaged(Paged): + """ + A paging container for iterating over a list of :class:`ExtensionInstanceForList ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ExtensionInstanceForList]'} + } + + def __init__(self, *args, **kwargs): + + super(ExtensionInstanceForListPaged, self).__init__(*args, **kwargs) diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/__init__.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/__init__.py new file mode 100644 index 00000000000..e8f158b24a3 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/__init__.py @@ -0,0 +1,16 @@ +# 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. +# -------------------------------------------------------------------------- + +from ._k8s_extensions_operations import K8sExtensionsOperations + +__all__ = [ + 'K8sExtensionsOperations', +] diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_k8s_extensions_operations.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_k8s_extensions_operations.py new file mode 100644 index 00000000000..716aefd7b06 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_k8s_extensions_operations.py @@ -0,0 +1,452 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class K8sExtensionsOperations(object): + """K8sExtensionsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach + it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to be used with the HTTP request. Constant value: "2020-07-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-07-01-preview" + + self.config = config + + def get( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, + custom_headers=None, raw=False, **operation_config): + """Gets details of the Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either + Microsoft.ContainerService (for AKS clusters) or Microsoft.Kubernetes + (for OnPrem K8S clusters). Possible values include: + 'Microsoft.ContainerService', 'Microsoft.Kubernetes' + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - + either managedClusters (for AKS clusters) or connectedClusters (for + OnPrem K8S clusters) or appliances (for Arc Appliances). Possible + values include: 'managedClusters','connectedClusters', 'appliances' + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. + :type extension_instance_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ExtensionInstance or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstance + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionInstanceName': self._serialize.url("extension_instance_name", extension_instance_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", + self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ExtensionInstance', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} + + def create( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, + extension_instance, custom_headers=None, raw=False, **operation_config): + """Create a new Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either + Microsoft.ContainerService (for AKS clusters) or Microsoft.Kubernetes + (for OnPrem K8S clusters). Possible values include: + 'Microsoft.ContainerService', 'Microsoft.Kubernetes' + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - + either managedClusters (for AKS clusters) or connectedClusters (for + OnPrem K8S clusters) or appliances (for Arc Appliances). Possible + values include: 'managedClusters','connectedClusters', 'appliances' + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. + :type extension_instance_name: str + :param extension_instance: Properties necessary to Create an Extension + Instance. + :type extension_instance: + ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstanceForCreate + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ExtensionInstance or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstance + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.create.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionInstanceName': self._serialize.url("extension_instance_name", extension_instance_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", + self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(extension_instance, 'ExtensionInstanceForCreate') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ExtensionInstance', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}' + '/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/' + 'extensions/{extensionInstanceName}'} + + def update( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, + extension_instance, custom_headers=None, raw=False, **operation_config): + """Update an existing Kubernetes Cluster Extension Instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either + Microsoft.ContainerService (for AKS clusters) or Microsoft.Kubernetes + (for OnPrem K8S clusters). Possible values include: + 'Microsoft.ContainerService', 'Microsoft.Kubernetes' + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - + either managedClusters (for AKS clusters) or connectedClusters (for + OnPrem K8S clusters) or appliances (for Arc Appliances). Possible + values include: 'managedClusters','connectedClusters', 'appliances' + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. + :type extension_instance_name: str + :param extension_instance: Properties to Update in the Extension + Instance. + :type extension_instance: + ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstanceUpdate + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ExtensionInstance or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstance + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionInstanceName': self._serialize.url("extension_instance_name", extension_instance_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", + self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(extension_instance, 'ExtensionInstanceUpdate') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ExtensionInstance', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}' + '/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/' + 'extensions/{extensionInstanceName}'} + + def delete( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, + custom_headers=None, raw=False, **operation_config): + """Delete a Kubernetes Cluster Extension Instance. This will cause the + Agent to Uninstall the extension instance from the cluster. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either + Microsoft.ContainerService (for AKS clusters) or Microsoft.Kubernetes + (for OnPrem K8S clusters). Possible values include: + 'Microsoft.ContainerService', 'Microsoft.Kubernetes' + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - + either managedClusters (for AKS clusters) or connectedClusters (for + OnPrem K8S clusters) or appliances (for Arc Appliances). Possible + values include: 'managedClusters','connectedClusters', 'appliances' + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param extension_instance_name: Name of an instance of the Extension. + :type extension_instance_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'extensionInstanceName': self._serialize.url("extension_instance_name", extension_instance_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", + self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}' + '/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/' + 'extensions/{extensionInstanceName}'} + + def list( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, custom_headers=None, raw=False, + **operation_config): + """List all Extension Instances. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either + Microsoft.ContainerService (for AKS clusters) or Microsoft.Kubernetes + (for OnPrem K8S clusters). Possible values include: + 'Microsoft.ContainerService', 'Microsoft.Kubernetes' + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - + either managedClusters (for AKS clusters) or connectedClusters (for + OnPrem K8S clusters) or appliances (for Arc Appliances). Possible + values include: 'managedClusters','connectedClusters', 'appliances' + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ExtensionInstanceForList + :rtype: + ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstanceForListPaged[~azure.mgmt.kubernetesconfiguration.models.ExtensionInstanceForList] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, + 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", + self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ExtensionInstanceForListPaged(internal_paging, self._deserialize.dependencies, + header_dict) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}' + '/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/' + 'extensions'} diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/version.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/version.py new file mode 100644 index 00000000000..e0ec669828c --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/version.py @@ -0,0 +1,13 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" + diff --git a/src/k8s-extension/setup.cfg b/src/k8s-extension/setup.cfg new file mode 100644 index 00000000000..5eab412034f --- /dev/null +++ b/src/k8s-extension/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/src/k8s-extension/setup.py b/src/k8s-extension/setup.py new file mode 100644 index 00000000000..c5fdcbfc5a8 --- /dev/null +++ b/src/k8s-extension/setup.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + +# TODO: Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = '0.1PP.14' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +# TODO: Add any additional SDK dependencies here +DEPENDENCIES = [] + +with open('README.rst', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='k8s-extension', + version=VERSION, + description='Microsoft Azure Command-Line Tools K8s-extension Extension', + # TODO: Update author and email, if applicable + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + # TODO: consider pointing directly to your source code instead of the generic repo + url='https://github.com/Azure/azure-cli-extensions', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_k8s_extension': ['azext_metadata.json']}, +) From 3e2ea64c089ece94daa605788d308fc4193a064f Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Wed, 10 Mar 2021 14:22:56 -0800 Subject: [PATCH 05/31] Update pipelines file --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 77ff718d967..3e1ef1ccca5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,7 +22,7 @@ stages: displayName: "K8s-Extension Test Suite" variables: K8S_EXTENSION_REPO_PATH: $(Agent.BuildDirectory)/s/compute-HybridMgmt-K8sPartnerExtensionTest - CLI_REPO_PATH: $(Agent.BuildDirectory)/s/azure-cli-extensions-pr + CLI_REPO_PATH: $(Agent.BuildDirectory)/s/azure-cli-extensions EXTENSION_NAME: "k8s-extension" EXTENSION_FILE_NAME: "k8s_extension" SUBSCRIPTION_ID: "15c06b1b-01d6-407b-bb21-740b8617dea3" From 9bbc0e462fd0d027ff32099b2657c530522b268c Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Wed, 10 Mar 2021 14:57:51 -0800 Subject: [PATCH 06/31] Update CODEOWNERS --- .github/CODEOWNERS | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 66f026834e8..435dbbae79f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -124,9 +124,11 @@ /src/ssh/ @rlrossiter @danybeam @arrownj -/src/k8sconfiguration/ @NarayanThiru +/src/k8sconfiguration/ @NarayanThiru @jonathan-innis -/src/k8s-configuration/ @NarayanThiru +/src/k8s-configuration/ @NarayanThiru @jonathan-innis + +/src/k8s-extension/ @NarayanThiru @jonathan-innis /src/log-analytics-solution/ @zhoxing-ms From 8d46cbc41b4469cb5795889c32ed28fa348528a5 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Thu, 11 Mar 2021 11:35:18 -0800 Subject: [PATCH 07/31] Update private preview pipelines --- azure-pipelines.yml | 72 +++++++++++++++++-- .../azext_k8s_extension/_consts.py | 7 ++ .../azext_k8s_extension/_consts_private.py | 7 ++ .../azext_k8s_extension/_help.py | 13 ++-- .../azext_k8s_extension/_params.py | 3 +- .../azext_k8s_extension/commands.py | 3 +- src/k8s-extension/setup.py | 3 +- 7 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 src/k8s-extension/azext_k8s_extension/_consts.py create mode 100644 src/k8s-extension/azext_k8s_extension/_consts_private.py diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3e1ef1ccca5..203370976cf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,11 +23,12 @@ stages: variables: K8S_EXTENSION_REPO_PATH: $(Agent.BuildDirectory)/s/compute-HybridMgmt-K8sPartnerExtensionTest CLI_REPO_PATH: $(Agent.BuildDirectory)/s/azure-cli-extensions - EXTENSION_NAME: "k8s-extension" - EXTENSION_FILE_NAME: "k8s_extension" SUBSCRIPTION_ID: "15c06b1b-01d6-407b-bb21-740b8617dea3" RESOURCE_GROUP: "K8sPartnerExtensionTest" BASE_CLUSTER_NAME: "k8s-extension-cluster" + + EXTENSION_NAME: "k8s-extension" + EXTENSION_FILE_NAME: "k8s_extension" jobs: - job: K8sExtensionTestSuite displayName: "Run the Test Suite" @@ -36,7 +37,6 @@ stages: steps: - checkout: self - checkout: K8sPartnerExtensionTest - - bash: | echo "Installing helm3" curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 @@ -55,6 +55,7 @@ stages: versionSpec: 3.6 - bash: | set -ev + echo "Building extension ${EXTENSION_NAME}..." # prepare and activate virtualenv pip install virtualenv @@ -71,12 +72,12 @@ stages: azdev extension build $(EXTENSION_NAME) workingDirectory: $(CLI_REPO_PATH) - displayName: "Setup and Build $(EXTENSION_NAME) with azdev" + displayName: "Setup and Build Extension with azdev" - bash: | K8S_EXTENSION_VERSION=$(ls ${EXTENSION_FILE_NAME}* | cut -d "-" -f2) echo "##vso[task.setvariable variable=K8S_EXTENSION_VERSION]$K8S_EXTENSION_VERSION" - cp * $(K8S_EXTENSION_REPO_PATH)/extensions + cp * $(K8S_EXTENSION_REPO_PATH)/bin workingDirectory: $(CLI_REPO_PATH)/dist displayName: "Copy the Built .whl to Extension Test Path" @@ -142,6 +143,67 @@ stages: .\Cleanup.ps1 -CI workingDirectory: $(K8S_EXTENSION_REPO_PATH) condition: succeededOrFailed() + +- stage: BuildPublishExtension + dependsOn: [] + displayName: "Build and Publish the Extension Artifact" + variables: + CLI_REPO_PATH: $(Agent.BuildDirectory)/s + IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranchName'], 'refs/heads/k8s-extension/private-preview'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private-preview'))] + jobs: + - job: BuildPublishExtension + displayName: "Build and Publish the Extension Artifact" + pool: + vmImage: 'ubuntu-16.04' + steps: + - bash: | + if [[ $IS_PRIVATE_BRANCH ]]; then + echo "Using the private preview of k8s-extension to build..." + + cp $(CLI_REPO_PATH)/src/k8s-extension $(CLI_REPO_PATH)/src/k8s-extension-private -r + cp $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts_private.py $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts.py + + EXTENSION_NAME="k8s-extension-private" + EXTENSION_FILE_NAME="k8s_extension_private" + + echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" + echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" + else + echo "Using the public version of k8s-extension to build..." + + EXTENSION_NAME="k8s-extension" + EXTENSION_FILE_NAME="k8s_extension" + + echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" + echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" + fi + displayName: "Copy Files, Set Variables based on Private Branch" + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: | + set -ev + echo "Building extension ${EXTENSION_NAME}..." + + # prepare and activate virtualenv + pip install virtualenv + python3 -m venv env/ + source env/bin/activate + + # clone azure-cli + pip install azdev + + ls $(CLI_REPO_PATH) + + azdev --version + azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME) + azdev extension build $(EXTENSION_NAME) + workingDirectory: $(CLI_REPO_PATH) + displayName: "Setup and Build Extension with azdev" + - task: PublishBuildArtifacts@1 + inputs: + pathToPublish: $(CLI_REPO_PATH)/dist - stage: AzureCLIOfficial displayName: "Azure Official CLI Code Checks" diff --git a/src/k8s-extension/azext_k8s_extension/_consts.py b/src/k8s-extension/azext_k8s_extension/_consts.py new file mode 100644 index 00000000000..e9f8156f307 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/_consts.py @@ -0,0 +1,7 @@ +# 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. +# -------------------------------------------------------------------------------------------- + +EXTENSION_NAME = 'k8s-extension' diff --git a/src/k8s-extension/azext_k8s_extension/_consts_private.py b/src/k8s-extension/azext_k8s_extension/_consts_private.py new file mode 100644 index 00000000000..18a01637c2d --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/_consts_private.py @@ -0,0 +1,7 @@ +# 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. +# -------------------------------------------------------------------------------------------- + +EXTENSION_NAME = 'k8s-extension-private' diff --git a/src/k8s-extension/azext_k8s_extension/_help.py b/src/k8s-extension/azext_k8s_extension/_help.py index 69011bb9d92..64e4be612ea 100644 --- a/src/k8s-extension/azext_k8s_extension/_help.py +++ b/src/k8s-extension/azext_k8s_extension/_help.py @@ -5,34 +5,35 @@ # -------------------------------------------------------------------------------------------- from knack.help_files import helps # pylint: disable=unused-import +import azext_k8s_extension._consts as consts -helps['k8s-extension'] = """ +helps[f'{consts.EXTENSION_NAME}'] = """ type: group short-summary: Commands to manage K8s-extensions. """ -helps['k8s-extension create'] = """ +helps[f'{consts.EXTENSION_NAME} create'] = """ type: command short-summary: Create a K8s-extension. """ -helps['k8s-extension list'] = """ +helps[f'{consts.EXTENSION_NAME} list'] = """ type: command short-summary: List K8s-extensions. """ -helps['k8s-extension delete'] = """ +helps[f'{consts.EXTENSION_NAME} delete'] = """ type: command short-summary: Delete a K8s-extension. """ -helps['k8s-extension show'] = """ +helps[f'{consts.EXTENSION_NAME} show'] = """ type: command short-summary: Show details of a K8s-extension. """ -helps['k8s-extension update'] = """ +helps[f'{consts.EXTENSION_NAME} update'] = """ type: command short-summary: Update a K8s-extension. """ diff --git a/src/k8s-extension/azext_k8s_extension/_params.py b/src/k8s-extension/azext_k8s_extension/_params.py index 0e870204887..d96fe3c2ba7 100644 --- a/src/k8s-extension/azext_k8s_extension/_params.py +++ b/src/k8s-extension/azext_k8s_extension/_params.py @@ -9,6 +9,7 @@ tags_type ) from azure.cli.core.commands.validators import get_default_location_from_resource_group +import azext_k8s_extension._consts as consts from azext_k8s_extension.action import ( AddConfigurationSettings, @@ -17,7 +18,7 @@ def load_arguments(self, _): - with self.argument_context('k8s-extension') as c: + with self.argument_context(consts.EXTENSION_NAME) as c: c.argument('tags', tags_type) c.argument('location', validator=get_default_location_from_resource_group) diff --git a/src/k8s-extension/azext_k8s_extension/commands.py b/src/k8s-extension/azext_k8s_extension/commands.py index 63fe78f7d2a..ff72ab62e08 100644 --- a/src/k8s-extension/azext_k8s_extension/commands.py +++ b/src/k8s-extension/azext_k8s_extension/commands.py @@ -6,6 +6,7 @@ # pylint: disable=line-too-long from azure.cli.core.commands import CliCommandType from azext_k8s_extension._client_factory import (cf_k8s_extension, cf_k8s_extension_operation) +import azext_k8s_extension._consts as consts def load_command_table(self, _): @@ -14,7 +15,7 @@ def load_command_table(self, _): operations_tmpl='azext_k8s_extension.vendored_sdks.operations#K8sExtensionsOperations.{}', client_factory=cf_k8s_extension) - with self.command_group('k8s-extension', k8s_extension_sdk, client_factory=cf_k8s_extension_operation, + with self.command_group(consts.EXTENSION_NAME, k8s_extension_sdk, client_factory=cf_k8s_extension_operation, is_preview=True) \ as g: g.custom_command('create', 'create_k8s_extension') diff --git a/src/k8s-extension/setup.py b/src/k8s-extension/setup.py index c5fdcbfc5a8..878f7f8d87a 100644 --- a/src/k8s-extension/setup.py +++ b/src/k8s-extension/setup.py @@ -8,6 +8,7 @@ from codecs import open from setuptools import setup, find_packages +import azext_k8s_extension._consts as consts try: from azure_bdist_wheel import cmdclass except ImportError: @@ -41,7 +42,7 @@ HISTORY = f.read() setup( - name='k8s-extension', + name=consts.EXTENSION_NAME, version=VERSION, description='Microsoft Azure Command-Line Tools K8s-extension Extension', # TODO: Update author and email, if applicable From 6c3ba419f9e0c5d191d0ba4fdce431455c1c5c47 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Thu, 11 Mar 2021 14:56:20 -0800 Subject: [PATCH 08/31] Remove open service mesh from public release --- .../azext_k8s_extension/custom.py | 2 - .../partner_extensions/OpenServiceMesh.py | 95 ------------------- 2 files changed, 97 deletions(-) delete mode 100644 src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index 469b4059dee..4b0657c1814 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -19,7 +19,6 @@ from .partner_extensions.ContainerInsights import ContainerInsights from .partner_extensions.AzureDefender import AzureDefender -from .partner_extensions.OpenServiceMesh import OpenServiceMesh from .partner_extensions.DefaultExtension import DefaultExtension from ._client_factory import cf_resources @@ -32,7 +31,6 @@ def ExtensionFactory(extension_name): extension_map = { 'microsoft.azuremonitor.containers': ContainerInsights, 'microsoft.azuredefender.kubernetes': AzureDefender, - 'microsoft.openservicemesh': OpenServiceMesh, } # Return the extension if we find it in the map, else return the default diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py deleted file mode 100644 index b9e530877dc..00000000000 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py +++ /dev/null @@ -1,95 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -# pylint: disable=unused-argument - -from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError -from knack.log import get_logger - -from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate -from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate -from azext_k8s_extension.vendored_sdks.models import ScopeCluster -from azext_k8s_extension.vendored_sdks.models import Scope - -from .PartnerExtensionModel import PartnerExtensionModel - -logger = get_logger(__name__) - - -class OpenServiceMesh(PartnerExtensionModel): - def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, - scope, auto_upgrade_minor_version, release_train, version, target_namespace, - release_namespace, configuration_settings, configuration_protected_settings, - configuration_settings_file, configuration_protected_settings_file): - - """ExtensionType 'microsoft.openservicemesh' specific validations & defaults for Create - Must create and return a valid 'ExtensionInstanceForCreate' object. - - """ - # NOTE-1: Replace default scope creation with your customization, if required - # Scope must always be cluster - ext_scope = None - if scope == 'namespace': - raise InvalidArgumentValueError("Invalid scope '{}'. This extension can be installed " - "only at 'cluster' scope.".format(scope)) - - scope_cluster = ScopeCluster(release_namespace=release_namespace) - ext_scope = Scope(cluster=scope_cluster, namespace=None) - - valid_release_trains = ['staging', 'pilot'] - # If release-train is not input, set it to 'stable' - if release_train is None: - raise RequiredArgumentMissingError( - "A release-train must be provided. Valid values are 'staging', 'pilot'." - ) - - if release_train.lower() in valid_release_trains: - # version is a mandatory if release-train is staging or pilot - if version is None: - raise RequiredArgumentMissingError( - "A version must be provided for release-train {}.".format(release_train) - ) - # If the release-train is 'staging' or 'pilot' then auto-upgrade-minor-version MUST be set to False - if auto_upgrade_minor_version or auto_upgrade_minor_version is None: - auto_upgrade_minor_version = False - logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train) - else: - raise InvalidArgumentValueError( - "Invalid release-train '{}'. Valid values are 'staging', 'pilot'.".format(release_train) - ) - - # NOTE-2: Return a valid ExtensionInstanceForCreate object, Instance name and flag for Identity - create_identity = False - extension_instance = ExtensionInstanceForCreate( - extension_type=extension_type, - auto_upgrade_minor_version=auto_upgrade_minor_version, - release_train=release_train, - version=version, - scope=ext_scope, - configuration_settings=configuration_settings, - configuration_protected_settings=configuration_protected_settings, - identity=None, - location="" - ) - return extension_instance, name, create_identity - - def Update(self, extension, auto_upgrade_minor_version, release_train, version): - """ExtensionType 'microsoft.openservicemesh' specific validations & defaults for Update - Must create and return a valid 'ExtensionInstanceUpdate' object. - - """ - # auto-upgrade-minor-version MUST be set to False if release_train is staging or pilot - if release_train.lower() in 'staging' 'pilot': - if auto_upgrade_minor_version or auto_upgrade_minor_version is None: - auto_upgrade_minor_version = False - # Set version to None to always get the latest version - user cannot override - version = None - logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train) - - return ExtensionInstanceUpdate( - auto_upgrade_minor_version=auto_upgrade_minor_version, - release_train=release_train, - version=version - ) From 43c67964d19c0a41ef29ebf56b44cad64bc4f7f3 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Thu, 11 Mar 2021 15:10:35 -0800 Subject: [PATCH 09/31] Update pipeline files --- azure-pipelines.yml | 459 ++++++++++++--------------------------- k8s-custom-pipelines.yml | 346 +++++++++++++++++++++++++++++ 2 files changed, 488 insertions(+), 317 deletions(-) create mode 100644 k8s-custom-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 203370976cf..565e9c56793 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,219 +1,128 @@ resources: - repositories: - - repository: K8sPartnerExtensionTest - type: git - endpoint: AzureReposConnection - name: One/compute-HybridMgmt-K8sPartnerExtensionTest +- repo: self trigger: batch: true branches: include: - - k8s-extension/public-preview - - k8s-extension/private-preview + - '*' + pr: branches: include: - - k8s-extension/public-preview - - k8s-extension/private-preview - -stages: -- stage: K8sExtensionTestSuite - displayName: "K8s-Extension Test Suite" - variables: - K8S_EXTENSION_REPO_PATH: $(Agent.BuildDirectory)/s/compute-HybridMgmt-K8sPartnerExtensionTest - CLI_REPO_PATH: $(Agent.BuildDirectory)/s/azure-cli-extensions - SUBSCRIPTION_ID: "15c06b1b-01d6-407b-bb21-740b8617dea3" - RESOURCE_GROUP: "K8sPartnerExtensionTest" - BASE_CLUSTER_NAME: "k8s-extension-cluster" - - EXTENSION_NAME: "k8s-extension" - EXTENSION_FILE_NAME: "k8s_extension" - jobs: - - job: K8sExtensionTestSuite - displayName: "Run the Test Suite" - pool: - vmImage: 'ubuntu-16.04' - steps: - - checkout: self - - checkout: K8sPartnerExtensionTest - - bash: | - echo "Installing helm3" - curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 - chmod 700 get_helm.sh - ./get_helm.sh - - echo "Installing kubectl" - curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" - chmod +x ./kubectl - sudo mv ./kubectl /usr/local/bin/kubectl - kubectl version --client - displayName: "Setup the VM with helm3 and kubectl" - - task: UsePythonVersion@0 - displayName: 'Use Python 3.6' - inputs: - versionSpec: 3.6 - - bash: | - set -ev - echo "Building extension ${EXTENSION_NAME}..." - - # prepare and activate virtualenv - pip install virtualenv - python3 -m venv env/ - source env/bin/activate - - # clone azure-cli - pip install azdev - - ls $(CLI_REPO_PATH) - - azdev --version - azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME) - azdev extension build $(EXTENSION_NAME) - - workingDirectory: $(CLI_REPO_PATH) - displayName: "Setup and Build Extension with azdev" - - - bash: | - K8S_EXTENSION_VERSION=$(ls ${EXTENSION_FILE_NAME}* | cut -d "-" -f2) - echo "##vso[task.setvariable variable=K8S_EXTENSION_VERSION]$K8S_EXTENSION_VERSION" - cp * $(K8S_EXTENSION_REPO_PATH)/bin - workingDirectory: $(CLI_REPO_PATH)/dist - displayName: "Copy the Built .whl to Extension Test Path" - - - bash: | - RAND_STR=$RANDOM - AKS_CLUSTER_NAME="${BASE_CLUSTER_NAME}-${RAND_STR}-aks" - ARC_CLUSTER_NAME="${BASE_CLUSTER_NAME}-${RAND_STR}-arc" - - JSON_STRING=$(jq -n \ - --arg SUB_ID "$SUBSCRIPTION_ID" \ - --arg RG "$RESOURCE_GROUP" \ - --arg AKS_CLUSTER_NAME "$AKS_CLUSTER_NAME" \ - --arg ARC_CLUSTER_NAME "$ARC_CLUSTER_NAME" \ - --arg K8S_EXTENSION_VERSION "$K8S_EXTENSION_VERSION" \ - '{subscriptionId: $SUB_ID, resourceGroup: $RG, aksClusterName: $AKS_CLUSTER_NAME, arcClusterName: $ARC_CLUSTER_NAME, extensionVersion: {"k8s-extension": $K8S_EXTENSION_VERSION, connectedk8s: "1.0.0"}}') - echo $JSON_STRING > settings.json - cat settings.json - workingDirectory: $(K8S_EXTENSION_REPO_PATH) - displayName: "Generate a settings.json file" - - - bash : | - echo "Downloading the kind script" - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-linux-amd64 - chmod +x ./kind - ./kind create cluster - displayName: "Create and Start the Kind cluster" - - - task: AzureCLI@2 - displayName: Bootstrap - inputs: - azureSubscription: AzureResourceConnection - scriptType: pscore - scriptLocation: inlineScript - inlineScript: | - .\Bootstrap.ps1 -CI - workingDirectory: $(K8S_EXTENSION_REPO_PATH) - - - task: AzureCLI@2 - displayName: Run the Test Suite - inputs: - azureSubscription: AzureResourceConnection - scriptType: pscore - scriptLocation: inlineScript - inlineScript: | - .\Test.ps1 -CI - workingDirectory: $(K8S_EXTENSION_REPO_PATH) - continueOnError: true - - - task: PublishTestResults@2 - inputs: - testResultsFormat: 'JUnit' - testResultsFiles: '**/TestResults.xml' - failTaskOnFailedTests: true - condition: succeededOrFailed() - - - task: AzureCLI@2 - displayName: Cleanup - inputs: - azureSubscription: AzureResourceConnection - scriptType: pscore - scriptLocation: inlineScript - inlineScript: | - .\Cleanup.ps1 -CI - workingDirectory: $(K8S_EXTENSION_REPO_PATH) - condition: succeededOrFailed() - -- stage: BuildPublishExtension - dependsOn: [] - displayName: "Build and Publish the Extension Artifact" - variables: - CLI_REPO_PATH: $(Agent.BuildDirectory)/s - IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranchName'], 'refs/heads/k8s-extension/private-preview'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private-preview'))] - jobs: - - job: BuildPublishExtension - displayName: "Build and Publish the Extension Artifact" - pool: - vmImage: 'ubuntu-16.04' - steps: - - bash: | - if [[ $IS_PRIVATE_BRANCH ]]; then - echo "Using the private preview of k8s-extension to build..." - - cp $(CLI_REPO_PATH)/src/k8s-extension $(CLI_REPO_PATH)/src/k8s-extension-private -r - cp $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts_private.py $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts.py - - EXTENSION_NAME="k8s-extension-private" - EXTENSION_FILE_NAME="k8s_extension_private" - - echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" - echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" - else - echo "Using the public version of k8s-extension to build..." - - EXTENSION_NAME="k8s-extension" - EXTENSION_FILE_NAME="k8s_extension" - - echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" - echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" - fi - displayName: "Copy Files, Set Variables based on Private Branch" + - '*' + +jobs: +- job: CredScan + displayName: "Credential Scan" + pool: + vmImage: "windows-2019" + steps: + - task: ms-codeanalysis.vss-microsoft-security-code-analysis-devops.build-task-credscan.CredScan@2 + displayName: 'Run Credential Scanner' + inputs: + toolMajorVersion: V2 + suppressionsFile: './scripts/ci/credscan/CredScanSuppressions.json' + - task: ms-codeanalysis.vss-microsoft-security-code-analysis-devops.build-task-postanalysis.PostAnalysis@1 + displayName: 'Post Analysis' + inputs: + AllTools: false + BinSkim: false + CredScan: true + RoslynAnalyzers: false + TSLint: false + ToolLogsNotFoundAction: 'Standard' + +- job: CheckLicenseHeader + displayName: "Check License" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: | + set -ev + + # prepare and activate virtualenv + python -m venv env/ + + chmod +x ./env/bin/activate + source ./env/bin/activate + + # clone azure-cli + git clone -q --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli + + pip install -q azdev + + azdev setup -c ../azure-cli -r ./ + + azdev --version + az --version + + azdev verify license + +- job: StaticAnalysis + displayName: "Static Analysis" + pool: + vmImage: 'ubuntu-16.04' + steps: - task: UsePythonVersion@0 displayName: 'Use Python 3.6' inputs: versionSpec: 3.6 - - bash: | - set -ev - echo "Building extension ${EXTENSION_NAME}..." - - # prepare and activate virtualenv - pip install virtualenv - python3 -m venv env/ - source env/bin/activate - - # clone azure-cli - pip install azdev - - ls $(CLI_REPO_PATH) + - bash: pip install wheel==0.30.0 pylint==1.9.5 flake8==3.5.0 requests + displayName: 'Install wheel, pylint, flake8, requests' + - bash: python scripts/ci/source_code_static_analysis.py + displayName: "Static Analysis" + +- job: IndexVerify + displayName: "Verify Extensions Index" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.7' + inputs: + versionSpec: 3.7 + - bash: | + #!/usr/bin/env bash + set -ev + pip install wheel==0.30.0 requests packaging + export CI="ADO" + python ./scripts/ci/test_index.py -v + displayName: "Verify Extensions Index" - azdev --version - azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME) - azdev extension build $(EXTENSION_NAME) - workingDirectory: $(CLI_REPO_PATH) - displayName: "Setup and Build Extension with azdev" - - task: PublishBuildArtifacts@1 - inputs: - pathToPublish: $(CLI_REPO_PATH)/dist - -- stage: AzureCLIOfficial - displayName: "Azure Official CLI Code Checks" - dependsOn: [] - jobs: - - job: CheckLicenseHeader - displayName: "Check License" - pool: - vmImage: 'ubuntu-16.04' - steps: +- job: SourceTests + displayName: "Integration Tests, Build Tests" + pool: + vmImage: 'ubuntu-16.04' + strategy: + matrix: + Python36: + python.version: '3.6' + Python38: + python.version: '3.8' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python $(python.version)' + inputs: + versionSpec: '$(python.version)' + - bash: pip install wheel==0.30.0 + displayName: 'Install wheel==0.30.0' + - bash: ./scripts/ci/test_source.sh + displayName: 'Run integration test and build test' + env: + ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) + ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) + +- job: LintModifiedExtensions + displayName: "CLI Linter on Modified Extensions" + condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) + pool: + vmImage: 'ubuntu-16.04' + steps: - task: UsePythonVersion@0 displayName: 'Use Python 3.6' inputs: @@ -222,125 +131,41 @@ stages: set -ev # prepare and activate virtualenv - python -m venv env/ - - chmod +x ./env/bin/activate - source ./env/bin/activate + pip install virtualenv + python -m virtualenv venv/ + source ./venv/bin/activate # clone azure-cli - git clone -q --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli - - pip install -q azdev + git clone --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli - azdev setup -c ../azure-cli -r ./ + pip install azdev azdev --version - az --version - - azdev verify license - - - job: StaticAnalysis - displayName: "Static Analysis" - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.6' - inputs: - versionSpec: 3.6 - - bash: pip install wheel==0.30.0 pylint==1.9.5 flake8==3.5.0 requests - displayName: 'Install wheel, pylint, flake8, requests' - - bash: python scripts/ci/source_code_static_analysis.py - displayName: "Static Analysis" - - - job: IndexVerify - displayName: "Verify Extensions Index" - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.7' - inputs: - versionSpec: 3.7 - - bash: | - #!/usr/bin/env bash - set -ev - pip install wheel==0.30.0 requests packaging - export CI="ADO" - python ./scripts/ci/test_index.py -v - displayName: "Verify Extensions Index" - - - job: SourceTests - displayName: "Integration Tests, Build Tests" - pool: - vmImage: 'ubuntu-16.04' - strategy: - matrix: - Python36: - python.version: '3.6' - Python38: - python.version: '3.8' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python $(python.version)' - inputs: - versionSpec: '$(python.version)' - - bash: pip install wheel==0.30.0 - displayName: 'Install wheel==0.30.0' - - bash: ./scripts/ci/test_source.sh - displayName: 'Run integration test and build test' - env: - ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) - ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) - - - job: LintModifiedExtensions - displayName: "CLI Linter on Modified Extensions" - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.6' - inputs: - versionSpec: 3.6 - - bash: | - set -ev - - # prepare and activate virtualenv - pip install virtualenv - python -m virtualenv venv/ - source ./venv/bin/activate - - # clone azure-cli - git clone --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli - - pip install azdev - - azdev --version - azdev setup -c ../azure-cli -r ./ -e k8s-extension - - # overwrite the default AZURE_EXTENSION_DIR set by ADO - AZURE_EXTENSION_DIR=~/.azure/cliextensions az --version - - AZURE_EXTENSION_DIR=~/.azure/cliextensions azdev linter --include-whl-extensions k8s-extension - displayName: "CLI Linter on Modified Extension" - env: - ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) - ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) + azdev setup -c ../azure-cli -r ./ - - job: IndexRefDocVerify - displayName: "Verify Ref Docs" - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.7' - inputs: - versionSpec: 3.7 - - bash: pip install wheel==0.30.0 - displayName: 'Install wheel==0.30.0' - - task: Bash@3 - displayName: "Verify Extension Ref Docs" - inputs: - targetType: 'filePath' - filePath: scripts/ci/test_index_ref_doc.sh + # overwrite the default AZURE_EXTENSION_DIR set by ADO + AZURE_EXTENSION_DIR=~/.azure/cliextensions az --version + + AZURE_EXTENSION_DIR=~/.azure/cliextensions python scripts/ci/verify_linter.py + displayName: "CLI Linter on Modified Extension" + env: + ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) + ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) + +- job: IndexRefDocVerify + displayName: "Verify Ref Docs" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.7' + inputs: + versionSpec: 3.7 + - bash: pip install wheel==0.30.0 + displayName: 'Install wheel==0.30.0' + - task: Bash@3 + displayName: "Verify Extension Ref Docs" + inputs: + targetType: 'filePath' + filePath: scripts/ci/test_index_ref_doc.sh \ No newline at end of file diff --git a/k8s-custom-pipelines.yml b/k8s-custom-pipelines.yml new file mode 100644 index 00000000000..b0fa1857598 --- /dev/null +++ b/k8s-custom-pipelines.yml @@ -0,0 +1,346 @@ +resources: + repositories: + - repository: K8sPartnerExtensionTest + type: git + endpoint: AzureReposConnection + name: One/compute-HybridMgmt-K8sPartnerExtensionTest + +trigger: + batch: true + branches: + include: + - k8s-extension/public-preview + - k8s-extension/private-preview +pr: + branches: + include: + - k8s-extension/public-preview + - k8s-extension/private-preview + +stages: +- stage: K8sExtensionTestSuite + displayName: "K8s-Extension Test Suite" + variables: + K8S_EXTENSION_REPO_PATH: $(Agent.BuildDirectory)/s/compute-HybridMgmt-K8sPartnerExtensionTest + CLI_REPO_PATH: $(Agent.BuildDirectory)/s/azure-cli-extensions + SUBSCRIPTION_ID: "15c06b1b-01d6-407b-bb21-740b8617dea3" + RESOURCE_GROUP: "K8sPartnerExtensionTest" + BASE_CLUSTER_NAME: "k8s-extension-cluster" + + EXTENSION_NAME: "k8s-extension" + EXTENSION_FILE_NAME: "k8s_extension" + jobs: + - job: K8sExtensionTestSuite + displayName: "Run the Test Suite" + pool: + vmImage: 'ubuntu-16.04' + steps: + - checkout: self + - checkout: K8sPartnerExtensionTest + - bash: | + echo "Installing helm3" + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + + echo "Installing kubectl" + curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" + chmod +x ./kubectl + sudo mv ./kubectl /usr/local/bin/kubectl + kubectl version --client + displayName: "Setup the VM with helm3 and kubectl" + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: | + set -ev + echo "Building extension ${EXTENSION_NAME}..." + + # prepare and activate virtualenv + pip install virtualenv + python3 -m venv env/ + source env/bin/activate + + # clone azure-cli + pip install azdev + + ls $(CLI_REPO_PATH) + + azdev --version + azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME) + azdev extension build $(EXTENSION_NAME) + + workingDirectory: $(CLI_REPO_PATH) + displayName: "Setup and Build Extension with azdev" + + - bash: | + K8S_EXTENSION_VERSION=$(ls ${EXTENSION_FILE_NAME}* | cut -d "-" -f2) + echo "##vso[task.setvariable variable=K8S_EXTENSION_VERSION]$K8S_EXTENSION_VERSION" + cp * $(K8S_EXTENSION_REPO_PATH)/bin + workingDirectory: $(CLI_REPO_PATH)/dist + displayName: "Copy the Built .whl to Extension Test Path" + + - bash: | + RAND_STR=$RANDOM + AKS_CLUSTER_NAME="${BASE_CLUSTER_NAME}-${RAND_STR}-aks" + ARC_CLUSTER_NAME="${BASE_CLUSTER_NAME}-${RAND_STR}-arc" + + JSON_STRING=$(jq -n \ + --arg SUB_ID "$SUBSCRIPTION_ID" \ + --arg RG "$RESOURCE_GROUP" \ + --arg AKS_CLUSTER_NAME "$AKS_CLUSTER_NAME" \ + --arg ARC_CLUSTER_NAME "$ARC_CLUSTER_NAME" \ + --arg K8S_EXTENSION_VERSION "$K8S_EXTENSION_VERSION" \ + '{subscriptionId: $SUB_ID, resourceGroup: $RG, aksClusterName: $AKS_CLUSTER_NAME, arcClusterName: $ARC_CLUSTER_NAME, extensionVersion: {"k8s-extension": $K8S_EXTENSION_VERSION, connectedk8s: "1.0.0"}}') + echo $JSON_STRING > settings.json + cat settings.json + workingDirectory: $(K8S_EXTENSION_REPO_PATH) + displayName: "Generate a settings.json file" + + - bash : | + echo "Downloading the kind script" + curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-linux-amd64 + chmod +x ./kind + ./kind create cluster + displayName: "Create and Start the Kind cluster" + + - task: AzureCLI@2 + displayName: Bootstrap + inputs: + azureSubscription: AzureResourceConnection + scriptType: pscore + scriptLocation: inlineScript + inlineScript: | + .\Bootstrap.ps1 -CI + workingDirectory: $(K8S_EXTENSION_REPO_PATH) + + - task: AzureCLI@2 + displayName: Run the Test Suite + inputs: + azureSubscription: AzureResourceConnection + scriptType: pscore + scriptLocation: inlineScript + inlineScript: | + .\Test.ps1 -CI + workingDirectory: $(K8S_EXTENSION_REPO_PATH) + continueOnError: true + + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: '**/TestResults.xml' + failTaskOnFailedTests: true + condition: succeededOrFailed() + + - task: AzureCLI@2 + displayName: Cleanup + inputs: + azureSubscription: AzureResourceConnection + scriptType: pscore + scriptLocation: inlineScript + inlineScript: | + .\Cleanup.ps1 -CI + workingDirectory: $(K8S_EXTENSION_REPO_PATH) + condition: succeededOrFailed() + +- stage: BuildPublishExtension + dependsOn: [] + displayName: "Build and Publish the Extension Artifact" + variables: + CLI_REPO_PATH: $(Agent.BuildDirectory)/s + IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranchName'], 'refs/heads/k8s-extension/private-preview'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private-preview'))] + jobs: + - job: BuildPublishExtension + displayName: "Build and Publish the Extension Artifact" + pool: + vmImage: 'ubuntu-16.04' + steps: + - bash: | + if [[ $IS_PRIVATE_BRANCH ]]; then + echo "Using the private preview of k8s-extension to build..." + + cp $(CLI_REPO_PATH)/src/k8s-extension $(CLI_REPO_PATH)/src/k8s-extension-private -r + cp $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts_private.py $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts.py + + EXTENSION_NAME="k8s-extension-private" + EXTENSION_FILE_NAME="k8s_extension_private" + + echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" + echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" + else + echo "Using the public version of k8s-extension to build..." + + EXTENSION_NAME="k8s-extension" + EXTENSION_FILE_NAME="k8s_extension" + + echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" + echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" + fi + displayName: "Copy Files, Set Variables based on Private Branch" + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: | + set -ev + echo "Building extension ${EXTENSION_NAME}..." + + # prepare and activate virtualenv + pip install virtualenv + python3 -m venv env/ + source env/bin/activate + + # clone azure-cli + pip install azdev + + ls $(CLI_REPO_PATH) + + azdev --version + azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME) + azdev extension build $(EXTENSION_NAME) + workingDirectory: $(CLI_REPO_PATH) + displayName: "Setup and Build Extension with azdev" + - task: PublishBuildArtifacts@1 + inputs: + pathToPublish: $(CLI_REPO_PATH)/dist + +- stage: AzureCLIOfficial + displayName: "Azure Official CLI Code Checks" + dependsOn: [] + jobs: + - job: CheckLicenseHeader + displayName: "Check License" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: | + set -ev + + # prepare and activate virtualenv + python -m venv env/ + + chmod +x ./env/bin/activate + source ./env/bin/activate + + # clone azure-cli + git clone -q --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli + + pip install -q azdev + + azdev setup -c ../azure-cli -r ./ + + azdev --version + az --version + + azdev verify license + + - job: StaticAnalysis + displayName: "Static Analysis" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: pip install wheel==0.30.0 pylint==1.9.5 flake8==3.5.0 requests + displayName: 'Install wheel, pylint, flake8, requests' + - bash: python scripts/ci/source_code_static_analysis.py + displayName: "Static Analysis" + + - job: IndexVerify + displayName: "Verify Extensions Index" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.7' + inputs: + versionSpec: 3.7 + - bash: | + #!/usr/bin/env bash + set -ev + pip install wheel==0.30.0 requests packaging + export CI="ADO" + python ./scripts/ci/test_index.py -v + displayName: "Verify Extensions Index" + + - job: SourceTests + displayName: "Integration Tests, Build Tests" + pool: + vmImage: 'ubuntu-16.04' + strategy: + matrix: + Python36: + python.version: '3.6' + Python38: + python.version: '3.8' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python $(python.version)' + inputs: + versionSpec: '$(python.version)' + - bash: pip install wheel==0.30.0 + displayName: 'Install wheel==0.30.0' + - bash: ./scripts/ci/test_source.sh + displayName: 'Run integration test and build test' + env: + ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) + ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) + + - job: LintModifiedExtensions + displayName: "CLI Linter on Modified Extensions" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: 3.6 + - bash: | + set -ev + + # prepare and activate virtualenv + pip install virtualenv + python -m virtualenv venv/ + source ./venv/bin/activate + + # clone azure-cli + git clone --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli + + pip install azdev + + azdev --version + + azdev setup -c ../azure-cli -r ./ -e k8s-extension + + # overwrite the default AZURE_EXTENSION_DIR set by ADO + AZURE_EXTENSION_DIR=~/.azure/cliextensions az --version + + AZURE_EXTENSION_DIR=~/.azure/cliextensions azdev linter --include-whl-extensions k8s-extension + displayName: "CLI Linter on Modified Extension" + env: + ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) + ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) + + - job: IndexRefDocVerify + displayName: "Verify Ref Docs" + pool: + vmImage: 'ubuntu-16.04' + steps: + - task: UsePythonVersion@0 + displayName: 'Use Python 3.7' + inputs: + versionSpec: 3.7 + - bash: pip install wheel==0.30.0 + displayName: 'Install wheel==0.30.0' + - task: Bash@3 + displayName: "Verify Extension Ref Docs" + inputs: + targetType: 'filePath' + filePath: scripts/ci/test_index_ref_doc.sh \ No newline at end of file From 009a83e95da65566623e25b4ca43c5553ae58cc2 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Thu, 11 Mar 2021 16:17:09 -0800 Subject: [PATCH 10/31] Update public extension pipeline --- k8s-custom-pipelines.yml | 49 +++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/k8s-custom-pipelines.yml b/k8s-custom-pipelines.yml index b0fa1857598..a5dbceabea2 100644 --- a/k8s-custom-pipelines.yml +++ b/k8s-custom-pipelines.yml @@ -18,8 +18,8 @@ pr: - k8s-extension/private-preview stages: -- stage: K8sExtensionTestSuite - displayName: "K8s-Extension Test Suite" +- stage: BuildTestPublishExtension + displayName: "Build, Test, and Publish Extension" variables: K8S_EXTENSION_REPO_PATH: $(Agent.BuildDirectory)/s/compute-HybridMgmt-K8sPartnerExtensionTest CLI_REPO_PATH: $(Agent.BuildDirectory)/s/azure-cli-extensions @@ -144,40 +144,37 @@ stages: workingDirectory: $(K8S_EXTENSION_REPO_PATH) condition: succeededOrFailed() -- stage: BuildPublishExtension - dependsOn: [] - displayName: "Build and Publish the Extension Artifact" - variables: - CLI_REPO_PATH: $(Agent.BuildDirectory)/s - IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranchName'], 'refs/heads/k8s-extension/private-preview'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private-preview'))] - jobs: - job: BuildPublishExtension - displayName: "Build and Publish the Extension Artifact" pool: vmImage: 'ubuntu-16.04' + displayName: "Build and Publish the Extension Artifact" + variables: + CLI_REPO_PATH: $(Agent.BuildDirectory)/s + IS_PRIVATE_BRANCH: $[or(and(eq(variables['Build.SourceBranchName'], 'refs/heads/k8s-extension/private-preview'), ne(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/public-preview')), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private-preview'))] steps: - bash: | - if [[ $IS_PRIVATE_BRANCH ]]; then - echo "Using the private preview of k8s-extension to build..." + echo "Using the private preview of k8s-extension to build..." - cp $(CLI_REPO_PATH)/src/k8s-extension $(CLI_REPO_PATH)/src/k8s-extension-private -r - cp $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts_private.py $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts.py + cp $(CLI_REPO_PATH)/src/k8s-extension $(CLI_REPO_PATH)/src/k8s-extension-private -r + cp $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts_private.py $(CLI_REPO_PATH)/src/k8s-extension-private/azext_k8s_extension/_consts.py - EXTENSION_NAME="k8s-extension-private" - EXTENSION_FILE_NAME="k8s_extension_private" + EXTENSION_NAME="k8s-extension-private" + EXTENSION_FILE_NAME="k8s_extension_private" - echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" - echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" - else - echo "Using the public version of k8s-extension to build..." + echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" + echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" + condition: and(succeeded(), eq(variables['IS_PRIVATE_BRANCH'], 'True')) + displayName: "Copy Files, Set Variables for k8s-extension-private" + - bash: | + echo "Using the public version of k8s-extension to build..." - EXTENSION_NAME="k8s-extension" - EXTENSION_FILE_NAME="k8s_extension" + EXTENSION_NAME="k8s-extension" + EXTENSION_FILE_NAME="k8s_extension" - echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" - echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" - fi - displayName: "Copy Files, Set Variables based on Private Branch" + echo "##vso[task.setvariable variable=EXTENSION_NAME]$EXTENSION_NAME" + echo "##vso[task.setvariable variable=EXTENSION_FILE_NAME]$EXTENSION_FILE_NAME" + condition: and(succeeded(), eq(variables['IS_PRIVATE_BRANCH'], 'False')) + displayName: "Copy Files, Set Variables for k8s-extension" - task: UsePythonVersion@0 displayName: 'Use Python 3.6' inputs: From 8e058c595946f45740c87ef6576349235d41ca76 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Thu, 11 Mar 2021 16:23:38 -0800 Subject: [PATCH 11/31] Change condition variable --- k8s-custom-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s-custom-pipelines.yml b/k8s-custom-pipelines.yml index a5dbceabea2..5bf0489f053 100644 --- a/k8s-custom-pipelines.yml +++ b/k8s-custom-pipelines.yml @@ -150,7 +150,7 @@ stages: displayName: "Build and Publish the Extension Artifact" variables: CLI_REPO_PATH: $(Agent.BuildDirectory)/s - IS_PRIVATE_BRANCH: $[or(and(eq(variables['Build.SourceBranchName'], 'refs/heads/k8s-extension/private-preview'), ne(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/public-preview')), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private-preview'))] + IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/k8s-extension/private-preview'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private-preview'))] steps: - bash: | echo "Using the private preview of k8s-extension to build..." From dea40c19ce9c5371ea7527f120c492ab2e6f6619 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Thu, 11 Mar 2021 17:47:00 -0800 Subject: [PATCH 12/31] Add version to public preview/private preview --- src/k8s-extension/azext_k8s_extension/_consts.py | 1 + src/k8s-extension/azext_k8s_extension/_consts_private.py | 1 + src/k8s-extension/setup.py | 6 +----- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/k8s-extension/azext_k8s_extension/_consts.py b/src/k8s-extension/azext_k8s_extension/_consts.py index e9f8156f307..820e38af31c 100644 --- a/src/k8s-extension/azext_k8s_extension/_consts.py +++ b/src/k8s-extension/azext_k8s_extension/_consts.py @@ -5,3 +5,4 @@ # -------------------------------------------------------------------------------------------- EXTENSION_NAME = 'k8s-extension' +VERSION = "0.1.1" diff --git a/src/k8s-extension/azext_k8s_extension/_consts_private.py b/src/k8s-extension/azext_k8s_extension/_consts_private.py index 18a01637c2d..bc4c8a2b694 100644 --- a/src/k8s-extension/azext_k8s_extension/_consts_private.py +++ b/src/k8s-extension/azext_k8s_extension/_consts_private.py @@ -5,3 +5,4 @@ # -------------------------------------------------------------------------------------------- EXTENSION_NAME = 'k8s-extension-private' +VERSION = "0.1PP.14" diff --git a/src/k8s-extension/setup.py b/src/k8s-extension/setup.py index 878f7f8d87a..d3d491fd48c 100644 --- a/src/k8s-extension/setup.py +++ b/src/k8s-extension/setup.py @@ -15,10 +15,6 @@ from distutils import log as logger logger.warn("Wheel is not available, disabling bdist_wheel hook") -# TODO: Confirm this is the right version number you want and it matches your -# HISTORY.rst entry. -VERSION = '0.1PP.14' - # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers CLASSIFIERS = [ @@ -43,7 +39,7 @@ setup( name=consts.EXTENSION_NAME, - version=VERSION, + version=consts.VERSION, description='Microsoft Azure Command-Line Tools K8s-extension Extension', # TODO: Update author and email, if applicable author='Microsoft Corporation', From e81e0101493c99a361576211c95d3e118449b1dd Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Fri, 12 Mar 2021 12:10:48 -0800 Subject: [PATCH 13/31] Update pipelines --- k8s-custom-pipelines.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/k8s-custom-pipelines.yml b/k8s-custom-pipelines.yml index 5bf0489f053..a4be34c3e7b 100644 --- a/k8s-custom-pipelines.yml +++ b/k8s-custom-pipelines.yml @@ -9,13 +9,13 @@ trigger: batch: true branches: include: - - k8s-extension/public-preview - - k8s-extension/private-preview + - k8s-extension/public + - k8s-extension/private pr: branches: include: - - k8s-extension/public-preview - - k8s-extension/private-preview + - k8s-extension/public + - k8s-extension/private stages: - stage: BuildTestPublishExtension @@ -150,7 +150,7 @@ stages: displayName: "Build and Publish the Extension Artifact" variables: CLI_REPO_PATH: $(Agent.BuildDirectory)/s - IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/k8s-extension/private-preview'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private-preview'))] + IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/k8s-extension/private'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private'))] steps: - bash: | echo "Using the private preview of k8s-extension to build..." From 9621a48df1feda8134be4a98df3a41d2b44e08b2 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Fri, 12 Mar 2021 13:13:39 -0800 Subject: [PATCH 14/31] Add different testing based on private branch --- k8s-custom-pipelines.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/k8s-custom-pipelines.yml b/k8s-custom-pipelines.yml index a4be34c3e7b..3bdfd70eb99 100644 --- a/k8s-custom-pipelines.yml +++ b/k8s-custom-pipelines.yml @@ -26,6 +26,7 @@ stages: SUBSCRIPTION_ID: "15c06b1b-01d6-407b-bb21-740b8617dea3" RESOURCE_GROUP: "K8sPartnerExtensionTest" BASE_CLUSTER_NAME: "k8s-extension-cluster" + IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/k8s-extension/private'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private'))] EXTENSION_NAME: "k8s-extension" EXTENSION_FILE_NAME: "k8s_extension" @@ -116,7 +117,19 @@ stages: workingDirectory: $(K8S_EXTENSION_REPO_PATH) - task: AzureCLI@2 - displayName: Run the Test Suite + displayName: Run the Test Suite Public Extensions Only + inputs: + azureSubscription: AzureResourceConnection + scriptType: pscore + scriptLocation: inlineScript + inlineScript: | + .\Test.ps1 -CI -Public + workingDirectory: $(K8S_EXTENSION_REPO_PATH) + continueOnError: true + condition: and(succeeded(), eq(variables['IS_PRIVATE_BRANCH'], 'False')) + + - task: AzureCLI@2 + displayName: Run the Test Suite on Private + Public Extensions inputs: azureSubscription: AzureResourceConnection scriptType: pscore @@ -125,6 +138,7 @@ stages: .\Test.ps1 -CI workingDirectory: $(K8S_EXTENSION_REPO_PATH) continueOnError: true + condition: and(succeeded(), eq(variables['IS_PRIVATE_BRANCH'], 'True')) - task: PublishTestResults@2 inputs: @@ -150,7 +164,6 @@ stages: displayName: "Build and Publish the Extension Artifact" variables: CLI_REPO_PATH: $(Agent.BuildDirectory)/s - IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/k8s-extension/private'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private'))] steps: - bash: | echo "Using the private preview of k8s-extension to build..." From 862a0355c54da89a13169de57dc92e07655e7a14 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Fri, 12 Mar 2021 13:22:30 -0800 Subject: [PATCH 15/31] Add annotations to extension model --- src/k8s-extension/azext_k8s_extension/custom.py | 6 +++--- .../partner_extensions/AzureDefender.py | 4 ++-- .../partner_extensions/ContainerInsights.py | 4 ++-- .../partner_extensions/DefaultExtension.py | 2 +- .../partner_extensions/PartnerExtensionModel.py | 14 +++++++++----- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index 4b0657c1814..b06567aca0b 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -17,9 +17,9 @@ # from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate from azext_k8s_extension.vendored_sdks.models import ErrorResponseException -from .partner_extensions.ContainerInsights import ContainerInsights -from .partner_extensions.AzureDefender import AzureDefender -from .partner_extensions.DefaultExtension import DefaultExtension +from azext_k8s_extension.partner_extensions.ContainerInsights import ContainerInsights +from azext_k8s_extension.partner_extensions.AzureDefender import AzureDefender +from azext_k8s_extension.partner_extensions.DefaultExtension import DefaultExtension from ._client_factory import cf_resources diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py index 172662f4e57..39329cc36cb 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py @@ -12,8 +12,8 @@ from azext_k8s_extension.vendored_sdks.models import ScopeCluster from azext_k8s_extension.vendored_sdks.models import Scope -from .PartnerExtensionModel import PartnerExtensionModel -from .ContainerInsights import _get_container_insights_settings +from azext_k8s_extension.partner_extensions.PartnerExtensionModel import PartnerExtensionModel +from azext_k8s_extension.partner_extensions.ContainerInsights import _get_container_insights_settings logger = get_logger(__name__) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py index ada94d985a9..f6662c29611 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py @@ -22,9 +22,9 @@ from azext_k8s_extension.vendored_sdks.models import ScopeCluster from azext_k8s_extension.vendored_sdks.models import Scope -from .PartnerExtensionModel import PartnerExtensionModel +from azext_k8s_extension.partner_extensions.PartnerExtensionModel import PartnerExtensionModel -from .._client_factory import ( +from azext_k8s_extension._client_factory import ( cf_resources, cf_resource_groups, cf_log_analytics) logger = get_logger(__name__) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py index 243371e47b7..d3e9a6827c2 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py @@ -11,7 +11,7 @@ from azext_k8s_extension.vendored_sdks.models import ScopeNamespace from azext_k8s_extension.vendored_sdks.models import Scope -from .PartnerExtensionModel import PartnerExtensionModel +from azext_k8s_extension.partner_extensions.PartnerExtensionModel import PartnerExtensionModel class DefaultExtension(PartnerExtensionModel): diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py index c863a8d3833..c0bf3b6e657 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py @@ -4,16 +4,20 @@ # -------------------------------------------------------------------------------------------- from abc import ABC, abstractmethod +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate class PartnerExtensionModel(ABC): @abstractmethod - def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, - scope, auto_upgrade_minor_version, release_train, version, target_namespace, - release_namespace, configuration_settings, configuration_protected_settings, - configuration_settings_file, configuration_protected_settings_file): + def Create(self, cmd, client, resource_group_name: str, cluster_name: str, name: str, cluster_type: str, + extension_type: str, scope: str, auto_upgrade_minor_version: bool, release_train: str, version: str, + target_namespace: str, release_namespace: str, configuration_settings: dict, + configuration_protected_settings: dict, configuration_settings_file: str, + configuration_protected_settings_file: str) -> ExtensionInstanceForCreate: pass @abstractmethod - def Update(self, extension, auto_upgrade_minor_version, release_train, version): + def Update(self, extension: ExtensionInstanceForCreate, auto_upgrade_minor_version: bool, + release_train: str, version: str) -> ExtensionInstanceUpdate: pass From e1c3d12cd8a58e98cd5d2e9575d3d96fdc585bc3 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Mon, 15 Mar 2021 11:41:42 -0700 Subject: [PATCH 16/31] Update k8s-custom-pipelines.yml --- k8s-custom-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/k8s-custom-pipelines.yml b/k8s-custom-pipelines.yml index 3bdfd70eb99..f4e2984ddf2 100644 --- a/k8s-custom-pipelines.yml +++ b/k8s-custom-pipelines.yml @@ -123,7 +123,7 @@ stages: scriptType: pscore scriptLocation: inlineScript inlineScript: | - .\Test.ps1 -CI -Public + .\Test.ps1 -CI -ExtensionType Public -OnlyPublicTests workingDirectory: $(K8S_EXTENSION_REPO_PATH) continueOnError: true condition: and(succeeded(), eq(variables['IS_PRIVATE_BRANCH'], 'False')) @@ -135,7 +135,7 @@ stages: scriptType: pscore scriptLocation: inlineScript inlineScript: | - .\Test.ps1 -CI + .\Test.ps1 -CI -ExtensionType Public workingDirectory: $(K8S_EXTENSION_REPO_PATH) continueOnError: true condition: and(succeeded(), eq(variables['IS_PRIVATE_BRANCH'], 'True')) @@ -353,4 +353,4 @@ stages: displayName: "Verify Extension Ref Docs" inputs: targetType: 'filePath' - filePath: scripts/ci/test_index_ref_doc.sh \ No newline at end of file + filePath: scripts/ci/test_index_ref_doc.sh From 3e309bf8d1218994b3135a9614e03b0e2cf41e88 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Tue, 16 Mar 2021 11:01:39 -0700 Subject: [PATCH 17/31] Update SDKs with Updated Swagger Spec for 2020-07-01-preview (#13) * Update sdks with updated swagger spec * Update version and history rst * Reorder release history timeline * Fix ExtensionInstanceForCreate for import --- src/k8s-extension/HISTORY.rst | 70 +-- .../azext_k8s_extension/_client_factory.py | 6 +- .../azext_k8s_extension/_consts.py | 2 +- .../partner_extensions/AzureDefender.py | 8 +- .../partner_extensions/ContainerInsights.py | 8 +- .../partner_extensions/DefaultExtension.py | 6 +- .../PartnerExtensionModel.py | 6 +- .../vendored_sdks/__init__.py | 6 +- .../vendored_sdks/_configuration.py | 6 +- .../_source_control_configuration_client.py | 60 +++ .../vendored_sdks/models/__init__.py | 48 +- .../vendored_sdks/models/_models.py | 473 +++++++++++------ .../vendored_sdks/models/_models_py3.py | 483 +++++++++++------- .../vendored_sdks/models/_paged_models.py | 21 +- ...rce_control_configuration_client_enums.py} | 0 .../vendored_sdks/operations/__init__.py | 8 +- ...perations.py => _extensions_operations.py} | 119 ++--- .../vendored_sdks/operations/_operations.py | 101 ++++ ...ource_control_configurations_operations.py | 386 ++++++++++++++ .../vendored_sdks/version.py | 2 +- 20 files changed, 1304 insertions(+), 515 deletions(-) create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/_source_control_configuration_client.py rename src/k8s-extension/azext_k8s_extension/vendored_sdks/models/{_k8s_extension_client_enums.py => _source_control_configuration_client_enums.py} (100%) rename src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/{_k8s_extensions_operations.py => _extensions_operations.py} (84%) create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_operations.py create mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_source_control_configurations_operations.py diff --git a/src/k8s-extension/HISTORY.rst b/src/k8s-extension/HISTORY.rst index 695f549b1a2..54c1e375f6f 100644 --- a/src/k8s-extension/HISTORY.rst +++ b/src/k8s-extension/HISTORY.rst @@ -3,81 +3,33 @@ Release History =============== -0.1.0 -++++++++++++++++++ -* Initial release. - -0.1.1 -++++++++++++++++++ -* Add support for microsoft-azure-defender extension type - -0.1.2 -++++++++++++++++++ - -* Add support for Arc Appliance cluster type - -0.1.3 -++++++++++++++++++ - -* Customization for microsoft.openservicemesh - -0.1PP.4 +0.2.0 ++++++++++++++++++ * Refactor for clear separation of extension-type specific customizations -* Introduce new versioning scheme to allow Preview releases by Partners - -0.1PP.5 -++++++++++++++++++ - -* OpenServiceMesh customization. -* If Version is passed in, accept None for AutoUpgradeMinorVersion, and not require it to be False. - -0.1PP.6 -++++++++++++++++++ - * OpenServiceMesh customization. -* Scope is always cluster. Version is mandatory for staging and pilot release-trains. - -0.1PP.7 -++++++++++++++++++ - * Fix clusterType of Microsoft.ResourceConnector resource - -0.1PP.8 -++++++++++++++++++ - * Update clusterType validation to allow 'appliances' * Update identity creation to use the appropriate parent resource's type and api-version * Throw error if cluster type is not one of the 3 supported types - -0.1PP.9 -++++++++++++++++++ - * Rename azuremonitor-containers extension type to microsoft.azuremonitor.containers +* Move CLI errors to non-deprecated error types +* Remove support for update -0.1PP.10 -++++++++++++++++++ - -* Add azuremonitor-containers back with alternative microsoft.azuremonitor.containers - -0.1PP.11 +0.1.3 ++++++++++++++++++ -* Add shorter aliases for long parameter names +* Customization for microsoft.openservicemesh -0.1PP.12 +0.1.2 ++++++++++++++++++ -* Remove support for azuremonitor-containers extension type naming +* Add support for Arc Appliance cluster type -0.1PP.13 +0.1.1 ++++++++++++++++++ +* Add support for microsoft-azure-defender extension type -* Move CLI errors to non-deprecated error types -* Remove support for update - -0.1PP.14 +0.1.0 ++++++++++++++++++ - -* Update help text, group CLI arguments +* Initial release. diff --git a/src/k8s-extension/azext_k8s_extension/_client_factory.py b/src/k8s-extension/azext_k8s_extension/_client_factory.py index a4ec83ee0cb..1a9a10c2615 100644 --- a/src/k8s-extension/azext_k8s_extension/_client_factory.py +++ b/src/k8s-extension/azext_k8s_extension/_client_factory.py @@ -8,12 +8,12 @@ def cf_k8s_extension(cli_ctx, *_): - from azext_k8s_extension.vendored_sdks import K8sExtensionClient - return get_mgmt_service_client(cli_ctx, K8sExtensionClient) + from azext_k8s_extension.vendored_sdks import SourceControlConfigurationClient + return get_mgmt_service_client(cli_ctx, SourceControlConfigurationClient) def cf_k8s_extension_operation(cli_ctx, _): - return cf_k8s_extension(cli_ctx).k8s_extensions + return cf_k8s_extension(cli_ctx).extensions def cf_resource_groups(cli_ctx, subscription_id=None): diff --git a/src/k8s-extension/azext_k8s_extension/_consts.py b/src/k8s-extension/azext_k8s_extension/_consts.py index 820e38af31c..d0fdaf7775f 100644 --- a/src/k8s-extension/azext_k8s_extension/_consts.py +++ b/src/k8s-extension/azext_k8s_extension/_consts.py @@ -5,4 +5,4 @@ # -------------------------------------------------------------------------------------------- EXTENSION_NAME = 'k8s-extension' -VERSION = "0.1.1" +VERSION = "0.2.0" diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py index 39329cc36cb..7721ea8c638 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py @@ -7,7 +7,7 @@ from knack.log import get_logger -from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate +from azext_k8s_extension.vendored_sdks.models import ExtensionInstance from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate from azext_k8s_extension.vendored_sdks.models import ScopeCluster from azext_k8s_extension.vendored_sdks.models import Scope @@ -25,7 +25,7 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t configuration_settings_file, configuration_protected_settings_file): """ExtensionType 'microsoft.azuredefender.kubernetes' specific validations & defaults for Create - Must create and return a valid 'ExtensionInstanceForCreate' object. + Must create and return a valid 'ExtensionInstance' object. """ # NOTE-1: Replace default scope creation with your customization! @@ -46,9 +46,9 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t _get_container_insights_settings(cmd, resource_group_name, cluster_name, configuration_settings, configuration_protected_settings, is_ci_extension_type) - # NOTE-2: Return a valid ExtensionInstanceForCreate object, Instance name and flag for Identity + # NOTE-2: Return a valid ExtensionInstance object, Instance name and flag for Identity create_identity = True - extension_instance = ExtensionInstanceForCreate( + extension_instance = ExtensionInstance( extension_type=extension_type, auto_upgrade_minor_version=auto_upgrade_minor_version, release_train=release_train, diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py index f6662c29611..a90b807020d 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py @@ -17,7 +17,7 @@ from msrestazure.azure_exceptions import CloudError from msrestazure.tools import parse_resource_id, is_valid_resource_id -from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate +from azext_k8s_extension.vendored_sdks.models import ExtensionInstance from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate from azext_k8s_extension.vendored_sdks.models import ScopeCluster from azext_k8s_extension.vendored_sdks.models import Scope @@ -37,7 +37,7 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t configuration_settings_file, configuration_protected_settings_file): """ExtensionType 'microsoft.azuremonitor.containers' specific validations & defaults for Create - Must create and return a valid 'ExtensionInstanceForCreate' object. + Must create and return a valid 'ExtensionInstance' object. """ # NOTE-1: Replace default scope creation with your customization! @@ -58,9 +58,9 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t _get_container_insights_settings(cmd, resource_group_name, cluster_name, configuration_settings, configuration_protected_settings, is_ci_extension_type) - # NOTE-2: Return a valid ExtensionInstanceForCreate object, Instance name and flag for Identity + # NOTE-2: Return a valid ExtensionInstance object, Instance name and flag for Identity create_identity = True - extension_instance = ExtensionInstanceForCreate( + extension_instance = ExtensionInstance( extension_type=extension_type, auto_upgrade_minor_version=auto_upgrade_minor_version, release_train=release_train, diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py index d3e9a6827c2..8e813502edd 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py @@ -5,7 +5,7 @@ # pylint: disable=unused-argument -from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate +from azext_k8s_extension.vendored_sdks.models import ExtensionInstance from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate from azext_k8s_extension.vendored_sdks.models import ScopeCluster from azext_k8s_extension.vendored_sdks.models import ScopeNamespace @@ -21,7 +21,7 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t configuration_settings_file, configuration_protected_settings_file): """Default validations & defaults for Create - Must create and return a valid 'ExtensionInstanceForCreate' object. + Must create and return a valid 'ExtensionInstance' object. """ ext_scope = None @@ -37,7 +37,7 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t release_train = 'stable' create_identity = False - extension_instance = ExtensionInstanceForCreate( + extension_instance = ExtensionInstance( extension_type=extension_type, auto_upgrade_minor_version=auto_upgrade_minor_version, release_train=release_train, diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py index c0bf3b6e657..96c489644e7 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py @@ -4,7 +4,7 @@ # -------------------------------------------------------------------------------------------- from abc import ABC, abstractmethod -from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceForCreate +from azext_k8s_extension.vendored_sdks.models import ExtensionInstance from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate @@ -14,10 +14,10 @@ def Create(self, cmd, client, resource_group_name: str, cluster_name: str, name: extension_type: str, scope: str, auto_upgrade_minor_version: bool, release_train: str, version: str, target_namespace: str, release_namespace: str, configuration_settings: dict, configuration_protected_settings: dict, configuration_settings_file: str, - configuration_protected_settings_file: str) -> ExtensionInstanceForCreate: + configuration_protected_settings_file: str) -> ExtensionInstance: pass @abstractmethod - def Update(self, extension: ExtensionInstanceForCreate, auto_upgrade_minor_version: bool, + def Update(self, extension: ExtensionInstance, auto_upgrade_minor_version: bool, release_train: str, version: str) -> ExtensionInstanceUpdate: pass diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/__init__.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/__init__.py index d94dccac4c2..874177b4d34 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/__init__.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/__init__.py @@ -9,9 +9,9 @@ # regenerated. # -------------------------------------------------------------------------- -from ._configuration import K8sExtensionClientConfiguration -from ._k8s_extension_client import K8sExtensionClient -__all__ = ['K8sExtensionClient', 'K8sExtensionClientConfiguration'] +from ._configuration import SourceControlConfigurationClientConfiguration +from ._source_control_configuration_client import SourceControlConfigurationClient +__all__ = ['SourceControlConfigurationClient', 'SourceControlConfigurationClientConfiguration'] from .version import VERSION diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/_configuration.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/_configuration.py index 48080b2ee7d..5043ed69594 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/_configuration.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/_configuration.py @@ -13,8 +13,8 @@ from .version import VERSION -class K8sExtensionClientConfiguration(AzureConfiguration): - """Configuration for K8sExtensionClient +class SourceControlConfigurationClientConfiguration(AzureConfiguration): + """Configuration for SourceControlConfigurationClient Note that all parameters used to create this instance are saved as instance attributes. @@ -37,7 +37,7 @@ def __init__( if not base_url: base_url = 'https://management.azure.com' - super(K8sExtensionClientConfiguration, self).__init__(base_url) + super(SourceControlConfigurationClientConfiguration, self).__init__(base_url) # Starting Autorest.Python 4.0.64, make connection pool activated by default self.keep_alive = True diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/_source_control_configuration_client.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/_source_control_configuration_client.py new file mode 100644 index 00000000000..a77176d8cb1 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/_source_control_configuration_client.py @@ -0,0 +1,60 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import SourceControlConfigurationClientConfiguration +from .operations import SourceControlConfigurationsOperations +from .operations import Operations +from .operations import ExtensionsOperations +from . import models + + +class SourceControlConfigurationClient(SDKClient): + """KubernetesConfiguration Client + + :ivar config: Configuration for client. + :vartype config: SourceControlConfigurationClientConfiguration + + :ivar source_control_configurations: SourceControlConfigurations operations + :vartype source_control_configurations: azure.mgmt.kubernetesconfiguration.operations.SourceControlConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.kubernetesconfiguration.operations.Operations + :ivar extensions: Extensions operations + :vartype extensions: azure.mgmt.kubernetesconfiguration.operations.ExtensionsOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The Azure subscription ID. This is a + GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = SourceControlConfigurationClientConfiguration(credentials, subscription_id, base_url) + super(SourceControlConfigurationClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2020-07-01-preview' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.source_control_configurations = SourceControlConfigurationsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self.config, self._serialize, self._deserialize) + self.extensions = ExtensionsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/__init__.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/__init__.py index 166f80c01ea..e74cb56832b 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/__init__.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/__init__.py @@ -10,60 +10,84 @@ # -------------------------------------------------------------------------- try: + from ._models_py3 import ComplianceStatus + from ._models_py3 import ConfigurationIdentity from ._models_py3 import ErrorDefinition from ._models_py3 import ErrorResponse, ErrorResponseException from ._models_py3 import ExtensionInstance - from ._models_py3 import ExtensionInstanceForCreate - from ._models_py3 import ExtensionInstanceForList from ._models_py3 import ExtensionInstanceUpdate from ._models_py3 import ExtensionStatus + from ._models_py3 import HelmOperatorProperties from ._models_py3 import ProxyResource from ._models_py3 import Resource + from ._models_py3 import ResourceProviderOperation + from ._models_py3 import ResourceProviderOperationDisplay from ._models_py3 import Result from ._models_py3 import Scope from ._models_py3 import ScopeCluster from ._models_py3 import ScopeNamespace - from ._models_py3 import ConfigurationIdentity + from ._models_py3 import SourceControlConfiguration + from ._models_py3 import SystemData except (SyntaxError, ImportError): + from ._models import ComplianceStatus + from ._models import ConfigurationIdentity from ._models import ErrorDefinition from ._models import ErrorResponse, ErrorResponseException from ._models import ExtensionInstance - from ._models import ExtensionInstanceForCreate - from ._models import ExtensionInstanceForList from ._models import ExtensionInstanceUpdate from ._models import ExtensionStatus + from ._models import HelmOperatorProperties from ._models import ProxyResource from ._models import Resource + from ._models import ResourceProviderOperation + from ._models import ResourceProviderOperationDisplay from ._models import Result from ._models import Scope from ._models import ScopeCluster from ._models import ScopeNamespace - from ._models import ConfigurationIdentity -from ._paged_models import ExtensionInstanceForListPaged -from ._k8s_extension_client_enums import ( + from ._models import SourceControlConfiguration + from ._models import SystemData +from ._paged_models import ExtensionInstancePaged +from ._paged_models import ResourceProviderOperationPaged +from ._paged_models import SourceControlConfigurationPaged +from ._source_control_configuration_client_enums import ( + ComplianceStateType, MessageLevelType, + OperatorType, + OperatorScopeType, + ProvisioningStateType, InstallStateType, LevelType, ResourceIdentityType, ) __all__ = [ + 'ComplianceStatus', + 'ConfigurationIdentity', 'ErrorDefinition', 'ErrorResponse', 'ErrorResponseException', 'ExtensionInstance', - 'ExtensionInstanceForCreate', - 'ExtensionInstanceForList', - 'ConfigurationIdentity', 'ExtensionInstanceUpdate', 'ExtensionStatus', + 'HelmOperatorProperties', 'ProxyResource', 'Resource', + 'ResourceProviderOperation', + 'ResourceProviderOperationDisplay', 'Result', 'Scope', 'ScopeCluster', 'ScopeNamespace', - 'ExtensionInstanceForListPaged', + 'SourceControlConfiguration', + 'SystemData', + 'SourceControlConfigurationPaged', + 'ResourceProviderOperationPaged', + 'ExtensionInstancePaged', + 'ComplianceStateType', 'MessageLevelType', + 'OperatorType', + 'OperatorScopeType', + 'ProvisioningStateType', 'InstallStateType', 'LevelType', 'ResourceIdentityType', diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py index 0a11097a24f..da1b94606cd 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py @@ -20,6 +20,47 @@ class CloudError(Model): _attribute_map = { } + +class ComplianceStatus(Model): + """Compliance Status details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar compliance_state: The compliance state of the configuration. + Possible values include: 'Pending', 'Compliant', 'Noncompliant', + 'Installed', 'Failed' + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.models.ComplianceStateType + :param last_config_applied: Datetime the configuration was last applied. + :type last_config_applied: datetime + :param message: Message from when the configuration was applied. + :type message: str + :param message_level: Level of the message. Possible values include: + 'Error', 'Warning', 'Information' + :type message_level: str or + ~azure.mgmt.kubernetesconfiguration.models.MessageLevelType + """ + + _validation = { + 'compliance_state': {'readonly': True}, + } + + _attribute_map = { + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, + 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, + 'message': {'key': 'message', 'type': 'str'}, + 'message_level': {'key': 'messageLevel', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ComplianceStatus, self).__init__(**kwargs) + self.compliance_state = None + self.last_config_applied = kwargs.get('last_config_applied', None) + self.message = kwargs.get('message', None) + self.message_level = kwargs.get('message_level', None) + + class ConfigurationIdentity(Model): """Identity for the managed cluster. @@ -126,6 +167,9 @@ class Resource(Model): :vartype name: str :ivar type: Resource type :vartype type: str + :param system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData """ _validation = { @@ -138,6 +182,7 @@ class Resource(Model): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__(self, **kwargs): @@ -145,6 +190,7 @@ def __init__(self, **kwargs): self.id = None self.name = None self.type = None + self.system_data = kwargs.get('system_data', None) class ProxyResource(Resource): @@ -159,6 +205,9 @@ class ProxyResource(Resource): :vartype name: str :ivar type: Resource type :vartype type: str + :param system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData """ _validation = { @@ -171,6 +220,7 @@ class ProxyResource(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__(self, **kwargs): @@ -189,6 +239,9 @@ class ExtensionInstance(ProxyResource): :vartype name: str :ivar type: Resource type :vartype type: str + :param system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData :param extension_type: Type of the Extension, of which this resource is an instance of. It must be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the Extension publisher. @@ -209,6 +262,10 @@ class ExtensionInstance(ProxyResource): :param configuration_settings: Configuration settings, as name-value pairs for configuring this instance of the extension. :type configuration_settings: dict[str, str] + :param configuration_protected_settings: Configuration settings that are + sensitive, as name-value pairs for configuring this instance of the + extension. + :type configuration_protected_settings: dict[str, str] :param install_state: Status of installation of this instance of the extension. Possible values include: 'Pending', 'Installed', 'Failed' :type install_state: str or @@ -248,19 +305,21 @@ class ExtensionInstance(ProxyResource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, 'version': {'key': 'properties.version', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'Scope'}, 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, 'install_state': {'key': 'properties.installState', 'type': 'str'}, 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, - 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, + 'identity': {'key': 'properties.identity', 'type': 'ConfigurationIdentity'}, } def __init__(self, **kwargs): @@ -271,176 +330,9 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) self.scope = kwargs.get('scope', None) self.configuration_settings = kwargs.get('configuration_settings', None) - self.install_state = kwargs.get('install_state', None) - self.statuses = kwargs.get('statuses', None) - self.creation_time = None - self.last_modified_time = None - self.last_status_time = None - self.error_info = None - self.identity = kwargs.get('identity', None) - - -class ExtensionInstanceForCreate(ProxyResource): - """Object to create a new Extension Instance. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: Resource Id - :vartype id: str - :ivar name: Resource name - :vartype name: str - :ivar type: Resource type - :vartype type: str - :param extension_type: Type of the Extension, of which this resource is an - instance of. It must be one of the Extension Types registered with - Microsoft.KubernetesConfiguration by the Extension publisher. - :type extension_type: str - :param auto_upgrade_minor_version: Flag to note if this instance - participates in auto upgrade of minor version, or not. - :type auto_upgrade_minor_version: bool - :param release_train: ReleaseTrain this extension instance participates in - for auto-upgrade (e.g. Stable, Preview, etc.) - only if - autoUpgradeMinorVersion is 'true'. - :type release_train: str - :param version: Version of the extension for this extension instance, if - it is 'pinned' to a specific version. autoUpgradeMinorVersion must be - 'false'. - :type version: str - :param scope: Scope at which the extension instance is installed. - :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope - :param configuration_settings: Configuration settings, as name-value pairs - for configuring this instance of the extension. - :type configuration_settings: dict[str, str] - :param configuration_protected_settings: Configuration settings that are - sensitive, as name-value pairs for configuring this instance of the - extension. - :type configuration_protected_settings: dict[str, str] - :param identity: The identity of the configuration. - :type identity: - ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(ExtensionInstanceForCreate, self).__init__(**kwargs) - self.extension_type = kwargs.get('extension_type', None) - self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) - self.release_train = kwargs.get('release_train', None) - self.version = kwargs.get('version', None) - self.scope = kwargs.get('scope', None) - self.configuration_settings = kwargs.get('configuration_settings', None) self.configuration_protected_settings = kwargs.get('configuration_protected_settings', None) - self.identity = kwargs.get('identity', None) - self.location = kwargs.get('location', None) - - -class ExtensionInstanceForList(ProxyResource): - """The Extension Instance object. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: Resource Id - :vartype id: str - :ivar name: Resource name - :vartype name: str - :ivar type: Resource type - :vartype type: str - :param extension_type: Type of the Extension, of which this resource is an - instance of. It must be one of the Extension Types registered with - Microsoft.KubernetesConfiguration by the Extension publisher. - :type extension_type: str - :param auto_upgrade_minor_version: Flag to note if this instance - participates in auto upgrade of minor version, or not. - :type auto_upgrade_minor_version: bool - :param release_train: ReleaseTrain this extension instance participates in - for auto-upgrade (e.g. Stable, Preview, etc.) - only if - autoUpgradeMinorVersion is 'true'. - :type release_train: str - :param version: Version of the extension for this extension instance, if - it is 'pinned' to a specific version. - :type version: str - :param scope: Scope at which the extension instance is installed. - :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope - :param install_state: Status of installation of this instance of the - extension. Possible values include: 'Pending', 'Installed', 'Failed' - :type install_state: str or - ~azure.mgmt.kubernetesconfiguration.models.InstallStateType - :ivar creation_time: DateLiteral (per ISO8601) noting the time the - resource was created by the client (user). - :vartype creation_time: str - :ivar last_modified_time: DateLiteral (per ISO8601) noting the time the - resource was modified by the client (user). - :vartype last_modified_time: str - :ivar last_status_time: DateLiteral (per ISO8601) noting the time of last - status from the agent. - :vartype last_status_time: str - :ivar error_info: Error information from the Agent - e.g. errors during - installation. - :vartype error_info: - ~azure.mgmt.kubernetesconfiguration.models.ErrorDefinition - :param identity: The identity of the configuration. - :type identity: - ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_status_time': {'readonly': True}, - 'error_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'install_state': {'key': 'properties.installState', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, - 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, - 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, - 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, - } - - def __init__(self, **kwargs): - super(ExtensionInstanceForList, self).__init__(**kwargs) - self.extension_type = kwargs.get('extension_type', None) - self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) - self.release_train = kwargs.get('release_train', None) - self.version = kwargs.get('version', None) - self.scope = kwargs.get('scope', None) self.install_state = kwargs.get('install_state', None) + self.statuses = kwargs.get('statuses', None) self.creation_time = None self.last_modified_time = None self.last_status_time = None @@ -512,6 +404,88 @@ def __init__(self, **kwargs): self.time = kwargs.get('time', None) +class HelmOperatorProperties(Model): + """Properties for Helm operator. + + :param chart_version: Version of the operator Helm chart. + :type chart_version: str + :param chart_values: Values override for the operator Helm chart. + :type chart_values: str + """ + + _attribute_map = { + 'chart_version': {'key': 'chartVersion', 'type': 'str'}, + 'chart_values': {'key': 'chartValues', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(HelmOperatorProperties, self).__init__(**kwargs) + self.chart_version = kwargs.get('chart_version', None) + self.chart_values = kwargs.get('chart_values', None) + + +class ResourceProviderOperation(Model): + """Supported operation of this resource provider. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param name: Operation name, in format of + {provider}/{resource}/{operation} + :type name: str + :param display: Display metadata associated with the operation. + :type display: + ~azure.mgmt.kubernetesconfiguration.models.ResourceProviderOperationDisplay + :ivar is_data_action: The flag that indicates whether the operation + applies to data plane. + :vartype is_data_action: bool + """ + + _validation = { + 'is_data_action': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + self.is_data_action = None + + +class ResourceProviderOperationDisplay(Model): + """Display metadata associated with the operation. + + :param provider: Resource provider: Microsoft KubernetesConfiguration. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description of this operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + class Result(Model): """Sample result definition. @@ -585,3 +559,164 @@ class ScopeNamespace(Model): def __init__(self, **kwargs): super(ScopeNamespace, self).__init__(**kwargs) self.target_namespace = kwargs.get('target_namespace', None) + + +class SourceControlConfiguration(ProxyResource): + """The SourceControl Configuration object returned in Get & Put response. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData + :param repository_url: Url of the SourceControl Repository. + :type repository_url: str + :param operator_namespace: The namespace to which this operator is + installed to. Maximum of 253 lower case alphanumeric characters, hyphen + and period only. Default value: "default" . + :type operator_namespace: str + :param operator_instance_name: Instance name of the operator - identifying + the specific configuration. + :type operator_instance_name: str + :param operator_type: Type of the operator. Possible values include: + 'Flux' + :type operator_type: str or + ~azure.mgmt.kubernetesconfiguration.models.OperatorType + :param operator_params: Any Parameters for the Operator instance in string + format. + :type operator_params: str + :param configuration_protected_settings: Name-value pairs of protected + configuration settings for the configuration + :type configuration_protected_settings: dict[str, str] + :param operator_scope: Scope at which the operator will be installed. + Possible values include: 'cluster', 'namespace'. Default value: "cluster" + . + :type operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.models.OperatorScopeType + :ivar repository_public_key: Public Key associated with this SourceControl + configuration (either generated within the cluster or provided by the + user). + :vartype repository_public_key: str + :param ssh_known_hosts_contents: Base64-encoded known_hosts contents + containing public SSH keys required to access private Git instances + :type ssh_known_hosts_contents: str + :param enable_helm_operator: Option to enable Helm Operator for this git + configuration. + :type enable_helm_operator: bool + :param helm_operator_properties: Properties for Helm operator. + :type helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.models.HelmOperatorProperties + :ivar provisioning_state: The provisioning state of the resource provider. + Possible values include: 'Accepted', 'Deleting', 'Running', 'Succeeded', + 'Failed' + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.models.ProvisioningStateType + :ivar compliance_status: Compliance Status of the Configuration + :vartype compliance_status: + ~azure.mgmt.kubernetesconfiguration.models.ComplianceStatus + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'repository_public_key': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'compliance_status': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, + 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, + 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, + 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, + 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, + 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, + 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, + 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, + 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + } + + def __init__(self, **kwargs): + super(SourceControlConfiguration, self).__init__(**kwargs) + self.repository_url = kwargs.get('repository_url', None) + self.operator_namespace = kwargs.get('operator_namespace', "default") + self.operator_instance_name = kwargs.get('operator_instance_name', None) + self.operator_type = kwargs.get('operator_type', None) + self.operator_params = kwargs.get('operator_params', None) + self.configuration_protected_settings = kwargs.get('configuration_protected_settings', None) + self.operator_scope = kwargs.get('operator_scope', "cluster") + self.repository_public_key = None + self.ssh_known_hosts_contents = kwargs.get('ssh_known_hosts_contents', None) + self.enable_helm_operator = kwargs.get('enable_helm_operator', None) + self.helm_operator_properties = kwargs.get('helm_operator_properties', None) + self.provisioning_state = None + self.compliance_status = None + + +class SystemData(Model): + """Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar created_by: A string identifier for the identity that created the + resource + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource: + user, application, managedIdentity, key + :vartype created_by_type: str + :ivar created_at: The timestamp of resource creation (UTC) + :vartype created_at: datetime + :ivar last_modified_by: A string identifier for the identity that last + modified the resource + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the + resource: user, application, managedIdentity, key + :vartype last_modified_by_type: str + :ivar last_modified_at: The timestamp of resource last modification (UTC) + :vartype last_modified_at: datetime + """ + + _validation = { + 'created_by': {'readonly': True}, + 'created_by_type': {'readonly': True}, + 'created_at': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'last_modified_by_type': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + } + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(SystemData, self).__init__(**kwargs) + self.created_by = None + self.created_by_type = None + self.created_at = None + self.last_modified_by = None + self.last_modified_by_type = None + self.last_modified_at = None diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py index 16b408963ab..36fe12c02ce 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py @@ -20,6 +20,47 @@ class CloudError(Model): _attribute_map = { } + +class ComplianceStatus(Model): + """Compliance Status details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar compliance_state: The compliance state of the configuration. + Possible values include: 'Pending', 'Compliant', 'Noncompliant', + 'Installed', 'Failed' + :vartype compliance_state: str or + ~azure.mgmt.kubernetesconfiguration.models.ComplianceStateType + :param last_config_applied: Datetime the configuration was last applied. + :type last_config_applied: datetime + :param message: Message from when the configuration was applied. + :type message: str + :param message_level: Level of the message. Possible values include: + 'Error', 'Warning', 'Information' + :type message_level: str or + ~azure.mgmt.kubernetesconfiguration.models.MessageLevelType + """ + + _validation = { + 'compliance_state': {'readonly': True}, + } + + _attribute_map = { + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, + 'last_config_applied': {'key': 'lastConfigApplied', 'type': 'iso-8601'}, + 'message': {'key': 'message', 'type': 'str'}, + 'message_level': {'key': 'messageLevel', 'type': 'str'}, + } + + def __init__(self, *, last_config_applied=None, message: str=None, message_level=None, **kwargs) -> None: + super(ComplianceStatus, self).__init__(**kwargs) + self.compliance_state = None + self.last_config_applied = last_config_applied + self.message = message + self.message_level = message_level + + class ConfigurationIdentity(Model): """Identity for the managed cluster. @@ -126,6 +167,9 @@ class Resource(Model): :vartype name: str :ivar type: Resource type :vartype type: str + :param system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData """ _validation = { @@ -138,13 +182,15 @@ class Resource(Model): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } - def __init__(self, **kwargs) -> None: + def __init__(self, *, system_data=None, **kwargs) -> None: super(Resource, self).__init__(**kwargs) self.id = None self.name = None self.type = None + self.system_data = system_data class ProxyResource(Resource): @@ -159,6 +205,9 @@ class ProxyResource(Resource): :vartype name: str :ivar type: Resource type :vartype type: str + :param system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData """ _validation = { @@ -171,10 +220,11 @@ class ProxyResource(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } - def __init__(self, **kwargs) -> None: - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, *, system_data=None, **kwargs) -> None: + super(ProxyResource, self).__init__(system_data=system_data, **kwargs) class ExtensionInstance(ProxyResource): @@ -189,6 +239,9 @@ class ExtensionInstance(ProxyResource): :vartype name: str :ivar type: Resource type :vartype type: str + :param system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData :param extension_type: Type of the Extension, of which this resource is an instance of. It must be one of the Extension Types registered with Microsoft.KubernetesConfiguration by the Extension publisher. @@ -209,6 +262,10 @@ class ExtensionInstance(ProxyResource): :param configuration_settings: Configuration settings, as name-value pairs for configuring this instance of the extension. :type configuration_settings: dict[str, str] + :param configuration_protected_settings: Configuration settings that are + sensitive, as name-value pairs for configuring this instance of the + extension. + :type configuration_protected_settings: dict[str, str] :param install_state: Status of installation of this instance of the extension. Possible values include: 'Pending', 'Installed', 'Failed' :type install_state: str or @@ -248,103 +305,25 @@ class ExtensionInstance(ProxyResource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, 'version': {'key': 'properties.version', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'Scope'}, 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, 'install_state': {'key': 'properties.installState', 'type': 'str'}, 'statuses': {'key': 'properties.statuses', 'type': '[ExtensionStatus]'}, 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, - 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, - } - - def __init__(self, *, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, configuration_settings=None, install_state=None, statuses=None, identity=None, **kwargs) -> None: - super(ExtensionInstance, self).__init__(**kwargs) - self.extension_type = extension_type - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.release_train = release_train - self.version = version - self.scope = scope - self.configuration_settings = configuration_settings - self.install_state = install_state - self.statuses = statuses - self.creation_time = None - self.last_modified_time = None - self.last_status_time = None - self.error_info = None - self.identity = identity - - -class ExtensionInstanceForCreate(ProxyResource): - """Object to create a new Extension Instance. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: Resource Id - :vartype id: str - :ivar name: Resource name - :vartype name: str - :ivar type: Resource type - :vartype type: str - :param extension_type: Type of the Extension, of which this resource is an - instance of. It must be one of the Extension Types registered with - Microsoft.KubernetesConfiguration by the Extension publisher. - :type extension_type: str - :param auto_upgrade_minor_version: Flag to note if this instance - participates in auto upgrade of minor version, or not. - :type auto_upgrade_minor_version: bool - :param release_train: ReleaseTrain this extension instance participates in - for auto-upgrade (e.g. Stable, Preview, etc.) - only if - autoUpgradeMinorVersion is 'true'. - :type release_train: str - :param version: Version of the extension for this extension instance, if - it is 'pinned' to a specific version. autoUpgradeMinorVersion must be - 'false'. - :type version: str - :param scope: Scope at which the extension instance is installed. - :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope - :param configuration_settings: Configuration settings, as name-value pairs - for configuring this instance of the extension. - :type configuration_settings: dict[str, str] - :param configuration_protected_settings: Configuration settings that are - sensitive, as name-value pairs for configuring this instance of the - extension. - :type configuration_protected_settings: dict[str, str] - :param identity: The identity of the configuration. - :type identity: - ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'configuration_settings': {'key': 'properties.configurationSettings', 'type': '{str}'}, - 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, - 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'properties.identity', 'type': 'ConfigurationIdentity'}, } - def __init__(self, *, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, configuration_settings=None, configuration_protected_settings=None, identity=None, location=None, **kwargs) -> None: - super(ExtensionInstanceForCreate, self).__init__(location=location,**kwargs) + def __init__(self, *, system_data=None, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, configuration_settings=None, configuration_protected_settings=None, install_state=None, statuses=None, identity=None, **kwargs) -> None: + super(ExtensionInstance, self).__init__(system_data=system_data, **kwargs) self.extension_type = extension_type self.auto_upgrade_minor_version = auto_upgrade_minor_version self.release_train = release_train @@ -352,95 +331,8 @@ def __init__(self, *, extension_type: str=None, auto_upgrade_minor_version: bool self.scope = scope self.configuration_settings = configuration_settings self.configuration_protected_settings = configuration_protected_settings - self.identity = identity - self.location = location - - -class ExtensionInstanceForList(ProxyResource): - """The Extension Instance object. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: Resource Id - :vartype id: str - :ivar name: Resource name - :vartype name: str - :ivar type: Resource type - :vartype type: str - :param extension_type: Type of the Extension, of which this resource is an - instance of. It must be one of the Extension Types registered with - Microsoft.KubernetesConfiguration by the Extension publisher. - :type extension_type: str - :param auto_upgrade_minor_version: Flag to note if this instance - participates in auto upgrade of minor version, or not. - :type auto_upgrade_minor_version: bool - :param release_train: ReleaseTrain this extension instance participates in - for auto-upgrade (e.g. Stable, Preview, etc.) - only if - autoUpgradeMinorVersion is 'true'. - :type release_train: str - :param version: Version of the extension for this extension instance, if - it is 'pinned' to a specific version. - :type version: str - :param scope: Scope at which the extension instance is installed. - :type scope: ~azure.mgmt.kubernetesconfiguration.models.Scope - :param install_state: Status of installation of this instance of the - extension. Possible values include: 'Pending', 'Installed', 'Failed' - :type install_state: str or - ~azure.mgmt.kubernetesconfiguration.models.InstallStateType - :ivar creation_time: DateLiteral (per ISO8601) noting the time the - resource was created by the client (user). - :vartype creation_time: str - :ivar last_modified_time: DateLiteral (per ISO8601) noting the time the - resource was modified by the client (user). - :vartype last_modified_time: str - :ivar last_status_time: DateLiteral (per ISO8601) noting the time of last - status from the agent. - :vartype last_status_time: str - :ivar error_info: Error information from the Agent - e.g. errors during - installation. - :vartype error_info: - ~azure.mgmt.kubernetesconfiguration.models.ErrorDefinition - :param identity: The identity of the configuration. - :type identity: - ~azure.mgmt.kubernetesconfiguration.models.ConfigurationIdentity - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'last_status_time': {'readonly': True}, - 'error_info': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'Scope'}, - 'install_state': {'key': 'properties.installState', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, - 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, - 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, - 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, - } - - def __init__(self, *, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, install_state=None, identity=None, **kwargs) -> None: - super(ExtensionInstanceForList, self).__init__(**kwargs) - self.extension_type = extension_type - self.auto_upgrade_minor_version = auto_upgrade_minor_version - self.release_train = release_train - self.version = version - self.scope = scope self.install_state = install_state + self.statuses = statuses self.creation_time = None self.last_modified_time = None self.last_status_time = None @@ -512,6 +404,88 @@ def __init__(self, *, code: str=None, display_status: str=None, level="Informati self.time = time +class HelmOperatorProperties(Model): + """Properties for Helm operator. + + :param chart_version: Version of the operator Helm chart. + :type chart_version: str + :param chart_values: Values override for the operator Helm chart. + :type chart_values: str + """ + + _attribute_map = { + 'chart_version': {'key': 'chartVersion', 'type': 'str'}, + 'chart_values': {'key': 'chartValues', 'type': 'str'}, + } + + def __init__(self, *, chart_version: str=None, chart_values: str=None, **kwargs) -> None: + super(HelmOperatorProperties, self).__init__(**kwargs) + self.chart_version = chart_version + self.chart_values = chart_values + + +class ResourceProviderOperation(Model): + """Supported operation of this resource provider. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param name: Operation name, in format of + {provider}/{resource}/{operation} + :type name: str + :param display: Display metadata associated with the operation. + :type display: + ~azure.mgmt.kubernetesconfiguration.models.ResourceProviderOperationDisplay + :ivar is_data_action: The flag that indicates whether the operation + applies to data plane. + :vartype is_data_action: bool + """ + + _validation = { + 'is_data_action': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + } + + def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = name + self.display = display + self.is_data_action = None + + +class ResourceProviderOperationDisplay(Model): + """Display metadata associated with the operation. + + :param provider: Resource provider: Microsoft KubernetesConfiguration. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description of this operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + class Result(Model): """Sample result definition. @@ -585,3 +559,164 @@ class ScopeNamespace(Model): def __init__(self, *, target_namespace: str=None, **kwargs) -> None: super(ScopeNamespace, self).__init__(**kwargs) self.target_namespace = target_namespace + + +class SourceControlConfiguration(ProxyResource): + """The SourceControl Configuration object returned in Get & Put response. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param system_data: Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources + :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData + :param repository_url: Url of the SourceControl Repository. + :type repository_url: str + :param operator_namespace: The namespace to which this operator is + installed to. Maximum of 253 lower case alphanumeric characters, hyphen + and period only. Default value: "default" . + :type operator_namespace: str + :param operator_instance_name: Instance name of the operator - identifying + the specific configuration. + :type operator_instance_name: str + :param operator_type: Type of the operator. Possible values include: + 'Flux' + :type operator_type: str or + ~azure.mgmt.kubernetesconfiguration.models.OperatorType + :param operator_params: Any Parameters for the Operator instance in string + format. + :type operator_params: str + :param configuration_protected_settings: Name-value pairs of protected + configuration settings for the configuration + :type configuration_protected_settings: dict[str, str] + :param operator_scope: Scope at which the operator will be installed. + Possible values include: 'cluster', 'namespace'. Default value: "cluster" + . + :type operator_scope: str or + ~azure.mgmt.kubernetesconfiguration.models.OperatorScopeType + :ivar repository_public_key: Public Key associated with this SourceControl + configuration (either generated within the cluster or provided by the + user). + :vartype repository_public_key: str + :param ssh_known_hosts_contents: Base64-encoded known_hosts contents + containing public SSH keys required to access private Git instances + :type ssh_known_hosts_contents: str + :param enable_helm_operator: Option to enable Helm Operator for this git + configuration. + :type enable_helm_operator: bool + :param helm_operator_properties: Properties for Helm operator. + :type helm_operator_properties: + ~azure.mgmt.kubernetesconfiguration.models.HelmOperatorProperties + :ivar provisioning_state: The provisioning state of the resource provider. + Possible values include: 'Accepted', 'Deleting', 'Running', 'Succeeded', + 'Failed' + :vartype provisioning_state: str or + ~azure.mgmt.kubernetesconfiguration.models.ProvisioningStateType + :ivar compliance_status: Compliance Status of the Configuration + :vartype compliance_status: + ~azure.mgmt.kubernetesconfiguration.models.ComplianceStatus + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'repository_public_key': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'compliance_status': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'repository_url': {'key': 'properties.repositoryUrl', 'type': 'str'}, + 'operator_namespace': {'key': 'properties.operatorNamespace', 'type': 'str'}, + 'operator_instance_name': {'key': 'properties.operatorInstanceName', 'type': 'str'}, + 'operator_type': {'key': 'properties.operatorType', 'type': 'str'}, + 'operator_params': {'key': 'properties.operatorParams', 'type': 'str'}, + 'configuration_protected_settings': {'key': 'properties.configurationProtectedSettings', 'type': '{str}'}, + 'operator_scope': {'key': 'properties.operatorScope', 'type': 'str'}, + 'repository_public_key': {'key': 'properties.repositoryPublicKey', 'type': 'str'}, + 'ssh_known_hosts_contents': {'key': 'properties.sshKnownHostsContents', 'type': 'str'}, + 'enable_helm_operator': {'key': 'properties.enableHelmOperator', 'type': 'bool'}, + 'helm_operator_properties': {'key': 'properties.helmOperatorProperties', 'type': 'HelmOperatorProperties'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'compliance_status': {'key': 'properties.complianceStatus', 'type': 'ComplianceStatus'}, + } + + def __init__(self, *, system_data=None, repository_url: str=None, operator_namespace: str="default", operator_instance_name: str=None, operator_type=None, operator_params: str=None, configuration_protected_settings=None, operator_scope="cluster", ssh_known_hosts_contents: str=None, enable_helm_operator: bool=None, helm_operator_properties=None, **kwargs) -> None: + super(SourceControlConfiguration, self).__init__(system_data=system_data, **kwargs) + self.repository_url = repository_url + self.operator_namespace = operator_namespace + self.operator_instance_name = operator_instance_name + self.operator_type = operator_type + self.operator_params = operator_params + self.configuration_protected_settings = configuration_protected_settings + self.operator_scope = operator_scope + self.repository_public_key = None + self.ssh_known_hosts_contents = ssh_known_hosts_contents + self.enable_helm_operator = enable_helm_operator + self.helm_operator_properties = helm_operator_properties + self.provisioning_state = None + self.compliance_status = None + + +class SystemData(Model): + """Top level metadata + https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar created_by: A string identifier for the identity that created the + resource + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource: + user, application, managedIdentity, key + :vartype created_by_type: str + :ivar created_at: The timestamp of resource creation (UTC) + :vartype created_at: datetime + :ivar last_modified_by: A string identifier for the identity that last + modified the resource + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the + resource: user, application, managedIdentity, key + :vartype last_modified_by_type: str + :ivar last_modified_at: The timestamp of resource last modification (UTC) + :vartype last_modified_at: datetime + """ + + _validation = { + 'created_by': {'readonly': True}, + 'created_by_type': {'readonly': True}, + 'created_at': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'last_modified_by_type': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + } + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs) -> None: + super(SystemData, self).__init__(**kwargs) + self.created_by = None + self.created_by_type = None + self.created_at = None + self.last_modified_by = None + self.last_modified_by_type = None + self.last_modified_at = None diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_paged_models.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_paged_models.py index 8f2e7eca24e..c545286fe54 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_paged_models.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_paged_models.py @@ -12,6 +12,19 @@ from msrest.paging import Paged +class SourceControlConfigurationPaged(Paged): + """ + A paging container for iterating over a list of :class:`SourceControlConfiguration ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[SourceControlConfiguration]'} + } + + def __init__(self, *args, **kwargs): + + super(SourceControlConfigurationPaged, self).__init__(*args, **kwargs) class ResourceProviderOperationPaged(Paged): """ A paging container for iterating over a list of :class:`ResourceProviderOperation ` object @@ -25,16 +38,16 @@ class ResourceProviderOperationPaged(Paged): def __init__(self, *args, **kwargs): super(ResourceProviderOperationPaged, self).__init__(*args, **kwargs) -class ExtensionInstanceForListPaged(Paged): +class ExtensionInstancePaged(Paged): """ - A paging container for iterating over a list of :class:`ExtensionInstanceForList ` object + A paging container for iterating over a list of :class:`ExtensionInstance ` object """ _attribute_map = { 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ExtensionInstanceForList]'} + 'current_page': {'key': 'value', 'type': '[ExtensionInstance]'} } def __init__(self, *args, **kwargs): - super(ExtensionInstanceForListPaged, self).__init__(*args, **kwargs) + super(ExtensionInstancePaged, self).__init__(*args, **kwargs) diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_k8s_extension_client_enums.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_source_control_configuration_client_enums.py similarity index 100% rename from src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_k8s_extension_client_enums.py rename to src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_source_control_configuration_client_enums.py diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/__init__.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/__init__.py index e8f158b24a3..6be16d2582d 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/__init__.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/__init__.py @@ -9,8 +9,12 @@ # regenerated. # -------------------------------------------------------------------------- -from ._k8s_extensions_operations import K8sExtensionsOperations +from ._source_control_configurations_operations import SourceControlConfigurationsOperations +from ._operations import Operations +from ._extensions_operations import ExtensionsOperations __all__ = [ - 'K8sExtensionsOperations', + 'SourceControlConfigurationsOperations', + 'Operations', + 'ExtensionsOperations', ] diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_k8s_extensions_operations.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_extensions_operations.py similarity index 84% rename from src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_k8s_extensions_operations.py rename to src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_extensions_operations.py index 716aefd7b06..e99f3328816 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_k8s_extensions_operations.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_extensions_operations.py @@ -15,11 +15,10 @@ from .. import models -class K8sExtensionsOperations(object): - """K8sExtensionsOperations operations. +class ExtensionsOperations(object): + """ExtensionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach - it as attribute. + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. :param client: Client for service requests. :param config: Configuration of service client. @@ -39,10 +38,9 @@ def __init__(self, client, config, serializer, deserializer): self.config = config - def get( - self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, - custom_headers=None, raw=False, **operation_config): - """Gets details of the Kubernetes Cluster Extension Instance. + def create( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, extension_instance, custom_headers=None, raw=False, **operation_config): + """Create a new Kubernetes Cluster Extension Instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -53,13 +51,17 @@ def get( :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters (for AKS clusters) or connectedClusters (for - OnPrem K8S clusters) or appliances (for Arc Appliances). Possible - values include: 'managedClusters','connectedClusters', 'appliances' + OnPrem K8S clusters). Possible values include: 'managedClusters', + 'connectedClusters' :type cluster_resource_name: str :param cluster_name: The name of the kubernetes cluster. :type cluster_name: str :param extension_instance_name: Name of an instance of the Extension. :type extension_instance_name: str + :param extension_instance: Properties necessary to Create an Extension + Instance. + :type extension_instance: + ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstance :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -72,7 +74,7 @@ def get( :class:`ErrorResponseException` """ # Construct URL - url = self.get.metadata['url'] + url = self.create.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -90,16 +92,19 @@ def get( # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", - self.config.accept_language, 'str') + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(extension_instance, 'ExtensionInstance') # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + request = self._client.put(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: @@ -114,12 +119,11 @@ def get( return client_raw_response return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} - def create( - self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, - extension_instance, custom_headers=None, raw=False, **operation_config): - """Create a new Kubernetes Cluster Extension Instance. + def get( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, custom_headers=None, raw=False, **operation_config): + """Gets details of the Kubernetes Cluster Extension Instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -130,17 +134,13 @@ def create( :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters (for AKS clusters) or connectedClusters (for - OnPrem K8S clusters) or appliances (for Arc Appliances). Possible - values include: 'managedClusters','connectedClusters', 'appliances' + OnPrem K8S clusters). Possible values include: 'managedClusters', + 'connectedClusters' :type cluster_resource_name: str :param cluster_name: The name of the kubernetes cluster. :type cluster_name: str :param extension_instance_name: Name of an instance of the Extension. :type extension_instance_name: str - :param extension_instance: Properties necessary to Create an Extension - Instance. - :type extension_instance: - ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstanceForCreate :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -153,7 +153,7 @@ def create( :class:`ErrorResponseException` """ # Construct URL - url = self.create.metadata['url'] + url = self.get.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -171,20 +171,15 @@ def create( # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", - self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(extension_instance, 'ExtensionInstanceForCreate') + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) + request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: @@ -199,13 +194,10 @@ def create( return client_raw_response return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}' - '/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/' - 'extensions/{extensionInstanceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} def update( - self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, - extension_instance, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, extension_instance, custom_headers=None, raw=False, **operation_config): """Update an existing Kubernetes Cluster Extension Instance. :param resource_group_name: The name of the resource group. @@ -217,8 +209,8 @@ def update( :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters (for AKS clusters) or connectedClusters (for - OnPrem K8S clusters) or appliances (for Arc Appliances). Possible - values include: 'managedClusters','connectedClusters', 'appliances' + OnPrem K8S clusters). Possible values include: 'managedClusters', + 'connectedClusters' :type cluster_resource_name: str :param cluster_name: The name of the kubernetes cluster. :type cluster_name: str @@ -264,8 +256,7 @@ def update( if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", - self.config.accept_language, 'str') + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(extension_instance, 'ExtensionInstanceUpdate') @@ -286,13 +277,10 @@ def update( return client_raw_response return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}' - '/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/' - 'extensions/{extensionInstanceName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} def delete( - self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, - custom_headers=None, raw=False, **operation_config): + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, extension_instance_name, custom_headers=None, raw=False, **operation_config): """Delete a Kubernetes Cluster Extension Instance. This will cause the Agent to Uninstall the extension instance from the cluster. @@ -305,8 +293,8 @@ def delete( :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters (for AKS clusters) or connectedClusters (for - OnPrem K8S clusters) or appliances (for Arc Appliances). Possible - values include: 'managedClusters','connectedClusters', 'appliances' + OnPrem K8S clusters). Possible values include: 'managedClusters', + 'connectedClusters' :type cluster_resource_name: str :param cluster_name: The name of the kubernetes cluster. :type cluster_name: str @@ -345,8 +333,7 @@ def delete( if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", - self.config.accept_language, 'str') + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) @@ -358,14 +345,11 @@ def delete( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}' - '/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/' - 'extensions/{extensionInstanceName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions/{extensionInstanceName}'} def list( - self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, custom_headers=None, raw=False, - **operation_config): - """List all Extension Instances. + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, custom_headers=None, raw=False, **operation_config): + """List all Source Control Configurations. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -376,8 +360,8 @@ def list( :type cluster_rp: str :param cluster_resource_name: The Kubernetes cluster resource name - either managedClusters (for AKS clusters) or connectedClusters (for - OnPrem K8S clusters) or appliances (for Arc Appliances). Possible - values include: 'managedClusters','connectedClusters', 'appliances' + OnPrem K8S clusters). Possible values include: 'managedClusters', + 'connectedClusters' :type cluster_resource_name: str :param cluster_name: The name of the kubernetes cluster. :type cluster_name: str @@ -386,9 +370,9 @@ def list( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: An iterator like instance of ExtensionInstanceForList + :return: An iterator like instance of ExtensionInstance :rtype: - ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstanceForListPaged[~azure.mgmt.kubernetesconfiguration.models.ExtensionInstanceForList] + ~azure.mgmt.kubernetesconfiguration.models.ExtensionInstancePaged[~azure.mgmt.kubernetesconfiguration.models.ExtensionInstance] :raises: :class:`ErrorResponseException` """ @@ -397,8 +381,7 @@ def prepare_request(next_link=None): # Construct URL url = self.list.metadata['url'] path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, - 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), @@ -422,8 +405,7 @@ def prepare_request(next_link=None): if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", - self.config.accept_language, 'str') + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) @@ -443,10 +425,7 @@ def internal_paging(next_link=None): header_dict = None if raw: header_dict = {} - deserialized = models.ExtensionInstanceForListPaged(internal_paging, self._deserialize.dependencies, - header_dict) + deserialized = models.ExtensionInstancePaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}' - '/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/' - 'extensions'} + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/extensions'} diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_operations.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_operations.py new file mode 100644 index 00000000000..245a93c8294 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_operations.py @@ -0,0 +1,101 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class Operations(object): + """Operations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to be used with the HTTP request. Constant value: "2020-07-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-07-01-preview" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """List all the available operations the KubernetesConfiguration resource + provider supports. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ResourceProviderOperation + :rtype: + ~azure.mgmt.kubernetesconfiguration.models.ResourceProviderOperationPaged[~azure.mgmt.kubernetesconfiguration.models.ResourceProviderOperation] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ResourceProviderOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.KubernetesConfiguration/operations'} diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_source_control_configurations_operations.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_source_control_configurations_operations.py new file mode 100644 index 00000000000..83a49e32146 --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/operations/_source_control_configurations_operations.py @@ -0,0 +1,386 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrest.polling import LROPoller, NoPolling +from msrestazure.polling.arm_polling import ARMPolling + +from .. import models + + +class SourceControlConfigurationsOperations(object): + """SourceControlConfigurationsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to be used with the HTTP request. Constant value: "2020-07-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-07-01-preview" + + self.config = config + + def get( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, source_control_configuration_name, custom_headers=None, raw=False, **operation_config): + """Gets details of the Source Control Configuration. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either + Microsoft.ContainerService (for AKS clusters) or Microsoft.Kubernetes + (for OnPrem K8S clusters). Possible values include: + 'Microsoft.ContainerService', 'Microsoft.Kubernetes' + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - + either managedClusters (for AKS clusters) or connectedClusters (for + OnPrem K8S clusters). Possible values include: 'managedClusters', + 'connectedClusters' + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control + Configuration. + :type source_control_configuration_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SourceControlConfiguration or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.kubernetesconfiguration.models.SourceControlConfiguration + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SourceControlConfiguration', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} + + def create_or_update( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, source_control_configuration_name, source_control_configuration, custom_headers=None, raw=False, **operation_config): + """Create a new Kubernetes Source Control Configuration. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either + Microsoft.ContainerService (for AKS clusters) or Microsoft.Kubernetes + (for OnPrem K8S clusters). Possible values include: + 'Microsoft.ContainerService', 'Microsoft.Kubernetes' + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - + either managedClusters (for AKS clusters) or connectedClusters (for + OnPrem K8S clusters). Possible values include: 'managedClusters', + 'connectedClusters' + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control + Configuration. + :type source_control_configuration_name: str + :param source_control_configuration: Properties necessary to Create + KubernetesConfiguration. + :type source_control_configuration: + ~azure.mgmt.kubernetesconfiguration.models.SourceControlConfiguration + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SourceControlConfiguration or ClientRawResponse if raw=true + :rtype: + ~azure.mgmt.kubernetesconfiguration.models.SourceControlConfiguration + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(source_control_configuration, 'SourceControlConfiguration') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SourceControlConfiguration', response) + if response.status_code == 201: + deserialized = self._deserialize('SourceControlConfiguration', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} + + + def _delete_initial( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, source_control_configuration_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 'sourceControlConfigurationName': self._serialize.url("source_control_configuration_name", source_control_configuration_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def delete( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, source_control_configuration_name, custom_headers=None, raw=False, polling=True, **operation_config): + """This will delete the YAML file used to set up the Source control + configuration, thus stopping future sync from the source repo. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either + Microsoft.ContainerService (for AKS clusters) or Microsoft.Kubernetes + (for OnPrem K8S clusters). Possible values include: + 'Microsoft.ContainerService', 'Microsoft.Kubernetes' + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - + either managedClusters (for AKS clusters) or connectedClusters (for + OnPrem K8S clusters). Possible values include: 'managedClusters', + 'connectedClusters' + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param source_control_configuration_name: Name of the Source Control + Configuration. + :type source_control_configuration_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: + :class:`ErrorResponseException` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_rp=cluster_rp, + cluster_resource_name=cluster_resource_name, + cluster_name=cluster_name, + source_control_configuration_name=source_control_configuration_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}'} + + def list( + self, resource_group_name, cluster_rp, cluster_resource_name, cluster_name, custom_headers=None, raw=False, **operation_config): + """List all Source Control Configurations. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param cluster_rp: The Kubernetes cluster RP - either + Microsoft.ContainerService (for AKS clusters) or Microsoft.Kubernetes + (for OnPrem K8S clusters). Possible values include: + 'Microsoft.ContainerService', 'Microsoft.Kubernetes' + :type cluster_rp: str + :param cluster_resource_name: The Kubernetes cluster resource name - + either managedClusters (for AKS clusters) or connectedClusters (for + OnPrem K8S clusters). Possible values include: 'managedClusters', + 'connectedClusters' + :type cluster_resource_name: str + :param cluster_name: The name of the kubernetes cluster. + :type cluster_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of SourceControlConfiguration + :rtype: + ~azure.mgmt.kubernetesconfiguration.models.SourceControlConfigurationPaged[~azure.mgmt.kubernetesconfiguration.models.SourceControlConfiguration] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'clusterRp': self._serialize.url("cluster_rp", cluster_rp, 'str'), + 'clusterResourceName': self._serialize.url("cluster_resource_name", cluster_resource_name, 'str'), + 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.SourceControlConfigurationPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations'} diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/version.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/version.py index e0ec669828c..3e682bbd5fb 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/version.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.1.0" +VERSION = "0.3.0" From 1df2ef5cebee34e490b40a79981bd2d199a1c50f Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Tue, 16 Mar 2021 11:39:04 -0700 Subject: [PATCH 18/31] remove py2 bdist support --- src/k8s-extension/setup.cfg | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/k8s-extension/setup.cfg b/src/k8s-extension/setup.cfg index 5eab412034f..e69de29bb2d 100644 --- a/src/k8s-extension/setup.cfg +++ b/src/k8s-extension/setup.cfg @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 From 054a903db08bb126410ba538f553c2420fb2989e Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Tue, 16 Mar 2021 12:30:38 -0700 Subject: [PATCH 19/31] Add custom table formatting --- .../azext_k8s_extension/_format.py | 24 +++++++++++++++++++ .../azext_k8s_extension/commands.py | 5 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/k8s-extension/azext_k8s_extension/_format.py diff --git a/src/k8s-extension/azext_k8s_extension/_format.py b/src/k8s-extension/azext_k8s_extension/_format.py new file mode 100644 index 00000000000..ef96f7cf88f --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/_format.py @@ -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. +# -------------------------------------------------------------------------------------------- + +from collections import OrderedDict + + +def k8s_extension_list_table_format(results): + return [__get_table_row(result) for result in results] + + +def k8s_extension_show_table_format(result): + return __get_table_row(result) + + +def __get_table_row(result): + return OrderedDict([ + ('name', result['name']), + ('extensionType', result['extensionType']), + ('version', result['version']), + ('installState', result['installState']), + ('lastModifiedTime', result['lastModifiedTime']) + ]) diff --git a/src/k8s-extension/azext_k8s_extension/commands.py b/src/k8s-extension/azext_k8s_extension/commands.py index ff72ab62e08..931662814c0 100644 --- a/src/k8s-extension/azext_k8s_extension/commands.py +++ b/src/k8s-extension/azext_k8s_extension/commands.py @@ -6,6 +6,7 @@ # pylint: disable=line-too-long from azure.cli.core.commands import CliCommandType from azext_k8s_extension._client_factory import (cf_k8s_extension, cf_k8s_extension_operation) +from azext_k8s_extension._format import k8s_extension_list_table_format, k8s_extension_show_table_format import azext_k8s_extension._consts as consts @@ -21,5 +22,5 @@ def load_command_table(self, _): g.custom_command('create', 'create_k8s_extension') g.custom_command('update', 'update_k8s_extension') g.custom_command('delete', 'delete_k8s_extension', confirmation=True) - g.custom_command('list', 'list_k8s_extension') - g.custom_show_command('show', 'show_k8s_extension') + g.custom_command('list', 'list_k8s_extension', table_transformer=k8s_extension_list_table_format) + g.custom_show_command('show', 'show_k8s_extension', table_transformer=k8s_extension_show_table_format) From b2982523471694f5bc056d1b9a15e405cddc3932 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Tue, 16 Mar 2021 15:27:43 -0700 Subject: [PATCH 20/31] Remove unnecessary files --- .github/pull.yml | 14 ------ .../azext_k8s_extension/_validators.py | 21 -------- .../partner_extensions/__init__.py | 5 ++ .../vendored_sdks/_k8s_extension_client.py | 50 ------------------- 4 files changed, 5 insertions(+), 85 deletions(-) delete mode 100644 .github/pull.yml delete mode 100644 src/k8s-extension/azext_k8s_extension/_validators.py delete mode 100644 src/k8s-extension/azext_k8s_extension/vendored_sdks/_k8s_extension_client.py diff --git a/.github/pull.yml b/.github/pull.yml deleted file mode 100644 index 8f65923a382..00000000000 --- a/.github/pull.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: "1" -rules: # Array of rules - - base: master # Required. Target branch - upstream: wei:master # Required. Must be in the same fork network. - mergeMethod: hardreset # Optional, one of [none, merge, squash, rebase, hardreset], Default: none. - mergeUnstable: false # Optional, merge pull request even when the mergeable_state is not clean. Default: false - - base: k8s-configuration - upstream: master # Required. Can be a branch in the same forked repo. - - base: k8s-extension/private-preview - upstream: master # Required. Can be a branch in the same forked repo. - - base: k8s-extension/public-preview - upstream: master # Required. Can be a branch in the same forked repo. - - base: release - upstream: master # Required. Can be a branch in the same forked repo. diff --git a/src/k8s-extension/azext_k8s_extension/_validators.py b/src/k8s-extension/azext_k8s_extension/_validators.py deleted file mode 100644 index 72270dab104..00000000000 --- a/src/k8s-extension/azext_k8s_extension/_validators.py +++ /dev/null @@ -1,21 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - - -def example_name_or_id_validator(cmd, namespace): - # Example of a storage account name or ID validator. - # See: https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#supporting-name-or-id-parameters # pylint: disable=line-too-long - - from azure.cli.core.commands.client_factory import get_subscription_id - from msrestazure.tools import is_valid_resource_id, resource_id - if namespace.storage_account: - if not is_valid_resource_id(namespace.RESOURCE): - namespace.storage_account = resource_id( - subscription=get_subscription_id(cmd.cli_ctx), - resource_group=namespace.resource_group_name, - namespace='Microsoft.Storage', - type='storageAccounts', - name=namespace.storage_account - ) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py index e69de29bb2d..eaff94925e3 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/_k8s_extension_client.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/_k8s_extension_client.py deleted file mode 100644 index 1b63ebfd1ac..00000000000 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/_k8s_extension_client.py +++ /dev/null @@ -1,50 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer - -from ._configuration import K8sExtensionClientConfiguration -from .operations import K8sExtensionsOperations -from . import models - - -class K8sExtensionClient(SDKClient): - """K8sExtension Client - - :ivar config: Configuration for client. - :vartype config: K8sExtensionClientConfiguration - - :ivar k8s_extensions: K8sExtensions operations - :vartype k8s_extensions: azure.mgmt.kubernetesconfiguration.operations.K8sExtensionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: The Azure subscription ID. This is a - GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) - :type subscription_id: str - :param str base_url: Service URL - """ - - def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = K8sExtensionClientConfiguration(credentials, subscription_id, base_url) - super(K8sExtensionClient, self).__init__(self.config.credentials, self.config) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2020-07-01-preview' - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.k8s_extensions = K8sExtensionsOperations( - self._client, self.config, self._serialize, self._deserialize) From afb4046a7e5d966cf48c968b00c878eb1ec8a50d Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Tue, 16 Mar 2021 15:34:00 -0700 Subject: [PATCH 21/31] Fix style issues --- .../azext_k8s_extension/partner_extensions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py index eaff94925e3..9ccaff6c1b8 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/__init__.py @@ -2,4 +2,4 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -# ----------------------------------------------------------------------------- \ No newline at end of file +# ----------------------------------------------------------------------------- From 21dff06eae89e8acf628ee463a834ac64e116b5b Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Tue, 16 Mar 2021 20:33:16 -0700 Subject: [PATCH 22/31] Fix branch based on comments --- azure-pipelines.yml | 2 +- src/k8s-extension/azext_k8s_extension/azext_metadata.json | 2 +- src/k8s-extension/azext_k8s_extension/custom.py | 1 - src/k8s-extension/setup.cfg | 0 4 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 src/k8s-extension/setup.cfg diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 565e9c56793..d43ef5102f0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -168,4 +168,4 @@ jobs: displayName: "Verify Extension Ref Docs" inputs: targetType: 'filePath' - filePath: scripts/ci/test_index_ref_doc.sh \ No newline at end of file + filePath: scripts/ci/test_index_ref_doc.sh diff --git a/src/k8s-extension/azext_k8s_extension/azext_metadata.json b/src/k8s-extension/azext_k8s_extension/azext_metadata.json index 30fdaf614ee..cf7b8927a07 100644 --- a/src/k8s-extension/azext_k8s_extension/azext_metadata.json +++ b/src/k8s-extension/azext_k8s_extension/azext_metadata.json @@ -1,4 +1,4 @@ { "azext.isPreview": true, "azext.minCliCoreVersion": "2.15.0" -} \ No newline at end of file +} diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index b06567aca0b..2b578a301ce 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -14,7 +14,6 @@ InvalidArgumentValueError, CommandNotFoundError from azure.cli.core.commands.client_factory import get_subscription_id from azext_k8s_extension.vendored_sdks.models import ConfigurationIdentity -# from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate from azext_k8s_extension.vendored_sdks.models import ErrorResponseException from azext_k8s_extension.partner_extensions.ContainerInsights import ContainerInsights diff --git a/src/k8s-extension/setup.cfg b/src/k8s-extension/setup.cfg deleted file mode 100644 index e69de29bb2d..00000000000 From 93919f2457af6f244ec8ab7da500591060ee7a06 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Wed, 17 Mar 2021 08:30:49 -0700 Subject: [PATCH 23/31] Update identity piece manually --- .../azext_k8s_extension/vendored_sdks/models/_models.py | 2 +- .../azext_k8s_extension/vendored_sdks/models/_models_py3.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py index da1b94606cd..c821dfc362a 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py @@ -306,6 +306,7 @@ class ExtensionInstance(ProxyResource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, @@ -319,7 +320,6 @@ class ExtensionInstance(ProxyResource): 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, - 'identity': {'key': 'properties.identity', 'type': 'ConfigurationIdentity'}, } def __init__(self, **kwargs): diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py index 36fe12c02ce..1ca6a98a35a 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py @@ -306,6 +306,7 @@ class ExtensionInstance(ProxyResource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, 'release_train': {'key': 'properties.releaseTrain', 'type': 'str'}, @@ -318,8 +319,7 @@ class ExtensionInstance(ProxyResource): 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'str'}, 'last_status_time': {'key': 'properties.lastStatusTime', 'type': 'str'}, - 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'}, - 'identity': {'key': 'properties.identity', 'type': 'ConfigurationIdentity'}, + 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'} } def __init__(self, *, system_data=None, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, configuration_settings=None, configuration_protected_settings=None, install_state=None, statuses=None, identity=None, **kwargs) -> None: From 7e40b3ad2eee2ae66e4b4f73c92b88b42fda7fe3 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Wed, 17 Mar 2021 09:33:16 -0700 Subject: [PATCH 24/31] Don't handle defaults at the CLI level --- src/k8s-extension/azext_k8s_extension/custom.py | 2 +- .../partner_extensions/DefaultExtension.py | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index 2b578a301ce..0ae0247a4b7 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -65,7 +65,7 @@ def show_k8s_extension(client, resource_group_name, cluster_name, name, cluster_ def create_k8s_extension(cmd, client, resource_group_name, cluster_name, name, cluster_type, - extension_type, scope='cluster', auto_upgrade_minor_version=None, release_train=None, + extension_type, scope=None, auto_upgrade_minor_version=None, release_train=None, version=None, target_namespace=None, release_namespace=None, configuration_settings=None, configuration_protected_settings=None, configuration_settings_file=None, configuration_protected_settings_file=None, tags=None): diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py index 8e813502edd..3117734116f 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py @@ -25,16 +25,13 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t """ ext_scope = None - if scope is None or scope.lower() == 'cluster': - scope_cluster = ScopeCluster(release_namespace=release_namespace) - ext_scope = Scope(cluster=scope_cluster, namespace=None) - else: - scope_namespace = ScopeNamespace(target_namespace=target_namespace) - ext_scope = Scope(namespace=scope_namespace, cluster=None) - - # If release-train is not input, set it to 'stable' - if release_train is None: - release_train = 'stable' + if scope is not None: + if scope.lower() == 'cluster': + scope_cluster = ScopeCluster(release_namespace=release_namespace) + ext_scope = Scope(cluster=scope_cluster, namespace=None) + elif scope.lower() == 'namespace': + scope_namespace = ScopeNamespace(target_namespace=target_namespace) + ext_scope = Scope(namespace=scope_namespace, cluster=None) create_identity = False extension_instance = ExtensionInstance( From d1befa8fd237e75cfb2a0582bb71b0e21aae1df3 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Wed, 17 Mar 2021 10:20:59 -0700 Subject: [PATCH 25/31] Remove defaults from CLI client --- src/k8s-extension/azext_k8s_extension/custom.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index 0ae0247a4b7..007e3ba0c07 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -19,6 +19,7 @@ from azext_k8s_extension.partner_extensions.ContainerInsights import ContainerInsights from azext_k8s_extension.partner_extensions.AzureDefender import AzureDefender from azext_k8s_extension.partner_extensions.DefaultExtension import DefaultExtension +import azext_k8s_extension._consts as consts from ._client_factory import cf_resources @@ -111,7 +112,6 @@ def create_k8s_extension(cmd, client, resource_group_name, cluster_name, name, c # Identity is not created by default. Extension type must specify if identity is required. create_identity = False - extension_instance = None # Scope & Namespace validation - common to all extension-types @@ -152,8 +152,8 @@ def update_k8s_extension(client, resource_group_name, cluster_type, cluster_name # TODO: Remove this after we eventually get PATCH implemented for update and uncomment raise CommandNotFoundError( - "\"k8s-extension update\" currently is not available. " - "Use \"k8s-extension create\" to update a previously created extension instance." + f"\"{consts.EXTENSION_NAME} update\" currently is not available. " + f"Use \"{consts.EXTENSION_NAME} create\" to update a previously created extension instance." ) # # Ensure some values are provided for update @@ -188,10 +188,7 @@ def delete_k8s_extension(client, resource_group_name, cluster_name, name, cluste """ # Determine ClusterRP cluster_rp = __get_cluster_rp(cluster_type) - - k8s_extension_instance_name = name - - return client.delete(resource_group_name, cluster_rp, cluster_type, cluster_name, k8s_extension_instance_name) + return client.delete(resource_group_name, cluster_rp, cluster_type, cluster_name, name) def __create_identity(cmd, resource_group_name, cluster_name, cluster_type, cluster_rp): From 076827cb9e052a83c372805087332f9bce5bd29d Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Wed, 17 Mar 2021 12:29:46 -0700 Subject: [PATCH 26/31] Check null target namespace with namespace scope --- src/k8s-extension/azext_k8s_extension/custom.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index 007e3ba0c07..92e5e5513a0 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -11,10 +11,11 @@ from msrestazure.azure_exceptions import CloudError from azure.cli.core.azclierror import ResourceNotFoundError, MutuallyExclusiveArgumentError, \ - InvalidArgumentValueError, CommandNotFoundError + InvalidArgumentValueError, CommandNotFoundError, RequiredArgumentMissingError from azure.cli.core.commands.client_factory import get_subscription_id from azext_k8s_extension.vendored_sdks.models import ConfigurationIdentity from azext_k8s_extension.vendored_sdks.models import ErrorResponseException +from azext_k8s_extension.vendored_sdks.models import Scope from azext_k8s_extension.partner_extensions.ContainerInsights import ContainerInsights from azext_k8s_extension.partner_extensions.AzureDefender import AzureDefender @@ -128,6 +129,7 @@ def create_k8s_extension(cmd, client, resource_group_name, cluster_name, name, c # Common validations __validate_version_and_auto_upgrade(extension_instance.version, extension_instance.auto_upgrade_minor_version) + __validate_scope_after_customization(extension_instance.scope) # Create identity, if required if create_identity: @@ -238,13 +240,17 @@ def __get_cluster_rp(cluster_type): def __validate_scope_and_namespace(scope, release_namespace, target_namespace): if scope == 'cluster': if target_namespace is not None: - message = "When Scope is 'cluster', target-namespace must not be given." + message = "When --scope is 'cluster', --target-namespace must not be given." raise MutuallyExclusiveArgumentError(message) else: if release_namespace is not None: - message = "When Scope is 'namespace', release-namespace must not be given." + message = "When --scope is 'namespace', --release-namespace must not be given." raise MutuallyExclusiveArgumentError(message) +def __validate_scope_after_customization(scope_obj: Scope): + if scope_obj is not None and scope_obj.namespace is not None and scope_obj.namespace.target_namespace is None: + message = "When --scope is 'namespace', --target-namespace must be given." + raise RequiredArgumentMissingError(message) def __validate_version_and_auto_upgrade(version, auto_upgrade_minor_version): if version is not None: From 550eea1b30279f2058d900c561f8851b44ce4c8a Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Wed, 17 Mar 2021 12:30:27 -0700 Subject: [PATCH 27/31] Update style --- src/k8s-extension/azext_k8s_extension/custom.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index 92e5e5513a0..2b29cd036c0 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -247,11 +247,13 @@ def __validate_scope_and_namespace(scope, release_namespace, target_namespace): message = "When --scope is 'namespace', --release-namespace must not be given." raise MutuallyExclusiveArgumentError(message) + def __validate_scope_after_customization(scope_obj: Scope): if scope_obj is not None and scope_obj.namespace is not None and scope_obj.namespace.target_namespace is None: message = "When --scope is 'namespace', --target-namespace must be given." raise RequiredArgumentMissingError(message) + def __validate_version_and_auto_upgrade(version, auto_upgrade_minor_version): if version is not None: if auto_upgrade_minor_version: From fbab3be6fe097d7e2db815954175ca6d45baa796 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Wed, 17 Mar 2021 13:39:49 -0700 Subject: [PATCH 28/31] Add cassandra operator and location to model --- .../azext_k8s_extension/custom.py | 2 + .../partner_extensions/AzureDefender.py | 4 +- .../partner_extensions/Cassandra.py | 57 +++++++++++++++++++ .../partner_extensions/ContainerInsights.py | 4 +- .../partner_extensions/DefaultExtension.py | 4 +- .../vendored_sdks/models/_models.py | 4 ++ .../vendored_sdks/models/_models_py3.py | 6 +- 7 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 src/k8s-extension/azext_k8s_extension/partner_extensions/Cassandra.py diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index 2b29cd036c0..ba9dbfce501 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -19,6 +19,7 @@ from azext_k8s_extension.partner_extensions.ContainerInsights import ContainerInsights from azext_k8s_extension.partner_extensions.AzureDefender import AzureDefender +from azext_k8s_extension.partner_extensions.Cassandra import Cassandra from azext_k8s_extension.partner_extensions.DefaultExtension import DefaultExtension import azext_k8s_extension._consts as consts @@ -32,6 +33,7 @@ def ExtensionFactory(extension_name): extension_map = { 'microsoft.azuremonitor.containers': ContainerInsights, 'microsoft.azuredefender.kubernetes': AzureDefender, + 'cassandradatacentersoperator': Cassandra } # Return the extension if we find it in the map, else return the default diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py index 7721ea8c638..dcd2853affc 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py @@ -55,9 +55,7 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t version=version, scope=ext_scope, configuration_settings=configuration_settings, - configuration_protected_settings=configuration_protected_settings, - identity=None, - location="" + configuration_protected_settings=configuration_protected_settings ) return extension_instance, name, create_identity diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/Cassandra.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/Cassandra.py new file mode 100644 index 00000000000..2a609ce125a --- /dev/null +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/Cassandra.py @@ -0,0 +1,57 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=unused-argument + +from azext_k8s_extension.vendored_sdks.models import ExtensionInstance +from azext_k8s_extension.vendored_sdks.models import ExtensionInstanceUpdate +from azext_k8s_extension.vendored_sdks.models import ScopeCluster +from azext_k8s_extension.vendored_sdks.models import ScopeNamespace +from azext_k8s_extension.vendored_sdks.models import Scope + +from azext_k8s_extension.partner_extensions.PartnerExtensionModel import PartnerExtensionModel + + +class Cassandra(PartnerExtensionModel): + def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, + scope, auto_upgrade_minor_version, release_train, version, target_namespace, + release_namespace, configuration_settings, configuration_protected_settings, + configuration_settings_file, configuration_protected_settings_file): + + """Default validations & defaults for Create + Must create and return a valid 'ExtensionInstance' object. + + """ + ext_scope = None + if scope is not None: + if scope.lower() == 'cluster': + scope_cluster = ScopeCluster(release_namespace=release_namespace) + ext_scope = Scope(cluster=scope_cluster, namespace=None) + elif scope.lower() == 'namespace': + scope_namespace = ScopeNamespace(target_namespace=target_namespace) + ext_scope = Scope(namespace=scope_namespace, cluster=None) + + create_identity = True + extension_instance = ExtensionInstance( + extension_type=extension_type, + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version, + scope=ext_scope, + configuration_settings=configuration_settings, + configuration_protected_settings=configuration_protected_settings, + ) + return extension_instance, name, create_identity + + def Update(self, extension, auto_upgrade_minor_version, release_train, version): + """Default validations & defaults for Update + Must create and return a valid 'ExtensionInstanceUpdate' object. + + """ + return ExtensionInstanceUpdate( + auto_upgrade_minor_version=auto_upgrade_minor_version, + release_train=release_train, + version=version + ) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py index a90b807020d..8c678b34915 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py @@ -67,9 +67,7 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t version=version, scope=ext_scope, configuration_settings=configuration_settings, - configuration_protected_settings=configuration_protected_settings, - identity=None, - location="" + configuration_protected_settings=configuration_protected_settings ) return extension_instance, name, create_identity diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py index 3117734116f..9a69199f838 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py @@ -41,9 +41,7 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t version=version, scope=ext_scope, configuration_settings=configuration_settings, - configuration_protected_settings=configuration_protected_settings, - identity=None, - location="" + configuration_protected_settings=configuration_protected_settings ) return extension_instance, name, create_identity diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py index c821dfc362a..f74ea5d809e 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models.py @@ -239,6 +239,8 @@ class ExtensionInstance(ProxyResource): :vartype name: str :ivar type: Resource type :vartype type: str + :param location: Location of resource type + :type location: str :param system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData @@ -305,6 +307,7 @@ class ExtensionInstance(ProxyResource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, @@ -324,6 +327,7 @@ class ExtensionInstance(ProxyResource): def __init__(self, **kwargs): super(ExtensionInstance, self).__init__(**kwargs) + self.location = kwargs.get('location', None) self.extension_type = kwargs.get('extension_type', None) self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) self.release_train = kwargs.get('release_train', None) diff --git a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py index 1ca6a98a35a..57f42c85edd 100644 --- a/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py +++ b/src/k8s-extension/azext_k8s_extension/vendored_sdks/models/_models_py3.py @@ -239,6 +239,8 @@ class ExtensionInstance(ProxyResource): :vartype name: str :ivar type: Resource type :vartype type: str + :param location: Location of resource type + :type location: str :param system_data: Top level metadata https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-contracts.md#system-metadata-for-all-azure-resources :type system_data: ~azure.mgmt.kubernetesconfiguration.models.SystemData @@ -305,6 +307,7 @@ class ExtensionInstance(ProxyResource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'identity': {'key': 'identity', 'type': 'ConfigurationIdentity'}, 'extension_type': {'key': 'properties.extensionType', 'type': 'str'}, @@ -322,8 +325,9 @@ class ExtensionInstance(ProxyResource): 'error_info': {'key': 'properties.errorInfo', 'type': 'ErrorDefinition'} } - def __init__(self, *, system_data=None, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, configuration_settings=None, configuration_protected_settings=None, install_state=None, statuses=None, identity=None, **kwargs) -> None: + def __init__(self, *, system_data=None, location: str=None, extension_type: str=None, auto_upgrade_minor_version: bool=None, release_train: str=None, version: str=None, scope=None, configuration_settings=None, configuration_protected_settings=None, install_state=None, statuses=None, identity=None, **kwargs) -> None: super(ExtensionInstance, self).__init__(system_data=system_data, **kwargs) + self.location = location self.extension_type = extension_type self.auto_upgrade_minor_version = auto_upgrade_minor_version self.release_train = release_train From eb4c58bb30928caef9fbff1778e68f326ef0d116 Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Wed, 24 Mar 2021 13:06:14 -0700 Subject: [PATCH 29/31] Update pipeline file --- k8s-custom-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s-custom-pipelines.yml b/k8s-custom-pipelines.yml index f4e2984ddf2..a603608b138 100644 --- a/k8s-custom-pipelines.yml +++ b/k8s-custom-pipelines.yml @@ -26,7 +26,7 @@ stages: SUBSCRIPTION_ID: "15c06b1b-01d6-407b-bb21-740b8617dea3" RESOURCE_GROUP: "K8sPartnerExtensionTest" BASE_CLUSTER_NAME: "k8s-extension-cluster" - IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/k8s-extension/private'), eq(variables['System.PullRequest.TargetBranch'], 'refs/heads/k8s-extension/private'))] + IS_PRIVATE_BRANCH: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/k8s-extension/private'), eq(variables['System.PullRequest.TargetBranch'], 'k8s-extension/private'))] EXTENSION_NAME: "k8s-extension" EXTENSION_FILE_NAME: "k8s_extension" From 3290f6e32cdd61b370f475055eb07d77d09753fe Mon Sep 17 00:00:00 2001 From: jonathan-innis Date: Fri, 2 Apr 2021 13:35:49 -0700 Subject: [PATCH 30/31] Disable refs docs --- k8s-custom-pipelines.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/k8s-custom-pipelines.yml b/k8s-custom-pipelines.yml index a603608b138..a3304668086 100644 --- a/k8s-custom-pipelines.yml +++ b/k8s-custom-pipelines.yml @@ -337,20 +337,3 @@ stages: env: ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId) ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch) - - - job: IndexRefDocVerify - displayName: "Verify Ref Docs" - pool: - vmImage: 'ubuntu-16.04' - steps: - - task: UsePythonVersion@0 - displayName: 'Use Python 3.7' - inputs: - versionSpec: 3.7 - - bash: pip install wheel==0.30.0 - displayName: 'Install wheel==0.30.0' - - task: Bash@3 - displayName: "Verify Extension Ref Docs" - inputs: - targetType: 'filePath' - filePath: scripts/ci/test_index_ref_doc.sh From 22c8e9247ed5ae5fa3cb0f273e69dd9e2053fe34 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Fri, 2 Apr 2021 16:15:58 -0700 Subject: [PATCH 31/31] Update to include better create warning logs and remove update context (#20) * Update to include better create warning logs and remove update context * Remove help text for update * Fix spelling error * Update message --- src/k8s-extension/HISTORY.rst | 6 ++++++ src/k8s-extension/azext_k8s_extension/_consts.py | 2 +- src/k8s-extension/azext_k8s_extension/_help.py | 5 ----- src/k8s-extension/azext_k8s_extension/commands.py | 1 - .../azext_k8s_extension/partner_extensions/AzureDefender.py | 3 ++- .../partner_extensions/ContainerInsights.py | 3 ++- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/k8s-extension/HISTORY.rst b/src/k8s-extension/HISTORY.rst index 54c1e375f6f..d20160a2199 100644 --- a/src/k8s-extension/HISTORY.rst +++ b/src/k8s-extension/HISTORY.rst @@ -3,6 +3,12 @@ Release History =============== +0.2.1 +++++++++++++++++++ + +* Remove `k8s-extension update` until PATCH is supported +* Improved logging for overwriting extension name with default + 0.2.0 ++++++++++++++++++ diff --git a/src/k8s-extension/azext_k8s_extension/_consts.py b/src/k8s-extension/azext_k8s_extension/_consts.py index d0fdaf7775f..144e9450012 100644 --- a/src/k8s-extension/azext_k8s_extension/_consts.py +++ b/src/k8s-extension/azext_k8s_extension/_consts.py @@ -5,4 +5,4 @@ # -------------------------------------------------------------------------------------------- EXTENSION_NAME = 'k8s-extension' -VERSION = "0.2.0" +VERSION = "0.2.1" diff --git a/src/k8s-extension/azext_k8s_extension/_help.py b/src/k8s-extension/azext_k8s_extension/_help.py index 64e4be612ea..562f0af58aa 100644 --- a/src/k8s-extension/azext_k8s_extension/_help.py +++ b/src/k8s-extension/azext_k8s_extension/_help.py @@ -32,8 +32,3 @@ type: command short-summary: Show details of a K8s-extension. """ - -helps[f'{consts.EXTENSION_NAME} update'] = """ - type: command - short-summary: Update a K8s-extension. -""" diff --git a/src/k8s-extension/azext_k8s_extension/commands.py b/src/k8s-extension/azext_k8s_extension/commands.py index 931662814c0..3a823177d1c 100644 --- a/src/k8s-extension/azext_k8s_extension/commands.py +++ b/src/k8s-extension/azext_k8s_extension/commands.py @@ -20,7 +20,6 @@ def load_command_table(self, _): is_preview=True) \ as g: g.custom_command('create', 'create_k8s_extension') - g.custom_command('update', 'update_k8s_extension') g.custom_command('delete', 'delete_k8s_extension', confirmation=True) g.custom_command('list', 'list_k8s_extension', table_transformer=k8s_extension_list_table_format) g.custom_show_command('show', 'show_k8s_extension', table_transformer=k8s_extension_show_table_format) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py index dcd2853affc..3124faec4c1 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py @@ -41,7 +41,8 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t is_ci_extension_type = False logger.warning('Ignoring name, release-namespace and scope parameters since %s ' - 'only supports cluster scope and single instance of this extension', extension_type) + 'only supports cluster scope and single instance of this extension.', extension_type) + logger.warning("Defaulting to extension name '%s' and release-namespace '%s'", name, release_namespace) _get_container_insights_settings(cmd, resource_group_name, cluster_name, configuration_settings, configuration_protected_settings, is_ci_extension_type) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py index 8c678b34915..eade4256205 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py @@ -53,7 +53,8 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t is_ci_extension_type = True logger.warning('Ignoring name, release-namespace and scope parameters since %s ' - 'only supports cluster scope and single instance of this extension', extension_type) + 'only supports cluster scope and single instance of this extension.', extension_type) + logger.warning("Defaulting to extension name '%s' and release-namespace '%s'", name, release_namespace) _get_container_insights_settings(cmd, resource_group_name, cluster_name, configuration_settings, configuration_protected_settings, is_ci_extension_type)