---
# Source: openshift-console-plugin/templates/patcher-serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: console-functions-plugin-patcher
  labels:
    helm.sh/chart: openshift-console-plugin-0.1.0
    app: console-functions-plugin
    app.kubernetes.io/name: console-functions-plugin
    app.kubernetes.io/instance: console-functions-plugin
    app.kubernetes.io/part-of: console-functions-plugin
    app.kubernetes.io/managed-by: Helm
---
# Source: openshift-console-plugin/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: console-functions-plugin
  labels:
    helm.sh/chart: openshift-console-plugin-0.1.0
    app: console-functions-plugin
    app.kubernetes.io/name: console-functions-plugin
    app.kubernetes.io/instance: console-functions-plugin
    app.kubernetes.io/part-of: console-functions-plugin
    app.kubernetes.io/managed-by: Helm
---
# Source: openshift-console-plugin/templates/patcher-clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: console-functions-plugin-patcher
  namespace: console-functions-plugin
  labels:
    helm.sh/chart: openshift-console-plugin-0.1.0
    app: console-functions-plugin
    app.kubernetes.io/name: console-functions-plugin
    app.kubernetes.io/instance: console-functions-plugin
    app.kubernetes.io/part-of: console-functions-plugin
    app.kubernetes.io/managed-by: Helm
rules:
  - apiGroups: ["operator.openshift.io"]
    resources: ["consoles"]
    verbs: ["get","list","patch", "update"]
---
# Source: openshift-console-plugin/templates/patcher-clusterrolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: console-functions-plugin-patcher
  namespace: console-functions-plugin
  labels:
    helm.sh/chart: openshift-console-plugin-0.1.0
    app: console-functions-plugin
    app.kubernetes.io/name: console-functions-plugin
    app.kubernetes.io/instance: console-functions-plugin
    app.kubernetes.io/part-of: console-functions-plugin
    app.kubernetes.io/managed-by: Helm
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: console-functions-plugin-patcher
subjects:
  - kind: ServiceAccount
    name: console-functions-plugin-patcher
    namespace: console-functions-plugin
---
# Source: openshift-console-plugin/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  annotations:
    service.alpha.openshift.io/serving-cert-secret-name: console-functions-plugin-cert
  name: console-functions-plugin
  namespace: console-functions-plugin
  labels:
    helm.sh/chart: openshift-console-plugin-0.1.0
    app: console-functions-plugin
    app.kubernetes.io/name: console-functions-plugin
    app.kubernetes.io/instance: console-functions-plugin
    app.kubernetes.io/part-of: console-functions-plugin
    app.kubernetes.io/managed-by: Helm
spec:
  ports:
    - name: 9443-tcp
      protocol: TCP
      port: 9443
      targetPort: 9443
  selector:
    app: console-functions-plugin
    app.kubernetes.io/name: console-functions-plugin
    app.kubernetes.io/instance: console-functions-plugin
    app.kubernetes.io/part-of: console-functions-plugin
  type: ClusterIP
  sessionAffinity: None
---
# Source: openshift-console-plugin/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: console-functions-plugin
  namespace: console-functions-plugin
  labels:
    helm.sh/chart: openshift-console-plugin-0.1.0
    app: console-functions-plugin
    app.kubernetes.io/name: console-functions-plugin
    app.kubernetes.io/instance: console-functions-plugin
    app.kubernetes.io/part-of: console-functions-plugin
    app.kubernetes.io/managed-by: Helm
    app.openshift.io/runtime-namespace: console-functions-plugin
spec:
  replicas: 2
  selector:
    matchLabels:
      app: console-functions-plugin
      app.kubernetes.io/name: console-functions-plugin
      app.kubernetes.io/instance: console-functions-plugin
      app.kubernetes.io/part-of: console-functions-plugin
  template:
    metadata:
      labels:
        helm.sh/chart: openshift-console-plugin-0.1.0
        app: console-functions-plugin
        app.kubernetes.io/name: console-functions-plugin
        app.kubernetes.io/instance: console-functions-plugin
        app.kubernetes.io/part-of: console-functions-plugin
        app.kubernetes.io/managed-by: Helm
    spec:
      containers:
        - name: console-functions-plugin
          image: ghcr.io/twogiants/console-functions-plugin@sha256:4ea185d4b043454ea9bb1823434f93c59f11eec4030aea837fb3e631d337f649
          ports:
            - containerPort: 9443
              protocol: TCP
          args:
            - "--https-port=9443"
          imagePullPolicy: IfNotPresent
          securityContext: 
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
          resources:
            requests:
              cpu: 10m
              memory: 50Mi
          volumeMounts:
            - name: console-functions-plugin-cert
              readOnly: true
              mountPath: /var/cert
      volumes:
        - name: console-functions-plugin-cert
          secret:
            secretName: console-functions-plugin-cert
            defaultMode: 420
      restartPolicy: Always
      dnsPolicy: ClusterFirst
      securityContext: 
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
---
# Source: openshift-console-plugin/templates/consoleplugin.yaml
apiVersion: console.openshift.io/v1
kind: ConsolePlugin
metadata:
  name: console-functions-plugin
  labels:
    helm.sh/chart: openshift-console-plugin-0.1.0
    app: console-functions-plugin
    app.kubernetes.io/name: console-functions-plugin
    app.kubernetes.io/instance: console-functions-plugin
    app.kubernetes.io/part-of: console-functions-plugin
    app.kubernetes.io/managed-by: Helm
spec:
  displayName: console-functions-plugin Plugin
  i18n: 
    loadType: Preload
  backend:
    type: Service
    service:
      name: console-functions-plugin
      namespace: console-functions-plugin
      port: 9443
      basePath: /
  proxy:
    - alias: backend
      endpoint:
        type: Service
        service:
          name: console-functions-plugin
          namespace: console-functions-plugin
          port: 9443
---
# Source: openshift-console-plugin/templates/patch-consoles-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
  name: console-functions-plugin-patcher
  namespace: console-functions-plugin
  labels:
    helm.sh/chart: openshift-console-plugin-0.1.0
    app: console-functions-plugin
    app.kubernetes.io/name: console-functions-plugin
    app.kubernetes.io/instance: console-functions-plugin
    app.kubernetes.io/part-of: console-functions-plugin
    app.kubernetes.io/managed-by: Helm
  annotations:
    helm.sh/hook: post-install,post-upgrade
    helm.sh/hook-delete-policy: before-hook-creation
spec:
  parallelism: 1
  template:
    metadata:
      labels:
        helm.sh/chart: openshift-console-plugin-0.1.0
        app: console-functions-plugin
        app.kubernetes.io/name: console-functions-plugin
        app.kubernetes.io/instance: console-functions-plugin
        app.kubernetes.io/part-of: console-functions-plugin
        app.kubernetes.io/managed-by: Helm
    spec:
      restartPolicy: OnFailure
      serviceAccountName: console-functions-plugin-patcher
      securityContext: 
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      terminationGracePeriodSeconds: 400
      dnsPolicy: ClusterFirst
      containers:
        - name: console-functions-plugin-patcher
          image: registry.redhat.io/openshift4/ose-tools-rhel9@sha256:ee65b244fc94d5765514c604dc0a288517dcdce68de65128d047622b6b30a618
          securityContext: 
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
          resources:
            requests:
              cpu: 10m
              memory: 50Mi
          command:
            - /bin/bash
            - -c
            - |
                existingPlugins=$(oc get consoles.operator.openshift.io cluster -o json | jq -c '.spec.plugins // []')
                mergedPlugins=$(jq --argjson existingPlugins "${existingPlugins}" --argjson consolePlugin '["console-functions-plugin"]' -c  -n '$existingPlugins + $consolePlugin | unique')
                patchedPlugins=$(jq --argjson mergedPlugins $mergedPlugins -n -c  '{ "spec": { "plugins": $mergedPlugins } }')
                oc patch consoles.operator.openshift.io cluster --patch $patchedPlugins  --type=merge
