computer_delete.go 975 字节
Newer Older
LinuxSuRen's avatar
LinuxSuRen 已提交
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
package cmd

import (
	"github.com/jenkins-zh/jenkins-cli/client"

	"github.com/jenkins-zh/jenkins-cli/app/i18n"

	"github.com/spf13/cobra"
)

// ComputerDeleteOption option for agent delete command
type ComputerDeleteOption struct {
	CommonOption
}

var computerDeleteOption ComputerDeleteOption

func init() {
	computerCmd.AddCommand(computerDeleteCmd)
}

var computerDeleteCmd = &cobra.Command{
	Use:     "delete",
	Aliases: GetAliasesDel(),
	Short:   i18n.T("Delete an agent from Jenkins"),
	Long:    i18n.T("Delete an agent from Jenkins"),
	Args:    cobra.MinimumNArgs(1),
	Example: `jcli agent delete agent-name`,
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		jClient := &client.ComputerClient{
			JenkinsCore: client.JenkinsCore{
				RoundTripper: computerDeleteOption.RoundTripper,
			},
		}
		getCurrentJenkinsAndClient(&(jClient.JenkinsCore))

		err = jClient.Delete(args[0])
		return
	},
	Annotations: map[string]string{
		since: "v0.0.24",
	},
}