E2C: Add cloud migration is_target server config option (#83419)

This commit is contained in:
Josh Hunt 2024-03-11 12:29:44 +00:00 committed by GitHub
parent fa888af212
commit 1ab8857e48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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"`

View File

@ -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,

View File

@ -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)
}