-
Notifications
You must be signed in to change notification settings - Fork 249
[services] Fix issue where env var is ignored #1570
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
Conversation
0a855a8
to
ecf452a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a quick pass. No major concerns, except for the lepp-stack
changes, which I don't follow.
I didn't quite understand how it all fits together, so need to make another review pass.
I need to pause for 🐕 walk and dinner. Will re-review soon...
@@ -19,7 +20,6 @@ | |||
"init_db": "initdb", | |||
"run_test": [ | |||
"mkdir -p /tmp/devbox/lapp", | |||
"export PGHOST=/tmp/devbox/lapp", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO savil: come back to this change. Refer to slack convo b/w mike and john
@@ -22,6 +23,7 @@ | |||
"run_test": [ | |||
"mkdir -p /tmp/devbox/lepp", | |||
"export PGHOST=/tmp/devbox/lepp", | |||
"rm -rf .devbox/virtenv/postgresql/data", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just makes testing easier by making run_test
more idempotent.
@@ -9,7 +9,8 @@ | |||
"env": { | |||
"NGINX_WEB_PORT": "8089", | |||
"NGINX_WEB_ROOT": "../../../my_app", | |||
"PGPORT": "5433" | |||
"PGPORT": "5433", | |||
"PGHOST": "/tmp/devbox/lepp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this if we're exporting PGHOST in run_test?
internal/boxcli/services.go
Outdated
Short: "Interact with devbox services", | ||
Short: "Interact with devbox services.", | ||
Long: "Interact with devbox services. Services start in a new shell. " + | ||
"Plugin services use envrinment variables specified by plugin unless " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: envrinment
@@ -526,15 +538,22 @@ func (d *Devbox) Services() (services.Services, error) { | |||
return result, nil | |||
} | |||
|
|||
func (d *Devbox) StartServices(ctx context.Context, serviceNames ...string) error { | |||
if !d.IsEnvEnabled() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I did re-implement this function in the PathStack PR. I wonder if that update caused this bug.
internal/impl/envpath/pathlists.go
Outdated
@@ -35,3 +36,22 @@ func JoinPathLists(pathLists ...string) string { | |||
} | |||
return strings.Join(cleaned, string(filepath.ListSeparator)) | |||
} | |||
|
|||
func RemoveFromPath(path, pathToRemove string) string { | |||
paths := strings.Split(path, string(os.PathListSeparator)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can use filepath.SplitList
} | ||
|
||
// Join the modified paths using ":" as the delimiter | ||
newPath := strings.Join(newPaths, string(os.PathListSeparator)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can use filepath.Join
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 37 too :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filepath.Join
is for directory paths! not for path lists!
e.g. /path/to/my/file vs path1:path2:path3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
} | ||
|
||
// Join the modified paths using ":" as the delimiter | ||
newPath := strings.Join(newPaths, string(os.PathListSeparator)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
Summary
Fixes #1565
The bugs:
--env-file
(and possibly via other methods) are ignored in nginx config.Intermediate causes:
envsubst
binary was a bin wrapped binary. This was resetting the env vars. Fix: Never use bin wrappers when inside adevbox run
(This was previously only scoped to using the CLI command explicitly, but now we do it any time we use RunScript function)Root cause:
Sorry in advance for all the boolean params. We should move to structs, but I didn't want to make those changes here.
How was it tested?
envsubst
regression in0.7.0
#1565.