From 5fac6a6ff8b1f01c1765744454a18944936974fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Schmitz=20von=20H=C3=BClst?= Date: Tue, 28 Apr 2026 08:38:51 +0200 Subject: [PATCH] feat: add init.sh post-initialization script (#88) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a post-initialization script that replaces all instances of function-template-python with the user's function name in: - package/crossplane.yaml (the Function resource name) - example/*.yaml (example function references) This enables the Crossplane CLI's xpkg init command to properly initialize the template by running the init.sh hook automatically. Fixes #88 Signed-off-by: Moritz Schmitz von Hülst --- init.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 init.sh diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..385fe63 --- /dev/null +++ b/init.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# This script helps initialize a new function project by +# replacing all instances of function-template-python with the +# name of your function. The script accepts two arguments: +# 1. The name of your function +# 2. The path to your function directory + +set -e + +cd "$2" || return + +# Replace function-template-python with the name of your function +# in package/crossplane.yaml +perl -pi -e s,function-template-python,"$1",g package/crossplane.yaml +# in example YAML files +find example -type f -print0 | xargs -0 -I {} perl -pi -e s,function-template-python,"$1",g {} + +echo "Function $1 has been initialized successfully"