From ae13135fc6d32d0ee810b45a99992a7b943f564f Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 23 Jun 2023 12:51:31 +0200 Subject: [PATCH] Follow up to #513 (#521) This reverts changes from #513 which ended up not being necessary. --- libs/databrickscfg/loader.go | 3 --- libs/databrickscfg/ops.go | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libs/databrickscfg/loader.go b/libs/databrickscfg/loader.go index e0507961..8179703a 100644 --- a/libs/databrickscfg/loader.go +++ b/libs/databrickscfg/loader.go @@ -76,9 +76,6 @@ func (l profileFromHostLoader) Configure(cfg *config.Config) error { // Normalized version of the configured host. host := normalizeHost(cfg.Host) match, err := findMatchingProfile(configFile, func(s *ini.Section) bool { - if cfg.Profile != "" { - return cfg.Profile == s.Name() - } key, err := s.GetKey("host") if err != nil { log.Tracef(ctx, "section %s: %s", s.Name(), err) diff --git a/libs/databrickscfg/ops.go b/libs/databrickscfg/ops.go index 9f3b8db4..4a4a27b0 100644 --- a/libs/databrickscfg/ops.go +++ b/libs/databrickscfg/ops.go @@ -89,6 +89,8 @@ func SaveToProfile(ctx context.Context, cfg *config.Config) error { return err } + // zeroval profile name before adding it to a section + cfg.Profile = "" cfg.ConfigFile = "" // clear old keys in case we're overriding the section @@ -97,7 +99,7 @@ func SaveToProfile(ctx context.Context, cfg *config.Config) error { } for _, attr := range config.ConfigAttributes { - if attr.IsZero(cfg) || attr.Name == "profile" { + if attr.IsZero(cfg) { continue } key := section.Key(attr.Name)