Skip to content

Commit

Permalink
Merge branch 'dev' into 3.12
Browse files Browse the repository at this point in the history
# Conflicts:
#	azure-pipelines.yml
  • Loading branch information
bebound committed Oct 16, 2024
2 parents 5287832 + 68e5f06 commit 256e9fd
Show file tree
Hide file tree
Showing 313 changed files with 131,004 additions and 83,938 deletions.
35 changes: 35 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ trigger:
branches:
include:
- '*'
exclude:
- 'release'

pr:
branches:
Expand Down Expand Up @@ -205,6 +207,11 @@ jobs:
TargetPath: '$(Build.ArtifactStagingDirectory)/metadata'
artifactName: metadata

- task: PipAuthenticate@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/release')
displayName: 'Pip Authenticate'
inputs:
artifactFeeds: $(AZURE_ARTIFACTS_FEEDS)

- script: |
set ARCH=$(Platform)
Expand Down Expand Up @@ -515,6 +522,11 @@ jobs:
TargetPath: '$(Build.ArtifactStagingDirectory)/metadata'
artifactName: metadata

- task: PipAuthenticate@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/release')
displayName: 'Pip Authenticate'
inputs:
artifactFeeds: $(AZURE_ARTIFACTS_FEEDS)

- script: |
set ARCH=$(Platform)
Expand Down Expand Up @@ -699,6 +711,13 @@ jobs:
displayName: 'Use Python 3.12'
inputs:
versionSpec: 3.12

- task: PipAuthenticate@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/release')
displayName: 'Pip Authenticate'
inputs:
artifactFeeds: $(AZURE_ARTIFACTS_FEEDS)

- script: |
if [[ "$(Build.Reason)" == "PullRequest" ]]; then
branch=$(System.PullRequest.TargetBranch)
Expand Down Expand Up @@ -981,6 +1000,12 @@ jobs:
- bash: ./scripts/ci/install_docker.sh
displayName: Install Docker

- task: PipAuthenticate@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/release')
displayName: 'Pip Authenticate'
inputs:
artifactFeeds: $(AZURE_ARTIFACTS_FEEDS)

- task: Bash@3
displayName: 'Build Rpm Package: Azure Linux'
inputs:
Expand Down Expand Up @@ -1071,6 +1096,11 @@ jobs:
steps:
- bash: ./scripts/ci/install_docker.sh
displayName: Install Docker
- task: PipAuthenticate@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/release')
displayName: 'Pip Authenticate'
inputs:
artifactFeeds: $(AZURE_ARTIFACTS_FEEDS)
- task: Bash@3
displayName: 'Build Rpm Package'
inputs:
Expand Down Expand Up @@ -1188,6 +1218,11 @@ jobs:
steps:
- bash: ./scripts/ci/install_docker.sh
displayName: Install Docker
- task: PipAuthenticate@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/release')
displayName: 'Pip Authenticate'
inputs:
artifactFeeds: $(AZURE_ARTIFACTS_FEEDS)
- task: Bash@3
displayName: 'Build $(deb_system) $(distro) $(arch) Package'
inputs:
Expand Down
1 change: 1 addition & 0 deletions scripts/release/debian/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ docker run --rm \
-e CLI_VERSION=$CLI_VERSION \
-e CLI_VERSION_REVISION=1~$DISTRO \
-e DEBIAN_FRONTEND=noninteractive \
-e PIP_INDEX_URL=$PIP_INDEX_URL \
$DISTRO_BASE_IMAGE \
/mnt/repo/scripts/release/debian/build.sh
3 changes: 2 additions & 1 deletion scripts/release/rpm/azurelinux.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ COPY . .
# Azure Linux 3's python3 is 3.12, the rpm paths are
# /usr/src/azl/RPMS/x86_64/azure-cli-2.63.0-1.azl3.x86_64.rpm
# /usr/src/azl/RPMS/aarch64/azure-cli-2.63.0-1.azl3.aarch64.rpm
RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \
RUN --mount=type=secret,id=PIP_INDEX_URL export PIP_INDEX_URL=$(cat /run/secrets/PIP_INDEX_URL) && \
dos2unix ./scripts/release/rpm/azure-cli.spec && \
REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=python3 PYTHON_CMD=python3 \
rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \
cp /usr/src/*/RPMS/*/azure-cli-${cli_version}-1.*.rpm /azure-cli-dev.rpm && \
Expand Down
4 changes: 4 additions & 0 deletions scripts/release/rpm/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ set -exv

CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g`

# PIP_INDEX_URL env must exist in `docker build --secret`, use an empty string if it doesn't exist.
export PIP_INDEX_URL=${PIP_INDEX_URL}

# Create a container image that includes the source code and a built RPM using this file.
docker build \
--target build-env \
--build-arg cli_version=${CLI_VERSION} \
--build-arg image=${IMAGE} \
--build-arg python_package=${PYTHON_PACKAGE} \
--secret id=PIP_INDEX_URL \
-f ./scripts/release/rpm/${DOCKERFILE}.dockerfile \
-t azure/azure-cli:${DOCKERFILE}-builder \
.
Expand Down
4 changes: 4 additions & 0 deletions scripts/release/rpm/pipeline_azurelinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ set -exv

CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g`

# PIP_INDEX_URL env must exist in `docker build --secret`, use an empty string if it doesn't exist.
export PIP_INDEX_URL=${PIP_INDEX_URL}

# Create a container image that includes the source code and a built RPM using this file.
docker build \
--target build-env \
--build-arg cli_version=${CLI_VERSION} \
--build-arg image=${IMAGE} \
--secret id=PIP_INDEX_URL \
-f ./scripts/release/rpm/azurelinux.dockerfile \
-t azure/azure-cli:azurelinux-builder \
.
Expand Down
3 changes: 2 additions & 1 deletion scripts/release/rpm/ubi.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ COPY . .

# RHEL 8's 'python3' is Python 3.6. RHEL 9's 'python3' is Python 3.9.
# We have to explicitly specify 'python39' to install Python 3.9.
RUN dos2unix ./scripts/release/rpm/azure-cli.spec && \
RUN --mount=type=secret,id=PIP_INDEX_URL export PIP_INDEX_URL=$(cat /run/secrets/PIP_INDEX_URL) && \
dos2unix ./scripts/release/rpm/azure-cli.spec && \
REPO_PATH=$(pwd) CLI_VERSION=$cli_version PYTHON_PACKAGE=$python_package PYTHON_CMD=python3.9 \
rpmbuild -v -bb --clean scripts/release/rpm/azure-cli.spec && \
cp /root/rpmbuild/RPMS/*/azure-cli-${cli_version}-1.*.rpm /azure-cli-dev.rpm && \
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/aaz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ._command import AAZCommand, AAZWaitCommand, AAZCommandGroup, \
register_callback, register_command, register_command_group, load_aaz_command_table, link_helper
from ._field_type import AAZIntType, AAZFloatType, AAZStrType, AAZBoolType, AAZDictType, AAZFreeFormDictType, \
AAZListType, AAZObjectType
AAZListType, AAZObjectType, AAZIdentityObjectType
from ._operation import AAZHttpOperation, AAZJsonInstanceUpdateOperation, AAZGenericInstanceUpdateOperation, \
AAZJsonInstanceDeleteOperation, AAZJsonInstanceCreateOperation
from ._prompt import AAZPromptInput, AAZPromptPasswordInput
Expand Down
5 changes: 3 additions & 2 deletions src/azure-cli-core/azure/cli/core/aaz/_content_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ def set_prop(self, prop_name, typ, arg_key=None, typ_kwargs=None):
value[prop_name] = {}
else:
raise NotImplementedError()
sub_values.append(value[prop_name])
sub_args.append(sub_arg)
if value != None: # noqa: E711, pylint: disable=singleton-comparison
sub_values.append(value[prop_name])
sub_args.append(sub_arg)

if sub_values:
self._sub_prop_builders[prop_name] = AAZContentBuilder(sub_values, sub_args)
Expand Down
7 changes: 6 additions & 1 deletion src/azure-cli-core/azure/cli/core/aaz/_field_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from collections import OrderedDict
from ._base import AAZBaseType, AAZValuePatch, AAZUndefined
from ._field_value import AAZObject, AAZDict, AAZFreeFormDict, AAZList, AAZSimpleValue
from ._field_value import AAZObject, AAZDict, AAZFreeFormDict, AAZList, AAZSimpleValue, \
AAZIdentityObject
from ._utils import to_snack_case
from .exceptions import AAZUnknownFieldError, AAZConflictFieldDefinitionError, AAZValuePrecisionLossError, \
AAZInvalidFieldError, AAZInvalidValueError
Expand Down Expand Up @@ -409,3 +410,7 @@ def process_data(self, data, **kwargs):
value[idx] = sub_data

return result


class AAZIdentityObjectType(AAZObjectType):
_ValueCls = AAZIdentityObject
91 changes: 91 additions & 0 deletions src/azure-cli-core/azure/cli/core/aaz/_field_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=protected-access
import copy

from ._base import AAZBaseValue, AAZValuePatch, AAZUndefined
Expand Down Expand Up @@ -444,3 +445,93 @@ def to_serialized_data(self, processor=None, keep_undefined_in_list=False, # py
if processor:
result = processor(self._schema, result)
return result


class AAZIdentityObject(AAZObject): # pylint: disable=too-few-public-methods
def to_serialized_data(self, processor=None, **kwargs):
calculate_data = dict()
if self._data == AAZUndefined:
result = AAZUndefined

elif self._data is None:
result = None

else:
result = {}
schema = self._schema

for name, field_schema in schema._fields.items():
if name in self._data:
v = self[name].to_serialized_data(processor=processor, **kwargs)
if v == AAZUndefined:
continue

if field_schema._serialized_name:
name = field_schema._serialized_name

if name in {"userAssigned", "systemAssigned"}:
calculate_data[name] = v
calculate_data["action"] = field_schema._flags.get("action", None) # no action in GET operation

else:
result[name] = v

result = self._build_identity(calculate_data, result)

if not result:
result = {"type": "None"} # empty identity

if not result and self._is_patch:
result = AAZUndefined

if processor:
result = processor(self._schema, result)

return result

def _build_identity(self, calculate_data, result):
action = calculate_data.get("action", None)
if not action:
return result

user_assigned = calculate_data.get("userAssigned", None)
system_assigned = calculate_data.get("systemAssigned", None)

identities = set(result.pop("userAssignedIdentities", {}).keys())
has_system_identity = "systemassigned" in result.pop("type", "").lower()

if action == "remove":
if user_assigned is not None:
if len(user_assigned) > 1: # remove each
identities -= set(user_assigned)

else: # remove all
identities = {}

if identities:
result["userAssignedIdentities"] = {k: {} for k in identities}
if system_assigned or not has_system_identity:
result["type"] = "UserAssigned"

else:
result["type"] = "SystemAssigned,UserAssigned"

elif not system_assigned and has_system_identity:
result["type"] = "SystemAssigned"

else: # assign or create
if user_assigned:
identities |= set(user_assigned)

if identities:
result["userAssignedIdentities"] = {k: {} for k in identities}
if system_assigned or has_system_identity:
result["type"] = "SystemAssigned,UserAssigned"

else:
result["type"] = "UserAssigned"

elif system_assigned or has_system_identity:
result["type"] = "SystemAssigned"

return result
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def default_api_version(self):
ResourceType.MGMT_ARO: '2023-11-22',
ResourceType.MGMT_DATABOXEDGE: '2021-02-01-preview',
ResourceType.MGMT_CUSTOMLOCATION: '2021-03-15-preview',
ResourceType.MGMT_CONTAINERSERVICE: SDKProfile('2024-07-01'),
ResourceType.MGMT_CONTAINERSERVICE: SDKProfile('2024-08-01'),
ResourceType.MGMT_APPCONTAINERS: '2022-10-01',
},
'2020-09-01-hybrid': {
Expand Down
Loading

0 comments on commit 256e9fd

Please sign in to comment.