---
# Direct test pod for the image hook orchestrator.
#
# This manifest runs the hook outside Forklift against a live VM.
# It is intentionally destructive: the hook stops the VM if it is running,
# creates PXD PVCs, copies FADA -> PXD, optionally verifies the copy, deletes
# the original FADA PVCs, rebinds the original PVC names to PXD PVs, and starts
# the VM again if it was running.
#
# The hook reads plan.yml and workload.yml from /tmp/hook (mounted from the
# ConfigMap below). Only the target namespace, StorageMap reference, VM name,
# and VM ID are required. VM PVCs are discovered from the live KubeVirt VM spec.
#
# Prerequisites:
#   1. Apply RBAC and runtime config:
#   2. Fill in all <placeholder> values in this file, including the hook image.
#   3. Delete any previous debug pod, then apply:
#        kubectl delete pod test-hook-<vm-name> -n openshift-mtv --ignore-not-found
#        kubectl apply -f test-hook-pod.yaml
#   4. Watch logs:
#        kubectl logs -f test-hook-<vm-name> -n openshift-mtv

# ConfigMap that simulates the Forklift hook mount at /tmp/hook.
apiVersion: v1
kind: ConfigMap
metadata:
  name: test-hook-<vm-name>
  namespace: openshift-mtv
data:
  plan.yml: |
    targetnamespace: <plan-target-namespace>
    vms:
      - ref:
          name: <vm-name>
          id: <vm-id>
    map:
      storage:
        name: <storage-map-name>
        namespace: openshift-mtv

  workload.yml: |
    vm:
      vm1:
        vm0:
          name: <vm-name>
          id: <vm-id>

---
# Pod that runs the image hook binary directly.
apiVersion: v1
kind: Pod
metadata:
  name: test-hook-<vm-name>
  namespace: openshift-mtv
  labels:
    app: fa-pxd-direct-hook-test
    vm: <vm-name>
spec:
  serviceAccountName: fa-pxd-converter
  restartPolicy: Never
  containers:
    - name: hook
      image: <hook-image>
      imagePullPolicy: Always
      volumeMounts:
        - name: hook
          mountPath: /tmp/hook
          readOnly: true
      resources:
        limits:
          cpu: "1"
          memory: 512Mi
        requests:
          cpu: 100m
          memory: 128Mi
  volumes:
    - name: hook
      configMap:
        name: test-hook-<vm-name>