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 remove tctl command for AutoUpdateConfig and AutoUpdateVersion #49532

Merged
merged 2 commits into from
Nov 28, 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
12 changes: 12 additions & 0 deletions tool/tctl/common/resource_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,8 @@ func (rc *ResourceCommand) Delete(ctx context.Context, client *authclient.Client
types.KindInstaller,
types.KindUIConfig,
types.KindNetworkRestrictions,
types.KindAutoUpdateConfig,
types.KindAutoUpdateVersion,
}
if !slices.Contains(singletonResources, rc.ref.Kind) && (rc.ref.Kind == "" || rc.ref.Name == "") {
return trace.BadParameter("provide a full resource name to delete, for example:\n$ tctl rm cluster/east\n")
Expand Down Expand Up @@ -1982,6 +1984,16 @@ func (rc *ResourceCommand) Delete(ctx context.Context, client *authclient.Client
return trace.Wrap(err)
}
fmt.Printf("git_server %q has been deleted\n", rc.ref.Name)
case types.KindAutoUpdateConfig:
if err := client.DeleteAutoUpdateConfig(ctx); err != nil {
return trace.Wrap(err)
}
fmt.Printf("AutoUpdateConfig has been deleted\n")
case types.KindAutoUpdateVersion:
if err := client.DeleteAutoUpdateVersion(ctx); err != nil {
return trace.Wrap(err)
}
fmt.Printf("AutoUpdateVersion has been deleted\n")
default:
return trace.BadParameter("deleting resources of type %q is not supported", rc.ref.Kind)
}
Expand Down
12 changes: 12 additions & 0 deletions tool/tctl/common/resource_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,12 @@ version: v1
protocmp.IgnoreFields(&headerv1.Metadata{}, "revision"),
protocmp.Transform(),
))

// Delete the resource
_, err = runResourceCommand(t, clt, []string{"rm", types.KindAutoUpdateConfig})
require.NoError(t, err)
_, err = runResourceCommand(t, clt, []string{"get", types.KindAutoUpdateConfig})
require.ErrorContains(t, err, "autoupdate_config \"autoupdate-config\" doesn't exist")
}

func testCreateAutoUpdateVersion(t *testing.T, clt *authclient.Client) {
Expand Down Expand Up @@ -2361,6 +2367,12 @@ version: v1
protocmp.IgnoreFields(&headerv1.Metadata{}, "revision"),
protocmp.Transform(),
))

// Delete the resource
_, err = runResourceCommand(t, clt, []string{"rm", types.KindAutoUpdateVersion})
require.NoError(t, err)
_, err = runResourceCommand(t, clt, []string{"get", types.KindAutoUpdateVersion})
require.ErrorContains(t, err, "autoupdate_version \"autoupdate-version\" doesn't exist")
}

func testCreateDynamicWindowsDesktop(t *testing.T, clt *authclient.Client) {
Expand Down
Loading