2020-07-30 04:59:12 -05:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
2021-11-03 05:31:56 -05:00
|
|
|
"context"
|
2020-07-30 04:59:12 -05:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/bus"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
|
|
)
|
|
|
|
|
2021-11-03 05:31:56 -05:00
|
|
|
func CheckOrgExists(ctx context.Context, orgID int64) error {
|
2020-07-30 04:59:12 -05:00
|
|
|
query := models.GetOrgByIdQuery{Id: orgID}
|
2021-12-28 10:36:22 -06:00
|
|
|
if err := bus.Dispatch(ctx, &query); err != nil {
|
2020-07-30 04:59:12 -05:00
|
|
|
if errors.Is(err, models.ErrOrgNotFound) {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return fmt.Errorf("failed to check whether org. with the given ID exists: %w", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|