Skip to content

Commit e467bd2

Browse files
committed
feat: add init.sh post-initialization script (#88)
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 <moritz@schmitzvonhuelst.de>
1 parent 9924336 commit e467bd2

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

init.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
# This script helps initialize a new function project by
4+
# replacing all instances of function-template-python with the
5+
# name of your function. The script accepts two arguments:
6+
# 1. The name of your function
7+
# 2. The path to your function directory
8+
9+
set -e
10+
11+
cd "$2" || return
12+
13+
# Replace function-template-python with the name of your function
14+
# in package/crossplane.yaml
15+
perl -pi -e s,function-template-python,"$1",g package/crossplane.yaml
16+
# in example YAML files
17+
find example -type f -print0 | xargs -0 -I {} perl -pi -e s,function-template-python,"$1",g {}
18+
19+
echo "Function $1 has been initialized successfully"

0 commit comments

Comments
 (0)