Example #1
0
func setAppType(app *definitions.Contracts, name, command, typ string) error {
	var t string

	log.WithFields(log.Fields{
		"task": command,
		"type": typ,
		"app":  name,
	}).Debug("Setting app type")

	if typ != "" {
		t = typ
	} else {
		switch command {
		case "test":
			t = app.TestType
		case "deploy":
			t = app.DeployType
		}
	}

	switch t {
	case "embark":
		app.AppType = definitions.EmbarkApp()
	case "sunit":
		app.AppType = definitions.SUnitApp()
	case "manual":
		app.AppType = definitions.GulpApp()
	default:
		app.AppType = definitions.EPMApp()
	}

	log.WithField("app type", app.AppType.Name).Debug()

	return nil
}
Example #2
0
func setAppType(app *definitions.Contracts, name, command, typ string) error {
	var t string

	logger.Debugf("Setting App Type. Task =>\t%s\n", command)
	logger.Debugf("\tChainType =>\t\t%s\n", typ)
	logger.Debugf("\tChainName =>\t\t%s\n", name)

	if typ != "" {
		t = typ
	} else {
		switch command {
		case "test":
			t = app.TestType
		case "deploy":
			t = app.DeployType
		}
	}

	switch t {
	case "embark":
		app.AppType = definitions.EmbarkApp()
	case "sunit":
		app.AppType = definitions.SUnitApp()
	case "manual":
		app.AppType = definitions.GulpApp()
	default:
		app.AppType = definitions.EPMApp()
	}

	logger.Debugf("\tApp Type =>\t\t%s\n", app.AppType.Name)

	return nil
}
Example #3
0
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 = "******"

	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
}