(cmd *cobra.Command)
| 135 | } |
| 136 | |
| 137 | func listPlugin(cmd *cobra.Command) { |
| 138 | server := common.GetServerInfo(cmd) |
| 139 | url := fmt.Sprintf("http://%s:%d/v1/plugin/", server.IP, server.Port) |
| 140 | response, err := common.CURLPerform("GET", url, nil, "", []common.HTTPOption{common.WithTimeout(common.GetTimeout(cmd)), common.WithORGID(common.GetORGID(cmd))}...) |
| 141 | if err != nil { |
| 142 | fmt.Println(err) |
| 143 | return |
| 144 | } |
| 145 | data := response.Get("DATA") |
| 146 | var ( |
| 147 | typeMaxSize = jsonparser.GetTheMaxSizeOfAttr(data, "TYPE") |
| 148 | nameMaxSize = jsonparser.GetTheMaxSizeOfAttr(data, "NAME") |
| 149 | userMaxSize = jsonparser.GetTheMaxSizeOfAttr(data, "USER") |
| 150 | ) |
| 151 | cmdFormat := "%-*s %-*s %-*s %-19s\n" |
| 152 | fmt.Printf(cmdFormat, typeMaxSize, "TYPE", nameMaxSize, "NAME", userMaxSize, "USER", "UPDATED_AT") |
| 153 | for i := range data.MustArray() { |
| 154 | d := data.GetIndex(i) |
| 155 | |
| 156 | fmt.Printf(cmdFormat, |
| 157 | typeMaxSize, common.PluginType(d.Get("TYPE").MustInt()), |
| 158 | nameMaxSize, d.Get("NAME").MustString(), |
| 159 | userMaxSize, common.PluginUser(d.Get("USER").MustInt()), |
| 160 | d.Get("UPDATED_AT").MustString(), |
| 161 | ) |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | func deletePlugin(cmd *cobra.Command, args []string) error { |
| 166 | if len(args) == 0 { |
no test coverage detected