Fix passthrough of pipeline notifications (#1058)

## Changes

Notifications weren't passed along because of a plural vs singular
mismatch.

## Tests

* Added unit test coverage.
* Manually confirmed it now works in an example bundle.
This commit is contained in:
Pieter Noordhuis 2023-12-12 12:36:06 +01:00 committed by GitHub
parent b479a7cf67
commit 37671d9f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -140,6 +140,12 @@ func BundleToTerraform(config *config.Root) *schema.Root {
conv(v, &l)
dst.Cluster = append(dst.Cluster, l)
}
for _, v := range src.Notifications {
var l schema.ResourcePipelineNotification
conv(v, &l)
dst.Notification = append(dst.Notification, l)
}
}
tfroot.Resource.Pipeline[k] = &dst

View File

@ -139,6 +139,26 @@ func TestConvertPipeline(t *testing.T) {
},
},
},
Notifications: []pipelines.Notifications{
{
Alerts: []string{
"on-update-fatal-failure",
},
EmailRecipients: []string{
"jane@doe.com",
},
},
{
Alerts: []string{
"on-update-failure",
"on-flow-failure",
},
EmailRecipients: []string{
"jane@doe.com",
"john@doe.com",
},
},
},
},
}
@ -153,6 +173,12 @@ func TestConvertPipeline(t *testing.T) {
out := BundleToTerraform(&config)
assert.Equal(t, "my pipeline", out.Resource.Pipeline["my_pipeline"].Name)
assert.Len(t, out.Resource.Pipeline["my_pipeline"].Library, 2)
notifs := out.Resource.Pipeline["my_pipeline"].Notification
assert.Len(t, notifs, 2)
assert.Equal(t, notifs[0].Alerts, []string{"on-update-fatal-failure"})
assert.Equal(t, notifs[0].EmailRecipients, []string{"jane@doe.com"})
assert.Equal(t, notifs[1].Alerts, []string{"on-update-failure", "on-flow-failure"})
assert.Equal(t, notifs[1].EmailRecipients, []string{"jane@doe.com", "john@doe.com"})
assert.Nil(t, out.Data)
}