apiVersion: troubleshoot.sh/v1beta3
kind: SupportBundle
metadata:
  name: optional-secrets-example
spec:
  collectors:
    # Required database - collection will fail if secret doesn't exist
    - postgres:
        collectorName: required-db
        uri:
          valueFrom:
            secretKeyRef:
              name: required-postgres
              key: uri
              optional: false  # Default behavior - secret must exist

    # Optional database - collection continues if secret doesn't exist
    - postgres:
        collectorName: optional-db
        uri:
          valueFrom:
            secretKeyRef:
              name: optional-postgres
              key: uri
              optional: true  # Gracefully degrades if secret is missing

    # Mixed required and optional TLS
    - postgres:
        collectorName: partially-optional
        uri: "postgresql://localhost:5432/db"
        tls:
          cacert:
            valueFrom:
              secretKeyRef:
                name: tls-certs
                key: ca.crt
                optional: false  # CA cert is required
          clientCert:
            valueFrom:
              secretKeyRef:
                name: tls-certs
                key: client.crt
                optional: true  # Client cert is optional (cert-only TLS)
          clientKey:
            valueFrom:
              secretKeyRef:
                name: tls-certs
                key: client.key
                optional: true  # Client key is optional
---
apiVersion: v1
kind: Secret
metadata:
  name: required-postgres
type: Opaque
stringData:
  uri: "postgresql://user:pass@required-postgres:5432/db"
# Note: optional-postgres secret intentionally not created
