Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile-common
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ pattern-install:
load-secrets: ## Loads secrets onto the cluster (unless explicitly disabled in values-global.yaml)
@$(ANSIBLE_RUN) rhvp.cluster_utils.load_secrets

##@ Debug Tasks
.PHONY: display-secrets-info
display-secrets-info: ## Display your secret material on terminal or show secret loading error. Use with caution!
@$(ANSIBLE_RUN) rhvp.cluster_utils.display_secrets_info

##@ Validation Tasks
.PHONY: validate-prereq
validate-prereq: ## verify pre-requisites
Expand All @@ -53,6 +58,7 @@ validate-schema: ## validates values files against schema in common/clustergroup
argo-healthcheck: ## Checks if all argo applications are synced
@$(ANSIBLE_RUN) rhvp.cluster_utils.argo_healthcheck

##@ Testing (CI) Tasks
.PHONY: run-ci-tests
run-ci-tests: ## To run ci-tests, set any needed env vars
@$(ANSIBLE_RUN) rhvp.cluster_utils.run_ci_tests
48 changes: 2 additions & 46 deletions pattern.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,6 @@ function is_container() {
return 1
}

function verify_image() {
local image="$1"

case "${image}" in
quay.io/validatedpatterns/*|quay.io/hybridcloudpatterns/*)
;;
*)
echo "Skipping image verification for third-party registry"
return 0
;;
esac

if ! command -v cosign >/dev/null 2>&1; then
echo "WARNING: cosign is not installed, cannot verify image signature"
echo "Install cosign to enable image verification: https://docs.sigstore.dev/cosign/system_config/installation/"
return 0
fi

echo "Verifying image signature for ${image}..."
local output rc
local oidc_issuer="${VP_COSIGN_OIDC_ISSUER:-https://token.actions.githubusercontent.com}"
local cert_identity="${VP_COSIGN_CERT_IDENTITY:-https://github.com/validatedpatterns/utility-container/.*}"
output=$(cosign verify \
--certificate-oidc-issuer "${oidc_issuer}" \
--certificate-identity-regexp "${cert_identity}" \
"${image}" 2>&1) && rc=$? || rc=$?

if [ "${rc}" -eq 0 ]; then
echo "Image signature verified successfully"
elif [ "${rc}" -ge 10 ] && [ "${rc}" -le 13 ]; then
echo "ERROR: Image signature verification failed for ${image} (exit code ${rc})"
echo "${output}"
echo "Set VP_VERIFY_IMAGE=false to skip this check"
exit 1
else
echo "WARNING: Could not verify image signature for ${image} (likely a network issue)"
echo "Set VP_VERIFY_IMAGE=false to skip this check"
fi
}

if is_container; then
echo "Already running in a container"
exec "$@"
Expand Down Expand Up @@ -139,10 +99,6 @@ if [ -n "${EXTRA_ARGS:-}" ]; then
EXTRA_ARGS_ARRAY=(${EXTRA_ARGS})
fi

if [ "${VP_VERIFY_IMAGE:-true}" != "false" ]; then
verify_image "$PATTERN_UTILITY_CONTAINER"
fi

# Copy Kubeconfig from current environment. The utilities will pick up ~/.kube/config if set so it's not mandatory
# $HOME is mounted as itself for any files that are referenced with absolute paths
# $HOME is mounted to /root because the UID in the container is 0 and that's where SSH looks for credentials
Expand Down Expand Up @@ -173,12 +129,12 @@ podman run -it --rm --pull=newer \
-e UUID_FILE \
-e VALUES_SECRET \
-e 'VP_*' \
${PKI_HOST_MOUNT_ARGS[@]+"${PKI_HOST_MOUNT_ARGS[@]}"} \
"${PKI_HOST_MOUNT_ARGS[@]}" \
-v "$(pwd -P)":"$(pwd -P)" \
-v "${HOME}":"${HOME}" \
-v "${HOME}":/pattern-home \
"${PODMAN_ARGS[@]}" \
${EXTRA_ARGS_ARRAY[@]+"${EXTRA_ARGS_ARRAY[@]}"} \
"${EXTRA_ARGS_ARRAY[@]}" \
-w "$(pwd -P)" \
"$PATTERN_UTILITY_CONTAINER" \
"$@"