github.com/yasker/longhorn-engine@v0.0.0-20160621014712-6ed6cfca0729/app/rm_replica.go (about)

     1  package app
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/Sirupsen/logrus"
     7  	"github.com/codegangsta/cli"
     8  )
     9  
    10  func RmReplicaCmd() cli.Command {
    11  	return cli.Command{
    12  		Name:      "rm-replica",
    13  		ShortName: "rm",
    14  		Action: func(c *cli.Context) {
    15  			if err := rmReplica(c); err != nil {
    16  				logrus.Fatalf("Error running rm replica command: %v", err)
    17  			}
    18  		},
    19  	}
    20  }
    21  
    22  func rmReplica(c *cli.Context) error {
    23  	if c.NArg() == 0 {
    24  		return errors.New("replica address is required")
    25  	}
    26  	replica := c.Args()[0]
    27  
    28  	controllerClient := getCli(c)
    29  	_, err := controllerClient.DeleteReplica(replica)
    30  	return err
    31  }