本文整理匯總了Golang中github.com/farmer-project/farmer/farmer.Box類的典型用法代碼示例。如果您正苦於以下問題:Golang Box類的具體用法?Golang Box怎麽用?Golang Box使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Box類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: BoxCreate
func BoxCreate(name string, repoUrl string, pathspec string, stream *hub.Stream) (err error) {
defer func() {
if err != nil {
stream.Write([]byte(err.Error()))
}
stream.Write([]byte("kthxbai"))
stream.Close()
}()
box := farmer.Box{
Name: name,
OutputStream: stream,
ErrorStream: stream,
RepoUrl: repoUrl,
Pathspec: pathspec,
CodeDirectory: os.Getenv("FARMER_BOX_DATA_LOCATION") + "/" + name,
CgroupParent: "level1",
}
if err := db.DB.Save(&box).Error; err != nil {
return err
}
if err := box.Create(); err != nil {
os.RemoveAll(box.CodeDirectory)
db.DB.Delete(&box)
return err
}
return db.DB.Save(&box).Error
}
示例2: AddDomain
func AddDomain(box *farmer.Box, url string, port string) error {
if err := box.AddDomain(url, port); err != nil {
return err
}
if err := ConfigureDomains(box); err != nil {
return err
}
return db.DB.Save(&box).Error
}
示例3: DeleteDomain
func DeleteDomain(box *farmer.Box, url string) error {
domain := &farmer.Domain{
BoxID: box.ID,
Url: url,
}
if err := db.DB.Find(domain).Error; err != nil {
return err
}
if err := box.DeleteDomain(url); err != nil {
return err
}
os.Remove(configFile(domain.Url, domain.Port))
return db.DB.Delete(domain).Error
}
示例4: BoxCreate
func BoxCreate(name string, repoUrl string, pathspec string, stream *hub.Stream) (err error) {
defer func() {
stream.Close(err)
}()
box := farmer.Box{
Name: name,
Directory: os.Getenv("FARMER_BOX_DATA_LOCATION") + "/" + name,
OutputStream: stream,
ErrorStream: stream,
UpdateTime: time.Now().Local().Format(farmer.TimeFormat),
}
box.KeepReleases, _ = strconv.Atoi(os.Getenv("FARMER_BOX_KEEP_RELEASES"))
if err = box.Setup(); err != nil {
return
}
if err = box.Release(repoUrl, pathspec); err != nil {
return
}
return
}