Exemplo n.º 1
1
func (a *Acl) AddDestroySub(c *cobra.Command) {
	destroyCmd := &cobra.Command{
		Use:   "destroy <token>",
		Short: "Destroy an ACL",
		Long:  "Destroy an ACL",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Destroy(args)
		},
	}

	oldDestroyCmd := &cobra.Command{
		Use:        "acl-destroy <token>",
		Short:      "Destroy an ACL",
		Long:       "Destroy an ACL",
		Deprecated: "Use acl destroy",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Destroy(args)
		},
	}

	c.AddCommand(destroyCmd)

	a.AddCommand(oldDestroyCmd)
}
Exemplo n.º 2
0
func (s *Session) AddInfoSub(cmd *cobra.Command) {
	infoCmd := &cobra.Command{
		Use:   "info <sessionId>",
		Short: "Get information on a session",
		Long:  "Get information on a session",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Info(args)
		},
	}

	oldInfoCmd := &cobra.Command{
		Use:        "session-info <sessionId>",
		Short:      "Get information on a session",
		Long:       "Get information on a session",
		Deprecated: "Use session info",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Info(args)
		},
	}

	s.AddDatacenterOption(infoCmd)
	s.AddTemplateOption(infoCmd)
	s.AddConsistency(infoCmd)
	s.AddDatacenterOption(oldInfoCmd)

	cmd.AddCommand(infoCmd)

	s.AddCommand(oldInfoCmd)
}
Exemplo n.º 3
0
func (a *Agent) AddChecksSub(c *cobra.Command) {
	checksCmd := &cobra.Command{
		Use:   "checks",
		Short: "Get the checks the agent is managing",
		Long:  "Get the checks the agent is managing",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Checks(args)
		},
	}

	oldChecksCmd := &cobra.Command{
		Use:        "agent-checks",
		Short:      "Get the checks the agent is managing",
		Long:       "Get the checks the agent is managing",
		Deprecated: "Use agent checks",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Checks(args)
		},
	}

	a.AddTemplateOption(checksCmd)
	c.AddCommand(checksCmd)

	a.AddCommand(oldChecksCmd)
}
Exemplo n.º 4
0
func (a *Agent) AddMembersSub(c *cobra.Command) {
	amo := &AgentMembersOptions{}

	membersCmd := &cobra.Command{
		Use:   "members",
		Short: "Get the members as seen by the serf agent",
		Long:  "Get the members as seen by the serf agent",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Members(args, amo)
		},
	}

	oldMembersCmd := &cobra.Command{
		Use:        "agent-members",
		Short:      "Get the members as seen by the serf agent",
		Long:       "Get the members as seen by the serf agent",
		Deprecated: "Use agent members",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Members(args, amo)
		},
	}

	membersCmd.Flags().BoolVar(&amo.wanFlag, "wan", false, "Get list of WAN members instead of LAN")
	oldMembersCmd.Flags().BoolVar(&amo.wanFlag, "wan", false, "Get list of WAN members instead of LAN")

	a.AddTemplateOption(membersCmd)
	c.AddCommand(membersCmd)

	a.AddCommand(oldMembersCmd)
}
Exemplo n.º 5
0
func (a *Acl) AddInfoSub(c *cobra.Command) {
	infoCmd := &cobra.Command{
		Use:   "info <token>",
		Short: "Query information about an ACL token",
		Long:  "Query information about an ACL token",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Info(args)
		},
	}

	oldInfoCmd := &cobra.Command{
		Use:        "acl-info <token>",
		Short:      "Query information about an ACL token",
		Long:       "Query information about an ACL token",
		Deprecated: "Use acl info",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Info(args)
		},
	}

	a.AddTemplateOption(infoCmd)
	c.AddCommand(infoCmd)

	a.AddCommand(oldInfoCmd)
}
Exemplo n.º 6
0
func (c *Check) AddPassSub(cmd *cobra.Command) {
	cfo := &CheckPassOptions{}

	passCmd := &cobra.Command{
		Use:   "pass <checkId>",
		Short: "Mark a local check as passing",
		Long:  "Mark a local check as passing",
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Pass(args, cfo)
		},
	}

	oldPassCmd := &cobra.Command{
		Use:        "check-pass <checkId>",
		Short:      "Mark a local check as passing",
		Long:       "Mark a local check as passing",
		Deprecated: "Use check pass",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Pass(args, cfo)
		},
	}

	passCmd.Flags().StringVar(&cfo.Note, "note", "", "Message to associate with check status")
	oldPassCmd.Flags().StringVar(&cfo.Note, "note", "", "Message to associate with check status")

	cmd.AddCommand(passCmd)

	c.AddCommand(oldPassCmd)
}
Exemplo n.º 7
0
func setupSendCommand(rootCmd *cobra.Command) {
	var vgname, lvname, srcname string

	cmd := &cobra.Command{
		Use:   "send",
		Short: "create a stream representation of thin LV into standard output",
		Run: func(cmd *cobra.Command, args []string) {
			if len(vgname) == 0 || len(lvname) == 1 {
				fmt.Fprintln(os.Stderr, "volume group and logical volume must be provided")
				cmd.Usage()
				os.Exit(1)
			}

			sender, err := newStreamSender(vgname, lvname, srcname, os.Stdout)
			if err != nil {
				fmt.Fprintln(os.Stderr, err)
				os.Exit(2)
			}

			if err := sender.Run(); err != nil {
				fmt.Fprintln(os.Stderr, err)
				os.Exit(3)
			}

			os.Exit(0)
		},
	}

	cmd.Flags().StringVarP(&vgname, "vg", "v", "", "volume group")
	cmd.Flags().StringVarP(&lvname, "lv", "l", "", "logical volume")
	cmd.Flags().StringVarP(&srcname, "incremental", "i", "", "source logical volume")

	rootCmd.AddCommand(cmd)
}
Exemplo n.º 8
0
func (s *Session) AddRenewSub(cmd *cobra.Command) {
	renewCmd := &cobra.Command{
		Use:   "renew <sessionId>",
		Short: "Renew the given session",
		Long:  "Renew the given session",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Renew(args)
		},
	}

	oldRenewCmd := &cobra.Command{
		Use:        "session-renew <sessionId>",
		Short:      "Renew the given session",
		Long:       "Renew the given session",
		Deprecated: "Use session renew",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Renew(args)
		},
	}

	s.AddDatacenterOption(renewCmd)
	s.AddTemplateOption(renewCmd)
	s.AddDatacenterOption(oldRenewCmd)

	cmd.AddCommand(renewCmd)

	s.AddCommand(oldRenewCmd)
}
Exemplo n.º 9
0
func (a *Agent) AddJoinSub(c *cobra.Command) {
	ajo := &AgentJoinOptions{}

	joinCmd := &cobra.Command{
		Use:   "join",
		Short: "Trigger the local agent to join a node",
		Long:  "Trigger the local agent to join a node",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Join(args, ajo)
		},
	}

	oldJoinCmd := &cobra.Command{
		Use:        "agent-join",
		Short:      "Trigger the local agent to join a node",
		Long:       "Trigger the local agent to join a node",
		Deprecated: "Use agent join",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Join(args, ajo)
		},
	}

	joinCmd.Flags().BoolVar(&ajo.wanFlag, "wan", false, "Get list of WAN join instead of LAN")
	oldJoinCmd.Flags().BoolVar(&ajo.wanFlag, "wan", false, "Get list of WAN join instead of LAN")

	a.AddTemplateOption(joinCmd)
	c.AddCommand(joinCmd)

	a.AddCommand(oldJoinCmd)
}
Exemplo n.º 10
0
func (s *Session) AddDestroySub(cmd *cobra.Command) {
	destroyCmd := &cobra.Command{
		Use:   "destroy <sessionId>",
		Short: "Destroy a session",
		Long:  "Destroy a session",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Destroy(args)
		},
	}

	oldDestroyCmd := &cobra.Command{
		Use:        "session-destroy <sessionId>",
		Short:      "Destroy a session",
		Long:       "Destroy a session",
		Deprecated: "Use session destroy",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Destroy(args)
		},
	}

	s.AddDatacenterOption(destroyCmd)
	s.AddDatacenterOption(oldDestroyCmd)

	cmd.AddCommand(destroyCmd)

	s.AddCommand(oldDestroyCmd)
}
Exemplo n.º 11
0
func (h *Health) AddNodeSub(cmd *cobra.Command) {
	nodeCmd := &cobra.Command{
		Use:   "node <nodeName>",
		Short: "Get the health info for a node",
		Long:  "Get the health info for a node",
		RunE: func(cmd *cobra.Command, args []string) error {
			return h.Node(args)
		},
	}

	oldNodeCmd := &cobra.Command{
		Use:        "health-node <nodeName>",
		Short:      "Get the health info for a node",
		Long:       "Get the health info for a node",
		Deprecated: "Use health node",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return h.Node(args)
		},
	}

	h.AddDatacenterOption(nodeCmd)
	h.AddDatacenterOption(oldNodeCmd)
	h.AddTemplateOption(nodeCmd)
	h.AddConsistency(nodeCmd)

	cmd.AddCommand(nodeCmd)

	h.AddCommand(oldNodeCmd)
}
Exemplo n.º 12
0
func (s *Session) AddNodeSub(cmd *cobra.Command) {
	nodeCmd := &cobra.Command{
		Use:   "node <nodeName>",
		Short: "Get active sessions for a node",
		Long:  "Get active sessions for a node",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Node(args)
		},
	}

	oldNodeCmd := &cobra.Command{
		Use:        "session-node <nodeName>",
		Short:      "Get active sessions for a node",
		Long:       "Get active sessions for a node",
		Deprecated: "Use session node",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Node(args)
		},
	}

	s.AddDatacenterOption(nodeCmd)
	s.AddTemplateOption(nodeCmd)
	s.AddConsistency(nodeCmd)
	s.AddDatacenterOption(oldNodeCmd)

	cmd.AddCommand(nodeCmd)

	s.AddCommand(oldNodeCmd)
}
Exemplo n.º 13
0
func (s *Service) AddMaintenanceSub(cmd *cobra.Command) {
	smo := &ServiceMaintenanceOptions{}

	maintenanceCmd := &cobra.Command{
		Use:   "maintenance",
		Short: "Manage maintenance mode of a service",
		Long:  "Manage maintenance mode of a service",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Maintenance(args, smo)
		},
	}

	oldMaintenanceCmd := &cobra.Command{
		Use:        "service-maintenance",
		Short:      "Manage maintenance mode of a service",
		Long:       "Manage maintenance mode of a service",
		Deprecated: "Use agent maintenance",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Maintenance(args, smo)
		},
	}

	maintenanceCmd.Flags().BoolVar(&smo.enabled, "enabled", true, "Boolean value for maintenance mode")
	maintenanceCmd.Flags().StringVar(&smo.reason, "reason", "", "Reason for entering maintenance mode")
	oldMaintenanceCmd.Flags().BoolVar(&smo.enabled, "enabled", true, "Boolean value for maintenance mode")
	oldMaintenanceCmd.Flags().StringVar(&smo.reason, "reason", "", "Reason for entering maintenance mode")

	s.AddTemplateOption(maintenanceCmd)
	cmd.AddCommand(maintenanceCmd)

	s.AddCommand(oldMaintenanceCmd)
}
Exemplo n.º 14
0
func (a *Agent) AddServicesSub(c *cobra.Command) {
	servicesCmd := &cobra.Command{
		Use:   "services",
		Short: "Get the services the agent is managing",
		Long:  "Get the services the agent is managing",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Services(args)
		},
	}

	oldServicesCmd := &cobra.Command{
		Use:        "agent-services",
		Short:      "Get the services the agent is managing",
		Long:       "Get the services the agent is managing",
		Deprecated: "Use agent services",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Services(args)
		},
	}

	a.AddTemplateOption(servicesCmd)
	c.AddCommand(servicesCmd)

	a.AddCommand(oldServicesCmd)
}
Exemplo n.º 15
0
func (c *Catalog) AddDatacentersSub(cmd *cobra.Command) {
	datacentersCmd := &cobra.Command{
		Use:   "datacenters",
		Short: "Get all the datacenters known by the Consul server",
		Long:  "Get all the datacenters known by the Consul server",
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Datacenters(args)
		},
	}

	oldDatacentersCmd := &cobra.Command{
		Use:        "catalog-datacenters",
		Short:      "Get all the datacenters known by the Consul server",
		Long:       "Get all the datacenters known by the Consul server",
		Deprecated: "Use catalog datacenters",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Datacenters(args)
		},
	}

	c.AddTemplateOption(datacentersCmd)
	cmd.AddCommand(datacentersCmd)

	c.AddCommand(oldDatacentersCmd)
}
Exemplo n.º 16
0
func (c *Catalog) AddNodeSub(cmd *cobra.Command) {
	nodeCmd := &cobra.Command{
		Use:   "node",
		Short: "Get the services provided by a node",
		Long:  "Get the services provided by a node",
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Node(args)
		},
	}

	oldNodeCmd := &cobra.Command{
		Use:        "catalog-node",
		Short:      "Get the services provided by a node",
		Long:       "Get the services provided by a node",
		Deprecated: "Use catalog node",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Node(args)
		},
	}

	c.AddDatacenterOption(nodeCmd)
	c.AddDatacenterOption(oldNodeCmd)

	c.AddTemplateOption(nodeCmd)
	c.AddConsistency(nodeCmd)
	cmd.AddCommand(nodeCmd)

	c.AddCommand(oldNodeCmd)
}
Exemplo n.º 17
0
func (s *Status) AddPeersSub(cmd *cobra.Command) {
	peersCmd := &cobra.Command{
		Use:   "peers",
		Short: "Get the current Raft peers",
		Long:  "Get the current Raft peers",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Peers(args)
		},
	}

	oldPeersCmd := &cobra.Command{
		Use:        "status-peers",
		Short:      "Get the current Raft peers",
		Long:       "Get the current Raft peers",
		Deprecated: "Use status peers",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Peers(args)
		},
	}

	s.AddTemplateOption(peersCmd)
	cmd.AddCommand(peersCmd)

	s.AddCommand(oldPeersCmd)
}
Exemplo n.º 18
0
func (s *Status) AddLeaderSub(cmd *cobra.Command) {
	leaderCmd := &cobra.Command{
		Use:   "leader",
		Short: "Get the current Raft leader",
		Long:  "Get the current Raft leader",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Leader(args)
		},
	}

	oldLeaderCmd := &cobra.Command{
		Use:        "status-leader",
		Short:      "Get the current Raft leader",
		Long:       "Get the current Raft leader",
		Deprecated: "Use status leader",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.Leader(args)
		},
	}

	s.AddTemplateOption(leaderCmd)
	cmd.AddCommand(leaderCmd)

	s.AddCommand(oldLeaderCmd)
}
Exemplo n.º 19
0
func setupRecvCommand(rootCmd *cobra.Command) {
	var vgname, poolname, lvname string

	cmd := &cobra.Command{
		Use:   "recv",
		Short: "create or update thin logcial volume with contents in standard input",
		Run: func(cmd *cobra.Command, args []string) {
			if len(vgname) == 0 || len(poolname) == 0 || len(lvname) == 0 {
				fmt.Fprintln(os.Stderr, "volume group, thin pool and logical volume must be provided")
				cmd.Usage()
				os.Exit(-1)
			}

			recver, err := newStreamRecver(vgname, poolname, lvname, os.Stdin)
			if err != nil {
				fmt.Fprintln(os.Stderr, err)
				os.Exit(2)
			}

			if err := recver.Run(); err != nil {
				fmt.Fprintln(os.Stderr, err)
				os.Exit(3)
			}

			os.Exit(0)
		},
	}

	cmd.Flags().StringVarP(&vgname, "vg", "v", "", "volume group")
	cmd.Flags().StringVarP(&poolname, "pool", "p", "", "thin pool")
	cmd.Flags().StringVarP(&lvname, "lv", "l", "", "logical volume")

	rootCmd.AddCommand(cmd)
}
Exemplo n.º 20
0
func (c *Check) AddFailSub(cmd *cobra.Command) {
	cfo := &CheckFailOptions{}

	failCmd := &cobra.Command{
		Use:   "fail <checkId>",
		Short: "Mark a local check as critical",
		Long:  "Mark a local check as critical",
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Fail(args, cfo)
		},
	}

	oldFailCmd := &cobra.Command{
		Use:        "check-fail <checkId>",
		Short:      "Mark a local check as critical",
		Long:       "Mark a local check as critical",
		Deprecated: "Use check fail",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Fail(args, cfo)
		},
	}

	failCmd.Flags().StringVar(&cfo.Note, "note", "", "Message to associate with check status")
	oldFailCmd.Flags().StringVar(&cfo.Note, "note", "", "Message to associate with check status")

	cmd.AddCommand(failCmd)

	c.AddCommand(oldFailCmd)
}
Exemplo n.º 21
0
func (c *Check) AddWarnSub(cmd *cobra.Command) {
	cfo := &CheckWarnOptions{}

	warnCmd := &cobra.Command{
		Use:   "warn <checkId>",
		Short: "Mark a local check as warning",
		Long:  "Mark a local check as warning",
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Warn(args, cfo)
		},
	}

	oldWarnCmd := &cobra.Command{
		Use:        "check-warn <checkId>",
		Short:      "Mark a local check as warning",
		Long:       "Mark a local check as warning",
		Deprecated: "Use check warn",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Warn(args, cfo)
		},
	}

	warnCmd.Flags().StringVar(&cfo.Note, "note", "", "Message to associate with check status")
	oldWarnCmd.Flags().StringVar(&cfo.Note, "note", "", "Message to associate with check status")

	cmd.AddCommand(warnCmd)

	c.AddCommand(oldWarnCmd)
}
Exemplo n.º 22
0
func (k *Kv) AddDeleteSub(cmd *cobra.Command) {
	kdo := &KvDeleteOptions{}

	deleteCmd := &cobra.Command{
		Use:   "delete <path>",
		Short: "Delete a given path from the K/V",
		Long:  "Delete a given path from the K/V",
		RunE: func(cmd *cobra.Command, args []string) error {
			return k.Delete(args, kdo)
		},
	}

	oldDeleteCmd := &cobra.Command{
		Use:        "kv-delete <path>",
		Short:      "Delete a given path from the K/V",
		Long:       "Delete a given path from the K/V",
		Deprecated: "Use kv delete",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return k.Delete(args, kdo)
		},
	}

	deleteCmd.Flags().StringVar(&kdo.ModifyIndex, "modifyindex", "", "Perform a Check-and-Set delete")
	deleteCmd.Flags().BoolVar(&kdo.DoRecurse, "recurse", false, "Perform a recursive delete")
	k.AddDatacenterOption(deleteCmd)

	oldDeleteCmd.Flags().StringVar(&kdo.ModifyIndex, "modifyindex", "", "Perform a Check-and-Set delete")
	oldDeleteCmd.Flags().BoolVar(&kdo.DoRecurse, "recurse", false, "Perform a recursive delete")
	k.AddDatacenterOption(oldDeleteCmd)

	cmd.AddCommand(deleteCmd)

	k.AddCommand(oldDeleteCmd)
}
Exemplo n.º 23
0
func loadEnvCommandsReturnNewRoot(osArgs []string, rootCmd *cobra.Command) *cobra.Command {
	logs.WithField("path", ggn.Home.Config.WorkPath).Debug("Loading envs")
	work := work.NewWork(ggn.Home.Config.WorkPath)

	newRootCmd := &cobra.Command{
		Use: "ggn",
	}

	for _, envNames := range work.ListEnvs() {
		env := work.LoadEnv(envNames)

		envCmd := &cobra.Command{
			Use:   env.GetName(),
			Short: "Run command for " + env.GetName(),
			Run: func(cmd *cobra.Command, args []string) {

				newRootCmd.AddCommand(prepareEnvCommands(env))
				newRootCmd.SetArgs(osArgs[1:])
				newRootCmd.Execute()
			},
		}
		rootCmd.AddCommand(envCmd)
	}
	return newRootCmd
}
Exemplo n.º 24
0
func (s *Session) AddListSub(cmd *cobra.Command) {
	listCmd := &cobra.Command{
		Use:   "list",
		Short: "List active sessions for a datacenter",
		Long:  "List active sessions for a datacenter",
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.List(args)
		},
	}

	oldListCmd := &cobra.Command{
		Use:        "session-list",
		Short:      "List active sessions for a datacenter",
		Long:       "List active sessions for a datacenter",
		Deprecated: "Use session list",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return s.List(args)
		},
	}

	s.AddDatacenterOption(listCmd)
	s.AddTemplateOption(listCmd)
	s.AddConsistency(listCmd)
	s.AddDatacenterOption(oldListCmd)

	cmd.AddCommand(listCmd)

	s.AddCommand(oldListCmd)
}
Exemplo n.º 25
0
func addNoderCommands(singularName string,
	maker func() client.Crudder,
	res *cobra.Command) {
	if _, ok := maker().(client.Noder); !ok {
		return
	}
	cmd := &cobra.Command{
		Use:   "nodes [id]",
		Short: fmt.Sprintf("List all nodes for a specifc %v", singularName),
		Run: func(c *cobra.Command, args []string) {
			if len(args) != 1 {
				log.Fatalf("%v requires 1 argument\n", c.UseLine())
			}
			obj := maker().(client.Noder)
			if client.SetId(obj, args[0]) != nil {
				log.Fatalf("Failed to parse ID %v for an %v\n", args[0], singularName)
			}
			objs, err := client.Nodes(obj)
			if err != nil {
				log.Fatalf("Failed to get nodes for %v(%v)\n", singularName, args[0])
			}
			fmt.Println(prettyJSON(objs))
		},
	}
	res.AddCommand(cmd)
}
Exemplo n.º 26
0
func (a *Agent) AddForceLeaveSub(c *cobra.Command) {
	forceLeaveCmd := &cobra.Command{
		Use:   "force-leave <node name>",
		Short: "Force the removal of a node",
		Long:  "Force the removal of a node",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.ForceLeave(args)
		},
	}

	oldForceLeaveCmd := &cobra.Command{
		Use:        "agent-force-leave",
		Short:      "Force the removal of a node",
		Long:       "Force the removal of a node",
		Deprecated: "Use agent force-leave",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.ForceLeave(args)
		},
	}

	a.AddTemplateOption(forceLeaveCmd)
	c.AddCommand(forceLeaveCmd)

	a.AddCommand(oldForceLeaveCmd)
}
Exemplo n.º 27
0
func (c *Catalog) AddServicesSub(cmd *cobra.Command) {
	servicesCmd := &cobra.Command{
		Use:   "services",
		Short: "Get all the services registered with a given DC",
		Long:  "Get all the services registered with a given DC",
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Services(args)
		},
	}

	oldServicesCmd := &cobra.Command{
		Use:        "catalog-services",
		Short:      "Get all the services registered with a given DC",
		Long:       "Get all the services registered with a given DC",
		Deprecated: "Use catalog services",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return c.Services(args)
		},
	}

	c.AddDatacenterOption(servicesCmd)
	c.AddDatacenterOption(oldServicesCmd)

	c.AddTemplateOption(servicesCmd)
	c.AddConsistency(servicesCmd)
	cmd.AddCommand(servicesCmd)

	c.AddCommand(oldServicesCmd)
}
Exemplo n.º 28
0
func (a *Agent) AddSelfSub(c *cobra.Command) {
	selfCmd := &cobra.Command{
		Use:   "self",
		Short: "Get agent configuration",
		Long:  "Get agent configuration",
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Self(args)
		},
	}

	oldSelfCmd := &cobra.Command{
		Use:        "agent-self",
		Short:      "Get agent configuration",
		Long:       "Get agent configuration",
		Deprecated: "Use agent self",
		Hidden:     true,
		RunE: func(cmd *cobra.Command, args []string) error {
			return a.Self(args)
		},
	}

	a.AddTemplateOption(selfCmd)
	c.AddCommand(selfCmd)

	a.AddCommand(oldSelfCmd)
}
Exemplo n.º 29
0
func (g CommandGroups) Add(c *cobra.Command) {
	for _, group := range g {
		for _, command := range group.Commands {
			c.AddCommand(command)
		}
	}
}
Exemplo n.º 30
0
// addVolumeCLI adds volume commands.
func addVolumeCLI(cmds *cobra.Command, out io.Writer) {
	cmdDescribeVolume := &cobra.Command{
		Use:   "describevolumes volumeIDs",
		Short: "get information of a list of volumes",
		Run: func(cmd *cobra.Command, args []string) {
			execDescribeVolumes(cmd, args, getAnchnetClient(cmd), out)
		},
	}

	cmdDetachVolume := &cobra.Command{
		Use:   "detachvolumes volumeIDs",
		Short: "detach a list of volumes",
		Run: func(cmd *cobra.Command, args []string) {
			execDetachVolumes(cmd, args, getAnchnetClient(cmd), out)
		},
	}

	cmdDeleteVolume := &cobra.Command{
		Use:   "deletevolumes volumeIDs",
		Short: "delete a list of volumes",
		Run: func(cmd *cobra.Command, args []string) {
			execDeleteVolumes(cmd, args, getAnchnetClient(cmd), out)
		},
	}

	// Add all sub-commands
	cmds.AddCommand(cmdDescribeVolume)
	cmds.AddCommand(cmdDetachVolume)
	cmds.AddCommand(cmdDeleteVolume)
}