Skip to content

Commit

Permalink
Change binding created_by format (#1351)
Browse files Browse the repository at this point in the history
Change created_by format
  • Loading branch information
KsaweryZietara authored Oct 17, 2024
1 parent def7eae commit c108691
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/broker/bind_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ func TestCreatedBy(t *testing.T) {
{
name: "Both Email and Origin are set",
context: broker.BindingContext{Email: &email, Origin: &origin},
expected: "[email protected] origin",
expected: "[email protected]",
},
}

Expand Down
23 changes: 5 additions & 18 deletions internal/broker/bind_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,12 @@ type BindingContext struct {
}

func (b *BindingContext) CreatedBy() string {
if b.Email == nil && b.Origin == nil {
return ""
if b.Email != nil && *b.Email != "" {
return *b.Email
} else if b.Origin != nil && *b.Origin != "" {
return *b.Origin
}

email := ""
if b.Email != nil {
email = *b.Email
}

origin := ""
if b.Origin != nil {
origin = *b.Origin
}

if email != "" && origin != "" {
return email + " " + origin
}

return email + origin
return ""
}

type BindingParams struct {
Expand Down

0 comments on commit c108691

Please sign in to comment.