feat: pass gcom sso_api_token to repo created from install command (#98973)

* feat: pass gcom sso_api_token to repo created from install command

* fix

* fix: extract gcom section to a func

* Update pkg/cmd/grafana-cli/utils/command_line.go

Co-authored-by: Giuseppe Guerra <giuseppe.guerra@grafana.com>

* fix: only set gcom token when the request is to GCOM

---------

Co-authored-by: Giuseppe Guerra <giuseppe.guerra@grafana.com>
This commit is contained in:
Syerikjan Kh
2025-01-15 08:15:18 -05:00
committed by GitHub
co-authored by Giuseppe Guerra
parent 79fc26ea87
commit dfe0712955
8 changed files with 88 additions and 22 deletions
+10
View File
@@ -149,6 +149,8 @@ func StartGrafanaEnv(t *testing.T, grafDir, cfgPath string) (string, *server.Tes
// CreateGrafDir creates the Grafana directory.
// The log by default is muted in the regression test, to activate it, pass option EnableLog = true
//
//nolint:gocyclo
func CreateGrafDir(t *testing.T, opts GrafanaOpts) (string, string) {
t.Helper()
@@ -459,6 +461,13 @@ func CreateGrafDir(t *testing.T, opts GrafanaOpts) (string, string) {
_, err = grafanaComSection.NewKey("api_url", opts.GrafanaComAPIURL)
require.NoError(t, err)
}
if opts.GrafanaComSSOAPIToken != "" {
grafanaComSection, err := getOrCreateSection("grafana_com")
require.NoError(t, err)
_, err = grafanaComSection.NewKey("sso_api_token", opts.GrafanaComSSOAPIToken)
require.NoError(t, err)
}
if opts.UnifiedStorageConfig != nil {
for k, v := range opts.UnifiedStorageConfig {
section, err := getOrCreateSection(fmt.Sprintf("unified_storage.%s", k))
@@ -519,6 +528,7 @@ type GrafanaOpts struct {
QueryRetries int64
GrafanaComAPIURL string
UnifiedStorageConfig map[string]setting.UnifiedStorageConfig
GrafanaComSSOAPIToken string
// When "unified-grpc" is selected it will also start the grpc server
APIServerStorageType options.StorageType