refactor: cleanup Dockerfile and project.toml lookups

This commit is contained in:
Jose Diaz-Gonzalez
2021-04-14 14:56:58 -04:00
parent cb16e11cf5
commit d68473bfc2
3 changed files with 22 additions and 21 deletions

View File

@@ -29,13 +29,15 @@ trigger-builder-pack-builder-build() {
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
local NEW_PROJECT_TOML="$(fn-builder-pack-computed-projectoml-path "$APP")"
if [[ -f "$NEW_PROJECT_TOML" ]]; then
if [[ "$NEW_DOCKERFILE" != "project.toml" ]]; then
local NEW_PROJECT_TOML="$(fn-builder-pack-computed-projecttoml-path "$APP")"
if [[ -n "$NEW_PROJECT_TOML" ]]; then
if [[ ! -f "$NEW_PROJECT_TOML" ]]; then
dokku_log_fail "Invalid projecttoml-path specified: $NEW_PROJECT_TOML"
fi
if [[ "$NEW_PROJECT_TOML" != "project.toml" ]]; then
mv "$NEW_PROJECT_TOML" project.toml
fi
else
rm project.toml
fi
local TMP_FILE=$(mktemp "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")

View File

@@ -36,9 +36,9 @@ cmd-builder-pack-report-single() {
fi
verify_app_name "$APP"
local flag_map=(
"--builder-pack-computed-projecttoml-path: $(fn-builder-pack-computed-projectoml-path "$APP")"
"--builder-pack-global-projecttoml-path: $(fn-builder-pack-global-projectoml-path "$APP")"
"--builder-pack-projecttoml-path: $(fn-builder-pack-projectoml-path "$APP")"
"--builder-pack-computed-projecttoml-path: $(fn-builder-pack-computed-projecttoml-path "$APP")"
"--builder-pack-global-projecttoml-path: $(fn-builder-pack-global-projecttoml-path "$APP")"
"--builder-pack-projecttoml-path: $(fn-builder-pack-projecttoml-path "$APP")"
)
if [[ -z "$INFO_FLAG" ]]; then
@@ -67,24 +67,24 @@ cmd-builder-pack-report-single() {
fi
}
fn-builder-pack-computed-projectoml-path() {
fn-builder-pack-computed-projecttoml-path() {
declare APP="$1"
file="$(fn-builder-pack-projectoml-path "$APP")"
file="$(fn-builder-pack-projecttoml-path "$APP")"
if [[ "$file" == "" ]]; then
file="$(fn-builder-pack-global-projectoml-path "$APP")"
file="$(fn-builder-pack-global-projecttoml-path "$APP")"
fi
echo "$file"
}
fn-builder-pack-global-projectoml-path() {
fn-builder-pack-global-projecttoml-path() {
declare APP="$1"
fn-plugin-property-get "builder-pack" "--global" "projecttoml-path" "project.toml"
}
fn-builder-pack-projectoml-path() {
fn-builder-pack-projecttoml-path() {
declare APP="$1"
fn-plugin-property-get "builder-pack" "$APP" "projecttoml-path" ""