#!/bin/sh
# Fix generated DeepCopy code to handle Spec/Status types correctly

if [ ! -f "apis/v1alpha1/zz_generated.deepcopy.go" ]; then
    echo "Generated file not found, skipping fix"
    exit 0
fi

# Fix all DeepCopyInto calls for Spec/Status to use value assignment instead
# This works because Go structs are copied by value
sed -i.bak \
    -e 's/in\.Spec\.DeepCopyInto(&out\.Spec)/out.Spec = in.Spec/g' \
    -e 's/in\.Status\.DeepCopyInto(&out\.Status)/out.Status = in.Status/g' \
    -e 's/in\.Spec\.DeepCopyInto(out\.Spec)/out.Spec = in.Spec/g' \
    -e 's/in\.Status\.DeepCopyInto(out\.Status)/out.Status = in.Status/g' \
    apis/v1alpha1/zz_generated.deepcopy.go

# Remove backup file
rm -f apis/v1alpha1/zz_generated.deepcopy.go.bak

echo "Fixed DeepCopy code"

