Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 214
Initialise a empty default bundle if BUNDLE_ROOT and DATABRICKS_BUNDLE_INCLUDES env vars are present#604
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
Uh oh!
There was an error while loading. Please reload this page.
Initialise a empty default bundle if BUNDLE_ROOT and DATABRICKS_BUNDLE_INCLUDES env vars are present #604
Changes from all commits
0da0a37ef32803658f2d632fa65993100f25e74315e35f4e77c78b4155db33e5e094a673a867d7a1ce07c0bb6344e2716c638b5036a5c376File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -6,6 +6,7 @@ import ( | ||
| "testing" | ||
| "github.com/databricks/cli/bundle/config" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
| @@ -102,3 +103,45 @@ func TestRootLookupError(t *testing.T) { | ||
| _, err := mustGetRoot() | ||
| require.ErrorContains(t, err, "unable to locate bundle root") | ||
| } | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test case where you have bundle.yml in the temp dir and also have ExtraInclude set and make sure it loads the config correctly? | ||
| func TestLoadYamlWhenIncludesEnvPresent(t *testing.T) { | ||
| chdir(t, filepath.Join(".", "tests", "basic")) | ||
| t.Setenv(ExtraIncludePathsKey, "test") | ||
| bundle, err := MustLoad() | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, "basic", bundle.Config.Bundle.Name) | ||
| cwd, err := os.Getwd() | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, cwd, bundle.Config.Path) | ||
| } | ||
| func TestLoadDefautlBundleWhenNoYamlAndRootAndIncludesEnvPresent(t *testing.T) { | ||
| dir := t.TempDir() | ||
| chdir(t, dir) | ||
| t.Setenv(envBundleRoot, dir) | ||
| t.Setenv(ExtraIncludePathsKey, "test") | ||
| bundle, err := MustLoad() | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, dir, bundle.Config.Path) | ||
| } | ||
| func TestErrorIfNoYamlNoRootEnvAndIncludesEnvPresent(t *testing.T) { | ||
| dir := t.TempDir() | ||
| chdir(t, dir) | ||
| t.Setenv(ExtraIncludePathsKey, "test") | ||
| _, err := MustLoad() | ||
| assert.Error(t, err) | ||
| } | ||
| func TestErrorIfNoYamlNoIncludesEnvAndRootEnvPresent(t *testing.T) { | ||
| dir := t.TempDir() | ||
| chdir(t, dir) | ||
| t.Setenv(envBundleRoot, dir) | ||
| _, err := MustLoad() | ||
| assert.Error(t, err) | ||
| } | ||
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.
If I understand correctly the behaviour is different from what is intended based on PR description
This will initialise it not only when BUNDLE_ROOT is set but also if there any bundle/databricks.yml in current or child dirs (https://github.com/databricks/cli/blob/main/bundle/root.go#L51-L56C9).
Is this correct?
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.
The assumption here is that
configFile, err := config.FileNames.FindInPath(path)is reached only when we have established a bundle root (either through BUNDLE_ROOT or by finding a *.yml).This functions returns an error only when there is no config file found (no *.yml). Which means BUNDLE_ROOT is set but there is no config file.
I will make it an explicit test though to make reasoning easier.
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 we be more explicit here? Our condition to have an empty config is:
Could you codify this condition? It would be somethin like