本文整理匯總了Golang中github.com/eris-ltd/eris-cli/definitions.BlankServiceDefinition函數的典型用法代碼示例。如果您正苦於以下問題:Golang BlankServiceDefinition函數的具體用法?Golang BlankServiceDefinition怎麽用?Golang BlankServiceDefinition使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BlankServiceDefinition函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RmData
// TODO: skip errors flag
func RmData(do *definitions.Do) (err error) {
if len(do.Operations.Args) == 0 {
do.Operations.Args = []string{do.Name}
}
for _, name := range do.Operations.Args {
do.Name = name
if util.IsDataContainer(do.Name, do.Operations.ContainerNumber) {
log.WithField("=>", do.Name).Info("Removing data container")
srv := definitions.BlankServiceDefinition()
srv.Operations.SrvContainerName = util.ContainersName("data", do.Name, do.Operations.ContainerNumber)
if err = perform.DockerRemove(srv.Service, srv.Operations, false, do.Volumes); err != nil {
log.Errorf("Error removing %s: %v", do.Name, err)
return err
}
} else {
err = fmt.Errorf("I cannot find that data container for %s. Please check the data container name you sent me.", do.Name)
log.Error(err)
return err
}
if do.RmHF {
log.WithField("=>", do.Name).Warn("Removing host directory")
if err = os.RemoveAll(filepath.Join(DataContainersPath, do.Name)); err != nil {
return err
}
}
}
do.Result = "success"
return err
}
示例2: NewService
func NewService(do *definitions.Do) error {
srv := definitions.BlankServiceDefinition()
srv.Name = do.Name
srv.Service.Name = do.Name
srv.Service.Image = do.Operations.Args[0]
srv.Service.AutoData = true
var err error
//get maintainer info
srv.Maintainer.Name, srv.Maintainer.Email, err = config.GitConfigUser()
if err != nil {
log.Debug(err.Error())
}
log.WithFields(log.Fields{
"service": srv.Service.Name,
"image": srv.Service.Image,
}).Debug("Creating a new service definition file")
err = WriteServiceDefinitionFile(srv, filepath.Join(ServicesPath, do.Name+".toml"))
if err != nil {
return err
}
do.Result = "success"
return nil
}
示例3: NewService
func NewService(do *definitions.Do) error {
srv := definitions.BlankServiceDefinition()
srv.Name = do.Name
srv.Service.Name = do.Name
srv.Service.Image = do.Args[0]
srv.Service.AutoData = true
//get maintainer info
uName, err := gitconfig.Username()
if err != nil {
logger.Debugf("Could not find git user.name, setting service.Maintainer.Name = \"\"")
uName = ""
}
email, err := gitconfig.Email()
if err != nil {
logger.Debugf("Could not find git user.email, setting service.Maintainer.Email = \"\"")
email = ""
}
srv.Maintainer.Name = uName
srv.Maintainer.Email = email
logger.Debugf("Creating a new srv def file =>\t%s:%s\n", srv.Service.Name, srv.Service.Image)
err = WriteServiceDefinitionFile(srv, path.Join(ServicesPath, do.Name+".toml"))
if err != nil {
return err
}
do.Result = "success"
return nil
}
示例4: RmData
func RmData(do *definitions.Do) error {
if util.IsDataContainer(do.Name, do.Operations.ContainerNumber) {
logger.Infoln("Removing data container " + do.Name)
srv := definitions.BlankServiceDefinition()
srv.Operations.SrvContainerName = util.ContainersName("data", do.Name, do.Operations.ContainerNumber)
err := perform.DockerRemove(srv.Service, srv.Operations, false)
if err != nil {
return err
}
} else {
return fmt.Errorf("I cannot find that data container. Please check the data container name you sent me.")
}
if do.RmHF {
logger.Println("Removing host folder " + do.Name)
err := os.RemoveAll(path.Join(DataContainersPath, do.Name))
if err != nil {
return err
}
}
do.Result = "success"
return nil
}
示例5: MockServiceDefinition
func MockServiceDefinition(servName string, newCont bool, cNum ...int) *definitions.ServiceDefinition {
srv := definitions.BlankServiceDefinition()
srv.Name = servName
if len(cNum) == 0 {
srv.Operations.ContainerNumber = util.AutoMagic(cNum[0], "service", newCont)
logger.Debugf("Mocking Service Definition =>\t%s:%d (autoassigned)\n", servName, cNum[0])
} else {
srv.Operations.ContainerNumber = cNum[0]
logger.Debugf("Mocking Service Definition =>\t%s:%d\n", servName, cNum[0])
}
ServiceFinalizeLoad(srv)
return srv
}
示例6: InspectData
func InspectData(do *definitions.Do) error {
if util.IsDataContainer(do.Name, do.Operations.ContainerNumber) {
log.WithField("=>", do.Name).Info("Inspecting data container")
srv := definitions.BlankServiceDefinition()
srv.Operations.SrvContainerName = util.ContainersName(definitions.TypeData, do.Name, do.Operations.ContainerNumber)
err := perform.DockerInspect(srv.Service, srv.Operations, do.Operations.Args[0])
if err != nil {
return err
}
} else {
return fmt.Errorf("I cannot find that data container. Please check the data container name you sent me.")
}
do.Result = "success"
return nil
}
示例7: MockServiceDefinition
func MockServiceDefinition(servName string, newCont bool, cNum ...int) *definitions.ServiceDefinition {
srv := definitions.BlankServiceDefinition()
srv.Name = servName
if len(cNum) == 0 {
srv.Operations.ContainerNumber = util.AutoMagic(cNum[0], definitions.TypeService, newCont)
log.WithField("=>", fmt.Sprintf("%s:%d", servName, cNum[0])).Debug("Mocking service definition (autoassigned)")
} else {
srv.Operations.ContainerNumber = cNum[0]
log.WithField("=>", fmt.Sprintf("%s:%d", servName, cNum[0])).Debug("Mocking service definition")
}
srv.Operations.ContainerType = definitions.TypeService
srv.Operations.Labels = util.Labels(servName, srv.Operations)
ServiceFinalizeLoad(srv)
return srv
}
示例8: RenameData
func RenameData(do *definitions.Do) error {
logger.Infof("Renaming Data =>\t\t%s:%s\n", do.Name, do.NewName)
logger.Debugf("\twith ContainerNumber =>\t%d\n", do.Operations.ContainerNumber)
if util.IsDataContainer(do.Name, do.Operations.ContainerNumber) {
srv := definitions.BlankServiceDefinition()
srv.Operations.SrvContainerName = util.ContainersName("data", do.Name, do.Operations.ContainerNumber)
err := perform.DockerRename(srv.Service, srv.Operations, do.Name, do.NewName)
if err != nil {
return err
}
} else {
return fmt.Errorf("I cannot find that data container. Please check the data container name you sent me.")
}
do.Result = "success"
return nil
}
示例9: LoadServiceDefinition
func LoadServiceDefinition(servName string, newCont bool, cNum ...int) (*definitions.ServiceDefinition, error) {
if len(cNum) == 0 {
cNum = append(cNum, 0)
}
if cNum[0] == 0 {
cNum[0] = util.AutoMagic(0, definitions.TypeService, newCont)
logger.Debugf("Loading Service Definition =>\t%s:%d (autoassigned)\n", servName, cNum[0])
} else {
logger.Debugf("Loading Service Definition =>\t%s:%d\n", servName, cNum[0])
}
srv := definitions.BlankServiceDefinition()
srv.Operations.ContainerType = definitions.TypeService
srv.Operations.ContainerNumber = cNum[0]
srv.Operations.Labels = util.Labels(servName, srv.Operations)
serviceConf, err := loadServiceDefinition(servName)
if err != nil {
return nil, err
}
if err = MarshalServiceDefinition(serviceConf, srv); err != nil {
return nil, err
}
if srv.Service == nil {
return nil, fmt.Errorf("No service given.")
}
if err = checkImage(srv.Service); err != nil {
return nil, err
}
// Docker 1.6 (which eris doesn't support) had different linking mechanism.
if ver, _ := util.DockerClientVersion(); ver >= version.DVER_MIN {
addDependencyVolumesAndLinks(srv.Dependencies, srv.Service, srv.Operations)
}
ServiceFinalizeLoad(srv)
return srv, nil
}
示例10: PretendToBeAService
func PretendToBeAService(serviceYourPretendingToBe string, cNum ...int) *def.ServiceDefinition {
srv := def.BlankServiceDefinition()
srv.Name = serviceYourPretendingToBe
if len(cNum) == 0 || cNum[0] == 0 {
logger.Debugf("Loading Service Definition =>\t%s:1 (autoassigned)\n", serviceYourPretendingToBe)
// TODO: findNextContainerIndex => util/container_operations.go
if len(cNum) == 0 {
cNum = append(cNum, 1)
} else {
cNum[0] = 1
}
} else {
logger.Debugf("Loading Service Definition =>\t%s:%d\n", serviceYourPretendingToBe, cNum[0])
}
srv.Operations.ContainerNumber = cNum[0]
giveMeAllTheNames(serviceYourPretendingToBe, srv)
return srv
}
示例11: PretendToBeAService
func PretendToBeAService(serviceYourPretendingToBe string, cNum ...int) *def.ServiceDefinition {
srv := def.BlankServiceDefinition()
srv.Name = serviceYourPretendingToBe
if len(cNum) == 0 || cNum[0] == 0 {
log.WithField("=>", fmt.Sprintf("%s:1", serviceYourPretendingToBe)).Debug("Loading service definition (autoassigned)")
// TODO: findNextContainerIndex => util/container_operations.go
if len(cNum) == 0 {
cNum = append(cNum, 1)
} else {
cNum[0] = 1
}
} else {
log.WithField("=>", fmt.Sprintf("%s:%d", serviceYourPretendingToBe, cNum[0])).Debug("Loading service definition")
}
srv.Operations.ContainerNumber = cNum[0]
giveMeAllTheNames(serviceYourPretendingToBe, srv)
return srv
}
示例12: NewService
func NewService(do *definitions.Do) error {
srv := definitions.BlankServiceDefinition()
srv.Name = do.Name
srv.Service.Name = do.Name
srv.Service.Image = do.Args[0]
srv.Service.AutoData = true
var err error
//get maintainer info
srv.Maintainer.Name, srv.Maintainer.Email, err = config.GitConfigUser()
if err != nil {
logger.Debugf(err.Error())
}
logger.Debugf("Creating a new srv def file =>\t%s:%s\n", srv.Service.Name, srv.Service.Image)
err = WriteServiceDefinitionFile(srv, path.Join(ServicesPath, do.Name+".toml"))
if err != nil {
return err
}
do.Result = "success"
return nil
}
示例13: LoadServiceDefinition
func LoadServiceDefinition(servName string, newCont bool, cNum ...int) (*definitions.ServiceDefinition, error) {
if len(cNum) == 0 {
cNum = append(cNum, 0)
}
if cNum[0] == 0 {
cNum[0] = util.AutoMagic(0, "service", newCont)
logger.Debugf("Loading Service Definition =>\t%s:%d (autoassigned)\n", servName, cNum[0])
} else {
logger.Debugf("Loading Service Definition =>\t%s:%d\n", servName, cNum[0])
}
srv := definitions.BlankServiceDefinition()
srv.Operations.ContainerNumber = cNum[0]
serviceConf, err := loadServiceDefinition(servName)
if err != nil {
return nil, err
}
if err = MarshalServiceDefinition(serviceConf, srv); err != nil {
return nil, err
}
if srv.Service == nil {
return nil, fmt.Errorf("No service given.")
}
if err = checkImage(srv.Service); err != nil {
return nil, err
}
if os.Getenv("TEST_IN_CIRCLE") != "true" { // this really should be docker version < 1.7...?
addDependencyVolumesAndLinks(srv)
}
ServiceFinalizeLoad(srv)
return srv, nil
}
示例14: DockerCreateDataContainer
// Build against Docker cli...
// Client version: 1.6.2, 1.7
// Client API version: 1.18, 1.19
// Verified against ...
// Client version: 1.6.2, 1.7
// Client API version: 1.18, 1.19
func DockerCreateDataContainer(srvName string, containerNumber int) error {
logger.Infof("Creating Data Container for =>\t%s\n", srvName)
srv := def.BlankServiceDefinition()
srv.Operations.DataContainerName = util.DataContainersName(srvName, containerNumber)
optsData, err := configureDataContainer(srv.Service, srv.Operations, nil)
if err != nil {
return err
}
srv.Operations.SrvContainerName = srv.Operations.DataContainerName // mock for the query function
if _, exists := ContainerExists(srv.Operations); exists {
logger.Infoln("Data container exists. Not creating.")
return nil
}
cont, err := createContainer(optsData)
if err != nil {
return err
}
logger.Infof("Data Container ID =>\t\t%s\n", cont.ID)
return nil
}
示例15: DefineAppActionService
func DefineAppActionService(do *definitions.Do, app *definitions.Contracts) error {
var cmd string
switch do.Name {
case "test":
cmd = app.AppType.TestCmd
case "deploy":
cmd = app.AppType.DeployCmd
default:
return fmt.Errorf("I do not know how to perform that task (%s)\nPlease check what you can do with contracts by typing [eris contracts].\n", do.Name)
}
// if manual, set task
if app.AppType.Name == "manual" {
switch do.Name {
case "test":
cmd = app.TestTask
case "deploy":
cmd = app.DeployTask
}
}
// task flag override
if do.Task != "" {
app.AppType = definitions.GulpApp()
cmd = do.Task
}
if cmd == "nil" {
return fmt.Errorf("I cannot perform that task against that app type.\n")
}
// build service that will run
do.Service.Name = app.Name + "_tmp_" + do.Name
do.Service.Image = app.AppType.BaseImage
do.Service.AutoData = true
do.Service.EntryPoint = app.AppType.EntryPoint
do.Service.Command = cmd
if do.Path != pwd {
do.Service.WorkDir = do.Path // do.Path is actually where the workdir inside the container goes
} else {
do.Service.WorkDir = filepath.Join(common.ErisContainerRoot, "apps", app.Name)
}
do.Service.User = "eris"
srv := definitions.BlankServiceDefinition()
srv.Service = do.Service
srv.Operations = do.Operations
loaders.ServiceFinalizeLoad(srv)
do.Service = srv.Service
do.Operations = srv.Operations
do.Operations.Follow = true
linkAppToChain(do, app)
if app.AppType.Name == "epm" {
prepareEpmAction(do, app)
}
// make data container and import do.Path to do.Path (if exists)
doData := definitions.NowDo()
doData.Name = do.Service.Name
doData.Operations = do.Operations
if do.Path != pwd {
doData.Destination = do.Path
} else {
doData.Destination = common.ErisContainerRoot
}
doData.Source = filepath.Join(common.DataContainersPath, doData.Name)
var loca string
if do.Path != pwd {
loca = filepath.Join(common.DataContainersPath, doData.Name, do.Path)
} else {
loca = filepath.Join(common.DataContainersPath, doData.Name, "apps", app.Name)
}
log.WithFields(log.Fields{
"path": do.Path,
"location": loca,
}).Debug("Creating app data container")
common.Copy(do.Path, loca)
if err := data.ImportData(doData); err != nil {
return err
}
do.Operations.DataContainerName = util.DataContainersName(doData.Name, doData.Operations.ContainerNumber)
log.Debug("App action built")
return nil
}