当前位置: 首页>>代码示例>>Golang>>正文


Golang App.GetName方法代码示例

本文整理汇总了Golang中github.com/tsuru/tsuru/provision.App.GetName方法的典型用法代码示例。如果您正苦于以下问题:Golang App.GetName方法的具体用法?Golang App.GetName怎么用?Golang App.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/tsuru/tsuru/provision.App的用法示例。


在下文中一共展示了App.GetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: deploy

func (p *dockerProvisioner) deploy(a provision.App, imageId string, evt *event.Event) error {
	if err := checkCanceled(evt); err != nil {
		return err
	}
	containers, err := p.listContainersByApp(a.GetName())
	if err != nil {
		return err
	}
	imageData, err := image.GetImageCustomData(imageId)
	if err != nil {
		return err
	}
	if len(containers) == 0 {
		toAdd := make(map[string]*containersToAdd, len(imageData.Processes))
		for processName := range imageData.Processes {
			_, ok := toAdd[processName]
			if !ok {
				ct := containersToAdd{Quantity: 0}
				toAdd[processName] = &ct
			}
			toAdd[processName].Quantity++
		}
		if err = setQuota(a, toAdd); err != nil {
			return err
		}
		_, err = p.runCreateUnitsPipeline(evt, a, toAdd, imageId, imageData.ExposedPort)
	} else {
		toAdd := getContainersToAdd(imageData, containers)
		if err = setQuota(a, toAdd); err != nil {
			return err
		}
		_, err = p.runReplaceUnitsPipeline(evt, a, toAdd, containers, imageId)
	}
	return err
}
开发者ID:tsuru,项目名称:tsuru,代码行数:35,代码来源:provisioner.go

示例2: RemoveUnit

func (p *FakeProvisioner) RemoveUnit(app provision.App, name string) error {
	if err := p.getError("RemoveUnit"); err != nil {
		return err
	}
	index := -1
	p.mut.Lock()
	defer p.mut.Unlock()
	pApp, ok := p.apps[app.GetName()]
	if !ok {
		return errNotProvisioned
	}
	for i, unit := range pApp.units {
		if unit.Name == name {
			index = i
			break
		}
	}
	if index == -1 {
		return errors.New("Unit not found.")
	}
	copy(pApp.units[index:], pApp.units[index+1:])
	pApp.units = pApp.units[:len(pApp.units)-1]
	pApp.unitLen--
	p.apps[app.GetName()] = pApp
	return nil
}
开发者ID:philiptzou,项目名称:tsuru,代码行数:26,代码来源:provisioner.go

示例3: AddUnits

func (p *dockerProvisioner) AddUnits(a provision.App, units uint, process string, w io.Writer) ([]provision.Unit, error) {
	if a.GetDeploys() == 0 {
		return nil, stderr.New("New units can only be added after the first deployment")
	}
	if units == 0 {
		return nil, stderr.New("Cannot add 0 units")
	}
	if w == nil {
		w = ioutil.Discard
	}
	writer := io.MultiWriter(w, &app.LogWriter{App: a})
	imageId, err := appCurrentImageName(a.GetName())
	if err != nil {
		return nil, err
	}
	conts, err := p.runCreateUnitsPipeline(writer, a, map[string]*containersToAdd{process: {Quantity: int(units)}}, imageId)
	routesRebuildOrEnqueue(a.GetName())
	if err != nil {
		return nil, err
	}
	result := make([]provision.Unit, len(conts))
	for i, c := range conts {
		result[i] = c.AsUnit(a)
	}
	return result, nil
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:26,代码来源:provisioner.go

示例4: gitDeployCmds

// gitDeployCmds returns the list of commands that are used when the
// provisioner deploys a unit using the Git repository method.
func gitDeployCmds(app provision.App, version string) ([]string, error) {
	repo, err := repository.Manager().GetRepository(app.GetName())
	if err != nil {
		return nil, err
	}
	return deployCmds(app, "git", repo.ReadOnlyURL, version)
}
开发者ID:Endika,项目名称:tsuru,代码行数:9,代码来源:commands.go

示例5: RemoveUnits

func (*dockerProvisioner) RemoveUnits(a provision.App, units uint) error {
	if a == nil {
		return errors.New("remove units: app should not be nil")
	}
	if units < 1 {
		return errors.New("remove units: units must be at least 1")
	}
	containers, err := listContainersByAppOrderedByStatus(a.GetName())
	if err != nil {
		return err
	}
	if units >= uint(len(containers)) {
		return errors.New("remove units: cannot remove all units from app")
	}
	var wg sync.WaitGroup
	for i := 0; i < int(units); i++ {
		wg.Add(1)
		go func(c container) {
			removeContainer(&c)
			wg.Done()
		}(containers[i])
	}
	wg.Wait()
	return nil
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:25,代码来源:provisioner.go

示例6: deployPipeline

func (p *dockerProvisioner) deployPipeline(app provision.App, imageId string, commands []string, w io.Writer) (string, error) {
	actions := []*action.Action{
		&insertEmptyContainerInDB,
		&createContainer,
		&startContainer,
		&updateContainerInDB,
		&followLogsAndCommit,
	}
	pipeline := action.NewPipeline(actions...)
	buildingImage, err := appNewImageName(app.GetName())
	if err != nil {
		return "", log.WrapError(fmt.Errorf("error getting new image name for app %s", app.GetName()))
	}
	args := runContainerActionsArgs{
		app:           app,
		imageID:       imageId,
		commands:      commands,
		writer:        w,
		isDeploy:      true,
		buildingImage: buildingImage,
		provisioner:   p,
	}
	err = pipeline.Execute(args)
	if err != nil {
		log.Errorf("error on execute deploy pipeline for app %s - %s", app.GetName(), err)
		return "", err
	}
	return buildingImage, nil
}
开发者ID:keymon,项目名称:tsuru,代码行数:29,代码来源:docker.go

示例7: Destroy

func (p *dockerProvisioner) Destroy(app provision.App) error {
	containers, err := listContainersByApp(app.GetName())
	if err != nil {
		log.Errorf("Failed to list app containers: %s", err.Error())
		return err
	}
	var containersGroup sync.WaitGroup
	containersGroup.Add(len(containers))
	for _, c := range containers {
		go func(c container) {
			defer containersGroup.Done()
			err := removeContainer(&c)
			if err != nil {
				log.Errorf("Unable to destroy container %s: %s", c.ID, err.Error())
			}
		}(c)
	}
	containersGroup.Wait()
	err = removeImage(assembleImageName(app.GetName()))
	if err != nil {
		log.Errorf("Failed to remove image: %s", err.Error())
	}
	r, err := getRouter()
	if err != nil {
		log.Errorf("Failed to get router: %s", err.Error())
		return err
	}
	err = r.RemoveBackend(app.GetName())
	if err != nil {
		log.Errorf("Failed to remove route backend: %s", err.Error())
		return err
	}
	return nil
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:34,代码来源:provisioner.go

示例8: ArchiveDeploy

func (p *swarmProvisioner) ArchiveDeploy(a provision.App, archiveURL string, evt *event.Event) (imgID string, err error) {
	baseImage := image.GetBuildImage(a)
	buildingImage, err := image.AppNewImageName(a.GetName())
	if err != nil {
		return "", errors.WithStack(err)
	}
	client, err := chooseDBSwarmNode()
	if err != nil {
		return "", err
	}
	cmds := dockercommon.ArchiveDeployCmds(a, archiveURL)
	srvID, task, err := runOnceBuildCmds(client, a, cmds, baseImage, buildingImage, evt)
	if srvID != "" {
		defer removeServiceAndLog(client, srvID)
	}
	if err != nil {
		return "", err
	}
	_, err = commitPushBuildImage(client, buildingImage, task.Status.ContainerStatus.ContainerID, a)
	if err != nil {
		return "", err
	}
	err = deployProcesses(client, a, buildingImage, nil)
	if err != nil {
		return "", errors.WithStack(err)
	}
	return buildingImage, nil
}
开发者ID:tsuru,项目名称:tsuru,代码行数:28,代码来源:provisioner.go

示例9: RemoveUnits

func (p *FakeProvisioner) RemoveUnits(app provision.App, n uint, process string, w io.Writer) error {
	if err := p.getError("RemoveUnits"); err != nil {
		return err
	}
	if n == 0 {
		return errors.New("cannot remove 0 units")
	}
	p.mut.Lock()
	defer p.mut.Unlock()
	pApp, ok := p.apps[app.GetName()]
	if !ok {
		return errNotProvisioned
	}
	var newUnits []provision.Unit
	removedCount := n
	for _, u := range pApp.units {
		if removedCount > 0 && u.ProcessName == process {
			removedCount--
			continue
		}
		newUnits = append(newUnits, u)
	}
	if removedCount > 0 {
		return errors.New("too many units to remove")
	}
	if w != nil {
		fmt.Fprintf(w, "removing %d units", n)
	}
	pApp.units = newUnits
	pApp.unitLen = len(newUnits)
	p.apps[app.GetName()] = pApp
	return nil
}
开发者ID:RichardKnop,项目名称:tsuru,代码行数:33,代码来源:fake_provisioner.go

示例10: ExecuteCommandIsolated

func (p *swarmProvisioner) ExecuteCommandIsolated(stdout, stderr io.Writer, a provision.App, cmd string, args ...string) error {
	if a.GetDeploys() == 0 {
		return errors.New("commands can only be executed after the first deploy")
	}
	img, err := image.AppCurrentImageName(a.GetName())
	if err != nil {
		return err
	}
	client, err := chooseDBSwarmNode()
	if err != nil {
		return err
	}
	opts := tsuruServiceOpts{
		app:           a,
		image:         img,
		isIsolatedRun: true,
	}
	cmds := []string{"/bin/bash", "-lc", cmd}
	cmds = append(cmds, args...)
	serviceID, _, err := runOnceCmds(client, opts, cmds, stdout, stderr)
	if serviceID != "" {
		removeServiceAndLog(client, serviceID)
	}
	return err
}
开发者ID:tsuru,项目名称:tsuru,代码行数:25,代码来源:provisioner.go

示例11: deployAndClean

func (p *dockerProvisioner) deployAndClean(a provision.App, imageId string, w io.Writer) error {
	err := p.deploy(a, imageId, w)
	if err != nil {
		p.cleanImage(a.GetName(), imageId)
	}
	return err
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:7,代码来源:provisioner.go

示例12: Provision

func (p *FakeProvisioner) Provision(app provision.App) error {
	if err := p.getError("Provision"); err != nil {
		return err
	}
	if p.Provisioned(app) {
		return &provision.Error{Reason: "App already provisioned."}
	}
	p.mut.Lock()
	defer p.mut.Unlock()
	p.apps[app.GetName()] = provisionedApp{
		app:     app,
		unitLen: 1,
		units: []provision.Unit{
			{
				Name:       app.GetName() + "/0",
				AppName:    app.GetName(),
				Type:       app.GetPlatform(),
				Status:     provision.StatusStarted,
				InstanceId: "i-080",
				Ip:         "10.10.10.1",
				Machine:    1,
			},
		},
	}
	return nil
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:26,代码来源:provisioner.go

示例13: Provision

func (p *JujuProvisioner) Provision(app provision.App) error {
	var buf bytes.Buffer
	charms, err := config.GetString("juju:charms-path")
	if err != nil {
		return errors.New(`Setting "juju:charms-path" is not defined.`)
	}
	args := []string{
		"deploy", "--repository", charms,
		"local:" + app.GetPlatform(), app.GetName(),
	}
	err = runCmd(false, &buf, &buf, args...)
	out := buf.String()
	if err != nil {
		app.Log("Failed to create machine: "+out, "tsuru")
		return cmdError(out, err, args)
	}
	setOption := []string{
		"set", app.GetName(), "app-repo=" + repository.ReadOnlyURL(app.GetName()),
	}
	runCmd(true, &buf, &buf, setOption...)
	if p.elbSupport() {
		router, err := Router()
		if err != nil {
			return err
		}
		if err = router.AddBackend(app.GetName()); err != nil {
			return err
		}
		p.enqueueUnits(app.GetName())
	}
	return nil
}
开发者ID:rochacon,项目名称:tsuru,代码行数:32,代码来源:provisioner.go

示例14: Swap

func (p *dockerProvisioner) Swap(app1, app2 provision.App) error {
	r, err := getRouterForApp(app1)
	if err != nil {
		return err
	}
	return r.Swap(app1.GetName(), app2.GetName())
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:7,代码来源:provisioner.go

示例15: Swap

func (JujuProvisioner) Swap(app1, app2 provision.App) error {
	r, err := Router()
	if err != nil {
		return err
	}
	return r.Swap(app1.GetName(), app2.GetName())
}
开发者ID:rochacon,项目名称:tsuru,代码行数:7,代码来源:provisioner.go


注:本文中的github.com/tsuru/tsuru/provision.App.GetName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。