From 4ab6f9b94768eddb4e99d34bcb075040cc0736d8 Mon Sep 17 00:00:00 2001 From: Matthieu Bernardin Date: Tue, 30 Jul 2024 14:55:47 -0400 Subject: [PATCH 1/4] fix: actually use CONFIG_TOML_FILE param if provided Signed-off-by: Ralph Bean --- task/build-vm-image/0.1/build-vm-image.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/task/build-vm-image/0.1/build-vm-image.yaml b/task/build-vm-image/0.1/build-vm-image.yaml index bb52a5c924..d217a28911 100644 --- a/task/build-vm-image/0.1/build-vm-image.yaml +++ b/task/build-vm-image/0.1/build-vm-image.yaml @@ -154,18 +154,19 @@ spec: echo "$BUILD_DIR" ssh -v $SSH_ARGS "$SSH_HOST" mkdir -p "$BUILD_DIR/workspaces" "$BUILD_DIR/scripts" "$BUILD_DIR/tmp" "$BUILD_DIR/tekton-results" "$BUILD_DIR/entitlement" - if [ ! -n "${CONFIG_TOML_FILE}" ]; then + if [! -n "${CONFIG_TOML_FILE}" ]; then echo "No CONFIG_TOML_FILE specified" - export CONFIG_TOML_FILE=config.toml if [ -f /var/workdir/source/config.toml ]; then echo "Using the config.toml file found in the repository root!" - echo " Remove the config.toml file or set params.CONFIG_TOML_FILE to another file to prevent using config.toml." + echo " Remove the config.toml file or set params.CONFIG_TOML_FILE to an invalid path to prevent its use." else - echo "No config.toml file found. Using an empty configuration." - touch /var/workdir/source/$CONFIG_TOML_FILE + echo "No config.toml file found. Set params.CONFIG_TOML_FILE to use one in the repository." + export CONFIG_TOML_FILE=config.toml fi fi - echo "Using the following config.toml file $CONFIG_TOML_FILE:" + # ensure that a config toml file is present in case one is not provided or the path is invalid + mkdir -p /var/workdir/source/$(dirname $CONFIG_TOML_FILE) + echo "Using the following config.toml file:" cat /var/workdir/source/$CONFIG_TOML_FILE From 2adf95772c5c453e5b077135c600190c185e4ab2 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Tue, 30 Jul 2024 15:06:41 -0400 Subject: [PATCH 2/4] Try to make this make more sense The logic here was pretty confusing. Trying to straighten it out. --- task/build-vm-image/0.1/build-vm-image.yaml | 25 ++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/task/build-vm-image/0.1/build-vm-image.yaml b/task/build-vm-image/0.1/build-vm-image.yaml index d217a28911..65bd481779 100644 --- a/task/build-vm-image/0.1/build-vm-image.yaml +++ b/task/build-vm-image/0.1/build-vm-image.yaml @@ -154,21 +154,20 @@ spec: echo "$BUILD_DIR" ssh -v $SSH_ARGS "$SSH_HOST" mkdir -p "$BUILD_DIR/workspaces" "$BUILD_DIR/scripts" "$BUILD_DIR/tmp" "$BUILD_DIR/tekton-results" "$BUILD_DIR/entitlement" - if [! -n "${CONFIG_TOML_FILE}" ]; then - echo "No CONFIG_TOML_FILE specified" - if [ -f /var/workdir/source/config.toml ]; then - echo "Using the config.toml file found in the repository root!" - echo " Remove the config.toml file or set params.CONFIG_TOML_FILE to an invalid path to prevent its use." - else - echo "No config.toml file found. Set params.CONFIG_TOML_FILE to use one in the repository." - export CONFIG_TOML_FILE=config.toml - fi + if [ ! -n "${CONFIG_TOML_FILE}" ]; then + echo "No CONFIG_TOML_FILE specified. Assuming config.toml" + export CONFIG_TOML_FILE=config.toml + fi + + if [ -f "/var/workdir/source/${CONFIG_TOML_FILE}" ]; then + echo "Using the ${CONFIG_TOML_FILE} file found in the repository root!" + else + echo "No ${CONFIG_TOML_FILE} file found in the repository. Set params.${CONFIG_TOML_FILE}_FILE to a valid config.toml file." + exit 1 fi - # ensure that a config toml file is present in case one is not provided or the path is invalid - mkdir -p /var/workdir/source/$(dirname $CONFIG_TOML_FILE) - echo "Using the following config.toml file:" - cat /var/workdir/source/$CONFIG_TOML_FILE + echo "Using the following ${CONFIG_TOML_FILE} file:" + cat /var/workdir/source/$CONFIG_TOML_FILE rsync -ra "/var/workdir/source/$CONFIG_TOML_FILE" "$SSH_HOST:$BUILD_DIR/config.toml" rsync -ra "$HOME/.docker/" "$SSH_HOST:$BUILD_DIR/.docker/" From 536965bc43235289cd9e02bca58f9581cdf8bb43 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Wed, 31 Jul 2024 08:32:18 -0400 Subject: [PATCH 3/4] Use empty config.toml file if one not found --- task/build-vm-image/0.1/build-vm-image.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task/build-vm-image/0.1/build-vm-image.yaml b/task/build-vm-image/0.1/build-vm-image.yaml index 65bd481779..4dea6bfd95 100644 --- a/task/build-vm-image/0.1/build-vm-image.yaml +++ b/task/build-vm-image/0.1/build-vm-image.yaml @@ -162,8 +162,8 @@ spec: if [ -f "/var/workdir/source/${CONFIG_TOML_FILE}" ]; then echo "Using the ${CONFIG_TOML_FILE} file found in the repository root!" else - echo "No ${CONFIG_TOML_FILE} file found in the repository. Set params.${CONFIG_TOML_FILE}_FILE to a valid config.toml file." - exit 1 + echo "No ${CONFIG_TOML_FILE} file found. Using an empty configuration." + touch "/var/workdir/source/${CONFIG_TOML_FILE}" fi echo "Using the following ${CONFIG_TOML_FILE} file:" From cecd998a4653d08c52ffcf288eff98c95dbc8e8c Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Wed, 31 Jul 2024 08:33:07 -0400 Subject: [PATCH 4/4] Make this log line more correct Andrew pointed out in code review that it's too specific to claim that it is found in the repository root. It could be in a subdir. --- task/build-vm-image/0.1/build-vm-image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task/build-vm-image/0.1/build-vm-image.yaml b/task/build-vm-image/0.1/build-vm-image.yaml index 4dea6bfd95..0fc6eb4665 100644 --- a/task/build-vm-image/0.1/build-vm-image.yaml +++ b/task/build-vm-image/0.1/build-vm-image.yaml @@ -160,7 +160,7 @@ spec: fi if [ -f "/var/workdir/source/${CONFIG_TOML_FILE}" ]; then - echo "Using the ${CONFIG_TOML_FILE} file found in the repository root!" + echo "Using the ${CONFIG_TOML_FILE} file found in the repository." else echo "No ${CONFIG_TOML_FILE} file found. Using an empty configuration." touch "/var/workdir/source/${CONFIG_TOML_FILE}"