Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use specified name for dashboard env var using valueFrom #1869

Merged
merged 1 commit into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions controllers/content/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ func (h *ContentResolver) getDashboardEnvs(ctx context.Context) (map[string]stri
if ref.Value != "" {
envs[ref.Name] = ref.Value
} else {
val, key, err := h.getReferencedValue(ctx, h.resource, ref.ValueFrom)
_, val, err := h.getReferencedValue(ctx, h.resource, ref.ValueFrom)
if err != nil {
return nil, fmt.Errorf("something went wrong processing referenced env %s, error: %w", ref.Name, err)
}
envs[key] = val
envs[ref.Name] = val
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/example-test/07-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: grafana-dashboard-jsonnet-project
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: jsonnet-env-vars
status:
conditions:
- type: DashboardSynchronized
status: "True"
17 changes: 0 additions & 17 deletions tests/e2e/example-test/07-jsonnet-project.yaml

This file was deleted.

72 changes: 72 additions & 0 deletions tests/e2e/example-test/07-jsonnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: "grafana-dashboard-jsonnet-project"
spec:
instanceSelector:
matchLabels:
dashboards: "grafana"
envs:
- name: "ENV"
value: "test"
jsonnetLib:
jPath:
- "vendor"
fileName: "test.jsonnet"
gzipJsonnetProject: |-
H4sIADxf5mQAA+2R3QqCMBiGPfYqPrwA3damZES3UEd1amtWYi50OiK690ZJYPR3UES05+B7Ybx8P3uzShaFUONSZoKrwPkECKGIMThpeFZE6FlbAFMaYcqiHsOAMGM4coB9ZJsr6kolpVlF5iITy1O56TO2NH3Qp73joj9C1s1fNqJs1kL77ftbZpj/CCm9nz8mpJs/MT7iAHrL9Cf8ef655EkObdowBNi7YPDqMvdi8FZKbas4CLTW/k7Wqp4Ln8tNoBPFV6NmuJhoqvvT5YxPPPcwcN394dsXWSwWi+UVjj9zQO4ACgAA
---
apiVersion: v1
kind: ConfigMap
metadata:
name: jsonnet-env-vars
data:
value: from-conf-map
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: jsonnet-env-vars
spec:
instanceSelector:
matchLabels:
dashboards: "grafana"
envs:
- name: LITERAL
value: literal
- name: CONF_MAP
valueFrom:
configMapKeyRef:
name: jsonnet-env-vars
key: value
jsonnet: >
{
"id": null,
"title": "jsonnet env vars",
"tags": [std.extVar("LITERAL"),std.extVar("CONF_MAP")],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"graphTooltip": 1,
"panels": [],
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [],
"refresh_intervals": []
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
"refresh": "5s",
"schemaVersion": 17,
"version": 0,
"links": []
}
2 changes: 1 addition & 1 deletion tests/e2e/example-test/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ spec:
- name: step-07
try:
- apply:
file: 07-jsonnet-project.yaml
file: 07-jsonnet.yaml
- assert:
file: 07-assert.yaml
- name: step-08
Expand Down