Skip to content

Commit 53344ff

Browse files
committed
internal/config/config.go: Do not save config when LAB_CORE_TOKEN is used
@doronbehar reported a bug in lab where they specified LAB_CORE_TOKEN on the command line and then value was saved in the config file. Using LAB_CORE_TOKEN or LAB_CORE_HOST should not overwrite the config file. Do not save the config when LAB_CORE_TOKEN or LAB_CORE_HOST is specified. Closes #868 Signed-off-by: Prarit Bhargava <prarit@redhat.com>
1 parent cce34e2 commit 53344ff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/config/config.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ func New(confpath string, r io.Reader) error {
7373
MainConfig.Set("core.load_token", loadToken)
7474
}
7575

76-
if err := MainConfig.WriteConfigAs(confpath); err != nil {
77-
return err
76+
if strings.TrimSpace(os.Getenv("LAB_CORE_TOKEN")) == "" && strings.TrimSpace(os.Getenv("LAB_CORE_HOST")) == "" {
77+
if err := MainConfig.WriteConfigAs(confpath); err != nil {
78+
return err
79+
}
7880
}
81+
7982
fmt.Printf("\nConfig saved to %s\n", confpath)
8083
err = MainConfig.ReadInConfig()
8184
if err != nil {

0 commit comments

Comments
 (0)