Skip to content

Commit cd7875d

Browse files
committed
Create kubectl-confirm-delete.go
1 parent 77f95b0 commit cd7875d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

kubectl-confirm-delete.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"os/exec"
7+
"strings"
8+
)
9+
10+
func main() {
11+
args := os.Args[1:]
12+
13+
if len(args) > 0 && args[0] == "delete" {
14+
fmt.Print("You're running delete command, are you sure you're not gonna fuck up anything? (y/n) : ")
15+
16+
var input string
17+
fmt.Scanln(&input)
18+
19+
if strings.ToLower(input) == "y" {
20+
cmd := exec.Command("kubectl", args...)
21+
cmd.Stdout = os.Stdout
22+
cmd.Stderr = os.Stderr
23+
err := cmd.Run()
24+
if err != nil {
25+
fmt.Println(err)
26+
os.Exit(1)
27+
}
28+
} else if strings.ToLower(input) == "n" {
29+
fmt.Println("Well, this time I saved your ass.")
30+
fmt.Println("Be more careful.")
31+
} else {
32+
fmt.Println("WTF?")
33+
}
34+
} else {
35+
cmd := exec.Command("kubectl", args...)
36+
cmd.Stdout = os.Stdout
37+
cmd.Stderr = os.Stderr
38+
err := cmd.Run()
39+
if err != nil {
40+
fmt.Println(err)
41+
os.Exit(1)
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)