Skip to content

Commit cac33b0

Browse files
authored
Merge pull request #202 from dgageot/remove-tools-gateway
Remove ToolsGateway because it's not used
2 parents dcab6f9 + 55f92de commit cac33b0

4 files changed

Lines changed: 14 additions & 80 deletions

File tree

cmd/root/gateway.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ import (
1111
const (
1212
flagGateway = "gateway"
1313
flagModelsGateway = "models-gateway"
14-
flagToolsGateway = "tools-gateway"
1514
envGateway = "CAGENT_GATEWAY"
1615
envModelsGateway = "CAGENT_MODELS_GATEWAY"
17-
envToolsGateway = "CAGENT_TOOLS_GATEWAY"
1816
)
1917

2018
type gatewayConfig struct {
@@ -36,21 +34,16 @@ func logEnvvarShadowing(flagValue, varName, flagName string) {
3634
func addGatewayFlags(cmd *cobra.Command) {
3735
cmd.PersistentFlags().StringVar(&gwConfig.mainGateway, flagGateway, "", "Set the gateway address to use for models and tool calls")
3836
cmd.PersistentFlags().StringVar(&runConfig.ModelsGateway, flagModelsGateway, "", "Set the models gateway address")
39-
cmd.PersistentFlags().StringVar(&runConfig.ToolsGateway, flagToolsGateway, "", "Set the tools gateway address")
4037

4138
// Don't allow gateway to be specified if a qualified gateway flag is provided
4239
cmd.MarkFlagsMutuallyExclusive(flagGateway, flagModelsGateway)
43-
cmd.MarkFlagsMutuallyExclusive(flagGateway, flagToolsGateway)
4440

4541
persistentPreRunE := cmd.PersistentPreRunE
4642
cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
4743
// verify mutual exclusion for environment variables
4844
if os.Getenv(envGateway) != "" && os.Getenv(envModelsGateway) != "" {
4945
return fmt.Errorf("environment variables %s and %s cannot be set at the same time", envGateway, envModelsGateway)
5046
}
51-
if os.Getenv(envGateway) != "" && os.Getenv(envToolsGateway) != "" {
52-
return fmt.Errorf("environment variables %s and %s cannot be set at the same time", envGateway, envToolsGateway)
53-
}
5447

5548
// Get gateway value from the environment.
5649
// This behavior sets both the models and tools gateway
@@ -59,31 +52,20 @@ func addGatewayFlags(cmd *cobra.Command) {
5952
logEnvvarShadowing(gwConfig.mainGateway, envGateway, flagGateway)
6053
gwConfig.mainGateway = mainGateway
6154
runConfig.ModelsGateway = mainGateway
62-
runConfig.ToolsGateway = mainGateway
6355
}
6456

6557
if gateway := os.Getenv(envModelsGateway); gateway != "" {
6658
logEnvvarShadowing(runConfig.ModelsGateway, envModelsGateway, flagModelsGateway)
6759
runConfig.ModelsGateway = gateway
6860
}
6961

70-
// Prefer the explicit tools gateway if provided
71-
if gateway := os.Getenv(envToolsGateway); gateway != "" {
72-
logEnvvarShadowing(runConfig.ToolsGateway, envToolsGateway, flagToolsGateway)
73-
runConfig.ToolsGateway = gateway
74-
}
75-
7662
// Set the qualified gateways to the main gateway if they haven't been set explicitly
7763
if runConfig.ModelsGateway == "" {
7864
runConfig.ModelsGateway = gwConfig.mainGateway
7965
}
80-
if runConfig.ToolsGateway == "" {
81-
runConfig.ToolsGateway = gwConfig.mainGateway
82-
}
8366

8467
// Ensure the gateway url is canonical.
8568
runConfig.ModelsGateway = canonize(runConfig.ModelsGateway)
86-
runConfig.ToolsGateway = canonize(runConfig.ToolsGateway)
8769

8870
// First call the original persistentPreRunE if it exists (from this command)
8971
if persistentPreRunE != nil {

cmd/root/gateway_test.go

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,103 +13,70 @@ func TestGatewayLogic(t *testing.T) {
1313
tests := []struct {
1414
name string
1515
envVars map[string]string
16-
args []string // CLI arguments
16+
args []string
1717
expectedModelsGateway string
18-
expectedToolsGateway string
1918
expectError bool
2019
errorContains string
2120
}{
2221
{
23-
name: "env_var_models_gateway_only",
24-
envVars: map[string]string{
25-
"CAGENT_MODELS_GATEWAY": "https://models.example.com",
26-
},
27-
args: []string{},
22+
name: "env_var_models_gateway",
23+
envVars: map[string]string{"CAGENT_MODELS_GATEWAY": "https://models.example.com"},
2824
expectedModelsGateway: "https://models.example.com",
2925
},
3026
{
31-
name: "env_var_gateway_sets_both",
32-
envVars: map[string]string{
33-
"CAGENT_GATEWAY": "https://gateway.example.com",
34-
},
35-
args: []string{},
27+
name: "env_var_gateway",
28+
envVars: map[string]string{"CAGENT_GATEWAY": "https://gateway.example.com"},
3629
expectedModelsGateway: "https://gateway.example.com",
37-
expectedToolsGateway: "https://gateway.example.com",
38-
},
39-
{
40-
name: "env_var_models_and_tools_gateway_independent",
41-
envVars: map[string]string{
42-
"CAGENT_MODELS_GATEWAY": "https://models.example.com",
43-
"CAGENT_TOOLS_GATEWAY": "https://tools.example.com",
44-
},
45-
args: []string{},
46-
expectedModelsGateway: "https://models.example.com",
47-
expectedToolsGateway: "https://tools.example.com",
4830
},
4931
{
5032
name: "cli_flag_models_gateway",
5133
args: []string{"--models-gateway", "https://cli-models.example.com"},
5234
expectedModelsGateway: "https://cli-models.example.com",
53-
expectedToolsGateway: "",
5435
},
5536
{
5637
name: "cli_flag_gateway_mutually_exclusive_with_models_gateway",
5738
args: []string{"--gateway", "https://gateway.example.com", "--models-gateway", "https://models.example.com"},
5839
expectError: true,
5940
errorContains: "if any flags in the group [gateway models-gateway] are set none of the others can be",
6041
},
61-
{
62-
name: "cli_flag_gateway_mutually_exclusive_with_tools_gateway",
63-
args: []string{"--gateway", "https://gateway.example.com", "--tools-gateway", "https://tools.example.com"},
64-
expectError: true,
65-
errorContains: "if any flags in the group [gateway tools-gateway] are set none of the others can be",
66-
},
6742
{
6843
name: "gateway_url_canonicalization_with_main_gateway",
6944
envVars: map[string]string{
7045
"CAGENT_GATEWAY": "https://gateway.example.com/", // Main gateway with trailing slash
7146
},
7247
args: []string{},
7348
expectedModelsGateway: "https://gateway.example.com",
74-
expectedToolsGateway: "https://gateway.example.com",
7549
},
7650
// Tests for combinations of environment variables and CLI arguments
7751
{
7852
name: "env_var_overrides_same_cli_flag",
7953
envVars: map[string]string{
8054
"CAGENT_MODELS_GATEWAY": "https://env-models.example.com",
81-
"CAGENT_TOOLS_GATEWAY": "https://env-tools.example.com",
8255
},
83-
args: []string{"--models-gateway", "https://cli-models.example.com", "--tools-gateway", "https://cli-tools.example.com"},
56+
args: []string{"--models-gateway", "https://cli-models.example.com"},
8457
expectedModelsGateway: "https://env-models.example.com",
85-
expectedToolsGateway: "https://env-tools.example.com",
8658
},
8759
{
8860
name: "env_var_main_gateway_overrides_cli_flags",
8961
envVars: map[string]string{
9062
"CAGENT_GATEWAY": "https://env-gateway.example.com",
9163
},
92-
args: []string{"--models-gateway", "https://cli-gateway.example.com", "--tools-gateway", "https://cli-tools.example.com"},
64+
args: []string{"--models-gateway", "https://cli-gateway.example.com"},
9365
expectedModelsGateway: "https://env-gateway.example.com",
94-
expectedToolsGateway: "https://env-gateway.example.com",
9566
},
9667
{
9768
name: "cli_flag_gateway_sets_both_gateways",
9869
args: []string{"--gateway", "https://cli-gateway.example.com"},
9970
expectedModelsGateway: "https://cli-gateway.example.com",
100-
expectedToolsGateway: "https://cli-gateway.example.com",
10171
},
10272
{
10373
name: "env_vars_both_gateways_override_cli_gateway_flag",
10474
envVars: map[string]string{
10575
"CAGENT_MODELS_GATEWAY": "https://env-models.example.com",
106-
"CAGENT_TOOLS_GATEWAY": "https://env-tools.example.com",
10776
},
10877
args: []string{"--gateway", "https://cli-gateway.example.com"},
10978
expectedModelsGateway: "https://env-models.example.com",
110-
expectedToolsGateway: "https://env-tools.example.com",
11179
},
112-
// Tests for environment variable mutual exclusion
11380
{
11481
name: "env_var_main_gateway_mutually_exclusive_with_models_gateway",
11582
envVars: map[string]string{
@@ -120,22 +87,11 @@ func TestGatewayLogic(t *testing.T) {
12087
expectError: true,
12188
errorContains: "environment variables CAGENT_GATEWAY and CAGENT_MODELS_GATEWAY cannot be set at the same time",
12289
},
123-
{
124-
name: "env_var_main_gateway_mutually_exclusive_with_tools_gateway",
125-
envVars: map[string]string{
126-
"CAGENT_GATEWAY": "https://gateway.example.com",
127-
"CAGENT_TOOLS_GATEWAY": "https://tools.example.com",
128-
},
129-
args: []string{},
130-
expectError: true,
131-
errorContains: "environment variables CAGENT_GATEWAY and CAGENT_TOOLS_GATEWAY cannot be set at the same time",
132-
},
13390
{
13491
name: "env_var_main_gateway_mutually_exclusive_with_both_specific_gateways",
13592
envVars: map[string]string{
13693
"CAGENT_GATEWAY": "https://gateway.example.com",
13794
"CAGENT_MODELS_GATEWAY": "https://models.example.com",
138-
"CAGENT_TOOLS_GATEWAY": "https://tools.example.com",
13995
},
14096
args: []string{},
14197
expectError: true,
@@ -182,7 +138,6 @@ func TestGatewayLogic(t *testing.T) {
182138

183139
// Verify expected gateway configuration
184140
assert.Equal(t, tt.expectedModelsGateway, runConfig.ModelsGateway, "Models gateway mismatch")
185-
assert.Equal(t, tt.expectedToolsGateway, runConfig.ToolsGateway, "Tools gateway mismatch")
186141
}
187142
})
188143
}

pkg/config/runtime.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ package config
33
type RuntimeConfig struct {
44
EnvFiles []string
55
ModelsGateway string
6-
ToolsGateway string
76
RedirectURI string
87
}

pkg/secrets/gather.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ func GatherMissingEnvVars(ctx context.Context, cfg *latest.Config, env environme
2929
}
3030

3131
// Tools
32-
if runtimeConfig.ToolsGateway == "" {
33-
if mcpGatewayURL := os.Getenv(mcp.DOCKER_MCP_GATEWAY_URL_ENV); mcpGatewayURL != "" {
34-
names, err := GatherEnvVarsForTools(ctx, cfg)
35-
if err != nil {
36-
return nil, err
37-
}
38-
for _, e := range names {
39-
requiredEnv[e] = true
40-
}
32+
if mcpGatewayURL := os.Getenv(mcp.DOCKER_MCP_GATEWAY_URL_ENV); mcpGatewayURL != "" {
33+
names, err := GatherEnvVarsForTools(ctx, cfg)
34+
if err != nil {
35+
return nil, err
36+
}
37+
for _, e := range names {
38+
requiredEnv[e] = true
4139
}
4240
}
4341

0 commit comments

Comments
 (0)