Skip to content

Commit 4bca943

Browse files
authored
Merge pull request #1512 from dgageot/remove-annoying-warning
Remove annoying warning
2 parents 86efabb + 2bc20b0 commit 4bca943

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

cmd/root/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ func monitorStdin(ctx context.Context, cancel context.CancelFunc, stdin *os.File
7575
}
7676

7777
func (f *apiFlags) runAPICommand(cmd *cobra.Command, args []string) error {
78+
f.runConfig.ModelsGateway = "http://localhost:7777"
79+
7880
telemetry.TrackCommand("api", args)
7981

8082
ctx := cmd.Context()

cmd/root/flags.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ func canonize(endpoint string) string {
5454
return strings.TrimSuffix(strings.TrimSpace(endpoint), "/")
5555
}
5656

57-
func logFlagShadowing(envValue, varName, flagName string) {
58-
if envValue != "" {
59-
_, _ = fmt.Fprintf(os.Stderr, "CLI flag --%s set, overriding environment variable %s\n", flagName, varName)
60-
}
61-
}
62-
6357
// loadUserConfig is the function used to load user configuration.
6458
// It can be overridden in tests.
6559
var loadUserConfig = userconfig.Load
@@ -70,12 +64,12 @@ func addGatewayFlags(cmd *cobra.Command, runConfig *config.RuntimeConfig) {
7064
persistentPreRunE := cmd.PersistentPreRunE
7165
cmd.PersistentPreRunE = func(_ *cobra.Command, args []string) error {
7266
// Precedence: CLI flag > environment variable > user config
73-
if runConfig.ModelsGateway != "" {
74-
logFlagShadowing(os.Getenv(envModelsGateway), envModelsGateway, flagModelsGateway)
75-
} else if gateway := os.Getenv(envModelsGateway); gateway != "" {
76-
runConfig.ModelsGateway = gateway
77-
} else if userCfg, err := loadUserConfig(); err == nil && userCfg.ModelsGateway != "" {
78-
runConfig.ModelsGateway = userCfg.ModelsGateway
67+
if runConfig.ModelsGateway == "" {
68+
if gateway := os.Getenv(envModelsGateway); gateway != "" {
69+
runConfig.ModelsGateway = gateway
70+
} else if userCfg, err := loadUserConfig(); err == nil && userCfg.ModelsGateway != "" {
71+
runConfig.ModelsGateway = userCfg.ModelsGateway
72+
}
7973
}
8074

8175
runConfig.ModelsGateway = canonize(runConfig.ModelsGateway)

0 commit comments

Comments
 (0)