Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow running the local scripts outside of the main FTL directory. #3017

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/console/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"
"net/http/httputil"
"net/url"
"os"
"path"
"path/filepath"
"time"
Expand All @@ -24,7 +25,7 @@ var proxyURL, _ = url.Parse("http://localhost:5173") //nolint:errcheck
var proxy = httputil.NewSingleHostReverseProxy(proxyURL)

func Server(ctx context.Context, timestamp time.Time, publicURL *url.URL, allowOrigin *url.URL) (http.Handler, error) {
gitRoot, ok := internal.GitRoot("").Get()
gitRoot, ok := internal.GitRoot(os.Getenv("FTL_DIR")).Get()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use an envar, plumb it through from a Kong config rather than using getenv directly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, this is local.go...disregard!

if !ok {
return nil, fmt.Errorf("failed to find Git root")
}
Expand Down
10 changes: 7 additions & 3 deletions scripts/ftl
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/bin/bash
set -euo pipefail
ftldir="$(dirname "$(readlink -f "$0")")/.."
export FTL_DIR="$(dirname "$(readlink -f "$0")")/.."

Check failure on line 3 in scripts/ftl

View workflow job for this annotation

GitHub Actions / Lint

warning: Declare and assign separately to avoid masking return values. [SC2155]
if [ ! "${HERMIT_ENV}" -ef ${FTL_DIR} ]; then

Check failure on line 4 in scripts/ftl

View workflow job for this annotation

GitHub Actions / Lint

note: Double quote to prevent globbing and word splitting. [SC2086]
. "${FTL_DIR}/bin/activate-hermit"

Check failure on line 5 in scripts/ftl

View workflow job for this annotation

GitHub Actions / Lint

note: Not following: ./bin/activate-hermit was not specified as input (see shellcheck -x). [SC1091]
fi

name="$(basename "$0")"
dest="${ftldir}/build/devel"
dest="${FTL_DIR}/build/devel"
src="./cmd/${name}"
if [ "${name}" = "ftl" ]; then
src="./frontend/cli"
fi
mkdir -p "$dest"
(cd "${ftldir}/${src}" && "${ftldir}/bin/go" build -ldflags="-s -w -buildid=" -o "$dest/${name}" .) && exec "$dest/${name}" "$@"
(cd "${FTL_DIR}/${src}" && "${FTL_DIR}/bin/go" build -ldflags="-s -w -buildid=" -o "$dest/${name}" .) && exec "$dest/${name}" "$@"