Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resource matchers to Windows desktop service config #46985

Merged
merged 16 commits into from
Oct 14, 2024
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
6 changes: 6 additions & 0 deletions lib/config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,12 @@ func applyWindowsDesktopConfig(fc *FileConfig, cfg *servicecfg.Config) error {
}
cfg.WindowsDesktop.HostLabels = servicecfg.NewHostLabelRules(hlrs...)

for _, matcher := range fc.WindowsDesktop.ResourceMatchers {
cfg.WindowsDesktop.ResourceMatchers = append(cfg.WindowsDesktop.ResourceMatchers, services.ResourceMatcher{
Labels: matcher.Labels,
})
}

if fc.WindowsDesktop.Labels != nil {
cfg.WindowsDesktop.Labels = maps.Clone(fc.WindowsDesktop.Labels)
}
Expand Down
2 changes: 2 additions & 0 deletions lib/config/fileconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2399,6 +2399,8 @@ type WindowsDesktopService struct {
// A host can match multiple rules and will get a union of all
// the matched labels.
HostLabels []WindowsHostLabelRule `yaml:"host_labels,omitempty"`
// ResourceMatchers match dynamic Windows desktop resources.
ResourceMatchers []ResourceMatcher `yaml:"resources,omitempty"`
}

// Check checks whether the WindowsDesktopService is valid or not
Expand Down
1 change: 1 addition & 0 deletions lib/service/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func (process *TeleportProcess) initWindowsDesktopServiceRegistered(logger *slog
DiscoveryLDAPAttributeLabels: cfg.WindowsDesktop.Discovery.LabelAttributes,
Hostname: cfg.Hostname,
ConnectedProxyGetter: proxyGetter,
ResourceMatchers: cfg.WindowsDesktop.ResourceMatchers,
})
if err != nil {
return trace.Wrap(err)
Expand Down
3 changes: 3 additions & 0 deletions lib/service/servicecfg/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"regexp"

"github.com/gravitational/teleport/lib/limiter"
"github.com/gravitational/teleport/lib/services"
"github.com/gravitational/teleport/lib/utils"
)

Expand Down Expand Up @@ -65,6 +66,8 @@ type WindowsDesktopConfig struct {
// HostLabels specifies rules that are used to apply labels to Windows hosts.
HostLabels HostLabelRules
Labels map[string]string
// ResourceMatchers match dynamic Windows desktop resources.
ResourceMatchers []services.ResourceMatcher
}

// WindowsHost is configuration for single Windows desktop host
Expand Down
2 changes: 2 additions & 0 deletions lib/srv/desktop/windows_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ type WindowsServiceConfig struct {
// ConnectedProxyGetter gets the proxies teleport is connected to.
ConnectedProxyGetter *reversetunnel.ConnectedProxyGetter
Labels map[string]string
// ResourceMatchers match dynamic Windows desktop resources.
ResourceMatchers []services.ResourceMatcher
}

// HeartbeatConfig contains the configuration for service heartbeats.
Expand Down
Loading