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


Golang project.GetServiceHash函数代码示例

本文整理汇总了Golang中github.com/docker/libcompose/project.GetServiceHash函数的典型用法代码示例。如果您正苦于以下问题:Golang GetServiceHash函数的具体用法?Golang GetServiceHash怎么用?Golang GetServiceHash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getHash

func (c *Container) getHash(imageName string) string {
	serviceConfig := *c.service.Config()
	imageInfo, err := c.client.InspectImage(imageName)
	if imageInfo != nil && err == nil {
		serviceConfig.Image = imageInfo.Id
	} else {
		serviceConfig.Image = imageName
	}

	return project.GetServiceHash(c.service.Name(), serviceConfig)
}
开发者ID:hetianxing668,项目名称:os,代码行数:11,代码来源:container.go

示例2: OutOfSync

func (c *Container) OutOfSync() (bool, error) {
	container, err := c.findExisting()
	if err != nil || container == nil {
		return false, err
	}

	info, err := c.client.InspectContainer(container.Id)
	if err != nil {
		return false, err
	}

	return info.Config.Labels[HASH.Str()] != project.GetServiceHash(c.service), nil
}
开发者ID:nickschuch,项目名称:up,代码行数:13,代码来源:container.go

示例3: createContainer

func (c *Container) createContainer(imageName string, configOverride *project.ServiceConfig) (*dockerclient.Container, error) {
	serviceConfig := c.service.serviceConfig
	if configOverride != nil {
		serviceConfig.Command = configOverride.Command
		serviceConfig.Tty = configOverride.Tty
	}
	config, err := ConvertToApi(serviceConfig)
	if err != nil {
		return nil, err
	}

	config.Image = imageName

	if config.Labels == nil {
		config.Labels = map[string]string{}
	}

	config.Labels[NAME.Str()] = c.name
	config.Labels[SERVICE.Str()] = c.service.name
	config.Labels[PROJECT.Str()] = c.service.context.Project.Name
	config.Labels[HASH.Str()] = project.GetServiceHash(c.service)

	err = c.populateAdditionalHostConfig(&config.HostConfig)
	if err != nil {
		return nil, err
	}

	logrus.Debugf("Creating container %s %#v", c.name, config)

	_, err = c.client.CreateContainer(config, c.name)
	if err != nil && err.Error() == "Not found" {
		logrus.Debugf("Not Found, pulling image %s", config.Image)
		if err = c.pull(config.Image); err != nil {
			return nil, err
		}
		if _, err = c.client.CreateContainer(config, c.name); err != nil {
			return nil, err
		}
	}

	if err != nil {
		logrus.Debugf("Failed to create container %s: %v", c.name, err)
		return nil, err
	}

	return c.findExisting()
}
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:47,代码来源:container.go

示例4: addServices

func addServices(p *project.Project, cfg *config.CloudConfig, enabled map[string]string, configs map[string]*project.ServiceConfig) {
	// Note: we ignore errors while loading services
	for name, serviceConfig := range configs {
		hash := project.GetServiceHash(name, *serviceConfig)

		if enabled[name] == hash {
			continue
		}

		if err := p.AddConfig(name, serviceConfig); err != nil {
			log.Infof("Failed loading service %s", name)
			continue
		}

		enabled[name] = hash
	}
}
开发者ID:clhudson2,项目名称:os,代码行数:17,代码来源:project.go

示例5: createContainer

func (c *Container) createContainer(imageName string) (*dockerclient.APIContainers, error) {
	createOpts, err := ConvertToAPI(c.service.serviceConfig, c.name)
	if err != nil {
		return nil, err
	}

	createOpts.Config.Image = imageName

	if createOpts.Config.Labels == nil {
		createOpts.Config.Labels = map[string]string{}
	}

	createOpts.Config.Labels[NAME.Str()] = c.name
	createOpts.Config.Labels[SERVICE.Str()] = c.service.name
	createOpts.Config.Labels[PROJECT.Str()] = c.service.context.Project.Name
	createOpts.Config.Labels[HASH.Str()] = project.GetServiceHash(c.service)

	err = c.populateAdditionalHostConfig(createOpts.HostConfig)
	if err != nil {
		return nil, err
	}

	logrus.Debugf("Creating container %s %#v", c.name, createOpts)

	_, err = c.client.CreateContainer(*createOpts)
	if err != nil && err == dockerclient.ErrNoSuchImage {
		logrus.Debugf("Not Found, pulling image %s", createOpts.Config.Image)
		if err = c.pull(createOpts.Config.Image); err != nil {
			return nil, err
		}
		if _, err = c.client.CreateContainer(*createOpts); err != nil {
			return nil, err
		}
	}

	if err != nil {
		logrus.Debugf("Failed to create container %s: %v", c.name, err)
		return nil, err
	}

	return c.findExisting()
}
开发者ID:gondor,项目名称:libcompose,代码行数:42,代码来源:container.go

示例6: addServices

func addServices(p *project.Project, enabled map[interface{}]interface{}, configs map[string]*project.ServiceConfig) map[interface{}]interface{} {
	// Note: we ignore errors while loading services
	unchanged := true
	for name, serviceConfig := range configs {
		hash := project.GetServiceHash(name, serviceConfig)

		if enabled[name] == hash {
			continue
		}

		if err := p.AddConfig(name, serviceConfig); err != nil {
			log.Infof("Failed loading service %s", name)
			continue
		}

		if unchanged {
			enabled = util.MapCopy(enabled)
			unchanged = false
		}
		enabled[name] = hash
	}
	return enabled
}
开发者ID:datawolf,项目名称:os,代码行数:23,代码来源:project.go

示例7: getHash

func (c *Container) getHash() string {
	return project.GetServiceHash(c.service.Name(), *c.service.Config())
}
开发者ID:Jdesk,项目名称:os,代码行数:3,代码来源:container.go


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