---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - ../../../base/gitea

helmCharts:
  - name: gitea
    repo: oci://docker.gitea.com/charts
    version: "12.6.0"
    releaseName: gitea
    namespace: gitea
    valuesFile: values.yaml

# The chart renders a `helm.sh/hook: test` connection Pod (busybox). We deploy
# via kustomize+ArgoCD (not `helm test`), so drop it rather than leave an orphan
# Pod pulling an unallowlisted image.
patches:
  - target:
      version: v1
      kind: Pod
      name: gitea-test-connection
    patch: |-
      $patch: delete
      apiVersion: v1
      kind: Pod
      metadata:
        name: gitea-test-connection
  # The chart renders the http Service with `targetPort: null` (it defaults the
  # target to the port name, which kustomize drops); pin it to 3000 so the
  # manifest is valid and the HTTPRoute backend resolves.
  - target:
      version: v1
      kind: Service
      name: gitea-http
    patch: |-
      - op: replace
        path: /spec/ports/0/targetPort
        value: 3000
  # SSH is disabled (DISABLE_SSH); drop the ssh Service the chart still renders.
  - target:
      version: v1
      kind: Service
      name: gitea-ssh
    patch: |-
      $patch: delete
      apiVersion: v1
      kind: Service
      metadata:
        name: gitea-ssh
