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
21 changes: 12 additions & 9 deletions lib/config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -1375,14 +1375,15 @@ func applyDiscoveryConfig(fc *FileConfig, cfg *servicecfg.Config) error {
Regions: matcher.Regions,
ResourceTags: matcher.ResourceTags,
}

if matcher.InstallParams != nil {
if slices.Contains(matcher.Types, services.AzureMatcherVM) {
m.Params = &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 {
m.Params.JoinMethod = matcher.InstallParams.JoinParams.Method
m.Params.JoinToken = matcher.InstallParams.JoinParams.TokenName
m.Params.ScriptName = matcher.InstallParams.ScriptName
}
}
cfg.Discovery.AzureMatchers = append(cfg.Discovery.AzureMatchers, m)
}
Expand All @@ -1396,13 +1397,15 @@ func applyDiscoveryConfig(fc *FileConfig, cfg *servicecfg.Config) error {
ProjectIDs: matcher.ProjectIDs,
ServiceAccounts: matcher.ServiceAccounts,
}
if matcher.InstallParams != nil {
if slices.Contains(matcher.Types, services.GCPMatcherCompute) {
m.Params = &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 {
m.Params.JoinMethod = matcher.InstallParams.JoinParams.Method
m.Params.JoinToken = matcher.InstallParams.JoinParams.TokenName
m.Params.ScriptName = matcher.InstallParams.ScriptName
}
}
cfg.Discovery.GCPMatchers = append(cfg.Discovery.GCPMatchers, m)
}
Expand Down
64 changes: 62 additions & 2 deletions lib/config/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3779,7 +3779,7 @@ func TestApplyDiscoveryConfig(t *testing.T) {
discoveryConfig: Discovery{
AzureMatchers: []AzureMatcher{
{
Types: []string{"aks"},
Types: []string{"aks", "vm"},
Subscriptions: []string{"abcd"},
},
},
Expand All @@ -3789,7 +3789,67 @@ func TestApplyDiscoveryConfig(t *testing.T) {
AzureMatchers: []types.AzureMatcher{
{
Subscriptions: []string{"abcd"},
Types: []string{"aks"},
Types: []string{"aks", "vm"},
Params: &types.InstallerParams{
PublicProxyAddr: "example.com",
},
},
},
},
},
{
name: "gcp matchers",
discoveryConfig: Discovery{
GCPMatchers: []GCPMatcher{
{
Types: []string{"gce"},
ProjectIDs: []string{"abcd"},
InstallParams: &InstallParams{
JoinParams: JoinParams{
TokenName: "gcp-token",
Method: "gcp",
},
ScriptName: "default-installer",
PublicProxyAddr: "proxy.example.com",
},
},
},
},
expectedDiscovery: servicecfg.DiscoveryConfig{
Enabled: true,
GCPMatchers: []types.GCPMatcher{
{
Types: []string{"gce"},
ProjectIDs: []string{"abcd"},
Params: &types.InstallerParams{
JoinMethod: "gcp",
JoinToken: "gcp-token",
ScriptName: "default-installer",
PublicProxyAddr: "proxy.example.com",
},
},
},
},
},
{
name: "gcp matchers no installer",
discoveryConfig: Discovery{
GCPMatchers: []GCPMatcher{
{
Types: []string{"gce"},
ProjectIDs: []string{"abcd"},
},
},
},
expectedDiscovery: servicecfg.DiscoveryConfig{
Enabled: true,
GCPMatchers: []types.GCPMatcher{
{
Types: []string{"gce"},
ProjectIDs: []string{"abcd"},
Params: &types.InstallerParams{
PublicProxyAddr: "example.com",
},
},
},
},
Expand Down
11 changes: 10 additions & 1 deletion lib/config/fileconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,9 @@ func TestDiscoveryConfig(t *testing.T) {
Labels: map[string]apiutils.Strings{
"discover_teleport": []string{"yes"},
},
Tags: map[string]apiutils.Strings{
"discover_teleport": []string{"yes"},
},
ProjectIDs: []string{"p1", "p2"},
},
},
Expand All @@ -973,11 +976,14 @@ func TestDiscoveryConfig(t *testing.T) {
expectedDiscoverySection: Discovery{
GCPMatchers: []GCPMatcher{
{
Types: []string{"gke"},
Types: []string{"gce"},
Locations: []string{"eucentral1"},
Labels: map[string]apiutils.Strings{
"discover_teleport": []string{"yes"},
},
Tags: map[string]apiutils.Strings{
"discover_teleport": []string{"yes"},
},
ProjectIDs: []string{"p1", "p2"},
ServiceAccounts: []string{"a@example.com", "b@example.com"},
InstallParams: &InstallParams{
Expand Down Expand Up @@ -1437,6 +1443,9 @@ func TestDiscoveryConfig(t *testing.T) {
if expectedAzure := testCase.expectedDiscoverySection.AzureMatchers; expectedAzure != nil {
require.Equal(t, expectedAzure, cfg.Discovery.AzureMatchers)
}
if expectedGCP := testCase.expectedDiscoverySection.GCPMatchers; expectedGCP != nil {
require.Equal(t, expectedGCP, cfg.Discovery.GCPMatchers)
}
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/config/testdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ okta_service:
// NoServicesConfigString is a configuration file with no services enabled
// but with values for all services set.
const NoServicesConfigString = `
version: v3
teleport:
nodename: node.example.com
proxy_server: "example.com"

auth_service:
enabled: no
Expand Down