-
Notifications
You must be signed in to change notification settings - Fork 0
DLT init reusing lakeflow-pipelines template #2
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
base: install-dlt-feat
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package dlt | ||
|
|
||
| import ( | ||
| "github.com/databricks/cli/cmd/root" | ||
| "github.com/databricks/cli/libs/template" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func initCommand() *cobra.Command { | ||
| var outputDir string | ||
| var configFile string | ||
| cmd := &cobra.Command{ | ||
| Use: "init", | ||
| Short: "Initialize a new DLT project", | ||
| PreRunE: root.MustWorkspaceClient, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| ctx := cmd.Context() | ||
|
|
||
| r := template.Resolver{ | ||
| TemplatePathOrUrl: "lakeflow-pipelines", | ||
| ConfigFile: configFile, | ||
| OutputDir: outputDir, | ||
| } | ||
|
|
||
| tmpl, err := r.Resolve(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| defer tmpl.Reader.Cleanup(ctx) | ||
|
|
||
| err = tmpl.Writer.PromptForInput(ctx, tmpl.Reader) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| tmpl.Writer.SetConfig("is_dlt", true) | ||
| err = tmpl.Writer.Finalize(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| return nil | ||
| }, | ||
| } | ||
| cmd.Flags().StringVar(&outputDir, "output-dir", "", "Directory to write the initialized template to") | ||
| cmd.Flags().StringVar(&configFile, "config-file", "", "JSON file containing key value pairs of input parameters required for template initialization") | ||
| return cmd | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,12 @@ | ||||||||
| # This is a Databricks asset bundle definition for {{.project_name}}. | ||||||||
| # See https://docs.databricks.com/dev-tools/bundles/index.html for documentation. | ||||||||
| bundle: | ||||||||
| {{$isDLT := eq .is_dlt true}}{{if $isDLT}}project{{else}}bundle{{end}}: | ||||||||
|
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.
Suggested change
Please play a bit with the |
||||||||
| name: {{.project_name}} | ||||||||
| uuid: {{bundle_uuid}} | ||||||||
| {{if not $isDLT}}uuid: {{bundle_uuid}}{{end}} | ||||||||
|
|
||||||||
| include: | ||||||||
| - resources/*.yml | ||||||||
| - resources/*/*.yml | ||||||||
| {{if $isDLT}}- ./*.yml{{else}}- resources/*.yml | ||||||||
|
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. The dlt template should include both |
||||||||
| - resources/*/*.yml{{end}} | ||||||||
|
|
||||||||
| # Variable declarations. These variables are assigned in the dev/prod targets below. | ||||||||
| variables: | ||||||||
|
|
@@ -25,6 +25,7 @@ targets: | |||||||
| # See also https://docs.databricks.com/dev-tools/bundles/deployment-modes.html. | ||||||||
| mode: development | ||||||||
| default: true | ||||||||
| {{if $isDLT}}deploy_on_run: true{{end}} | ||||||||
|
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. This would leave a blank line when false; please experiment with |
||||||||
| workspace: | ||||||||
| host: {{workspace_host}} | ||||||||
| variables: | ||||||||
|
|
@@ -36,11 +37,11 @@ targets: | |||||||
| mode: production | ||||||||
| workspace: | ||||||||
| host: {{workspace_host}} | ||||||||
| # We explicitly deploy to /Workspace/Users/{{user_name}} to make sure we only have a single copy. | ||||||||
| root_path: /Workspace/Users/{{user_name}}/.bundle/${bundle.name}/${bundle.target} | ||||||||
| permissions: | ||||||||
| {{if not $isDLT}}# We explicitly deploy to /Workspace/Users/{{user_name}} to make sure we only have a single copy. | ||||||||
| root_path: /Workspace/Users/{{user_name}}/.bundle/${bundle.name}/${bundle.target}}{{end}} | ||||||||
| {{if $isDLT}}owner: user@company.com{{else}}permissions: | ||||||||
|
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. Please keep in mind that the template won't yet work if you replace the root_path with the owner as I originally suggested. The CLI would first need to support that. So you should probably sequence this change to be later. |
||||||||
| - {{if is_service_principal}}service_principal{{else}}user{{end}}_name: {{user_name}} | ||||||||
| level: CAN_MANAGE | ||||||||
| level: CAN_MANAGE{{end}} | ||||||||
| variables: | ||||||||
| catalog: {{.default_catalog}} | ||||||||
| schema: {{template `prod_schema` .}} | ||||||||
|
|
||||||||
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.