-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
executable file
·99 lines (94 loc) · 2.37 KB
/
main.go
File metadata and controls
executable file
·99 lines (94 loc) · 2.37 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import (
"fmt"
"github.com/jgrigorian/certscan/cmd/list"
"github.com/jgrigorian/certscan/cmd/show"
"github.com/urfave/cli/v2"
"log"
"os"
"sort"
)
func main() {
//list.Certificates()
// CLI
app := &cli.App{
Name: "certscan",
Usage: "Tool to interact with tls secrets in a kubernetes cluster",
OnUsageError: func(ctx *cli.Context, err error, isSubcommand bool) error {
if isSubcommand {
return err
}
fmt.Fprintf(ctx.App.Writer, "WRONG: %#v\n", err)
return nil
},
Commands: []*cli.Command{
///////////////////////////////////////////////////////////
// LIST
///////////////////////////////////////////////////////////
{
Name: "list",
Usage: "Option for listing certificates",
Subcommands: []*cli.Command{
{
Name: "certificates",
Usage: "list certificates",
Action: func(c *cli.Context) error {
return list.Certificates(c)
},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "expiring",
Aliases: []string{"e"},
Usage: "List only expired or expiring certificates",
},
&cli.StringFlag{
Name: "namespace",
Aliases: []string{"n"},
Usage: "Desired namespace (Example: default)",
},
&cli.BoolFlag{
Name: "all-namespaces",
Aliases: []string{"A"},
Usage: "All namespaces",
},
},
},
},
},
///////////////////////////////////////////////////////////
// SHOW
///////////////////////////////////////////////////////////
{
Name: "show",
Usage: "Option for showing certificate details",
Subcommands: []*cli.Command{
{
Name: "certificate",
Usage: "show certificate",
Action: func(c *cli.Context) error {
return show.Certificate(c)
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "secret",
Aliases: []string{"s"},
Usage: "Name of the desired secret. Example: staging-ssl-secret",
},
&cli.StringFlag{
Name: "namespace",
Aliases: []string{"n"},
Usage: "Desired namespace (Example: default). NOTE: If no namespace is provided, default is used.",
},
},
},
},
},
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}