mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-11 22:49:54 +00:00
Make Linux desktop requestable (#397)
Export-Source-Commit: 696335b5bef921b09d1790256dac2f0fbff34fd0
This commit is contained in:
committed by
Gus Rivera
parent
fc3d8bd714
commit
700bdada2a
@@ -4776,6 +4776,8 @@ func (c *Client) ListResources(ctx context.Context, req proto.ListResourcesReque
|
||||
resources[i] = respResource.GetAppServer()
|
||||
case types.KindNode:
|
||||
resources[i] = respResource.GetNode()
|
||||
case types.KindLinuxDesktop:
|
||||
resources[i] = proto.UnpackLinuxDesktop(respResource.GetLinuxDesktop())
|
||||
case types.KindWindowsDesktop:
|
||||
resources[i] = respResource.GetWindowsDesktop()
|
||||
case types.KindWindowsDesktopService:
|
||||
|
||||
@@ -1614,6 +1614,7 @@ var RequestableResourceKinds = []string{
|
||||
KindDatabase,
|
||||
KindApp,
|
||||
KindWindowsDesktop,
|
||||
KindLinuxDesktop,
|
||||
KindUserGroup,
|
||||
KindSAMLIdPServiceProvider,
|
||||
KindIdentityCenterAccount,
|
||||
|
||||
@@ -2518,6 +2518,7 @@ func (a *ServerWithRoles) ListResources(ctx context.Context, req proto.ListResou
|
||||
types.KindAppServer,
|
||||
types.KindKubeServer,
|
||||
types.KindWindowsDesktop,
|
||||
types.KindLinuxDesktop,
|
||||
types.KindWindowsDesktopService,
|
||||
types.KindUserGroup,
|
||||
types.KindSAMLIdPServiceProvider,
|
||||
|
||||
Vendored
+18
@@ -39,6 +39,7 @@ import (
|
||||
authproto "github.com/gravitational/teleport/api/client/proto"
|
||||
apidefaults "github.com/gravitational/teleport/api/defaults"
|
||||
identitycenterv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/identitycenter/v1"
|
||||
linuxdesktopv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/linuxdesktop/v1"
|
||||
scopesv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/scopes/v1"
|
||||
"github.com/gravitational/teleport/api/internalutils/stream"
|
||||
apitracing "github.com/gravitational/teleport/api/observability/tracing"
|
||||
@@ -1813,6 +1814,23 @@ func (c *Cache) listResources(ctx context.Context, req authproto.ListResourcesRe
|
||||
},
|
||||
)
|
||||
return resp, trace.Wrap(err)
|
||||
case types.KindLinuxDesktop:
|
||||
resp, err := buildListResourcesResponse(
|
||||
func(yield func(types.ResourceWithLabels) bool) {
|
||||
for desktop := range c.collections.linuxDesktops.store.resources(linuxDesktopNameIndex, req.StartKey, "") {
|
||||
if !yield(types.Resource153ToResourceWithLabels(desktop)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
},
|
||||
limit,
|
||||
filter,
|
||||
func(r types.ResourceWithLabels) types.ResourceWithLabels {
|
||||
unwrapper := r.(types.Resource153UnwrapperT[*linuxdesktopv1.LinuxDesktop])
|
||||
return types.Resource153ToResourceWithLabels(proto.CloneOf(unwrapper.UnwrapT()))
|
||||
},
|
||||
)
|
||||
return resp, trace.Wrap(err)
|
||||
case types.KindKubeServer:
|
||||
resp, err := buildListResourcesResponse(
|
||||
c.collections.kubeServers.store.resources(kubeServerNameIndex, req.StartKey, ""),
|
||||
|
||||
@@ -1628,6 +1628,9 @@ func (s *PresenceService) listResources(ctx context.Context, req proto.ListResou
|
||||
case types.KindWindowsDesktop:
|
||||
keyPrefix = []string{windowsDesktopsPrefix}
|
||||
unmarshalItemFunc = backendItemToWindowsDesktop
|
||||
case types.KindLinuxDesktop:
|
||||
keyPrefix = []string{linuxDesktopKey}
|
||||
unmarshalItemFunc = backendItemToLinuxDesktop
|
||||
case types.KindKubeServer:
|
||||
return s.listKubeServers(ctx, req)
|
||||
case types.KindUserGroup:
|
||||
@@ -2119,6 +2122,17 @@ func backendItemToWindowsDesktop(item backend.Item) (types.ResourceWithLabels, e
|
||||
)
|
||||
}
|
||||
|
||||
// backendItemToLinuxDesktop unmarshals `backend.Item` into a
|
||||
// `LinuxDesktops`, returning it as a `types.ResourceWithLabels`.
|
||||
func backendItemToLinuxDesktop(item backend.Item) (types.ResourceWithLabels, error) {
|
||||
linuxDesktop, err := services.UnmarshalLinuxDesktop(
|
||||
item.Value,
|
||||
services.WithExpires(item.Expires),
|
||||
services.WithRevision(item.Revision),
|
||||
)
|
||||
return types.Resource153ToResourceWithLabels(linuxDesktop), err
|
||||
}
|
||||
|
||||
// backendItemToWindowsDesktopService unmarshals `backend.Item` into a
|
||||
// `types.WindowsDesktopService`, returning it as a `types.ResourceWithLabels`.
|
||||
func backendItemToWindowsDesktopService(item backend.Item) (types.ResourceWithLabels, error) {
|
||||
|
||||
@@ -47,6 +47,7 @@ export function getNumAddedResources(addedResources: ResourceMap) {
|
||||
Object.keys(addedResources.kube_cluster).length +
|
||||
Object.keys(addedResources.user_group).length +
|
||||
Object.keys(addedResources.windows_desktop).length +
|
||||
Object.keys(addedResources.linux_desktop).length +
|
||||
Object.keys(addedResources.saml_idp_service_provider).length +
|
||||
Object.keys(addedResources.namespace).length +
|
||||
Object.keys(addedResources.aws_ic_account_assignment).length
|
||||
|
||||
Reference in New Issue
Block a user