本文整理匯總了Golang中github.com/lxc/lxd.Client.PutImageInfo方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.PutImageInfo方法的具體用法?Golang Client.PutImageInfo怎麽用?Golang Client.PutImageInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lxc/lxd.Client
的用法示例。
在下文中一共展示了Client.PutImageInfo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doImageEdit
func (c *imageCmd) doImageEdit(client *lxd.Client, image string) error {
// If stdin isn't a terminal, read text from it
if !termios.IsTerminal(int(syscall.Stdin)) {
contents, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return err
}
newdata := shared.BriefImageInfo{}
err = yaml.Unmarshal(contents, &newdata)
if err != nil {
return err
}
return client.PutImageInfo(image, newdata)
}
// Extract the current value
config, err := client.GetImageInfo(image)
if err != nil {
return err
}
brief := config.Brief()
data, err := yaml.Marshal(&brief)
if err != nil {
return err
}
// Spawn the editor
content, err := shared.TextEditor("", []byte(c.imageEditHelp()+"\n\n"+string(data)))
if err != nil {
return err
}
for {
// Parse the text received from the editor
newdata := shared.BriefImageInfo{}
err = yaml.Unmarshal(content, &newdata)
if err == nil {
err = client.PutImageInfo(image, newdata)
}
// Respawn the editor
if err != nil {
fmt.Fprintf(os.Stderr, i18n.G("Config parsing error: %s")+"\n", err)
fmt.Println(i18n.G("Press enter to start the editor again"))
_, err := os.Stdin.Read(make([]byte, 1))
if err != nil {
return err
}
content, err = shared.TextEditor("", content)
if err != nil {
return err
}
continue
}
break
}
return nil
}