mirror of https://github.com/grafana/grafana
k8s: add feature toggle and stub to save dashboards k8s (#62053)
parent
a0405912a8
commit
4965cf2eda
@ -0,0 +1,35 @@ |
||||
package service |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana/pkg/services/dashboards" |
||||
"github.com/grafana/grafana/pkg/services/featuremgmt" |
||||
"github.com/grafana/grafana/pkg/services/store/entity" |
||||
"github.com/grafana/grafana/pkg/services/store/k8saccess" |
||||
) |
||||
|
||||
func ProvideSimpleDashboardService( |
||||
features featuremgmt.FeatureToggles, |
||||
svc *DashboardServiceImpl, |
||||
k8s k8saccess.K8SAccess, |
||||
store entity.EntityStoreServer, |
||||
) dashboards.DashboardService { |
||||
if features.IsEnabled(featuremgmt.FlagK8sDashboards) { |
||||
if k8s.GetSystemClient() == nil { |
||||
panic("k8s dashboards requires the k8s client registered") |
||||
} |
||||
return k8saccess.NewDashboardService(svc, store) |
||||
} |
||||
return svc |
||||
} |
||||
|
||||
func ProvideDashboardProvisioningService( |
||||
features featuremgmt.FeatureToggles, orig *DashboardServiceImpl, |
||||
) dashboards.DashboardProvisioningService { |
||||
return orig |
||||
} |
||||
|
||||
func ProvideDashboardPluginService( |
||||
features featuremgmt.FeatureToggles, orig *DashboardServiceImpl, |
||||
) dashboards.PluginService { |
||||
return orig |
||||
} |
@ -0,0 +1,93 @@ |
||||
package k8saccess |
||||
|
||||
import ( |
||||
"context" |
||||
"fmt" |
||||
|
||||
"github.com/grafana/grafana/pkg/models" |
||||
"github.com/grafana/grafana/pkg/services/dashboards" |
||||
"github.com/grafana/grafana/pkg/services/store/entity" |
||||
) |
||||
|
||||
type k8sDashboardService struct { |
||||
orig dashboards.DashboardService |
||||
store entity.EntityStoreServer |
||||
} |
||||
|
||||
var _ dashboards.DashboardService = (*k8sDashboardService)(nil) |
||||
|
||||
func NewDashboardService(orig dashboards.DashboardService, store entity.EntityStoreServer) dashboards.DashboardService { |
||||
return &k8sDashboardService{ |
||||
orig: orig, |
||||
store: store, |
||||
} |
||||
} |
||||
|
||||
func (s *k8sDashboardService) BuildSaveDashboardCommand(ctx context.Context, dto *dashboards.SaveDashboardDTO, shouldValidateAlerts bool, validateProvisionedDashboard bool) (*dashboards.SaveDashboardCommand, error) { |
||||
return s.orig.BuildSaveDashboardCommand(ctx, dto, shouldValidateAlerts, validateProvisionedDashboard) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) DeleteDashboard(ctx context.Context, dashboardId int64, orgId int64) error { |
||||
return s.orig.DeleteDashboard(ctx, dashboardId, orgId) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) FindDashboards(ctx context.Context, query *models.FindPersistedDashboardsQuery) ([]dashboards.DashboardSearchProjection, error) { |
||||
return s.orig.FindDashboards(ctx, query) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) GetDashboard(ctx context.Context, query *dashboards.GetDashboardQuery) error { |
||||
return s.orig.GetDashboard(ctx, query) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) GetDashboardACLInfoList(ctx context.Context, query *dashboards.GetDashboardACLInfoListQuery) error { |
||||
return s.orig.GetDashboardACLInfoList(ctx, query) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) GetDashboards(ctx context.Context, query *dashboards.GetDashboardsQuery) error { |
||||
return s.orig.GetDashboards(ctx, query) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) GetDashboardTags(ctx context.Context, query *dashboards.GetDashboardTagsQuery) error { |
||||
return s.orig.GetDashboardTags(ctx, query) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) GetDashboardUIDByID(ctx context.Context, query *dashboards.GetDashboardRefByIDQuery) error { |
||||
return s.orig.GetDashboardUIDByID(ctx, query) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) HasAdminPermissionInDashboardsOrFolders(ctx context.Context, query *models.HasAdminPermissionInDashboardsOrFoldersQuery) error { |
||||
return s.orig.HasAdminPermissionInDashboardsOrFolders(ctx, query) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) HasEditPermissionInFolders(ctx context.Context, query *models.HasEditPermissionInFoldersQuery) error { |
||||
return s.orig.HasEditPermissionInFolders(ctx, query) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) ImportDashboard(ctx context.Context, dto *dashboards.SaveDashboardDTO) (*dashboards.Dashboard, error) { |
||||
return s.orig.ImportDashboard(ctx, dto) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) MakeUserAdmin(ctx context.Context, orgID int64, userID, dashboardID int64, setViewAndEditPermissions bool) error { |
||||
return s.orig.MakeUserAdmin(ctx, orgID, userID, dashboardID, setViewAndEditPermissions) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) SaveDashboard(ctx context.Context, dto *dashboards.SaveDashboardDTO, allowUiUpdate bool) (*dashboards.Dashboard, error) { |
||||
fmt.Printf("SAVE: " + dto.Dashboard.UID) |
||||
return s.orig.SaveDashboard(ctx, dto, allowUiUpdate) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) SearchDashboards(ctx context.Context, query *models.FindPersistedDashboardsQuery) error { |
||||
return s.orig.SearchDashboards(ctx, query) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) UpdateDashboardACL(ctx context.Context, uid int64, items []*dashboards.DashboardACL) error { |
||||
return s.orig.UpdateDashboardACL(ctx, uid, items) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) DeleteACLByUser(ctx context.Context, userID int64) error { |
||||
return s.orig.DeleteACLByUser(ctx, userID) |
||||
} |
||||
|
||||
func (s *k8sDashboardService) CountDashboardsInFolder(ctx context.Context, query *dashboards.CountDashboardsInFolderQuery) (int64, error) { |
||||
return s.orig.CountDashboardsInFolder(ctx, query) |
||||
} |
Loading…
Reference in new issue