Skip to content

Commit

Permalink
chore: Use only GF_* env vars in backend
Browse files Browse the repository at this point in the history
Signed-off-by: Mahendra Paipuri <mahendra.paipuri@gmail.com>
  • Loading branch information
mahendrapaipuri committed Jul 12, 2024
1 parent d5f4b7d commit 6f6da02
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .ci/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ services:
- GF_SERVER_PROTOCOL=https
- GF_SERVER_CERT_KEY=/etc/grafana/tls/localhost.key
- GF_SERVER_CERT_FILE=/etc/grafana/tls/localhost.crt
- IGNORE_HTTPS_ERRORS=true
- GF_REPORTER_PLUGIN_IGNORE_HTTPS_ERRORS=true
# Grafana image renderer
- GF_RENDERING_SERVER_URL=http://renderer_tls:8081/render
- GF_RENDERING_CALLBACK_URL=https://grafana_tls:${GF_SERVER_HTTP_PORT:-3000}/
Expand Down
5 changes: 2 additions & 3 deletions pkg/plugin/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ func loadSettings(data json.RawMessage, secureData map[string]string) (*Config,
if os.Getenv("GF_APP_URL") != "" {
config.AppURL = os.Getenv("GF_APP_URL")
}
// grafana-image-renderer uses IGNORE_HTTPS_ERRORS to skip TLS check and we
// leverage it here
if os.Getenv("IGNORE_HTTPS_ERRORS") != "" || os.Getenv("GF_REPORTER_PLUGIN_IGNORE_HTTPS_ERRORS") != "" {
// Only allow configuring using GF_* env vars
if os.Getenv("GF_REPORTER_PLUGIN_IGNORE_HTTPS_ERRORS") != "" {
config.SkipTLSCheck = true
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestSettings(t *testing.T) {
func TestSettingsWithEnvVars(t *testing.T) {
// Set env vars
t.Setenv("GF_APP_URL", "https://localhost:3000")
t.Setenv("IGNORE_HTTPS_ERRORS", "true")
t.Setenv("GF_REPORTER_PLUGIN_IGNORE_HTTPS_ERRORS", "true")

Convey("When creating a new config from empty JSONData", t, func() {
const configJSON = `{}`
Expand Down
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ The following configuration parameters are directly tied to Grafana instance

- `skipTlsCheck`: If Grafana instance is configured to use TLS with self signed certificates
set this parameter to `true` to skip TLS certificate check. This can be set using
environment variable `IGNORE_HTTPS_ERRORS` as well. If the environment variable is
environment variable `GF_REPORTER_PLUGIN_IGNORE_HTTPS_ERRORS` as well. If the environment variable is
found, it will take precedence over the value set it the config.

> [!IMPORTANT]
Expand Down

0 comments on commit 6f6da02

Please sign in to comment.