Skip to content

Commit

Permalink
✅ Add a test for kpt
Browse files Browse the repository at this point in the history
kpt wants a function configuration at once.
  • Loading branch information
antoinemartin committed Jan 26, 2023
1 parent 9beefad commit 788be67
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 18 deletions.
17 changes: 17 additions & 0 deletions tests/multi-replacement/functions/01_multi-transformation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: builtin
kind: LocalConfiguration
metadata:
name: configuration-map
annotations:
config.kaweezle.com/inject-local: "true"
config.kubernetes.io/function: |
exec:
path: ../../krmfnbuiltin
data:
sish:
server: target.link
hostname: myhost.target.link
host_key: AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAID+4/eqtPTLC18TE8ZP7NeF4ZP68/wnY2d7mhH/KVs79AAAABHNzaDo=
traefik:
dashboard_enabled: true
expose: true
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
apiVersion: builtin
kind: LocalConfiguration
metadata:
name: configuration-map
annotations:
config.kaweezle.com/inject-local: "true"
config.kubernetes.io/function: |
exec:
path: ../../krmfnbuiltin
data:
sish:
server: target.link
hostname: myhost.target.link
host_key: AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAID+4/eqtPTLC18TE8ZP7NeF4ZP68/wnY2d7mhH/KVs79AAAABHNzaDo=
traefik:
dashboard_enabled: true
expose: true
---
apiVersion: builtin
kind: ReplacementTransformer
metadata:
name: replacement-transformer
Expand Down
32 changes: 32 additions & 0 deletions tests/test_krmfnbuiltin_kpt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# DEPENDENCEIS
# kustomize
# yq

#set -uexo pipefail
set -e pipefail

temp_file=$(mktemp)
temp_file_2=$(mktemp)

trap "find . -type d -name 'applications' -exec rm -rf {} +; rm -f $temp_file $temp_file_2" EXIT

for d in $(ls -d */); do
echo "Running Test in $d..."
cd $d
rm -rf applications
echo " > Performing kustomizations..."
kpt fn source original >$temp_file
for f in functions/*; do
cat $temp_file | kpt fn eval - --exec ../../krmfnbuiltin --fn-config $f >$temp_file_2
mv $temp_file_2 $temp_file
done
cat $temp_file | kpt fn sink applications
for f in $(ls -1 expected); do
echo " > Checking $f..."
diff <(yq eval -P expected/$f) <(yq eval -P applications/$f)
done
cd ..
done
echo "Done ok 🎉"

0 comments on commit 788be67

Please sign in to comment.