forked from toolshed/abra
@ -20,6 +20,8 @@ func UpdateTag(pattern, image, tag string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Debugf("considering '%s' config(s) for tag update", strings.Join(composeFiles, ", "))
|
||||
|
||||
for _, composeFile := range composeFiles {
|
||||
opts := stack.Deploy{Composefiles: []string{composeFile}}
|
||||
emptyEnv := make(map[string]string)
|
||||
@ -35,7 +37,7 @@ func UpdateTag(pattern, image, tag string) error {
|
||||
|
||||
img, _ := reference.ParseNormalizedNamed(service.Image)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
return err
|
||||
}
|
||||
|
||||
composeImage := reference.Path(img)
|
||||
@ -47,16 +49,20 @@ func UpdateTag(pattern, image, tag string) error {
|
||||
}
|
||||
composeTag := img.(reference.NamedTagged).Tag()
|
||||
|
||||
logrus.Debugf("parsed '%s' from '%s'", composeTag, service.Image)
|
||||
|
||||
if image == composeImage {
|
||||
bytes, err := ioutil.ReadFile(composeFile)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
return err
|
||||
}
|
||||
|
||||
old := fmt.Sprintf("%s:%s", composeImage, composeTag)
|
||||
new := fmt.Sprintf("%s:%s", composeImage, tag)
|
||||
replacedBytes := strings.Replace(string(bytes), old, new, -1)
|
||||
|
||||
logrus.Debugf("updating '%s' to '%s' in '%s'", old, new, compose.Filename)
|
||||
|
||||
if err := ioutil.WriteFile(compose.Filename, []byte(replacedBytes), 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -74,6 +80,8 @@ func UpdateLabel(pattern, serviceName, label string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Debugf("considering '%s' config(s) for label update", strings.Join(composeFiles, ", "))
|
||||
|
||||
for _, composeFile := range composeFiles {
|
||||
opts := stack.Deploy{Composefiles: []string{composeFile}}
|
||||
emptyEnv := make(map[string]string)
|
||||
@ -104,6 +112,9 @@ func UpdateLabel(pattern, serviceName, label string) error {
|
||||
|
||||
old := fmt.Sprintf("coop-cloud.${STACK_NAME}.%s.version=%s", service.Name, value)
|
||||
replacedBytes := strings.Replace(string(bytes), old, label, -1)
|
||||
|
||||
logrus.Debugf("updating '%s' to '%s' in '%s'", old, label, compose.Filename)
|
||||
|
||||
if err := ioutil.WriteFile(compose.Filename, []byte(replacedBytes), 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user