feat: add orphan support (#3849)

* feat: add resource orphanage

* feat: deny custom state in build for regular users

* Minor protoc improvements
This commit is contained in:
Ammar Bandukwala
2022-09-06 17:07:00 +00:00
committed by GitHub
parent 209e011404
commit 4f0105ef7e
16 changed files with 334 additions and 51 deletions
+18 -1
View File
@@ -12,6 +12,7 @@ import (
// nolint
func deleteWorkspace() *cobra.Command {
var orphan bool
cmd := &cobra.Command{
Annotations: workspaceCommand,
Use: "delete <workspace>",
@@ -36,9 +37,21 @@ func deleteWorkspace() *cobra.Command {
if err != nil {
return err
}
var state []byte
if orphan {
cliui.Warn(
cmd.ErrOrStderr(),
"Orphaning workspace requires template edit permission",
)
}
before := time.Now()
build, err := client.CreateWorkspaceBuild(cmd.Context(), workspace.ID, codersdk.CreateWorkspaceBuildRequest{
Transition: codersdk.WorkspaceTransitionDelete,
Transition: codersdk.WorkspaceTransitionDelete,
ProvisionerState: state,
Orphan: orphan,
})
if err != nil {
return err
@@ -53,6 +66,10 @@ func deleteWorkspace() *cobra.Command {
return nil
},
}
cmd.Flags().BoolVar(&orphan, "orphan", false,
`Delete a workspace without deleting its resources. This can delete a
workspace in a broken state, but may also lead to unaccounted cloud resources.`,
)
cliui.AllowSkipPrompt(cmd)
return cmd
}