()
| 131 | } |
| 132 | |
| 133 | func RegisterAgentUpgradeCommand() *cobra.Command { |
| 134 | agentUpgrade := &cobra.Command{ |
| 135 | Use: "agent-upgrade", |
| 136 | Short: "agent upgrade operation commands", |
| 137 | Example: "deepflow-ctl agent-upgrade list\n" + |
| 138 | "deepflow-ctl agent-upgrade agent-name --image-name=deepflow-agent\n" + |
| 139 | "deepflow-ctl agent-upgrade cancel agent-name\n", |
| 140 | Run: func(cmd *cobra.Command, args []string) { |
| 141 | if len(args) == 2 { |
| 142 | if args[0] == "cancel" { |
| 143 | cancelUpgadeAgent(cmd, args) |
| 144 | } else { |
| 145 | fmt.Println(cmd.Example) |
| 146 | } |
| 147 | } else if len(args) == 1 { |
| 148 | if args[0] == "list" { |
| 149 | listAgentUpgrade(cmd, args) |
| 150 | } else if imageName != "" { |
| 151 | if filepath.IsAbs(imageName) { |
| 152 | printutil.ErrorfWithColor( |
| 153 | "invalid image name(%s), please use command `deepflow-ctl repo agent list` to get image name\n"+ |
| 154 | "reference doc: https://deepflow.io/docs/zh/install/upgrade/", |
| 155 | imageName, |
| 156 | ) |
| 157 | return |
| 158 | } |
| 159 | upgadeAgent(cmd, args) |
| 160 | } else { |
| 161 | fmt.Println(cmd.Example) |
| 162 | } |
| 163 | |
| 164 | } else { |
| 165 | fmt.Println(cmd.Example) |
| 166 | } |
| 167 | }, |
| 168 | } |
| 169 | agentUpgrade.Flags().StringVarP(&imageName, "image-name", "I", "", "") |
| 170 | |
| 171 | return agentUpgrade |
| 172 | } |
| 173 | |
| 174 | func listAgentUpgrade(cmd *cobra.Command, args []string) { |
| 175 | // 生成URL |
no test coverage detected