Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to use email from propagated claims #514

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions controllers/idler/idler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ func (r *Reconciler) getUserEmailsFromMURs(ctx context.Context, hostCluster *clu
if err != nil {
return emails, errs.Wrapf(err, "could not get the MUR")
}
if email := getMUR.Annotations[toolchainv1alpha1.MasterUserRecordEmailAnnotationKey]; email != "" {
emails = append(emails, getMUR.Annotations[toolchainv1alpha1.MasterUserRecordEmailAnnotationKey])
if email := getMUR.Spec.PropagatedClaims.Email; email != "" {
emails = append(emails, getMUR.Spec.PropagatedClaims.Email)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you already assigned getMUR.Spec.PropagatedClaims.Email into email, you could do something like this:

Suggested change
emails = append(emails, getMUR.Spec.PropagatedClaims.Email)
emails = append(emails, email)

but it's a minor thing

}
}
} else {
Expand Down
10 changes: 6 additions & 4 deletions controllers/idler/idler_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ func TestCreateNotification(t *testing.T) {
usernames := []string{"alex"}
nsTmplSet := newNSTmplSet(test.MemberOperatorNs, "alex", "advanced", "abcde11", namespaces, usernames)
mur := newMUR("alex")
delete(mur.Annotations, toolchainv1alpha1.MasterUserRecordEmailAnnotationKey)
mur.Spec.PropagatedClaims.Email = ""
reconciler, _, _, _, _ := prepareReconcile(t, idler.Name, getHostCluster, idler, nsTmplSet, mur)
//when
err := reconciler.createNotification(context.TODO(), idler, "testPodName", "testapptype")
Expand All @@ -988,7 +988,7 @@ func TestCreateNotification(t *testing.T) {
usernames := []string{"alex"}
nsTmplSet := newNSTmplSet(test.MemberOperatorNs, "alex", "advanced", "abcde11", namespaces, usernames)
mur := newMUR("alex")
mur.Annotations[toolchainv1alpha1.MasterUserRecordEmailAnnotationKey] = "invalid-email-address"
mur.Spec.PropagatedClaims.Email = "invalid-email-address"
reconciler, _, _, _, _ := prepareReconcile(t, idler.Name, getHostCluster, idler, nsTmplSet, mur)
//when
err := reconciler.createNotification(context.TODO(), idler, "testPodName", "testapptype")
Expand Down Expand Up @@ -1454,8 +1454,10 @@ func newMUR(name string) *toolchainv1alpha1.MasterUserRecord {
Namespace: test.HostOperatorNs,
Name: name,
Finalizers: []string{toolchainv1alpha1.FinalizerName},
Annotations: map[string]string{
toolchainv1alpha1.MasterUserRecordEmailAnnotationKey: fmt.Sprintf("%[email protected]", name),
},
Spec: toolchainv1alpha1.MasterUserRecordSpec{
PropagatedClaims: toolchainv1alpha1.PropagatedClaims{
Email: fmt.Sprintf("%[email protected]", name),
},
},
}
Expand Down
Loading