From d90af9b01b5dfde8d6df75d1fc83358ba627ba11 Mon Sep 17 00:00:00 2001 From: Alex Ott Date: Tue, 19 Nov 2024 12:01:05 +0100 Subject: [PATCH] [Exporter] Fix interactive selection of services --- exporter/command.go | 11 +++++++---- exporter/command_test.go | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/exporter/command.go b/exporter/command.go index 72eb8f25dd..bfbbcad82e 100644 --- a/exporter/command.go +++ b/exporter/command.go @@ -49,7 +49,7 @@ func (ic *importContext) allServicesAndListing() (string, string) { return strings.Join(maps.Keys(services), ","), strings.Join(maps.Keys(listing), ",") } -func (ic *importContext) interactivePrompts() { +func (ic *importContext) interactivePrompts() string { req, _ := http.NewRequest("GET", "/", nil) for ic.Client.DatabricksClient.Config.Authenticate(req) != nil { ic.Client.DatabricksClient.Config.Host = askFor("🔑 Databricks Workspace URL:") @@ -71,20 +71,23 @@ func (ic *importContext) interactivePrompts() { } } - ic.listing = map[string]struct{}{} keys := maps.Keys(services) slices.Sort(keys) + enabledServices := map[string]struct{}{} for _, service := range keys { resources := services[service] if !askFlag(fmt.Sprintf("✅ Generate for service `%s` (%s) and related resources?", service, strings.Join(resources, ","))) { continue } - ic.listing[service] = struct{}{} if service == "mounts" { ic.mounts = true } + enabledServices[service] = struct{}{} } + keys = maps.Keys(enabledServices) + slices.Sort(keys) + return strings.Join(keys, ",") } // Run import according to flags @@ -164,7 +167,7 @@ func Run(args ...string) error { return err } if !skipInteractive { - ic.interactivePrompts() + configuredListing = ic.interactivePrompts() } if len(prefix) > 0 { ic.prefix = prefix + "_" diff --git a/exporter/command_test.go b/exporter/command_test.go index 1ea1683a7b..fea12b0c6e 100644 --- a/exporter/command_test.go +++ b/exporter/command_test.go @@ -43,7 +43,8 @@ func TestInteractivePrompts(t *testing.T) { }, }, } - ic.interactivePrompts() + services := ic.interactivePrompts() assert.Equal(t, "y", ic.match) assert.True(t, ic.mounts) + assert.Equal(t, "a,mounts", services) }