Skip to content

Commit ad058ed

Browse files
authored
Fix panic in auto-completion handler for pipelines run/open (#3408)
## Changes Copying fix applied to autocompletion in bundle to pipelines run/open: #3358 ## Why Before, cmd.ValidArgsFunction is not working properly, as in the terminal, Tab does not autocomplete the resource key. databricks pipelines run ... Now autocompletes with databricks pipelines run resource-name ## Tests New acceptance tests that trigger completion handler for pipelines run/open.
1 parent 1b75df6 commit ad058ed

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

acceptance/pipelines/open/output.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ Opening browser at [DATABRICKS_URL]/pipelines/[UUID]?o=[NUMID]
2626
Error: exec: "open": cannot run executable found relative to current directory
2727

2828
Exit code (musterr): 1
29+
30+
=== test auto-completion handler
31+
>>> [PIPELINES] __complete open ,
32+
test-pipelines-open
33+
:4
34+
Completion ended with directive: ShellCompDirectiveNoFileComp

acceptance/pipelines/open/script

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ musterr trace $PIPELINES open
1111

1212
title "open with KEY, expect same output as opening without KEY"
1313
musterr trace $PIPELINES open test-pipelines-open
14+
15+
title "test auto-completion handler"
16+
trace $PIPELINES __complete open ,

acceptance/pipelines/run/run-pipeline/output.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ Update ID: [UUID]
2323
Update for pipeline completed successfully.
2424
Pipeline configurations for this update:
2525
• All tables are refreshed
26+
27+
=== completion handler
28+
>>> [PIPELINES] __complete run ,
29+
my_pipeline
30+
:4
31+
Completion ended with directive: ShellCompDirectiveNoFileComp

acceptance/pipelines/run/run-pipeline/script

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ trace $PIPELINES run
44

55
title "Run pipeline with KEY, expect same output as without KEY"
66
trace $PIPELINES run my_pipeline
7+
8+
title "completion handler"
9+
trace $PIPELINES __complete run ,

cmd/pipelines/open.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ If there is only one pipeline in the project, KEY is optional and the pipeline w
126126
}
127127

128128
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
129+
ctx := logdiag.InitContext(cmd.Context())
130+
cmd.SetContext(ctx)
131+
129132
b := root.MustConfigureBundle(cmd)
130133
if logdiag.HasError(cmd.Context()) {
131134
return nil, cobra.ShellCompDirectiveError

cmd/pipelines/run.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ Refreshes all tables in the pipeline unless otherwise specified.`,
231231
}
232232

233233
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
234+
ctx := logdiag.InitContext(cmd.Context())
235+
cmd.SetContext(ctx)
236+
234237
b := root.MustConfigureBundle(cmd)
235238
if logdiag.HasError(cmd.Context()) {
236239
return nil, cobra.ShellCompDirectiveError

0 commit comments

Comments
 (0)