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

feat: contact point overrides #1670

Merged
merged 3 commits into from
Oct 3, 2024
Merged

feat: contact point overrides #1670

merged 3 commits into from
Oct 3, 2024

Conversation

theSuess
Copy link
Member

@theSuess theSuess commented Sep 9, 2024

Allows users to override settings using config maps or secrets.

I've intentionally not used the templating logic of data sources as IMHO this will cause more issues downstream, especially with contact point templates.

An example contact point would look like this:

apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaContactPoint
metadata:
  name: grafanacontactpoint-sample
spec:
  name: grafanacontactpoint-sample
  type: "email"
  instanceSelector:
    matchLabels:
      instance: my-grafana-cloud-stack
  settings:
    addresses: [email protected]
  valuesFrom:
    - targetPath: subject
      valueFrom:
        secretKeyRef:
          name: super-secret-data
          key: secret-subject

which will result in:

apiVersion: 1
contactPoints:
    - orgId: 1
      name: grafanacontactpoint-sample
      receivers:
        - uid: 5628b3a0-8fb1-44a8-a694-46bb8849c484
          type: email
          settings:
            addresses: [email protected]
            subject: <value-from-secret>
          disableResolveMessage: false

Fixes: #1595

for _, override := range contactPoint.Spec.ValuesFrom {
val, _, err := getReferencedValue(ctx, r.Client, contactPoint, override.ValueFrom)
if err != nil {
return nil, fmt.Errorf("getting referenced value: %w", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if one of the overrides fail, we would also not apply any others. If we wanted that, we could log and continue here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to fail early here to make sure we don't have a partially applied resource marked as success

Copy link
Collaborator

@pb82 pb82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, an example would be nice

@theSuess theSuess force-pushed the feat/contact-point-secrets branch from 0982039 to e50d440 Compare October 3, 2024 12:08
@theSuess theSuess enabled auto-merge October 3, 2024 12:18
@theSuess theSuess added this pull request to the merge queue Oct 3, 2024
Merged via the queue into master with commit ca143c5 Oct 3, 2024
14 checks passed
@theSuess theSuess deleted the feat/contact-point-secrets branch October 3, 2024 12:26
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.

GrafanaContactPoint doesn't support values from secretkeyref
2 participants