Skip to content

Commit

Permalink
fix builder choco bug
Browse files Browse the repository at this point in the history
  • Loading branch information
colbylwilliams committed Jan 5, 2023
1 parent ba4e356 commit 966b195
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions bake/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.3.3
++++++
+ Fix choco bug in builder

0.3.2
++++++
+ Fix bug in builder
Expand Down
2 changes: 1 addition & 1 deletion bake/azext_bake/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bake/azext_bake/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 4 additions & 9 deletions bake/azext_bake/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
26 changes: 7 additions & 19 deletions bake/azext_bake/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')


Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bake/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 966b195

Please sign in to comment.