Skip to content

Commit

Permalink
Merge branch 'master' into responder-alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
axdotl authored May 22, 2023
2 parents 5231aab + fe35b34 commit e728676
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 4 additions & 6 deletions incident/incident_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,12 @@ func TestResponders_Validate(t *testing.T) {
{Type: User},
}
err = validateResponders(Responders)
assert.Equal(t, err.Error(), errors.New("For responder either name"+
" or id must be provided.").Error())
assert.Equal(t, err.Error(), errors.New("For responder type user either username or id must be provided.").Error())

Responders = []Responder{
{
Type: User,
Name: "cem",
Type: User,
Username: "cem@example.com",
},
}
err = validateResponders(Responders)
Expand All @@ -492,8 +491,7 @@ func TestResponders_Validate(t *testing.T) {
Type: Team},
}
err = validateResponders(Responders)
assert.Equal(t, err.Error(), errors.New("For responder either name"+
" or id must be provided.").Error())
assert.Equal(t, err.Error(), errors.New("For responder type team either team name or id must be provided.").Error())

Responders = []Responder{
{
Expand Down
8 changes: 6 additions & 2 deletions incident/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ type Responder struct {
Type ResponderType `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Id string `json:"id,omitempty"`
Username string `json:"username,omitempty"`
}

func validateResponders(responders []Responder) error {
Expand All @@ -871,8 +872,11 @@ func validateResponders(responders []Responder) error {
if !(responder.Type == User || responder.Type == Team) {
return errors.New("Responder type should be one of these: 'User', 'Team'.")
}
if responder.Name == "" && responder.Id == "" {
return errors.New("For responder either name or id must be provided.")
if responder.Type == User && responder.Username == "" && responder.Id == "" {
return errors.New("For responder type user either username or id must be provided.")
}
if responder.Type == Team && responder.Name == "" && responder.Id == "" {
return errors.New("For responder type team either team name or id must be provided.")
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion policy/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ type UpdateAlertPolicyRequest struct {
Message string `json:"message,omitempty"`
Continue *bool `json:"continue,omitempty"`
Alias string `json:"alias,omitempty"`
AlertDescription string `json:"alertDescription,omitempty"`
AlertDescription string `json:"description,omitempty"`
Entity string `json:"entity,omitempty"`
Source string `json:"source,omitempty"`
IgnoreOriginalDetails *bool `json:"ignoreOriginalDetails,omitempty"`
Expand Down

0 comments on commit e728676

Please sign in to comment.