diff --git a/libs/databrickscfg/loader.go b/libs/databrickscfg/loader.go index e0507961a..8179703a3 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 9f3b8db46..4a4a27b06 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)