Skip to content

Commit

Permalink
fix: change receiver model pointer to value
Browse files Browse the repository at this point in the history
Signed-off-by: François Gouteroux <[email protected]>
  • Loading branch information
fgouteroux committed Apr 25, 2023
1 parent 9a8d1f9 commit d14eb77
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions api/v2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (api *API) getReceiversHandler(params receiver_ops.GetReceiversParams) midd

receivers := make([]*open_api_models.Receiver, 0, len(api.alertmanagerConfig.Receivers))
for _, r := range api.alertmanagerConfig.Receivers {
receivers = append(receivers, &open_api_models.Receiver{Name: &r.Name})
receivers = append(receivers, &open_api_models.Receiver{Name: r.Name})
}

return receiver_ops.NewGetReceiversOK().WithPayload(receivers)
Expand Down Expand Up @@ -406,7 +406,7 @@ func (api *API) getAlertGroupsHandler(params alertgroup_ops.GetAlertGroupsParams

for _, alertGroup := range alertGroups {
ag := &open_api_models.AlertGroup{
Receiver: &open_api_models.Receiver{Name: &alertGroup.Receiver},
Receiver: &open_api_models.Receiver{Name: alertGroup.Receiver},
Labels: ModelLabelSetToAPILabelSet(alertGroup.Labels),
Alerts: make([]*open_api_models.GettableAlert, 0, len(alertGroup.Alerts)),
}
Expand Down
4 changes: 2 additions & 2 deletions api/v2/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ func TestAlertToOpenAPIAlert(t *testing.T) {
UpdatedAt: convertDateTime(updated),
Fingerprint: &fp,
Receivers: []*open_api_models.Receiver{
{Name: &receivers[0]},
{Name: &receivers[1]},
{Name: receivers[0]},
{Name: receivers[1]},
},
}, openAPIAlert)
}
Expand Down
2 changes: 1 addition & 1 deletion api/v2/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func AlertToOpenAPIAlert(alert *types.Alert, status types.AlertStatus, receivers

apiReceivers := make([]*open_api_models.Receiver, 0, len(receivers))
for i := range receivers {
apiReceivers = append(apiReceivers, &open_api_models.Receiver{Name: &receivers[i]})
apiReceivers = append(apiReceivers, &open_api_models.Receiver{Name: receivers[i]})
}

fp := alert.Fingerprint().String()
Expand Down
4 changes: 2 additions & 2 deletions api/v2/models/receiver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ definitions:
type: object
properties:
name:
x-nullable: false
type: string
required:
- name
Expand Down
6 changes: 4 additions & 2 deletions api/v2/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d14eb77

Please sign in to comment.