-
Notifications
You must be signed in to change notification settings - Fork 227
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
[Renaming] ComputeNixEnv -> ComputeEnv; ensurePackagesAreInstalled -> ensureStateIsCurrent #1675
Conversation
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
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.
There's a bunch of other functions you will need to change if you want to keep consistency:
Good call.
- NixEnv -> DevboxEnvExports
- NixEnvOpts -> DevboxEnvExportsOpts
- ensurePackagesAreInstalledAndComputeEnv -> computeCurrentDevboxEnv
- NixEnvPath (maybe?) -> yep,
devboxEnvPath
@mikeland73 PTAL
1eb5988
to
6746aba
Compare
38313c4
to
96630ea
Compare
Also, treating |
3f884b3
to
e01fe99
Compare
@mikeland73 PTAL |
ping |
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.
Some comments. Approving to unblock.
Only blocker for me:
computeDevboxEnv
vs computeCurrentDevboxEnv
This distinction means nothing to me. computeCurrentDevboxEnv
should be something like ensureProjectStateIsCurrentAndComputeEnv
. If you want to shorten it could also be ensureStateIsCurrentAndComputeEnv
I think when a function is complex, giving it a longer name for clarity is better.
I also think in many cases we can drop Devbox
from variables and function names. So computeEnv
or computeEnvironment
. At the end of the day, the struct is named devbox so it's fairly clear what the subject is.
devbox.go
Outdated
@@ -23,7 +23,7 @@ type Devbox interface { | |||
Install(ctx context.Context) error | |||
IsEnvEnabled() bool | |||
ListScripts() []string | |||
NixEnv(ctx context.Context, opts devopt.NixEnvOpts) (string, error) | |||
DevboxEnvExports(ctx context.Context, opts devopt.DevboxEnvExports) (string, error) |
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.
EnvExports
? So if the struct name is devbox:
devbox.EnvExports
?
Also a bit repetitive but usually our option structs end in Opt
. We should leave for consistency. (so EnvExportOpts
)
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.
Yeah, lets call it EnvExports
. Good call.
Yeah, I drop the Opt
because devopt
already specifies it. For consistency, I can drop it from the other places as well? Happy to do a follow up.
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.
Upon further inspection, I am renaming to EnvExportOpts
and adding this naming guideline in the devopts package:
// Naming Convention:
// - suffix Opts for structs corresponding to a Devbox api function
// - omit suffix Opts for other structs that are composed into an Opts struct
internal/impl/devbox.go
Outdated
// DevboxEnvExports returns a string of the env-vars that would need to be applied | ||
// to define a Devbox environment. The string is of the form `export KEY=VALUE` for each | ||
// env-var that needs to be applied. | ||
func (d *Devbox) DevboxEnvExports(ctx context.Context, opts devopt.DevboxEnvExports) (string, error) { | ||
ctx, task := trace.NewTask(ctx, "devboxNixEnv") |
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.
make sure trace tasks and profiling names are changed too.
The distinction is: I don't see the value in being so explicit TBH, because then we'll end up with super long sentences for functions.
If you're not sure the first time you encounter the name, you can inspect the docblock of the function to understand what it does, and in your mind you'll realize "Ah, the current is referring to ensuring the environment is current or up to date". And henceforth it'll be clear. |
This is not quite why
My issues with
Does that make sense? |
…led -> ensureProjectStateIsCurrent
5ed63b1
to
60a70f9
Compare
I'd already indicated that I wasn't sure if
Fair enough. And its not such a big deal to me so I've changed it for now. But I have added a TODO to find a better name. I consider it a mild code-smell to introduce a function when the callers can just directly invoke the core-primitives themselves (in this case, And then, over time, as has happened here with the "no such host" check, we introduce behavior changes as well. So, it is no longer exactly composing the two functions. And then this begs the question, what is the "core concept of this function" and when should one invoke it versus directly invoking the two functions it is composing? |
60a70f9
to
0be16d0
Compare
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Summary
These names were getting rather stale. Hopefully, the new ones represent
them more accurately.
How was it tested?
compiles and cicd tests should pass