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


Golang App.GetPlatform方法代码示例

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


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

示例1: addUnitsWithHost

func addUnitsWithHost(a provision.App, units uint, destinationHost ...string) ([]provision.Unit, error) {
	if units == 0 {
		return nil, errors.New("Cannot add 0 units")
	}
	length, err := getContainerCountForAppName(a.GetName())
	if err != nil {
		return nil, err
	}
	if length < 1 {
		return nil, errors.New("New units can only be added after the first deployment")
	}
	writer := app.LogWriter{App: a, Writer: ioutil.Discard}
	result := make([]provision.Unit, int(units))
	container, err := getOneContainerByAppName(a.GetName())
	if err != nil {
		return nil, err
	}
	imageId := container.Image
	for i := uint(0); i < units; i++ {
		container, err := start(a, imageId, &writer, destinationHost...)
		if err != nil {
			return nil, err
		}
		result[i] = provision.Unit{
			Name:    container.ID,
			AppName: a.GetName(),
			Type:    a.GetPlatform(),
			Ip:      container.HostAddr,
			Status:  provision.StatusBuilding,
		}
	}
	return result, nil
}
开发者ID:philiptzou,项目名称:tsuru,代码行数:33,代码来源:provisioner.go

示例2: getImage

// getImage returns the image name or id from an app.
// when the container image is empty is returned the platform image.
// when a deploy is multiple of 10 is returned the platform image.
func getImage(app provision.App) string {
	c, err := getOneContainerByAppName(app.GetName())
	if err != nil || c.Image == "" || usePlatformImage(app) {
		return assembleImageName(app.GetPlatform())
	}
	return c.Image
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:10,代码来源:docker.go

示例3: AddUnits

func (p *FakeProvisioner) AddUnits(app provision.App, n uint) ([]provision.Unit, error) {
	if err := p.getError("AddUnits"); err != nil {
		return nil, err
	}
	if n == 0 {
		return nil, errors.New("Cannot add 0 units.")
	}
	p.mut.Lock()
	defer p.mut.Unlock()
	pApp, ok := p.apps[app.GetName()]
	if !ok {
		return nil, errNotProvisioned
	}
	name := app.GetName()
	platform := app.GetPlatform()
	length := uint(len(pApp.units))
	for i := uint(0); i < n; i++ {
		unit := provision.Unit{
			Name:    fmt.Sprintf("%s/%d", name, pApp.unitLen),
			AppName: name,
			Type:    platform,
			Status:  provision.StatusStarted,
			Ip:      fmt.Sprintf("10.10.10.%d", length+i),
		}
		pApp.units = append(pApp.units, unit)
		pApp.unitLen++
	}
	result := make([]provision.Unit, int(n))
	copy(result, pApp.units[length:])
	p.apps[app.GetName()] = pApp
	return result, nil
}
开发者ID:philiptzou,项目名称:tsuru,代码行数:32,代码来源:provisioner.go

示例4: 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

示例5: asUnit

func (c *container) asUnit(a provision.App) provision.Unit {
	return provision.Unit{
		Name:    c.ID,
		AppName: a.GetName(),
		Type:    a.GetPlatform(),
		Ip:      c.HostAddr,
		Status:  provision.StatusBuilding,
	}
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:9,代码来源:docker.go

示例6: AddUnitsToNode

func (p *FakeProvisioner) AddUnitsToNode(app provision.App, n uint, process string, w io.Writer, nodeAddr string) ([]provision.Unit, error) {
	if err := p.getError("AddUnits"); err != nil {
		return nil, err
	}
	if n == 0 {
		return nil, errors.New("Cannot add 0 units.")
	}
	p.mut.Lock()
	defer p.mut.Unlock()
	pApp, ok := p.apps[app.GetName()]
	if !ok {
		return nil, errNotProvisioned
	}
	name := app.GetName()
	platform := app.GetPlatform()
	length := uint(len(pApp.units))
	for i := uint(0); i < n; i++ {
		val := atomic.AddInt32(&uniqueIpCounter, 1)
		var hostAddr string
		if nodeAddr != "" {
			hostAddr = net.URLToHost(nodeAddr)
		} else if len(p.nodes) > 0 {
			for _, n := range p.nodes {
				hostAddr = net.URLToHost(n.Address())
				break
			}
		} else {
			hostAddr = fmt.Sprintf("10.10.10.%d", val)
		}
		unit := provision.Unit{
			ID:          fmt.Sprintf("%s-%d", name, pApp.unitLen),
			AppName:     name,
			Type:        platform,
			Status:      provision.StatusStarted,
			Ip:          hostAddr,
			ProcessName: process,
			Address: &url.URL{
				Scheme: "http",
				Host:   fmt.Sprintf("%s:%d", hostAddr, val),
			},
		}
		err := routertest.FakeRouter.AddRoute(name, unit.Address)
		if err != nil {
			return nil, err
		}
		pApp.units = append(pApp.units, unit)
		pApp.unitLen++
	}
	result := make([]provision.Unit, int(n))
	copy(result, pApp.units[length:])
	p.apps[app.GetName()] = pApp
	if w != nil {
		fmt.Fprintf(w, "added %d units", n)
	}
	return result, nil
}
开发者ID:tsuru,项目名称:tsuru,代码行数:56,代码来源:fake_provisioner.go

示例7: getBuildImage

// getBuildImage returns the image name from app or plaftorm.
// the platform image will be returned if:
// * there are no containers;
// * the container have an empty image name;
// * the deploy number is multiple of 10.
// in all other cases the app image name will be returne.
func (p *dockerProvisioner) getBuildImage(app provision.App) string {
	if p.usePlatformImage(app) {
		return platformImageName(app.GetPlatform())
	}
	appImageName, err := appCurrentImageName(app.GetName())
	if err != nil {
		return platformImageName(app.GetPlatform())
	}
	return appImageName
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:16,代码来源:image.go

示例8: GetBuildImage

// GetBuildImage returns the image name from app or plaftorm.
// the platform image will be returned if:
// * there are no containers;
// * the container have an empty image name;
// * the deploy number is multiple of 10.
// in all other cases the app image name will be returne.
func GetBuildImage(app provision.App) string {
	if usePlatformImage(app) {
		return PlatformImageName(app.GetPlatform())
	}
	appImageName, err := AppCurrentImageName(app.GetName())
	if err != nil {
		return PlatformImageName(app.GetPlatform())
	}
	return appImageName
}
开发者ID:tsuru,项目名称:tsuru,代码行数:16,代码来源:image.go

示例9: taskToUnit

func taskToUnit(task *swarm.Task, service *swarm.Service, node *swarm.Node, a provision.App) provision.Unit {
	addr := node.Spec.Labels[labelNodeDockerAddr.String()]
	host := tsuruNet.URLToHost(addr)
	return provision.Unit{
		ID:          task.ID,
		AppName:     a.GetName(),
		ProcessName: service.Spec.Annotations.Labels[labelAppProcess.String()],
		Type:        a.GetPlatform(),
		Ip:          host,
		Status:      stateMap[task.Status.State],
		Address:     &url.URL{},
	}
}
开发者ID:tsuru,项目名称:tsuru,代码行数:13,代码来源:provisioner.go

示例10: getImage

// getImage returns the image name or id from an app.
// when the container image is empty is returned the platform image.
// when a deploy is multiple of 10 is returned the platform image.
func getImage(app provision.App) string {
	c, err := getOneContainerByAppName(app.GetName())
	if err != nil || c.Image == "" {
		return assembleImageName(app.GetPlatform())
	}
	if usePlatformImage(app) {
		err := removeImage(c.Image)
		if err != nil {
			log.Error(err.Error())
		}
		return assembleImageName(app.GetPlatform())
	}
	return c.Image
}
开发者ID:philiptzou,项目名称:tsuru,代码行数:17,代码来源:docker.go

示例11: 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

示例12: getImage

// getImage returns the image name or id from an app.
// when the container image is empty is returned the platform image.
// when a deploy is multiple of 10 is returned the platform image.
func getImage(app provision.App) string {
	var c container
	coll := collection()
	defer coll.Close()
	coll.Find(bson.M{"appname": app.GetName()}).One(&c)
	if c.Image == "" {
		return assembleImageName(app.GetPlatform())
	}
	if usePlatformImage(app) {
		err := removeImage(c.Image)
		if err != nil {
			log.Error(err.Error())
		}
		return assembleImageName(app.GetPlatform())
	}
	return c.Image
}
开发者ID:kennylixi,项目名称:tsuru,代码行数:20,代码来源:docker.go

示例13: asUnit

func (c *container) asUnit(a provision.App) provision.Unit {
	status := provision.Status(c.Status)
	if c.Status == "" {
		status = provision.StatusBuilding
	}
	cType := c.Type
	if cType == "" {
		cType = a.GetPlatform()
	}
	return provision.Unit{
		Name:        c.ID,
		AppName:     a.GetName(),
		Type:        cType,
		Ip:          c.HostAddr,
		Status:      status,
		ProcessName: c.ProcessName,
	}
}
开发者ID:keymon,项目名称:tsuru,代码行数:18,代码来源:docker.go


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