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

Implement spec.uid for GrafanaDatasource #1735

Merged
merged 5 commits into from
Nov 11, 2024

Conversation

Baarsgaard
Copy link
Contributor

@Baarsgaard Baarsgaard commented Oct 28, 2024

I noticed the editable field actually does work, it is not used by the Operator, but is is part of the serialized payload and will configure the resulting datasource.
The same was true for OrgId

Manual Testing

make start-kind
kind export kubeconfig --name kind-grafana
kubectl delete grafana-operator --all
kubectl apply -f tests/example-resources.yaml
kubectl port-forward svc/grafana-testdata-service 3000 >/dev/null &
# Open http://localhost:3000/d/testdata-dash/new-dashboard
# username: root
# password: secret

kubectl apply -f tmp.yml
# See that the dashboard panel is populated with 2 new datasources
# One with a generated UID and one with a defined UID
# Repeatedly deleting and applying tmp.yml should result in a new UID for one of the datasources every time.

tmp.yml

---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDatasource
metadata:
  name: spec-uid
spec:
  resyncPeriod: 3s
  instanceSelector:
    matchLabels:
      test: "testdata"
  uid: spec-uid
  datasource:
    orgId: 1
    isDefault: true
    name: spec-uid
    type: grafana-testdata-datasource
    access: proxy
    basicAuth: false
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDatasource
metadata:
  name: metadata-uid
spec:
  resyncPeriod: 3s
  instanceSelector:
    matchLabels:
      test: "testdata"
  datasource:
    orgId: 1
    isDefault: true
    name: metadata-uid
    type: grafana-testdata-datasource
    access: proxy
    basicAuth: false

@Baarsgaard Baarsgaard marked this pull request as ready for review November 2, 2024 14:59
@theSuess theSuess enabled auto-merge November 11, 2024 09:02
@theSuess theSuess disabled auto-merge November 11, 2024 09:02
@theSuess theSuess enabled auto-merge November 11, 2024 09:03
@theSuess theSuess added this pull request to the merge queue Nov 11, 2024
Merged via the queue into grafana:master with commit 3b42b31 Nov 11, 2024
13 of 14 checks passed
@Baarsgaard Baarsgaard deleted the datasource_spec_uid branch November 11, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants