Skip to content

Commit 11c84e4

Browse files
authored
[Exporter] Fix interactive selection of services (#4245)
## Changes <!-- Summary of your changes that are easy to understand --> Resolves #2191 ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [ ] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [x] relevant acceptance tests are passing - [ ] using Go SDK
1 parent 985012a commit 11c84e4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

exporter/command.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (ic *importContext) allServicesAndListing() (string, string) {
4949
return strings.Join(maps.Keys(services), ","), strings.Join(maps.Keys(listing), ",")
5050
}
5151

52-
func (ic *importContext) interactivePrompts() {
52+
func (ic *importContext) interactivePrompts() string {
5353
req, _ := http.NewRequest("GET", "/", nil)
5454
for ic.Client.DatabricksClient.Config.Authenticate(req) != nil {
5555
ic.Client.DatabricksClient.Config.Host = askFor("🔑 Databricks Workspace URL:")
@@ -71,20 +71,23 @@ func (ic *importContext) interactivePrompts() {
7171
}
7272
}
7373

74-
ic.listing = map[string]struct{}{}
7574
keys := maps.Keys(services)
7675
slices.Sort(keys)
76+
enabledServices := map[string]struct{}{}
7777
for _, service := range keys {
7878
resources := services[service]
7979
if !askFlag(fmt.Sprintf("✅ Generate for service `%s` (%s) and related resources?",
8080
service, strings.Join(resources, ","))) {
8181
continue
8282
}
83-
ic.listing[service] = struct{}{}
8483
if service == "mounts" {
8584
ic.mounts = true
8685
}
86+
enabledServices[service] = struct{}{}
8787
}
88+
keys = maps.Keys(enabledServices)
89+
slices.Sort(keys)
90+
return strings.Join(keys, ",")
8891
}
8992

9093
// Run import according to flags
@@ -164,7 +167,7 @@ func Run(args ...string) error {
164167
return err
165168
}
166169
if !skipInteractive {
167-
ic.interactivePrompts()
170+
configuredListing = ic.interactivePrompts()
168171
}
169172
if len(prefix) > 0 {
170173
ic.prefix = prefix + "_"

exporter/command_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ func TestInteractivePrompts(t *testing.T) {
4343
},
4444
},
4545
}
46-
ic.interactivePrompts()
46+
services := ic.interactivePrompts()
4747
assert.Equal(t, "y", ic.match)
4848
assert.True(t, ic.mounts)
49+
assert.Equal(t, "a,mounts", services)
4950
}

0 commit comments

Comments
 (0)