本文整理匯總了Golang中minicli.Response.Data方法的典型用法代碼示例。如果您正苦於以下問題:Golang Response.Data方法的具體用法?Golang Response.Data怎麽用?Golang Response.Data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類minicli.Response
的用法示例。
在下文中一共展示了Response.Data方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: cliVmScreenshot
func cliVmScreenshot(c *minicli.Command, resp *minicli.Response) error {
file := c.StringArgs["filename"]
var max int
if arg := c.StringArgs["maximum"]; arg != "" {
v, err := strconv.Atoi(arg)
if err != nil {
return err
}
max = v
}
vm := vms.FindVM(c.StringArgs["vm"])
if vm == nil {
return vmNotFound(c.StringArgs["vm"])
}
data, err := vm.Screenshot(max)
if err != nil {
return err
}
path := filepath.Join(*f_base, strconv.Itoa(vm.GetID()), "screenshot.png")
if file != "" {
path = file
}
// add user data in case this is going across meshage
err = ioutil.WriteFile(path, data, os.FileMode(0644))
if err != nil {
return err
}
resp.Data = data
return nil
}
示例2: Info
// Info populates resp with info about the VMs running in the active namespace.
func (vms VMs) Info(masks []string, resp *minicli.Response) {
vmLock.Lock()
defer vmLock.Unlock()
resp.Header = masks
res := VMs{} // for res.Data
for _, vm := range vms {
if !inNamespace(vm) {
continue
}
// Update dynamic fields before querying info
vm.UpdateNetworks()
// Copy the VM and use the copy from here on. This ensures that the
// Tabular info matches the Data field.
vm := vm.Copy()
res[vm.GetID()] = vm
row := []string{}
for _, mask := range masks {
if v, err := vm.Info(mask); err != nil {
// Field most likely not set for VM type
row = append(row, "N/A")
} else {
row = append(row, v)
}
}
resp.Tabular = append(resp.Tabular, row)
}
resp.Data = res
}