From 966b195032a3a56caab38cf7af581d5ceb4bedb8 Mon Sep 17 00:00:00 2001 From: Colby Williams Date: Thu, 5 Jan 2023 10:04:23 -0600 Subject: [PATCH] fix builder choco bug --- README.md | 2 +- bake/HISTORY.rst | 4 ++++ bake/azext_bake/_constants.py | 2 +- bake/azext_bake/_utils.py | 2 +- bake/azext_bake/_validators.py | 13 ++++--------- bake/azext_bake/custom.py | 26 +++++++------------------- bake/setup.py | 2 +- builder/Dockerfile | 2 +- 8 files changed, 20 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 5f7babe..22c3da2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Microsoft Azure CLI Extension for creating (or _"baking"_) custom virtual machin To install the Azure CLI Custom Image Helper extension, simply run the following command: ```sh -az extension add --source https://github.com/colbylwilliams/az-bake/releases/latest/download/bake-0.3.2-py3-none-any.whl -y +az extension add --source https://github.com/colbylwilliams/az-bake/releases/latest/download/bake-0.3.3-py3-none-any.whl -y ``` ### Update diff --git a/bake/HISTORY.rst b/bake/HISTORY.rst index 0998851..2c53fb3 100644 --- a/bake/HISTORY.rst +++ b/bake/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +0.3.3 +++++++ ++ Fix choco bug in builder + 0.3.2 ++++++ + Fix bug in builder diff --git a/bake/azext_bake/_constants.py b/bake/azext_bake/_constants.py index 972d290..45dc232 100644 --- a/bake/azext_bake/_constants.py +++ b/bake/azext_bake/_constants.py @@ -289,7 +289,7 @@ def tag_key(key): - displayName: Install az bake # get the latest version of az bake from the github releases and install it bash: | - az extension add --source https://github.com/colbylwilliams/az-bake/releases/latest/download/bake-0.3.2-py3-none-any.whl -y + az extension add --source https://github.com/colbylwilliams/az-bake/releases/latest/download/bake-0.3.3-py3-none-any.whl -y az bake upgrade - displayName: Run az bake diff --git a/bake/azext_bake/_utils.py b/bake/azext_bake/_utils.py index 73b5b42..3341d77 100644 --- a/bake/azext_bake/_utils.py +++ b/bake/azext_bake/_utils.py @@ -126,7 +126,7 @@ def get_install_choco_packages(image: Image) -> List[ChocoPackage]: for c in image.install.choco.packages: logger.info(f'Getting choco config for {c} type {type(c)}') # if only the id was givin, check the index for the rest of the config - choco_node = ChocoPackage(choco_index[c.id]) if c.id_only and c.id in choco_index else c.copy() + choco_node = ChocoPackage(choco_index[c.id]) if c.id_only and c.id in choco_index else ChocoPackage(get_dict(c)) # TODO # if defaults were given, add them to the config diff --git a/bake/azext_bake/_validators.py b/bake/azext_bake/_validators.py index 6e55b04..b8f522e 100644 --- a/bake/azext_bake/_validators.py +++ b/bake/azext_bake/_validators.py @@ -61,8 +61,10 @@ def process_bake_repo_build_namespace(cmd, ns): raise ArgumentUsageError('--repo-url, --repo-token, and --repo-revision can not be used in a CI environment') ci = CI() - env_key = 'GITHUB_TOKEN' if ci.provider == 'github' else 'SYSTEM_ACCESSTOKEN' - logger.warning(f'WARNING: {env_key} environment variable not set. This is required for private repositories.') + + if ci.token is None: + env_key = 'GITHUB_TOKEN' if ci.provider == 'github' else 'SYSTEM_ACCESSTOKEN' + logger.warning(f'WARNING: {env_key} environment variable not set. This is required for private repositories.') repo = Repo(url=ci.url, token=ci.token, ref=ci.ref, revision=ci.revision) @@ -241,9 +243,6 @@ def bake_yaml_validator(cmd, ns, path=None): raise RequiredArgumentMissingError('usage error: --repository-path is required.') bake_config = get_yaml_file_data(BakeConfig, path) - print('') - print(bake_config) - print('') if hasattr(ns, 'bake_obj'): ns.bake_obj = bake_config @@ -260,10 +259,6 @@ def bake_yaml_validator(cmd, ns, path=None): def image_yaml_validator(cmd, ns, path): image = get_yaml_file_data(Image, path) - print('') - print(image) - print('') - if hasattr(ns, 'image'): ns.image = image diff --git a/bake/azext_bake/custom.py b/bake/azext_bake/custom.py index 80f73ad..0dfd272 100644 --- a/bake/azext_bake/custom.py +++ b/bake/azext_bake/custom.py @@ -197,18 +197,6 @@ def bake_repo_build(cmd, repository_path, image_names: Sequence[str] = None, san def bake_repo_validate(cmd, repository_path, sandbox: Sandbox = None, gallery: Gallery = None, images: Sequence[Image] = None): - print('') - print('Sabndbox:') - print(get_dict(sandbox)) - print('') - print('Gallery:') - print(get_dict(gallery)) - print('') - print('Images:') - print('') - for image in images: - print(get_dict(image)) - print('') logger.info('Validating repository') @@ -398,16 +386,16 @@ def bake_builder_build(cmd, sandbox: Sandbox = None, gallery: Gallery = None, im if powershell_scripts: inject_powershell_provisioner(image.dir, powershell_scripts) - choco_install = get_install_choco_packages(image) + choco_packages = get_install_choco_packages(image) - user_choco_install = [c for c in choco_install if c.user] - if user_choco_install: - choco_user_config = get_choco_package_config(user_choco_install) + user_choco_packages = [package for package in choco_packages if package.user] + if user_choco_packages: + choco_user_config = get_choco_package_config(user_choco_packages) inject_choco_provisioners(image.dir, choco_user_config, for_user=True) - machine_choco_install = [c for c in choco_install if not c.user] - if machine_choco_install: - machine_choco_config = get_choco_package_config(machine_choco_install) + machine_choco_packages = [package for package in choco_packages if not package.user] + if machine_choco_packages: + machine_choco_config = get_choco_package_config(machine_choco_packages) inject_choco_provisioners(image.dir, machine_choco_config, for_user=False) # winget_config = get_install_winget(image) diff --git a/bake/setup.py b/bake/setup.py index 921bd4b..fe7a1b5 100644 --- a/bake/setup.py +++ b/bake/setup.py @@ -17,7 +17,7 @@ logger.warn("Wheel is not available, disabling bdist_wheel hook") # Must match a HISTORY.rst entry. -VERSION = '0.3.2' +VERSION = '0.3.3' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers diff --git a/builder/Dockerfile b/builder/Dockerfile index 49152b8..a4620d5 100644 --- a/builder/Dockerfile +++ b/builder/Dockerfile @@ -38,7 +38,7 @@ LABEL maintainer="Microsoft" \ RUN apk add --no-cache packer --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community # install az-bake -RUN az extension add --source https://github.com/colbylwilliams/az-bake/releases/latest/download/bake-0.3.2-py3-none-any.whl -y +RUN az extension add --source https://github.com/colbylwilliams/az-bake/releases/latest/download/bake-0.3.3-py3-none-any.whl -y # Terminate container on stop STOPSIGNAL SIGTERM