Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion lib/config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -1277,16 +1277,23 @@ func applySSHConfig(fc *FileConfig, cfg *servicecfg.Config) (err error) {
// getInstallerProxyAddr determines the address of the proxy for discovered
// nodes to connect to.
func getInstallerProxyAddr(installParams *InstallParams, fc *FileConfig) string {
// Explicit proxy address.
if installParams != nil && installParams.PublicProxyAddr != "" {
return installParams.PublicProxyAddr
}
// Proxy address from config.
if fc.ProxyServer != "" {
return fc.ProxyServer
}
if fc.Proxy.Enabled() && len(fc.Proxy.PublicAddr) > 0 {
return fc.Proxy.PublicAddr[0]
}
return ""
// Possible proxy address for v1/v2 config.
if len(fc.AuthServers) > 0 {
Comment thread
codingllama marked this conversation as resolved.
Outdated
return fc.AuthServers[0]
}
// Probably not a proxy address, but we have nothing better.
return fc.AuthServer
}

func applyDiscoveryConfig(fc *FileConfig, cfg *servicecfg.Config) error {
Expand Down
76 changes: 76 additions & 0 deletions lib/config/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4117,3 +4117,79 @@ func TestApplyKubeConfig(t *testing.T) {
})
}
}

func TestGetInstallerProxyAddr(t *testing.T) {
t.Parallel()
tests := []struct {
name string
installParams *InstallParams
fc *FileConfig
expectedProxyAddr string
}{
{
name: "empty",
fc: &FileConfig{},
expectedProxyAddr: "",
},
{
name: "explicit proxy addr",
installParams: &InstallParams{
PublicProxyAddr: "explicit.example.com",
},
fc: &FileConfig{
Global: Global{
ProxyServer: "proxy.example.com",
},
},
expectedProxyAddr: "explicit.example.com",
},
{
name: "proxy server",
fc: &FileConfig{
Global: Global{
ProxyServer: "proxy.example.com",
},
},
expectedProxyAddr: "proxy.example.com",
},
{
name: "local proxy service",
fc: &FileConfig{
Global: Global{
AuthServer: "auth.example.com",
},
Proxy: Proxy{
Service: Service{
EnabledFlag: "yes",
},
PublicAddr: apiutils.Strings{"proxy.example.com"},
Comment thread
codingllama marked this conversation as resolved.
Outdated
},
},
expectedProxyAddr: "proxy.example.com",
},
{
name: "v1/v2 auth servers",
fc: &FileConfig{
Version: "v2",
Global: Global{
AuthServers: []string{"proxy.example.com"},
},
},
expectedProxyAddr: "proxy.example.com",
},
{
name: "auth server",
fc: &FileConfig{
Global: Global{
AuthServer: "auth.example.com",
},
},
expectedProxyAddr: "auth.example.com",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.expectedProxyAddr, getInstallerProxyAddr(tc.installParams, tc.fc))
})
}
}