Skip to content

Commit 9c47e55

Browse files
authored
Use trap to delete temporary file (#3081)
Allows the last command to be `kpt fn eval` which will propagate its exit status.
1 parent 810f425 commit 9c47e55

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

porch/scripts/create-deployment-blueprint.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,27 @@ function customize-image-in-env {
131131
local NEW="${2}"
132132
local TAG="${NEW##*:}"
133133
local IMG="${NEW%:*}"
134+
local FN_CONFIG="${PORCH_DIR}/.build/set-image-config.yaml"
134135

135-
cat > set-image-config.yaml << EOF
136+
cat > "${FN_CONFIG}" << EOF
136137
apiVersion: fn.kpt.dev/v1alpha1
137138
kind: SetImage
138139
metadata:
139140
name: my-func-config
140141
image:
141142
name: ${OLD}
142143
newName: ${IMG}
143-
newTag: "${TAG}"
144+
newTag: ${TAG}
144145
additionalImageFields:
145146
- group: apps
146147
version: v1
147148
kind: Deployment
148149
path: spec/template/spec/containers[]/env[]/value
149150
EOF
150151

151-
kpt fn eval "${DESTINATION}" --image set-image:v0.1.0 --fn-config set-image-config.yaml
152-
rm set-image-config.yaml
152+
trap "rm -f ${FN_CONFIG}" EXIT
153+
154+
kpt fn eval "${DESTINATION}" --image set-image:v0.1.0 --fn-config "${FN_CONFIG}" || echo "kpt fn eval failed"
153155
}
154156

155157
function customize-sa {

0 commit comments

Comments
 (0)