-
Notifications
You must be signed in to change notification settings - Fork 409
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
Add databricks_workspace_file
resource
#2266
Conversation
With recent release of the workspace file support it's now possible to store arbitrary files in the workspace, not only notebooks. It's also recommended way to store init scripts to avoid security problems associated with storing init scripts on DBFS.
ce30f6e
to
9026889
Compare
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.
- sdk has to be used for all new resources.
- finish s/notebook/file/g in the docs ;)
workspace/resource_workspace_file.go
Outdated
if err != nil { | ||
return err | ||
} | ||
notebooksAPI := NewNotebooksAPI(ctx, c) |
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.
SDK has to be used for all new resources.
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.
I wrote why it wasn't used :-)
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.
Please use the c.WorkspaceClient()
instead of NewNotebooksAPI
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2266 +/- ##
==========================================
- Coverage 88.79% 88.74% -0.06%
==========================================
Files 139 140 +1
Lines 11477 11549 +72
==========================================
+ Hits 10191 10249 +58
- Misses 861 868 +7
- Partials 425 432 +7
|
workspace/resource_workspace_file.go
Outdated
if err != nil { | ||
return err | ||
} | ||
notebooksAPI := NewNotebooksAPI(ctx, c) |
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.
Please use the c.WorkspaceClient()
instead of NewNotebooksAPI
workspace/resource_workspace_file.go
Outdated
Path: path, | ||
Overwrite: true, | ||
} | ||
err = notebooksAPI.Import(ctx, createNotebook) |
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.
client.Workspace.Import(ctx, ws_api.Import{
Content: base64.StdEncoding.EncodeToString(content),
Format: ws_api.ExportFormatAuto,
Path: path,
Overwrite: true,
})
workspace/resource_workspace_file.go
Outdated
path := d.Get("path").(string) | ||
parent := filepath.ToSlash(filepath.Dir(path)) | ||
if parent != "/" { | ||
err = notebooksAPI.MkdirsByPath(ctx, parent) |
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.
err = notebooksAPI.MkdirsByPath(ctx, parent) | |
err = client.Workspace..MkdirsByPath(ctx, parent) |
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.
lgtm
# Version changelog ## 1.16.0 * Added [databricks_workspace_file](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/workspace_file) resource ([#2266](#2266)). * Added `notification_settings` block to [databricks_job](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/job) resource ([#2276](#2276)). * Added missing permission to [databricks_aws_crossaccount_policy](https://registry.terraform.io/providers/databricks/databricks/latest/docs/data-sources/aws_crossaccount_policy) data source ([#2283](#2283)). * Fixed [databricks_sql_table](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/sql_table) doc ([#2281](#2281)). * Fixed doc on tag propagation and tag conflict for [databricks_instance_pool](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/instance_pool) resource ([#2242](#2242)). * Document & export [databricks_workspace_conf](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/workspace_conf) parameters for legacy init scripts ([#2280](#2280)). * Removed deprecated `CREATE_VIEW` from code of [databricks_grants](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/grants) resource ([#2230](#2230)). * Exporter: relax handling of problematic files/directories ([#2258](#2258)).
# Version changelog ## 1.16.0 * Added [databricks_workspace_file](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/workspace_file) resource ([#2266](#2266)). * Added `notification_settings` block to [databricks_job](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/job) resource ([#2276](#2276)). * Added missing permission to [databricks_aws_crossaccount_policy](https://registry.terraform.io/providers/databricks/databricks/latest/docs/data-sources/aws_crossaccount_policy) data source ([#2283](#2283)). * Fixed [databricks_sql_table](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/sql_table) doc ([#2281](#2281)). * Fixed doc on tag propagation and tag conflict for [databricks_instance_pool](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/instance_pool) resource ([#2242](#2242)). * Document & export [databricks_workspace_conf](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/workspace_conf) parameters for legacy init scripts ([#2280](#2280)). * Removed deprecated `CREATE_VIEW` from code of [databricks_grants](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/grants) resource ([#2230](#2230)). * Exporter: relax handling of problematic files/directories ([#2258](#2258)).
Changes
With recent release of the workspace file support it's now possible to store arbitrary files in the workspace, not only notebooks. It's also recommended way to store init scripts to avoid security problems associated with storing init scripts on DBFS.
I deliberately didn't use the Go SDK as all code was already available. Migration to Go SDK will follow after discussions on the change required for supporting list command (see #2258)
This fixes #2206
Tests
make test
run locallydocs/
folderinternal/acceptance