Skip to content

Instantly share code, notes, and snippets.

@abangser
Created February 27, 2026 16:02
Show Gist options
  • Select an option

  • Save abangser/8d9c709fe3aec2bf85ff1fd626881f50 to your computer and use it in GitHub Desktop.

Select an option

Save abangser/8d9c709fe3aec2bf85ff1fd626881f50 to your computer and use it in GitHub Desktop.
Transform all components in a Pulumi schema.json via the Kratix CLI. This allows you to review which will be created before running the CLI commands.
#!/usr/bin/env bash
# Example:
# ./generate-all-pulumi-components ./schema.json syntasso.io
# ./generate-all-pulumi-components https://example.com/schema.json syntasso.io
# Notes:
# - This uses the current CLI exactly as-is.
# - --kind is taken from the token suffix (pkg:module:Kind -> Kind).
# - --component is always explicit, so multi-component schemas work deterministically.
# - This generates a list of commands to run as a new bash script allowing you to debug any issues.
set -euo pipefail
SCHEMA="${1:?schema path or URL}"
GROUP="${2:?api group, e.g. syntasso.io}"
OUT_DIR="${3:-./generated-promises}"
COMMAND_SCRIPT="${4:-$OUT_DIR/run-generate-pulumi-components.sh}"
schema_source="$SCHEMA"
temp_schema_file=""
if [[ "$SCHEMA" =~ ^https?:// ]]; then
temp_schema_file="$(mktemp)"
trap 'rm -f "$temp_schema_file"' EXIT
curl -fsSL "$SCHEMA" -o "$temp_schema_file"
schema_source="$temp_schema_file"
fi
mkdir -p "$OUT_DIR"
cat > "$COMMAND_SCRIPT" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
EOF
count=0
while IFS=$'\t' read -r token raw_kind; do
# Kubernetes Kind should be alphanumeric/CamelCase-ish
kind="$(echo "$raw_kind" | sed -E 's/[^[:alnum:]]//g')"
# Promise name must be DNS-friendly
base_name="$(echo "$token" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+|-+$//g')"
suffix="$(printf '%s' "$token" | shasum | cut -c1-6)"
promise_name="${base_name}-${suffix}"
printf 'kratix init pulumi-component-promise %q --schema %q --component %q --group %q --kind %q --dir %q\n' \
"$promise_name" \
"$SCHEMA" \
"$token" \
"$GROUP" \
"$kind" \
"$OUT_DIR/$promise_name" \
>> "$COMMAND_SCRIPT"
count=$((count + 1))
echo "queued: $promise_name (component=$token kind=$kind)"
done < <(jq -r '
.resources
| to_entries[]
| select(.value.isComponent == true)
| [.key, (.key | split(":") | last)]
| @tsv
' "$schema_source")
chmod +x "$COMMAND_SCRIPT"
echo "wrote $count command(s) to $COMMAND_SCRIPT"
echo "run it with: $COMMAND_SCRIPT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment