Skip to content

Commit

Permalink
Fix create-deployment-kpt.sh: only manipulate the 'porch-controllers'…
Browse files Browse the repository at this point in the history
… Deployment resource, as opposed to all resources in the 9-controllers.yaml file
  • Loading branch information
kispaljr committed May 27, 2024
1 parent 29119eb commit a0fc113
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions scripts/create-deployment-kpt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,25 @@ function load-custom-images {
}

function main() {

echo "Loading images into kind cluster ${KIND_CONTEXT_NAME}..."
load-custom-images

echo "Preparing porch kpt package in ${DESTINATION}..."
rm -rf ${DESTINATION}/porch || true
kpt pkg get https://github.com/nephio-project/catalog/tree/main/nephio/core/porch ${DESTINATION}

yq -i eval 'del(.spec.template.spec.containers[0].env)' "${DESTINATION}/porch/9-controllers.yaml"
yq -i eval '.spec.template.spec.containers[0].env = []' "${DESTINATION}/porch/9-controllers.yaml"

IFS=',' read -ra RECONCILERS <<< "$ENABLED_RECONCILERS"
for i in "${RECONCILERS[@]}"; do
# Update the porch-controllers Deployment env variables to enable the reconciler.
RECONCILER_ENV_VAR="ENABLE_$(echo "$i" | tr '[:lower:]' '[:upper:]')"
reconciler="$RECONCILER_ENV_VAR" \
yq -i eval '.spec.template.spec.containers[0].env += {"name": env(reconciler), "value": "true"}' \
"${DESTINATION}/porch/9-controllers.yaml"
done
kpt fn eval ${DESTINATION}/porch \
--image gcr.io/kpt-fn/starlark:v0.5.0 \
--match-kind Deployment \
--match-name porch-controllers \
--match-namespace porch-system \
-- "reconcilers=$ENABLED_RECONCILERS" 'source=
reconcilers = ctx.resource_list["functionConfig"]["data"]["reconcilers"].split(",")
for resource in ctx.resource_list["items"]:
c = resource["spec"]["template"]["spec"]["containers"][0]
c["env"] = []
for r in reconcilers:
c["env"].append({"name": "ENABLE_" + r.upper(), "value": "true"})
'

customize-pkg-images \
"porch-server:v2.0.0" \
Expand All @@ -159,7 +162,12 @@ function main() {
"porch-wrapper-server:v2.0.0" \
"${WRAPPER_SERVER_IMAGE}"

echo "Deploying porch with newly built images..."
deploy-porch-dev-pkg

echo
echo Done.
echo
}

validate
Expand Down

0 comments on commit a0fc113

Please sign in to comment.