Skip to content

Not able to patch Oauth with patchType: application/strategic-merge-patch+json  #26

@donflavour

Description

@donflavour

I'm pretty sure that the following snippet worked before, but unfortunately with 0.1.4 I don't get it running anymore
OCP 4.8.35 & Patch operator 1.4.0

apiVersion: redhatcop.redhat.io/v1alpha1
kind: Patch
metadata:
  name: ldap
  namespace: my-namespace
spec:
  serviceAccountRef:
    name: patch-operator
  patches:
    ldap-oauth-provider:
      targetObjectRef:
        apiVersion: config.openshift.io/v1
        kind: OAuth
        name: cluster
      patchTemplate: |
        spec:
          identityProviders:
          - ldap:
              attributes:
                email:
                  - mail
                id:
                  - dn
                name:
                  - cn
                preferredUsername:
                  - cn
              bindDN: CN=<cn>,OU=<ou>,OU=<ou>,OU=<ou>,OU=<ou>,DC=<dc>,DC=<dc>
              bindPassword:
                name: ldap-secret
              ca:
                name: ldap-ca-bundle
              insecure: false
              url: "{{ (index . 1).data.url }}"
            mappingMethod: claim
            name: ldap
            type: LDAP   
      patchType: application/strategic-merge-patch+json
      sourceObjectRefs:
      - apiVersion: v1
        kind: ConfigMap
        name: ldap-url
        namespace: my-namespace

I'm receiving the following error message:

  Patch Statuses:
    Ldap - Oauth - Provider:
      /cluster:
        Last Transition Time:  2022-05-18T15:34:42Z
        Message:               the body of the request was in an unknown format - accepted media types include: application/json-patch+json, application/merge-patch+json, application/apply-patch+yaml
        Observed Generation:   15
        Reason:                LastReconcileCycleFailed
        Status:                True
        Type:                  ReconcileError

When I change the patchType to application/merge-patch+json, the patch is successfully reconciled but the existing oauth part (htpasswd) is overwritten.

Best
Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions