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

Feature request: discover GOKRAZY_PARENT_DIR by walking $PWD up (til $HOME) #194

Open
bradfitz opened this issue Apr 9, 2023 · 1 comment

Comments

@bradfitz
Copy link
Contributor

bradfitz commented Apr 9, 2023

I want to store a number of my gokrazy configs together in a single git repo, not in $HOME/gokrazy.

But I also don't want to type gok --parent_dir=$HOME/src/github.com/bradfitz/private/gokrazy -i mosquitto .... every time.

Currently, as defined,

https://github.com/gokrazy/internal/blob/5f469e7488b0/instanceflag/instanceflag.go#L74-L78
https://github.com/gokrazy/internal/blob/5f469e7488b0/instanceflag/instanceflag.go#L14-L23

... the behavior is today:

  • use $GOKRAZY_PARENT_DIR from the environment, if present
  • if not, use $HOME/gokrazy

I actually missed any docs about GOKRAZY_PARENT_DIR but while researching it found Anisse also confused (https://mas.to/@aissen@octodon.social/109688845672265750), saying:

To summarize, storing the configs in ~/gokrazy by default seemed really weird, it feels like something that should be in a repository. Not necessarily the app repo, but maybe a "gokrazy instance" repo.

So I guess this bug is the same as that Anisse's comment. My concrete proposal is:

Keep the current behavior, but with a search step in the middle, akin to how git walks up the tree looking for a .git dir:

If GOKRAZY_PARENT_DIR isn't defined in the environment, walk up pwd (to a maximum root of $HOME), looking for $DIR/gokrazy, stopping at the first dir found.

Then if I'm in my private git repo, I can put a "gokrazy" in there and gok will use those.

@stapelberg stapelberg changed the title Feature request: more flexibility in gok --parent_dir Feature request: discover GOKRAZY_PARENT_DIR by walking $PWD up (til $HOME) Apr 14, 2023
@stapelberg
Copy link
Contributor

Seems like a reasonable request. The only (small) downside is the potential for picking up gokrazy directories incorrectly. E.g. when working in ~/go/src/github.com/gokrazy/breakglass, it should not pick up ~/go/src/github.com/gokrazy as an instance dir. Maybe we should keep ~/gokrazy as default and first search location, and only do the $PWD walking if ~/gokrazy does not exist (and $GOKRAZY_PARENT_DIR is empty of course)

Do you want to send a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants