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
27 changes: 16 additions & 11 deletions lib/config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -1545,16 +1545,18 @@ func applyDiscoveryConfig(fc *FileConfig, cfg *servicecfg.Config) error {

for _, matcher := range fc.Discovery.AzureMatchers {
var installerParams *types.InstallerParams
if matcher.InstallParams != nil {
if slices.Contains(matcher.Types, types.AzureMatcherVM) {
installerParams = &types.InstallerParams{
JoinMethod: matcher.InstallParams.JoinParams.Method,
JoinToken: matcher.InstallParams.JoinParams.TokenName,
ScriptName: matcher.InstallParams.ScriptName,
PublicProxyAddr: getInstallerProxyAddr(matcher.InstallParams, fc),
}
if matcher.InstallParams.Azure != nil {
installerParams.Azure = &types.AzureInstallerParams{
ClientID: matcher.InstallParams.Azure.ClientID,
if matcher.InstallParams != nil {
installerParams.JoinMethod = matcher.InstallParams.JoinParams.Method
installerParams.JoinToken = matcher.InstallParams.JoinParams.TokenName
installerParams.ScriptName = matcher.InstallParams.ScriptName
if matcher.InstallParams.Azure != nil {
installerParams.Azure = &types.AzureInstallerParams{
ClientID: matcher.InstallParams.Azure.ClientID,
}
}
}
}
Expand All @@ -1576,14 +1578,17 @@ func applyDiscoveryConfig(fc *FileConfig, cfg *servicecfg.Config) error {

for _, matcher := range fc.Discovery.GCPMatchers {
var installerParams *types.InstallerParams
if matcher.InstallParams != nil {
if slices.Contains(matcher.Types, types.GCPMatcherCompute) {
installerParams = &types.InstallerParams{
JoinMethod: matcher.InstallParams.JoinParams.Method,
JoinToken: matcher.InstallParams.JoinParams.TokenName,
ScriptName: matcher.InstallParams.ScriptName,
PublicProxyAddr: getInstallerProxyAddr(matcher.InstallParams, fc),
}
if matcher.InstallParams != nil {
installerParams.JoinMethod = matcher.InstallParams.JoinParams.Method
installerParams.JoinToken = matcher.InstallParams.JoinParams.TokenName
installerParams.ScriptName = matcher.InstallParams.ScriptName
}
}

serviceMatcher := types.GCPMatcher{
Types: matcher.Types,
Locations: matcher.Locations,
Expand Down
26 changes: 19 additions & 7 deletions lib/config/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4304,6 +4304,11 @@ func TestDiscoveryConfig(t *testing.T) {
"service_accounts": []string{"a@example.com", "b@example.com"},
},
}
cfg["version"] = "v3"
cfg["teleport"].(cfgMap)["proxy_server"] = "example.com"
cfg["proxy_service"] = cfgMap{
"enabled": "no",
}
},
expectedGCPMatchers: []types.GCPMatcher{{
Types: []string{"gce"},
Expand All @@ -4317,9 +4322,10 @@ func TestDiscoveryConfig(t *testing.T) {
ProjectIDs: []string{"p1", "p2"},
ServiceAccounts: []string{"a@example.com", "b@example.com"},
Params: &types.InstallerParams{
JoinMethod: types.JoinMethodGCP,
JoinToken: types.GCPInviteTokenName,
ScriptName: installers.InstallerScriptName,
JoinMethod: types.JoinMethodGCP,
JoinToken: types.GCPInviteTokenName,
ScriptName: installers.InstallerScriptName,
PublicProxyAddr: "example.com",
},
}},
},
Expand Down Expand Up @@ -4632,6 +4638,11 @@ func TestDiscoveryConfig(t *testing.T) {
},
},
}
cfg["version"] = "v3"
cfg["teleport"].(cfgMap)["proxy_server"] = "example.com"
cfg["proxy_service"] = cfgMap{
"enabled": "no",
}
},
expectedAzureMatchers: []types.AzureMatcher{{
Types: []string{"vm"},
Expand All @@ -4642,10 +4653,11 @@ func TestDiscoveryConfig(t *testing.T) {
"discover_teleport": []string{"yes"},
},
Params: &types.InstallerParams{
JoinMethod: "azure",
JoinToken: "azure-discovery-token",
ScriptName: "default-installer",
Azure: &types.AzureInstallerParams{},
JoinMethod: "azure",
JoinToken: "azure-discovery-token",
ScriptName: "default-installer",
PublicProxyAddr: "example.com",
Azure: &types.AzureInstallerParams{},
},
}},
},
Expand Down