Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Improve commit message for containers releases
Browse files Browse the repository at this point in the history
Changes the Git commit message for containers release from

```
Release containers

default:deployment/foo
- quay.io/bar/nginx:master-d9500ad8
- quay.io/bar/logger:master-d9500ad8

default:deployment/moo
- quay.io/bar/nginx:master-d9500ad8
```

to

```
Update image refs in default:deployment/foo, default:deployment/moo

default:deployment/foo
- quay.io/bar/nginx:master-d9500ad8
- quay.io/bar/logger:master-d9500ad8

default:deployment/moo
- quay.io/bar/nginx:master-d9500ad8
```
  • Loading branch information
rndstr committed Oct 30, 2018
1 parent 706adb1 commit 2a418fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions release/releaser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ func Test_UpdateContainers(t *testing.T) {
Target: newSidecarRef,
}},
},
Commit: "Release containers\n\ndefault:deployment/helloworld\n- quay.io/weaveworks/helloworld:master-a000002\n- weaveworks/sidecar:master-a000002\n",
Commit: "Update image refs in default:deployment/helloworld\n\ndefault:deployment/helloworld\n- quay.io/weaveworks/helloworld:master-a000002\n- weaveworks/sidecar:master-a000002\n",
},
false: {
Result: update.ControllerResult{
Expand All @@ -886,7 +886,7 @@ func Test_UpdateContainers(t *testing.T) {
Target: newSidecarRef,
}},
},
Commit: "Release containers\n\ndefault:deployment/helloworld\n- quay.io/weaveworks/helloworld:master-a000002\n- weaveworks/sidecar:master-a000002\n",
Commit: "Update image refs in default:deployment/helloworld\n\ndefault:deployment/helloworld\n- quay.io/weaveworks/helloworld:master-a000002\n- weaveworks/sidecar:master-a000002\n",
},
},
},
Expand Down Expand Up @@ -918,7 +918,7 @@ func Test_UpdateContainers(t *testing.T) {
},
},
},
Commit: "Release containers\n\ndefault:deployment/helloworld\n- weaveworks/sidecar:master-a000002\n",
Commit: "Update image refs in default:deployment/helloworld\n\ndefault:deployment/helloworld\n- weaveworks/sidecar:master-a000002\n",
},
false: {Err: errors.New("cannot satisfy specs")},
},
Expand Down Expand Up @@ -996,7 +996,7 @@ func Test_UpdateContainers(t *testing.T) {
},
},
},
Commit: "Release containers\n\ndefault:deployment/locked-service\n- quay.io/weaveworks/locked-service:2\n",
Commit: "Update image refs in default:deployment/locked-service\n\ndefault:deployment/locked-service\n- quay.io/weaveworks/locked-service:2\n",
},
false: {
Result: update.ControllerResult{
Expand All @@ -1009,7 +1009,7 @@ func Test_UpdateContainers(t *testing.T) {
},
},
},
Commit: "Release containers\n\ndefault:deployment/locked-service\n- quay.io/weaveworks/locked-service:2\n",
Commit: "Update image refs in default:deployment/locked-service\n\ndefault:deployment/locked-service\n- quay.io/weaveworks/locked-service:2\n",
},
},
},
Expand Down
15 changes: 8 additions & 7 deletions update/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,18 @@ func (s ContainerSpecs) ReleaseType() ReleaseType {
}

func (s ContainerSpecs) CommitMessage(result Result) string {
buf := &bytes.Buffer{}
fmt.Fprintln(buf, "Release containers")
var workloads []string
body := &bytes.Buffer{}
for _, res := range result.AffectedResources() {
fmt.Fprintf(buf, "\n%s", res)
workloads = append(workloads, res.String())
fmt.Fprintf(body, "\n%s", res)
for _, upd := range result[res].PerContainer {
fmt.Fprintf(buf, "\n- %s", upd.Target)
fmt.Fprintf(body, "\n- %s", upd.Target)
}
fmt.Fprintln(buf)
fmt.Fprintln(body)
}
if err := result.Error(); err != "" {
fmt.Fprintf(buf, "\n%s", result.Error())
fmt.Fprintf(body, "\n%s", result.Error())
}
return buf.String()
return fmt.Sprintf("Update image refs in %s\n%s", strings.Join(workloads, ", "), body.String())
}

0 comments on commit 2a418fe

Please sign in to comment.