mirror of https://github.com/grafana/grafana.git
Secrets: Adding developer mode config (#111008)
adding developer mode and feature flags for e2e tests
This commit is contained in:
parent
fcf781c24a
commit
1f071f5bd7
|
@ -25,7 +25,7 @@ func RegisterDependencies(
|
||||||
}
|
}
|
||||||
|
|
||||||
// We shouldn't need to create the DB in HG, as that will use the MT api server.
|
// We shouldn't need to create the DB in HG, as that will use the MT api server.
|
||||||
if cfg.StackID == "" {
|
if cfg.StackID == "" || cfg.SecretsManagement.IsDeveloperMode {
|
||||||
// Some DBs that claim to be MySQL/Postgres-compatible might not support table locking.
|
// Some DBs that claim to be MySQL/Postgres-compatible might not support table locking.
|
||||||
lockDatabase := cfg.Raw.Section("database").Key("migration_locking").MustBool(true)
|
lockDatabase := cfg.Raw.Section("database").Key("migration_locking").MustBool(true)
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ type SecretsManagerSettings struct {
|
||||||
GCWorkerPollInterval time.Duration
|
GCWorkerPollInterval time.Duration
|
||||||
// How long to wait for the process to clean up a secure value to complete.
|
// How long to wait for the process to clean up a secure value to complete.
|
||||||
GCWorkerPerSecureValueCleanupTimeout time.Duration
|
GCWorkerPerSecureValueCleanupTimeout time.Duration
|
||||||
|
// Whether the secrets management is running in developer mode.
|
||||||
|
IsDeveloperMode bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg *Cfg) readSecretsManagerSettings() {
|
func (cfg *Cfg) readSecretsManagerSettings() {
|
||||||
|
@ -53,6 +55,8 @@ func (cfg *Cfg) readSecretsManagerSettings() {
|
||||||
cfg.SecretsManagement.GCWorkerPollInterval = secretsMgmt.Key("gc_worker_poll_interval").MustDuration(1 * time.Minute)
|
cfg.SecretsManagement.GCWorkerPollInterval = secretsMgmt.Key("gc_worker_poll_interval").MustDuration(1 * time.Minute)
|
||||||
cfg.SecretsManagement.GCWorkerPerSecureValueCleanupTimeout = secretsMgmt.Key("gc_worker_per_request_timeout").MustDuration(5 * time.Second)
|
cfg.SecretsManagement.GCWorkerPerSecureValueCleanupTimeout = secretsMgmt.Key("gc_worker_per_request_timeout").MustDuration(5 * time.Second)
|
||||||
|
|
||||||
|
cfg.SecretsManagement.IsDeveloperMode = secretsMgmt.Key("developer_mode").MustBool(false)
|
||||||
|
|
||||||
// Extract available KMS providers from configuration sections
|
// Extract available KMS providers from configuration sections
|
||||||
providers := make(map[string]map[string]string)
|
providers := make(map[string]map[string]string)
|
||||||
for _, section := range cfg.Raw.Sections() {
|
for _, section := range cfg.Raw.Sections() {
|
||||||
|
|
|
@ -170,4 +170,26 @@ domain = example.com
|
||||||
assert.Equal(t, MisconfiguredProvider, cfg.SecretsManagement.CurrentEncryptionProvider)
|
assert.Equal(t, MisconfiguredProvider, cfg.SecretsManagement.CurrentEncryptionProvider)
|
||||||
assert.Empty(t, cfg.SecretsManagement.ConfiguredKMSProviders)
|
assert.Empty(t, cfg.SecretsManagement.ConfiguredKMSProviders)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("should handle configuration with developer mode on", func(t *testing.T) {
|
||||||
|
iniContent := `
|
||||||
|
[secrets_manager]
|
||||||
|
developer_mode = true
|
||||||
|
`
|
||||||
|
cfg, err := NewCfgFromBytes([]byte(iniContent))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
assert.True(t, cfg.SecretsManagement.IsDeveloperMode)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("should handle configuration without developer mode set", func(t *testing.T) {
|
||||||
|
iniContent := `
|
||||||
|
[secrets_manager]
|
||||||
|
encryption_provider = aws_kms
|
||||||
|
`
|
||||||
|
cfg, err := NewCfgFromBytes([]byte(iniContent))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
assert.False(t, cfg.SecretsManagement.IsDeveloperMode)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ publicDashboards=true
|
||||||
grafanaAPIServer=true
|
grafanaAPIServer=true
|
||||||
queryLibrary=true
|
queryLibrary=true
|
||||||
queryService=true
|
queryService=true
|
||||||
|
secretsManagementAppPlatform = true
|
||||||
|
secretsManagementAppPlatformUI = true
|
||||||
|
|
||||||
[environment]
|
[environment]
|
||||||
stack_id = 12345
|
stack_id = 12345
|
||||||
|
@ -36,3 +38,6 @@ host = localhost:7777
|
||||||
|
|
||||||
[cloud_migration]
|
[cloud_migration]
|
||||||
developer_mode = true ; Enable developer mode to use in-memory implementations of 3rdparty services needed.
|
developer_mode = true ; Enable developer mode to use in-memory implementations of 3rdparty services needed.
|
||||||
|
|
||||||
|
[secrets_manager]
|
||||||
|
developer_mode = true
|
||||||
|
|
Loading…
Reference in New Issue