Skip to content

Commit

Permalink
revert log bug
Browse files Browse the repository at this point in the history
  • Loading branch information
colbylwilliams committed Jan 6, 2023
1 parent 0ecab6e commit e2559f6
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@
"id": "terminal",
"color": "terminal.ansiMagenta"
}
},
{
"label": "util: clear images",
"command": "python3",
"args": [
"tools${pathSeparator}clear-images.py"
],
"icon": {
"id": "terminal",
"color": "terminal.ansiMagenta"
}
}
],
"inputs": [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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.9-py3-none-any.whl -y
az extension add --source https://github.com/colbylwilliams/az-bake/releases/latest/download/bake-0.3.10-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.10
++++++
* Revert bug that could create log file

0.3.9
++++++
* Save all image config files to builder storage
Expand Down
7 changes: 4 additions & 3 deletions bake/azext_bake/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
from azure.cli.core.azclierror import FileOperationError, ValidationError
from knack.log import get_logger as knack_get_logger

from ._constants import OUTPUT_DIR, STORAGE_DIR
from ._constants import IN_BUILDER, OUTPUT_DIR, STORAGE_DIR
from ._data import ChocoPackage, Image, PowershellScript, get_dict


def get_logger(name):
'''Get the logger for the extension'''
_logger = knack_get_logger(name)

# if IN_BUILDER and STORAGE_DIR.is_dir():
if STORAGE_DIR.is_dir():
# this must only happen in the builder, otherwise
# the log file could be created on users machines
if IN_BUILDER and STORAGE_DIR.is_dir():
import logging
log_file = OUTPUT_DIR / 'builder.log'
formatter = logging.Formatter('{asctime} [{name:^28}] {levelname:<8}: {message}',
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.9'
VERSION = '0.3.10'

# 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.9-py3-none-any.whl -y
RUN az extension add --source https://github.com/colbylwilliams/az-bake/releases/latest/download/bake-0.3.10-py3-none-any.whl -y

# Terminate container on stop
STOPSIGNAL SIGTERM
Expand Down
22 changes: 22 additions & 0 deletions tools/clear-images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from os import walk
from pathlib import Path
from shutil import rmtree

REPO_DIR = Path(__file__).resolve().parent.parent
IMAGES_DIR = REPO_DIR / 'images'

files_del = []
dirs_del = []

# walk the images directory and find all the child directories
for dirpath, dirnames, files in walk(IMAGES_DIR):
# os.walk includes the root directory (i.e. repo/images) so we need to skip it
if not IMAGES_DIR.samefile(dirpath) and Path(dirpath).parent.samefile(IMAGES_DIR):
files_del.extend([Path(dirpath) / f for f in files if not f.lower() == 'image.yaml' and not f.lower() == 'image.yml'])
dirs_del.extend([Path(dirpath) / d for d in dirnames])

for f in files_del:
f.unlink()

for d in dirs_del:
rmtree(d)

0 comments on commit e2559f6

Please sign in to comment.