Skip to content

Commit

Permalink
add optional title fields to build type
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
  • Loading branch information
krancour committed Nov 26, 2019
1 parent 781f57f commit b1d7855
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
12 changes: 12 additions & 0 deletions pkg/brigade/build.go
Expand Up @@ -12,6 +12,18 @@ type Build struct {
Type string `json:"type"`
// Provider is the name of the service that caused the event (github, vsts, cron, ...)
Provider string `json:"provider"`
// ShortTitle is an optional field for a short (and not necessarily unique)
// string value that can be added to a build by a gateway to ascribe context
// that may be meaningful to human users. For instance, the GitHub gateway
// COULD label a build triggered by a pull request with the title or number of
// that pull request.
ShortTitle string `json:"short_title"`
// LongTitle is an optional field for a longer (and not necessarily unique)
// string value that can be added to a build by a gateway to ascribe context
// that may be meaningful to human users. For instance, the GitHub gateway
// COULD label a build triggered by a pull request with the title or number of
// that pull request.
LongTitle string `json:"long_title"`
// CloneURL is the URL at which the repository can be cloned.
// This is optional at the build-level. If set, it overrides the same setting
// at the projet-level.
Expand Down
14 changes: 9 additions & 5 deletions pkg/storage/kube/build.go
Expand Up @@ -109,6 +109,8 @@ func (s *store) CreateBuild(build *brigade.Build) error {
StringData: map[string]string{
"build_id": buildName,
"build_name": buildName,
"short_title": build.ShortTitle,
"long_title": build.LongTitle,
"clone_url": build.CloneURL,
"commit_id": build.Revision.Commit,
"commit_ref": build.Revision.Ref,
Expand Down Expand Up @@ -201,11 +203,13 @@ func NewBuildFromSecret(secret v1.Secret) *brigade.Build {
lbs := secret.ObjectMeta.Labels
sv := SecretValues(secret.Data)
return &brigade.Build{
ID: lbs["build"],
ProjectID: lbs["project"],
Type: sv.String("event_type"),
Provider: sv.String("event_provider"),
CloneURL: sv.String("clone_url"),
ID: lbs["build"],
ProjectID: lbs["project"],
Type: sv.String("event_type"),
Provider: sv.String("event_provider"),
ShortTitle: sv.String("short_title"),
LongTitle: sv.String("long_title"),
CloneURL: sv.String("clone_url"),
Revision: &brigade.Revision{
Commit: sv.String("commit_id"),
Ref: sv.String("commit_ref"),
Expand Down
2 changes: 2 additions & 0 deletions pkg/storage/kube/build_test.go
Expand Up @@ -23,6 +23,8 @@ func TestNewBuildFromSecret(t *testing.T) {
Data: map[string][]byte{
"event_type": []byte("foo"),
"event_provider": []byte("bar"),
"short_title": []byte("this is a short title"),
"long_title": []byte("this is a long title"),
"payload": []byte("this is a payload"),
"script": []byte("ohai"),
"commit_id": []byte("abc123"),
Expand Down
6 changes: 4 additions & 2 deletions pkg/storage/kube/store_test.go
Expand Up @@ -127,8 +127,10 @@ var (

// stubBuild is a build
stubBuild = &brigade.Build{
ID: stubBuildID,
ProjectID: stubProjectID,
ID: stubBuildID,
ProjectID: stubProjectID,
ShortTitle: "this is a short title",
LongTitle: "this is a long title",
Revision: &brigade.Revision{
Commit: "abc123",
Ref: "refs/heads/master",
Expand Down

0 comments on commit b1d7855

Please sign in to comment.