Skip to content

Commit

Permalink
Add resource matchers to Windows desktop service config (#46985)
Browse files Browse the repository at this point in the history
* Add DynamicWindowsDesktop to proto

* Add resource matchers to Windows desktop service config

* move rpc to separate server

* e

* remove dynamic windows from paginated resource

* Update api/proto/teleport/legacy/types/types.proto

Co-authored-by: rosstimothy <[email protected]>

* gci

---------

Co-authored-by: rosstimothy <[email protected]>
  • Loading branch information
probakowski and rosstimothy authored Oct 14, 2024
1 parent 4c7fa50 commit af3ac37
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
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

0 comments on commit af3ac37

Please sign in to comment.