Commit 64c7ab20 authored by Matt Butcher's avatar Matt Butcher

feat(cli): Add 'helm deployment delete'

Closes #239
parent 37c27a97
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"errors"
"github.com/codegangsta/cli"
"github.com/kubernetes/helm/pkg/format"
)
func init() {
addCommands(deleteCmd())
}
func deleteCmd() cli.Command {
return cli.Command{
Name: "delete",
Usage: "Deletes the supplied deployment",
ArgsUsage: "DEPLOYMENT",
Action: func(c *cli.Context) { run(c, deleteDeployment) },
}
}
func deleteDeployment(c *cli.Context) error {
args := c.Args()
if len(args) < 1 {
return errors.New("First argument, deployment name, is required. Try 'helm get --help'")
}
name := args[0]
deployment, err := NewClient(c).DeleteDeployment(name)
if err != nil {
return err
}
return format.YAML(deployment)
}
...@@ -40,6 +40,13 @@ func deploymentCommands() cli.Command { ...@@ -40,6 +40,13 @@ func deploymentCommands() cli.Command {
Usage: "Dump the configuration file for this deployment.", Usage: "Dump the configuration file for this deployment.",
ArgsUsage: "DEPLOYMENT", ArgsUsage: "DEPLOYMENT",
}, },
{
Name: "delete",
Aliases: []string{"del"},
Usage: "Deletes the named deployment(s).",
ArgsUsage: "DEPLOYMENT [DEPLOYMENT [...]]",
Action: func(c *cli.Context) { run(c, deleteDeployment) },
},
{ {
Name: "manifest", Name: "manifest",
Usage: "Dump the Kubernetes manifest file for this deployment.", Usage: "Dump the Kubernetes manifest file for this deployment.",
...@@ -53,15 +60,16 @@ func deploymentCommands() cli.Command { ...@@ -53,15 +60,16 @@ func deploymentCommands() cli.Command {
}, },
{ {
Name: "list", Name: "list",
Usage: "list all deployments, or filter by an optional pattern", Aliases: []string{"ls"},
ArgsUsage: "PATTERN", Usage: "list all deployments, or filter by an optional regular expression.",
Action: func(c *cli.Context) { run(c, list) }, ArgsUsage: "REGEXP",
Action: func(c *cli.Context) { run(c, listDeployments) },
}, },
}, },
} }
} }
func list(c *cli.Context) error { func listDeployments(c *cli.Context) error {
list, err := NewClient(c).ListDeployments() list, err := NewClient(c).ListDeployments()
if err != nil { if err != nil {
return err return err
...@@ -90,3 +98,18 @@ func list(c *cli.Context) error { ...@@ -90,3 +98,18 @@ func list(c *cli.Context) error {
format.List(list) format.List(list)
return nil return nil
} }
func deleteDeployment(c *cli.Context) error {
args := c.Args()
if len(args) < 1 {
return errors.New("First argument, deployment name, is required. Try 'helm get --help'")
}
for _, name := range args {
deployment, err := NewClient(c).DeleteDeployment(name)
if err != nil {
return err
}
format.Info("Deleted %q at %s", name, deployment.DeletedAt)
}
return nil
}
...@@ -34,15 +34,15 @@ fi ...@@ -34,15 +34,15 @@ fi
KUBECTL=$(which kubectl) || error_exit "Cannot find kubectl" KUBECTL=$(which kubectl) || error_exit "Cannot find kubectl"
echo "Starting resourcifier..." echo "Starting resourcifier..."
pkill -f $RESOURCIFIER #pkill -f $RESOURCIFIER
nohup $RESOURCIFIER > $LOGDIR/resourcifier.log 2>&1 --kubectl="${KUBECTL}" --port=8082 & nohup $RESOURCIFIER > $LOGDIR/resourcifier.log 2>&1 --kubectl="${KUBECTL}" --port=8082 &
echo "Starting expandybird..." echo "Starting expandybird..."
pkill -f $EXPANDYBIRD #pkill -f $EXPANDYBIRD
nohup $EXPANDYBIRD > $LOGDIR/expandybird.log 2>&1 --port=8081 --expansion_binary=expansion/expansion.py & nohup $EXPANDYBIRD > $LOGDIR/expandybird.log 2>&1 --port=8081 --expansion_binary=expansion/expansion.py &
echo "Starting deployment manager..." echo "Starting deployment manager..."
pkill -f $MANAGER #pkill -f $MANAGER
nohup $MANAGER > $LOGDIR/manager.log 2>&1 --port="${MANAGER_PORT}" --kubectl="${KUBECTL}" --expanderURL=http://localhost:8081 --deployerURL=http://localhost:8082 & nohup $MANAGER > $LOGDIR/manager.log 2>&1 --port="${MANAGER_PORT}" --kubectl="${KUBECTL}" --expanderURL=http://localhost:8081 --deployerURL=http://localhost:8082 &
if [[ "$KUBE_PROXY" ]]; then if [[ "$KUBE_PROXY" ]]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment