Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions internal/profiles/koanf.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ func KoanfValueFromOption(opt options.Option, pName string) (value string, ok bo
)

// Case 1: Koanf Key is the ActiveProfile Key, get value from main koanf instance
if opt.KoanfKey != "" && opt.KoanfKey == options.RootActiveProfileOption.KoanfKey && mainKoanfInstance != nil {
kValue = mainKoanfInstance.KoanfInstance().Get(opt.KoanfKey)
if opt.KoanfKey != "" && strings.EqualFold(opt.KoanfKey, options.RootActiveProfileOption.KoanfKey) && mainKoanfInstance != nil {
kValue = mainKoanfInstance.KoanfInstance().Get("activeprofile")
if kValue == nil {
kValue = mainKoanfInstance.KoanfInstance().Get(opt.KoanfKey)
}
} else {
// // Case 2: --profile flag has been set, get value from set profile koanf instance
// // Case 3: no --profile flag set, get value from active profile koanf instance defined in main koanf instance
Expand Down Expand Up @@ -126,7 +129,7 @@ func (k KoanfConfig) ProfileNames() (profileNames []string) {
mainKoanfKeys := k.KoanfInstance().All()
for key := range mainKoanfKeys {
// Do not add Active profile koanf key to profileNames
if key == options.RootActiveProfileOption.KoanfKey {
if strings.EqualFold(key, options.RootActiveProfileOption.KoanfKey) {
continue
}

Expand Down Expand Up @@ -291,7 +294,7 @@ func (k KoanfConfig) DefaultMissingKoanfKeys() (err error) {
}

for _, opt := range options.Options() {
if opt.KoanfKey == "" || opt.KoanfKey == options.RootActiveProfileOption.KoanfKey {
if opt.KoanfKey == "" || strings.EqualFold(opt.KoanfKey, options.RootActiveProfileOption.KoanfKey) {
continue
}

Expand Down