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/models"
|
2022-10-13 07:40:46 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/org"
|
2020-07-30 04:59:12 -05:00
|
|
|
)
|
|
|
|
|
2022-04-08 06:56:38 -05:00
|
|
|
type DashboardStore interface {
|
|
|
|
GetDashboard(context.Context, *models.GetDashboardQuery) error
|
|
|
|
}
|
|
|
|
|
2022-10-13 07:40:46 -05:00
|
|
|
func CheckOrgExists(ctx context.Context, orgService org.Service, orgID int64) error {
|
|
|
|
query := org.GetOrgByIdQuery{ID: orgID}
|
|
|
|
_, err := orgService.GetByID(ctx, &query)
|
|
|
|
if 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
|
|
|
|
}
|