Skip to content

Commit

Permalink
tctl: allow creating desktops from YAML file
Browse files Browse the repository at this point in the history
To date: we have supported registering desktops in a few ways:

1. By discovering them from LDAP
2. By listing "static hosts" in the configuration file
3. Via our API
   https://github.com/gravitational/teleport/tree/master/examples/desktop-registration

This extends tctl to support creating a desktop from a YAML resource
definition, which provides an alternative for those who want more
control over the name and labels of their desktops, but don't want to
write and maintain an integration using our API.

Closes #27106
  • Loading branch information
zmb3 committed Jun 1, 2023
1 parent db64101 commit dd9a0ca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tool/tctl/common/resource_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func (rc *ResourceCommand) Initialize(app *kingpin.Application, config *service.
types.KindDevice: rc.createDevice,
types.KindOktaImportRule: rc.createOktaImportRule,
types.KindIntegration: rc.createIntegration,
types.KindWindowsDesktop: rc.createWindowsDesktop,
}
rc.config = config

Expand Down Expand Up @@ -576,6 +577,20 @@ func (rc *ResourceCommand) createNetworkRestrictions(ctx context.Context, client
return nil
}

func (rc *ResourceCommand) createWindowsDesktop(ctx context.Context, client auth.ClientI, raw services.UnknownResource) error {
wd, err := services.UnmarshalWindowsDesktop(raw.Raw)
if err != nil {
return trace.Wrap(err)
}

if err := client.UpsertWindowsDesktop(ctx, wd); err != nil {
return trace.Wrap(err)
}

fmt.Printf("windows desktop %q has been updated\n", wd.GetName())
return nil
}

func (rc *ResourceCommand) createApp(ctx context.Context, client auth.ClientI, raw services.UnknownResource) error {
app, err := services.UnmarshalApp(raw.Raw)
if err != nil {
Expand Down

0 comments on commit dd9a0ca

Please sign in to comment.