/
main.go
51 lines (44 loc) · 1.11 KB
/
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
46
47
48
49
50
51
package main
import (
"fmt"
"github.com/spf13/cobra"
"net/url"
"os"
)
func newRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "import",
Long: "Import Helm Chart where only public code into local repository.",
Example: `
$ helm import https://example.com/path/to/file.tgz
$ helm import https://github.com/user/repo/
$ helm import https://github.com/user/repo/tree/branch
$ helm import https://github.com/user/repo/tree/branch/path/to`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
u, err := url.Parse(args[0])
if err != nil {
return err
}
return Import(*u)
},
SilenceErrors: true,
SilenceUsage: true,
}
cmd.SetUsageTemplate(`Usage:{{if .Runnable}}
helm import URL{{end}}{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if .HasExample}}
Examples:
{{.Example}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}`)
cmd.AddCommand()
return cmd
}
func main() {
cmd := newRootCmd()
if err := cmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}