Skip to content

feat(cli): handle a few environment variables with correct order of precedence#195

Merged
skevetter merged 2 commits intoskevetter:mainfrom
dubinsky:environment-variables-should-override
Dec 31, 2025
Merged

feat(cli): handle a few environment variables with correct order of precedence#195
skevetter merged 2 commits intoskevetter:mainfrom
dubinsky:environment-variables-should-override

Conversation

@dubinsky
Copy link

@dubinsky dubinsky commented Dec 29, 2025

first steps in the direction of #196...

@dubinsky
Copy link
Author

@skevetter none of the checks are triggered by a pull request now, while before most of them were (I think). Is this change intentional? Thanks!

@skevetter
Copy link
Owner

Is this change intentional?

For the (brief) moment, yes. I am refactoring the workflows to better support code contributions and releases.

@dubinsky dubinsky force-pushed the environment-variables-should-override branch from f72ad49 to f42ac8a Compare December 29, 2025 21:19
@dubinsky
Copy link
Author

Is this change intentional?

For the (brief) moment, yes. I am refactoring the workflows to better support code contributions and releases.

Thank you so much!!

@dubinsky dubinsky force-pushed the environment-variables-should-override branch 2 times, most recently from c97e278 to 3632fc5 Compare December 30, 2025 03:49
@skevetter
Copy link
Owner

Is this change intentional?

For the (brief) moment, yes. I am refactoring the workflows to better support code contributions and releases.

Thank you so much!!

Thank you for your patience. I think I have the workflows in a better place now.

// Defines a string flag with specified name, environment variable, default value, and usage string.
// The argument p points to a string variable in which to store the value of the flag.
func StringVarE(f *flag.FlagSet, p *string, name string, env string, value string, usage string) {
key := "DEVPOD_" + env
Copy link
Owner

Choose a reason for hiding this comment

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

minor: I would make DEVPOD_ into a re-usable constant like DevpodEnvPrefix

Copy link
Author

Choose a reason for hiding this comment

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

done

if err == nil {
return result
}
return def
Copy link
Owner

Choose a reason for hiding this comment

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

question: Should the error fail silently or should we log it here? And check if error is not nil first

if err != nil {
    log.Warnf("invalid boolean value %s for key %s, falling back to default %v", value, key, default)
    return default
}

Copy link
Author

Choose a reason for hiding this comment

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

done

f.BoolVar(p, name, GetBoolEnv(key, value), usage+". You can also use "+key+" to set this")
}

func GetBoolEnv(key string, def bool) bool {
Copy link
Owner

Choose a reason for hiding this comment

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

opinion: default or defaultValue in lieu of def for clarity

Copy link
Author

Choose a reason for hiding this comment

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

done


// Defines a string flag with specified name, environment variable, default value, and usage string.
// The argument p points to a string variable in which to store the value of the flag.
func StringVarE(f *flag.FlagSet, p *string, name string, env string, value string, usage string) {
Copy link
Owner

Choose a reason for hiding this comment

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

optional: if you can think of a more recognizable value for p *string, it may be helpful to future readers. And same for value, if it is intended to be a default/fallback value then perhaps use defaultValue.

Copy link
Author

Choose a reason for hiding this comment

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

done

flags.StringVar(&globalFlags.Provider, "provider", "", "The provider to use. Needs to be configured for the selected context.")
flags.BoolVar(&globalFlags.Debug, "debug", false, "Prints the stack trace if an error occurs")
flags.BoolVar(&globalFlags.Silent, "silent", false, "Run in silent mode and prevents any devpod log output except panics & fatals")
StringVarE(flags, &globalFlags.LogOutput, "log-output", "LOG_OUTPUT", "plain", "The log format to use. Can be either plain, raw or json")
Copy link
Owner

Choose a reason for hiding this comment

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

question: wrt comment above, perhaps the prefix would be more visible here as DEVPOD_ENV_PREFIX+VAL (e.g., DEVPOD_ENV_PREFIX+LOG_OUTPUT). Thoughts?

Copy link
Author

Choose a reason for hiding this comment

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

done

@dubinsky
Copy link
Author

Thank you for your patience. I think I have the workflows in a better place now.

Thank you!
Various pre-commit checks that used to run last now run first - excellent!

…recedence

Signed-off-by: Leonid Dubinsky <dub@podval.org>
Signed-off-by: Leonid Dubinsky <dub@podval.org>
@dubinsky dubinsky force-pushed the environment-variables-should-override branch from cf13c4f to d77b18b Compare December 31, 2025 17:54
@skevetter
Copy link
Owner

Thank you for your patience. I think I have the workflows in a better place now.

Thank you! Various pre-commit checks that used to run last now run first - excellent!

Great work!

Let me know if you encounter any pain points or have any general feedback. My intent is for contribution process to be streamlined and frictionless for both contributors and reviewers.

Also, if you're interested in being a reviewer, let me know. I would be more than happy to share the work :)

@dubinsky
Copy link
Author

Great work!

Thank you!

Let me know if you encounter any pain points or have any general feedback.

Thanks!

  1. What is your preferred approach for the branches of the merged pull requests - delete or keep?
  2. I recently started getting errors "executing agent command agent error: /tmp/dub/devpod/agent: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /tmp/dub/devpod/agent)", and I am not sure what needs to be adjusted - is my Linux distribution too new, are the distributions in the containers and virtual machines that I use too old, or is there a way to build for a specific version of GLibc?
  3. gcloud provider fork needs to be fully adopted and its module names, dependencies and build adjusted; I am not up for that task, so I'll wait for you do wield the magic ;)

My intent is for contribution process to be streamlined and frictionless for both contributors and reviewers.

Great!

Also, if you're interested in being a reviewer, let me know. I would be more than happy to share the work :)

I am honored by this offer, but this being a new code-base in a new programming language for me, I do not yet feel confident enough to accept it. We'll see how it goes ;)

@skevetter
Copy link
Owner

What is your preferred approach for the branches of the merged pull requests - delete or keep?

Delete. To keep things tidy.

I recently started getting errors "executing agent command agent error: /tmp/dub/devpod/agent: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /tmp/dub/devpod/agent)", and I am not sure what needs to be adjusted - is my Linux distribution too new, are the distributions in the containers and virtual machines that I use too old, or is there a way to build for a specific version of GLibc?

I will have to get back to you on that. There has been a number of dependency upgrades (go, rust, node), upgrading the go version, etc.

the distributions in the containers and virtual machines that I use too old

Possibly this. If you see GLIBC_2.38 not found , in general, it means the program was compiled with a newer version of glibc than what the OS is using.

This may be a build configuration issue I need to investigate. The application is compiled with CGO_ENABLED, so there may be some work involved to unlink that dependency.

gcloud provider fork needs to be fully adopted and its module names, dependencies and build adjusted; I am not up for that task, so I'll wait for you do wield the magic ;)

still on my todo list

I do not yet feel confident enough

no worries

@dubinsky
Copy link
Author

This may be a build configuration issue I need to investigate. The application is compiled with CGO_ENABLED, so there may be some work involved to unlink that dependency.

I do not think the build picks up ambient version - it is 2.42 on the machine where I build.
Machine where I run using ssh provider has 2.36; it is under my control, so I can up the version there, but things stopped working on standard GCloud machines also...

If this is a result of the changes to the build/dependencies, it would be nice to make it a bit more flexible...

gcloud provider fork needs to be fully adopted and its module names, dependencies and build adjusted; I am not up for that task, so I'll wait for you do wield the magic ;)

still on my todo list

no pressure ;)

@dubinsky
Copy link
Author

what do I need to do for this to get merged?

@skevetter
Copy link
Owner

what do I need to do for this to get merged?

Nothing on your end. A recent upgrade to tauri v2 messed with some of the artifacts that get built in the release. Once I have that resolved, this change will be merged.

@skevetter skevetter merged commit 84ad5f8 into skevetter:main Dec 31, 2025
34 checks passed
@dubinsky
Copy link
Author

Thank you!

@dubinsky dubinsky deleted the environment-variables-should-override branch December 31, 2025 21:54
@dubinsky dubinsky mentioned this pull request Jan 2, 2026
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

Successfully merging this pull request may close these issues.

2 participants