-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathadmin_delete_orga.go
More file actions
66 lines (53 loc) · 2.06 KB
/
admin_delete_orga.go
File metadata and controls
66 lines (53 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package cmd
import (
"strings"
"github.com/qovery/qovery-cli/pkg"
"github.com/spf13/cobra"
)
var (
organizationIds []string
allowFailedClusters bool
adminDeleteOrgaCmd = &cobra.Command{
Use: "delete",
Short: "Delete one or more organizations by their IDs",
Long: `Delete one or more organizations by providing their IDs. Clusters must be deleted before via the force-delete-cluster command
Examples:
# Delete a single organization
qovery admin delete --organization-id org-123
# Delete multiple organizations (comma-separated)
qovery admin delete --organization-id "org-123,org-456,org-789"
# Delete multiple organizations (repeated flag)
qovery admin delete --organization-id org-123 --organization-id org-456
# Mix both formats
qovery admin delete -o "org-123,org-456" -o org-789
# Allow deletion of organizations with failed clusters
qovery admin delete -o org-123 --allow-failed-clusters
# Disable dry-run to actually delete
qovery admin delete -o org-123 --disable-dry-run`,
Run: func(cmd *cobra.Command, args []string) {
deleteOrganizations()
},
}
)
func init() {
adminDeleteOrgaCmd.Flags().StringSliceVarP(&organizationIds, "organization-id", "o", []string{}, "Organization ID(s) to delete (comma-separated or repeated flag)")
adminDeleteOrgaCmd.Flags().BoolVarP(&allowFailedClusters, "allow-failed-clusters", "f", false, "Allow deletion of organizations with failed or non-deployed clusters")
adminDeleteOrgaCmd.Flags().BoolVarP(&dryRun, "disable-dry-run", "y", false, "Disable dry run mode")
_ = adminDeleteOrgaCmd.MarkFlagRequired("organization-id")
adminCmd.AddCommand(adminDeleteOrgaCmd)
}
func deleteOrganizations() {
// Parse comma-separated values in case user provides "id1,id2,id3"
var parsedIds []string
for _, id := range organizationIds {
// Split by comma and trim spaces
parts := strings.Split(id, ",")
for _, part := range parts {
trimmed := strings.TrimSpace(part)
if trimmed != "" {
parsedIds = append(parsedIds, trimmed)
}
}
}
pkg.DeleteOrganizations(parsedIds, allowFailedClusters, dryRun)
}