/
root.go
50 lines (39 loc) · 1.23 KB
/
root.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
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
const (
defaultCfgFile = "charts-syncer.yaml"
)
var (
rootUsage = `charts-syncer is a tool to synchronize chart repositories from a source repository to a target repository
Find more information at: https://github.com/bitnami-labs/charts-syncer`
rootConfig string
rootDryRun bool
rootInsecure bool
)
func newRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "charts-syncer",
Short: "tool to synchronize helm chart repositories",
Long: rootUsage,
// Do not show the Usage page on every raised error
SilenceUsage: true,
}
cmd.PersistentFlags().BoolVar(&rootDryRun, "dry-run", false, "Only shows the charts pending to be synced without syncing them")
cmd.PersistentFlags().StringVarP(&rootConfig, "config", "c", "", fmt.Sprintf("Config file. Defaults to ./%s or $HOME/%s)", defaultCfgFile, defaultCfgFile))
cmd.PersistentFlags().BoolVar(&rootInsecure, "insecure", false, "Allow insecure SSL connections")
// Add subcommands
cmd.AddCommand(
newSyncCmd(),
newVersionCmd(),
)
// Workaround to disable help subcommand
// https://github.com/spf13/cobra/issues/587
cmd.SetHelpCommand(&cobra.Command{
Use: "no-help",
Hidden: true,
})
return cmd
}