mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 00:37:04 -06:00
E2C: Add cloud migration is_target server config option (#83419)
This commit is contained in:
parent
fa888af212
commit
1ab8857e48
@ -1808,3 +1808,8 @@ read_only_toggles =
|
||||
[public_dashboards]
|
||||
# Set to false to disable public dashboards
|
||||
enabled = true
|
||||
|
||||
###################################### Cloud Migration ######################################
|
||||
[cloud_migration]
|
||||
# Set to true to enable target-side migration UI
|
||||
is_target = false
|
||||
|
@ -227,6 +227,7 @@ export interface GrafanaConfig {
|
||||
sharedWithMeFolderUID?: string;
|
||||
rootFolderUID?: string;
|
||||
localFileSystemAvailable?: boolean;
|
||||
cloudMigrationIsTarget?: boolean;
|
||||
|
||||
// The namespace to use for kubernetes apiserver requests
|
||||
namespace: string;
|
||||
|
@ -172,6 +172,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
|
||||
sharedWithMeFolderUID: string | undefined;
|
||||
rootFolderUID: string | undefined;
|
||||
localFileSystemAvailable: boolean | undefined;
|
||||
cloudMigrationIsTarget: boolean | undefined;
|
||||
|
||||
constructor(options: GrafanaBootConfig) {
|
||||
this.bootData = options.bootData;
|
||||
|
@ -247,6 +247,8 @@ type FrontendSettingsDTO struct {
|
||||
PublicDashboardAccessToken string `json:"publicDashboardAccessToken"`
|
||||
PublicDashboardsEnabled bool `json:"publicDashboardsEnabled"`
|
||||
|
||||
CloudMigrationIsTarget bool `json:"cloudMigrationIsTarget"`
|
||||
|
||||
DateFormats setting.DateFormats `json:"dateFormats,omitempty"`
|
||||
|
||||
LoginError string `json:"loginError,omitempty"`
|
||||
|
@ -94,6 +94,8 @@ func (hs *HTTPServer) GetFrontendSettings(c *contextmodel.ReqContext) {
|
||||
}
|
||||
|
||||
// getFrontendSettings returns a json object with all the settings needed for front end initialisation.
|
||||
//
|
||||
//nolint:gocyclo
|
||||
func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.FrontendSettingsDTO, error) {
|
||||
availablePlugins, err := hs.availablePlugins(c.Req.Context(), c.SignedInUser.GetOrgID())
|
||||
if err != nil {
|
||||
@ -161,6 +163,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
hasAccess := accesscontrol.HasAccess(hs.AccessControl, c)
|
||||
secretsManagerPluginEnabled := kvstore.EvaluateRemoteSecretsPlugin(c.Req.Context(), hs.secretsPluginManager, hs.Cfg) == nil
|
||||
trustedTypesDefaultPolicyEnabled := (hs.Cfg.CSPEnabled && strings.Contains(hs.Cfg.CSPTemplate, "require-trusted-types-for")) || (hs.Cfg.CSPReportOnlyEnabled && strings.Contains(hs.Cfg.CSPReportOnlyTemplate, "require-trusted-types-for"))
|
||||
isCloudMigrationTarget := hs.Features.IsEnabled(c.Req.Context(), featuremgmt.FlagOnPremToCloudMigrations) && hs.Cfg.CloudMigrationIsTarget
|
||||
|
||||
frontendSettings := &dtos.FrontendSettingsDTO{
|
||||
DefaultDatasource: defaultDS,
|
||||
@ -218,6 +221,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
DisableFrontendSandboxForPlugins: hs.Cfg.DisableFrontendSandboxForPlugins,
|
||||
PublicDashboardAccessToken: c.PublicDashboardAccessToken,
|
||||
PublicDashboardsEnabled: hs.Cfg.PublicDashboardsEnabled,
|
||||
CloudMigrationIsTarget: isCloudMigrationTarget,
|
||||
SharedWithMeFolderUID: folder.SharedWithMeFolderUID,
|
||||
RootFolderUID: accesscontrol.GeneralFolderUID,
|
||||
LocalFileSystemAvailable: hs.Cfg.LocalFileSystemAvailable,
|
||||
|
@ -495,6 +495,9 @@ type Cfg struct {
|
||||
// Public dashboards
|
||||
PublicDashboardsEnabled bool
|
||||
|
||||
// Cloud Migration
|
||||
CloudMigrationIsTarget bool
|
||||
|
||||
// Feature Management Settings
|
||||
FeatureManagement FeatureMgmtSettings
|
||||
|
||||
@ -1286,6 +1289,7 @@ func (cfg *Cfg) parseINIFile(iniFile *ini.File) error {
|
||||
|
||||
cfg.readFeatureManagementConfig()
|
||||
cfg.readPublicDashboardsSettings()
|
||||
cfg.readCloudMigrationSettings()
|
||||
|
||||
// read experimental scopes settings.
|
||||
scopesSection := iniFile.Section("scopes")
|
||||
@ -2005,3 +2009,8 @@ func (cfg *Cfg) readPublicDashboardsSettings() {
|
||||
publicDashboards := cfg.Raw.Section("public_dashboards")
|
||||
cfg.PublicDashboardsEnabled = publicDashboards.Key("enabled").MustBool(true)
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readCloudMigrationSettings() {
|
||||
cloudMigration := cfg.Raw.Section("cloud_migration")
|
||||
cfg.CloudMigrationIsTarget = cloudMigration.Key("is_target").MustBool(false)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user