本文整理汇总了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)
}
示例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
}
示例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()
}
示例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
}
}
示例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()
}
示例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
}
示例7: getHash
func (c *Container) getHash() string {
return project.GetServiceHash(c.service.Name(), *c.service.Config())
}