Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Kidswiss committed Sep 20, 2024
1 parent 853c130 commit 0dc4904
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ __debug_bin*

hack/res
hack/tmp
hack/diff/function.yaml
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,6 @@ install-proxy:

.PHONY: render-diff
render-diff: docker-build-branchtag ## Render diff between the cluter in KUBECONF and the local branch
pwd
ls -al hack/diff
hack/diff/compare.sh
18 changes: 12 additions & 6 deletions hack/diff/compare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function get_state() {
name="$2"
dir_name="hack/tmp/$type-$name"

echo "getting state of $type/$name"

mkdir -p "$dir_name"

while read -r res_type res_name
Expand Down Expand Up @@ -49,7 +51,7 @@ function run_single_diff() {

kubectl get "$type" "$name" -oyaml > hack/tmp/xr.yaml
comp=$(kubectl get "$type" "$name" -oyaml | yq -r '.spec.compositionRef.name')
echo "composition: $comp"
echo "composition: $comp $type/$name"
kubectl get compositions.apiextensions.crossplane.io "$comp" -oyaml > hack/tmp/composition.yaml
go run github.com/crossplane/crossplane/cmd/[email protected] render hack/tmp/xr.yaml hack/tmp/composition.yaml hack/diff/function.yaml -o "$dir_name" > "$res_dir_name/$3.yaml"
}
Expand All @@ -65,21 +67,25 @@ function get_pnt_func_version() {
function template_func_file() {
export PNT_VERSION=$1
export APPCAT_VERSION=$2
cat "$(dirname "$0")/function.yaml.tmpl" | envsubst > "$(dirname "$0")/function.yaml"
}
function diff_func() {
run_func "$1"
# run_func "$1"
trap stop_func EXIT
while read -r type name rest
do
get_state "$type" "$name"
# we only get the state on the first run for two reasons:
# speed things up
# avoid any diffs that could come from actual changes on the cluster
[ "first" == "$2" ] && get_state "$type" "$name"
get_claim_namespace "$type" "$name"
run_single_diff "$type" "$name" "$2"
done <<< "$(kubectl get composite --no-headers | sed 's/\// /g' )"
stop_func
# stop_func
}
# do the diff
Expand Down Expand Up @@ -115,11 +121,11 @@ function clean() {
rm -rf "$(dirname "$0")/function.yaml"
}
stop_func
# stop_func
clean
trap clean EXIT
template_func_file "$(get_pnt_func_version)"
template_func_file "$(get_pnt_func_version)" "$(get_running_func_version)"
echo "Render live manifests"
first_diff
Expand Down
8 changes: 4 additions & 4 deletions hack/diff/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ kind: Function
metadata:
name: function-appcat
annotations:
render.crossplane.io/runtime: Development
render.crossplane.io/runtime-docker-cleanup: Stop
spec:
# The tag here doesn't matter, as the annotation above instructs
# crank to connect to a local grpc endpoint.
package: ghcr.io/vshn/appcat:v4.92.0-func
package: ghcr.io/vshn/appcat:add_diff_script
---
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata:
name: function-patch-and-transform
annotations:
render.crossplane.io/runtime-docker-cleanup: Stop
spec:
package: xpkg.upbound.io/crossplane-contrib/function-patch-and-transform:v0.1.4
8 changes: 4 additions & 4 deletions hack/diff/function.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ kind: Function
metadata:
name: function-appcat
annotations:
render.crossplane.io/runtime: Development
render.crossplane.io/runtime-docker-cleanup: Stop
spec:
# The tag here doesn't matter, as the annotation above instructs
# crank to connect to a local grpc endpoint.
package: ghcr.io/vshn/appcat:v4.92.0-func
package: ghcr.io/vshn/appcat:$APPCAT_VERSION
---
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata:
name: function-patch-and-transform
annotations:
render.crossplane.io/runtime-docker-cleanup: Stop
spec:
package: xpkg.upbound.io/crossplane-contrib/function-patch-and-transform:$PNT_VERSION

0 comments on commit 0dc4904

Please sign in to comment.