From 5bd21bc6696de435a0a127ff335c72c4bedf5a99 Mon Sep 17 00:00:00 2001 From: Edoardo Spadolini Date: Fri, 8 Aug 2025 11:20:31 +0200 Subject: [PATCH] tctl: support getting and deleting relay_server items (#57644) --- lib/services/resource.go | 2 ++ tool/tctl/common/resource_command.go | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/services/resource.go b/lib/services/resource.go index 7848e6df7ef..bae58a6a2cd 100644 --- a/lib/services/resource.go +++ b/lib/services/resource.go @@ -297,6 +297,8 @@ func ParseShortcut(in string) (string, error) { return types.KindInferenceSecret, nil case types.KindInferencePolicy, "inference_policies": return types.KindInferencePolicy, nil + case types.KindRelayServer, types.KindRelayServer + "s": + return types.KindRelayServer, nil } return "", trace.BadParameter("unsupported resource: %q - resources should be expressed as 'type/name', for example 'connector/github'", in) } diff --git a/tool/tctl/common/resource_command.go b/tool/tctl/common/resource_command.go index 6a4bb9381d1..69df56fa6f9 100644 --- a/tool/tctl/common/resource_command.go +++ b/tool/tctl/common/resource_command.go @@ -2369,6 +2369,11 @@ func (rc *ResourceCommand) Delete(ctx context.Context, client *authclient.Client fmt.Printf("AutoUpdateAgentRollout has been deleted\n") case types.KindHealthCheckConfig: return trace.Wrap(rc.deleteHealthCheckConfig(ctx, client)) + case types.KindRelayServer: + if err := client.DeleteRelayServer(ctx, rc.ref.Name); err != nil { + return trace.Wrap(err) + } + fmt.Printf("relay_server %+q has been deleted\n", rc.ref.Name) default: return trace.BadParameter("deleting resources of type %q is not supported", rc.ref.Kind) } @@ -3719,6 +3724,22 @@ func (rc *ResourceCommand) getCollection(ctx context.Context, client *authclient } } return &scopedRoleAssignmentCollection{items: items}, nil + case types.KindRelayServer: + if rc.ref.Name != "" { + rs, err := client.GetRelayServer(ctx, rc.ref.Name) + if err != nil { + return nil, trace.Wrap(err) + } + return namedResourceCollection{types.ProtoResource153ToLegacy(rs)}, nil + } + var c namedResourceCollection + for rs, err := range clientutils.Resources(ctx, client.ListRelayServers) { + if err != nil { + return nil, trace.Wrap(err) + } + c = append(c, types.ProtoResource153ToLegacy(rs)) + } + return c, nil } return nil, trace.BadParameter("getting %q is not supported", rc.ref.String()) }