func (settings *FSouza_ClientSettings) nodeSettings(client *FSouza_Client, node Node) FSouza_ClientSettings { tokens := conf.Tokens{} tokens.SetToken("NODE", node.Id()) tokens.SetToken("NODEMACHINE", node.MachineName()) copy := settings.copy(tokens) return copy }
func (settings *FSouza_ClientSettings) copy(tokens conf.Tokens) FSouza_ClientSettings { settings_json := settings.toJson() if tokens != nil { settings_json = tokens.TokenReplace(settings_json) } copy := FSouza_ClientSettings{} copy.fromJson(settings_json) return copy }
func (settings *FSouza_ClientSettings) instanceSettings(client *FSouza_Client, instance Instance) FSouza_ClientSettings { tokens := conf.Tokens{} tokens.SetToken("INSTANCE", instance.Id()) tokens.SetToken("INSTANCEMACHINE", instance.MachineName()) copy := settings.copy(tokens) if settings.Host.Links != nil && len(settings.Host.Links) > 0 { newLinks := []string{} for _, link := range settings.Host.Links { linkSplit := strings.SplitN(link, ":", 2) if transformedSet, found := settings.dependencies.DependencyIdTranform(linkSplit[0]); found { for _, transformed := range transformedSet { linkSplit[0] = transformed linkSplit[1] = strings.Replace(linkSplit[1], "%SOURCE", transformed, -1) newLinks = append(newLinks, strings.Join(linkSplit, ":")) } } else { newLinks = append(newLinks, link) } } copy.Host.Links = newLinks } if settings.Host.VolumesFrom != nil && len(settings.Host.VolumesFrom) > 0 { newVolumesFrom := []string{} for _, volumeFrom := range settings.Host.VolumesFrom { volumeFromSplit := strings.SplitN(volumeFrom, ":", 2) if transformedSet, found := settings.dependencies.DependencyIdTranform(volumeFromSplit[0]); found { for _, transformed := range transformedSet { volumeFromSplit[0] = transformed newVolumesFrom = append(newVolumesFrom, strings.Join(volumeFromSplit, ":")) } } else { newVolumesFrom = append(newVolumesFrom, volumeFrom) } } copy.Host.VolumesFrom = newVolumesFrom } return copy }