Repository navigation
Expand file tree
/
Copy pathdelete.go
More file actions
52 lines (45 loc) · 1.63 KB
/
Copy pathdelete.go
File metadata and controls
52 lines (45 loc) · 1.63 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
package main
import (
"fmt"
"os"
"os/exec"
)
func DeletePool(cfg *config) error {
if Ask(fmt.Sprintf("Are you sure you want to delete the pool [%s > %s]?", cfg.projectID, cfg.poolName)) {
cmd := exec.Command("gcloud", "iam", "workload-identity-pools", "delete", cfg.poolName, "--project", cfg.projectID, "--location", "global", "--quiet")
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to delete pool: %v", err)
}
fmt.Println("Pool deleted successfully - it will be removed after a 30 day grace period and can be restored until then.")
}
return nil
}
func DeleteProvider(cfg *config) error {
if Ask(fmt.Sprintf("Are you sure you want to delete the provider [%s > %s > %s]?", cfg.projectID, cfg.poolName, cfg.providerName)) {
cmd := exec.Command("gcloud", "iam", "workload-identity-pools", "providers", "delete",
cfg.providerName,
"--project", cfg.projectID,
"--location", "global",
"--quiet",
"--workload-identity-pool", cfg.poolName)
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to delete provider: %v", err)
}
fmt.Println("Provider deleted successfully - it will be removed after a 30 day grace period and can be restored until then.")
}
return nil
}
func RestoreProvider(cfg *config) error {
cmd := exec.Command("gcloud", "iam", "workload-identity-pools", "providers", "undelete",
cfg.providerName,
"--project", cfg.projectID,
"--location", "global",
"--workload-identity-pool", cfg.poolName)
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to restore provider: %v", err)
}
return nil
}