forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (40 loc) · 783 Bytes
/
main.go
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
package main
import (
"log"
"os"
"path/filepath"
"github.com/alecthomas/kong"
)
var (
version = "dev"
cli struct {
Version kong.VersionFlag
Aws AwsCmd `kong:"cmd,name=aws"`
Netlify NetlifyCmd `kong:"cmd,name=netlify"`
}
)
func main() {
log.SetFlags(0)
ctx := kong.Parse(&cli,
kong.Name("releaser"),
kong.UsageOnError(),
kong.Vars{
"version": version,
},
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
Summary: true,
}))
ctx.FatalIfErrorf(ctx.Run())
}
// getEnvOrSecret retrieves secret's value from secret file or env
func getEnvOrSecret(name string) string {
if v, ok := os.LookupEnv(name); ok {
return v
}
b, err := os.ReadFile(filepath.Join("/run/secrets", name))
if err != nil {
return ""
}
return string(b)
}