@@ -79,6 +79,9 @@ main() {
7979 make uninstall-deploy
8080 test_helm_chart
8181 fi
82+
83+ test_version_flag " webhook"
84+ test_version_flag " proxy"
8285}
8386
8487test_helm_chart () {
@@ -115,4 +118,56 @@ poll_webhook_readiness() {
115118 ${KUBECTL} wait --for=condition=available --timeout=5m deployment/azure-wi-webhook-controller-manager -n azure-workload-identity-system
116119}
117120
121+ test_version_flag () {
122+ echo " Testing version flag for $1 image..."
123+ local image_name=" $1 "
124+ message=$( docker run --platform linux/amd64 --quiet " ${REGISTRY:- mcr.microsoft.com/ oss/ azure/ workload-identity} /${image_name} :${IMAGE_VERSION} " --version 2>&1 )
125+
126+ # Validate that it's valid JSON
127+ if ! echo " $message " | jq empty > /dev/null 2>&1 ; then
128+ echo " Invalid JSON output: $message "
129+ return 1
130+ fi
131+
132+ # Extract and validate fields
133+ build_version=$( echo " $message " | jq -r .buildVersion)
134+ git_commit=$( echo " $message " | jq -r .gitCommit)
135+ build_date=$( echo " $message " | jq -r .buildDate)
136+ go_version=$( echo " $message " | jq -r .goVersion)
137+ platform=$( echo " $message " | jq -r .platform)
138+
139+ if [[ -z " $build_version " || " $build_version " == " null" ]]; then
140+ echo " Missing BuildVersion"
141+ return 1
142+ fi
143+
144+ if [[ " $build_version " != " $IMAGE_VERSION " ]]; then
145+ echo " BuildVersion does not match IMAGE_VERSION: $build_version != $IMAGE_VERSION "
146+ return 1
147+ fi
148+
149+ if [[ -z " $git_commit " || " $git_commit " == " null" ]]; then
150+ echo " Missing GitCommit"
151+ return 1
152+ fi
153+
154+ if [[ -z " $build_date " || " $build_date " == " null" ]]; then
155+ echo " Missing BuildDate"
156+ return 1
157+ fi
158+
159+ if [[ -z " $go_version " || " $go_version " == " null" ]]; then
160+ echo " Missing GoVersion"
161+ return 1
162+ fi
163+
164+ if [[ -z " $platform " || " $platform " == " null" ]]; then
165+ echo " Missing Platform"
166+ return 1
167+ fi
168+
169+ echo " Version info looks good:"
170+ echo " $message "
171+ }
172+
118173main
0 commit comments