|
|
|
@ -10,12 +10,18 @@ import (
|
|
|
|
|
|
|
|
|
|
var version = "0.0.1"
|
|
|
|
|
|
|
|
|
|
var commands []cli.Command
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
commands = cmds()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
|
app.Name = "helm"
|
|
|
|
|
app.Version = version
|
|
|
|
|
app.Usage = `Deploy and manage packages.`
|
|
|
|
|
app.Commands = commands()
|
|
|
|
|
app.Commands = commands
|
|
|
|
|
|
|
|
|
|
// TODO: make better
|
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
@ -38,73 +44,8 @@ func main() {
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func commands() []cli.Command {
|
|
|
|
|
func cmds() []cli.Command {
|
|
|
|
|
return []cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "dm",
|
|
|
|
|
Usage: "Manage DM on Kubernetes",
|
|
|
|
|
Subcommands: []cli.Command{
|
|
|
|
|
{
|
|
|
|
|
Name: "install",
|
|
|
|
|
Usage: "Install DM on Kubernetes.",
|
|
|
|
|
Description: ``,
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
cli.BoolFlag{
|
|
|
|
|
Name: "dry-run",
|
|
|
|
|
Usage: "Show what would be installed, but don't install anything.",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
Action: func(c *cli.Context) {
|
|
|
|
|
if err := install(c.Bool("dry-run")); err != nil {
|
|
|
|
|
format.Err("%s (Run 'helm doctor' for more information)", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "uninstall",
|
|
|
|
|
Usage: "Uninstall the DM from Kubernetes.",
|
|
|
|
|
Description: ``,
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
cli.BoolFlag{
|
|
|
|
|
Name: "dry-run",
|
|
|
|
|
Usage: "Show what would be installed, but don't install anything.",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
Action: func(c *cli.Context) {
|
|
|
|
|
if err := uninstall(c.Bool("dry-run")); err != nil {
|
|
|
|
|
format.Err("%s (Run 'helm doctor' for more information)", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "status",
|
|
|
|
|
Usage: "Show status of DM.",
|
|
|
|
|
Action: func(c *cli.Context) {
|
|
|
|
|
format.Err("Not yet implemented")
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "target",
|
|
|
|
|
Usage: "Displays information about cluster.",
|
|
|
|
|
ArgsUsage: "",
|
|
|
|
|
Action: func(c *cli.Context) {
|
|
|
|
|
if err := target(c.Bool("dry-run")); err != nil {
|
|
|
|
|
format.Err("%s (Is the cluster running?)", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
cli.BoolFlag{
|
|
|
|
|
Name: "dry-run",
|
|
|
|
|
Usage: "Only display the underlying kubectl commands.",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "init",
|
|
|
|
|
Usage: "Initialize the client and install DM on Kubernetes.",
|
|
|
|
@ -122,68 +63,16 @@ func commands() []cli.Command {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "doctor",
|
|
|
|
|
Usage: "Run a series of checks for necessary prerequisites.",
|
|
|
|
|
ArgsUsage: "",
|
|
|
|
|
Action: func(c *cli.Context) {
|
|
|
|
|
if err := doctor(); err != nil {
|
|
|
|
|
format.Err("%s", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "create",
|
|
|
|
|
Usage: "Create a new local chart for editing.",
|
|
|
|
|
Action: func(c *cli.Context) { run(c, create) },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "package",
|
|
|
|
|
Aliases: []string{"pack"},
|
|
|
|
|
Usage: "Given a chart directory, package it into a release.",
|
|
|
|
|
Action: func(c *cli.Context) { run(c, pack) },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "deploy",
|
|
|
|
|
Aliases: []string{"install"},
|
|
|
|
|
Usage: "Deploy a chart into the cluster.",
|
|
|
|
|
Action: func(c *cli.Context) { run(c, deploy) },
|
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
|
cli.BoolFlag{
|
|
|
|
|
Name: "dry-run",
|
|
|
|
|
Usage: "Only display the underlying kubectl commands.",
|
|
|
|
|
},
|
|
|
|
|
cli.BoolFlag{
|
|
|
|
|
Name: "stdin,i",
|
|
|
|
|
Usage: "Read a configuration from STDIN.",
|
|
|
|
|
},
|
|
|
|
|
cli.StringFlag{
|
|
|
|
|
Name: "name",
|
|
|
|
|
Usage: "Name of deployment, used for deploy and update commands (defaults to template name)",
|
|
|
|
|
},
|
|
|
|
|
// TODO: I think there is a Generic flag type that we can implement parsing with.
|
|
|
|
|
cli.StringFlag{
|
|
|
|
|
Name: "properties,p",
|
|
|
|
|
Usage: "A comma-separated list of key=value pairs: 'foo=bar,foo2=baz'.",
|
|
|
|
|
},
|
|
|
|
|
cli.StringFlag{
|
|
|
|
|
// FIXME: This is not right. It's sort of a half-baked forward
|
|
|
|
|
// port of dm.go.
|
|
|
|
|
Name: "repository",
|
|
|
|
|
Usage: "The default repository",
|
|
|
|
|
Value: "kubernetes/application-dm-templates",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "search",
|
|
|
|
|
},
|
|
|
|
|
listCmd(),
|
|
|
|
|
getCmd(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func addCommands(cmds ...cli.Command) {
|
|
|
|
|
commands = append(commands, cmds...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func run(c *cli.Context, f func(c *cli.Context) error) {
|
|
|
|
|
if err := f(c); err != nil {
|
|
|
|
|
os.Stderr.Write([]byte(err.Error()))
|
|
|
|
|