-
Notifications
You must be signed in to change notification settings - Fork 55
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
Extract functionality to detect if the CLI is running on DBR #1889
base: main
Are you sure you want to change the base?
Conversation
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
Test Details: go/deco-tests/11731384827 |
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.
Thanks! Minor comments.
|
||
import "context" | ||
|
||
// key is a private type to prevent collisions with other packages. |
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: I don't understand this comment. Wouldn't the type still be namespaced within the DB package?
|
||
// RunsOnRuntime returns the cached detection result from the context. | ||
// It expects a context returned by [DetectRuntime] or [MockRuntime]. | ||
func RunsOnRuntime(ctx context.Context) bool { |
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.
Can you add a one line note regarding why we cache the result? I presume it's because the stat("/databricks")
call can be expensive on DBR.
Changes
Whether or not the CLI is running on DBR can be detected once and stored in the command's context.
By storing it in the context, it can easily be mocked for testing.
This builds on the simpler approach and conversation in #1744. It unblocks testing of the DBR-specific paths while not compromising on the checks we can perform to test if the CLI is running on DBR.
Tests
dbr
packageConfigureWSFS
mutator