func()

in pkg/client/sonar/sonar.go [525:549]


func (sc Client) checkWebhookExist(webhookName string) (bool, error) {
	resp, err := sc.resty.R().
		Get("/webhooks/list")
	if err != nil {
		return false, fmt.Errorf("failed to send request to list all webhooks!: %w", err)
	}
	if resp.IsError() {
		errMsg := fmt.Sprintf("failed to list webhooks on server! Response code - %v", resp.StatusCode())
		return false, errors.New(errMsg)
	}

	var raw WebhooksListResponse
	err = json.Unmarshal(resp.Body(), &raw)
	if err != nil {
		return false, fmt.Errorf(cantUnmarshalMsg, resp.Body(), err)
	}

	for _, v := range raw.Webhooks {
		if v.Name == webhookName {
			return true, nil
		}
	}

	return false, nil
}