-
Notifications
You must be signed in to change notification settings - Fork 131
Integrate contrib types into unified Bicep extension #11915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
36dbc69
d849d1a
45d8666
cd9ddbe
3a5cf25
17223c4
48f5a3f
86b641f
9db7446
e190f95
1f3180e
037ee66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,6 +237,13 @@ jobs: | |
| with: | ||
| node-version-file: .node-version | ||
|
|
||
| - name: Install yq | ||
| # Required by make generate-bicep-types-contrib to parse defaults.yaml. | ||
| run: | | ||
| mkdir -p "${RUNNER_TEMP}/bin" | ||
| GOBIN="${RUNNER_TEMP}/bin" go install github.com/mikefarah/yq/v4@v4.44.3 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous comment: can the yq version be an env var similar to the other tool vars at top of the workflow? |
||
| echo "${RUNNER_TEMP}/bin" >> "${GITHUB_PATH}" | ||
| - name: Generate Bicep extensibility types from OpenAPI specs | ||
| run: | | ||
| make generate-bicep-types VERSION=${{ env.REL_VERSION == 'edge' && 'latest' || env.REL_VERSION }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,80 @@ generate-bicep-types: generate-node-installed generate-pnpm-installed ## Generat | |
| CI=true pnpm -C hack/bicep-types-radius/src/autorest.bicep install && pnpm -C hack/bicep-types-radius/src/autorest.bicep run build; \ | ||
| echo "Run generator from hack/bicep-types-radius/src/generator dir"; \ | ||
| CI=true pnpm -C hack/bicep-types-radius/src/generator install && pnpm -C hack/bicep-types-radius/src/generator run generate --specs-dir ../../../../swagger --release-version ${VERSION} --verbose | ||
| @echo "$(ARROW) Generating Bicep types for default contrib resource type namespaces..." | ||
| @$(MAKE) generate-bicep-types-contrib | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be a prerequisite this target instead of sub call to make? In other words, on line 144 add |
||
| @echo "$(ARROW) Rebuilding unified Bicep types index..." | ||
| CI=true pnpm -C hack/bicep-types-radius/src/generator run rebuild-index --release-version ${VERSION} | ||
|
|
||
| # Generates Bicep types.json files for the default contrib resource type | ||
| # namespaces listed in deploy/manifest/defaults.yaml. | ||
| # | ||
| # Each entry in defaults.yaml uses <namespace>/<typeName> format | ||
| # (e.g. Radius.Compute/containers). This target: | ||
| # 1. Reads defaults.yaml to discover which types to include. | ||
| # 2. Groups entries by namespace. | ||
| # 3. For each namespace, passes ALL per-type manifest files to | ||
| # `generate` so they are merged into a single output. | ||
| # | ||
| # Per-type manifest files live under deploy/manifest/built-in-providers/self-hosted/ | ||
| # as individual YAML files (e.g. containers.yaml, routes.yaml). | ||
| DEFAULTS_YAML := deploy/manifest/defaults.yaml | ||
| BICEP_TYPES_CONTRIB_API_VERSION ?= 2025-08-01-preview | ||
| BICEP_TYPES_OUTPUT_BASE := hack/bicep-types-radius/generated/radius | ||
| BICEP_TYPES_CONTRIB_MANIFEST_DIR := deploy/manifest/built-in-providers/self-hosted | ||
|
|
||
| .PHONY: generate-yq-installed | ||
| generate-yq-installed: | ||
| @echo "$(ARROW) Detecting yq..." | ||
| @which yq > /dev/null || { echo "run 'go install github.com/mikefarah/yq/v4@latest' to install yq, then ensure ~/go/bin is on your PATH"; exit 1; } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be the same version of yq used in the GitHub workflows. |
||
| @echo "$(ARROW) OK" | ||
|
|
||
| .PHONY: generate-bicep-types-contrib | ||
| generate-bicep-types-contrib: generate-yq-installed ## Generates Bicep types.json files for default contrib namespaces from defaults.yaml. | ||
| # Discover unique namespaces from defaults.yaml. | ||
| @NAMESPACES=$$(yq '.defaultRegistration[]' $(DEFAULTS_YAML) | sed 's|/.*||' | sort -u) && \ | ||
| for ns in $$NAMESPACES; do \ | ||
| ns_lower=$$(echo "$$ns" | tr '[:upper:]' '[:lower:]') && \ | ||
| out_dir="$(BICEP_TYPES_OUTPUT_BASE)/$$ns_lower/$(BICEP_TYPES_CONTRIB_API_VERSION)" && \ | ||
| manifest_args="" && \ | ||
| for entry in $$(yq '.defaultRegistration[]' $(DEFAULTS_YAML) | grep "^$$ns/"); do \ | ||
| type_name=$$(echo "$$entry" | cut -d'/' -f2) && \ | ||
| manifest="$(BICEP_TYPES_CONTRIB_MANIFEST_DIR)/$$type_name.yaml" && \ | ||
| if [ ! -f "$$manifest" ]; then \ | ||
| echo "ERROR: Manifest not found: $$manifest (from entry '$$entry')"; \ | ||
| exit 1; \ | ||
| fi && \ | ||
| manifest_args="$$manifest_args $$manifest"; \ | ||
| done && \ | ||
| echo " -> $$ns ($$manifest_args) -> $$out_dir" && \ | ||
| go run ./bicep-tools/cmd/manifest-to-bicep generate $$manifest_args "$$out_dir" && \ | ||
| mkdir -p "$$out_dir/docs" || exit 1; \ | ||
| done | ||
|
Comment on lines
+179
to
+198
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a non-trivial nested shell loop embedded in a Makefile. It is hard to read, hard to test, and easy to break (line continuations, && chains, || exit 1). Strongly consider extracting to build/scripts/generate-bicep-contrib.sh and invoking it from the recipe. That also lets you set -euo pipefail and add shellcheck coverage. Aligns with the project's .github/instructions/shell.instructions.md guidance. |
||
|
|
||
| # Publishing the unified `radius` Bicep extension. Runnable locally against any | ||
| # OCI registry (e.g. a local Zot/CRane-backed registry, or biceptypes.azurecr.io | ||
| # after `az acr login`). Both BICEP_PUBLISH_TARGET and the local Bicep CLI must | ||
| # be available. CI workflows (added separately) call this target after | ||
| # generating types and authenticating to the registry. | ||
| # | ||
| # Example: | ||
| # make publish-bicep-extension BICEP_PUBLISH_TARGET=br:biceptypes.azurecr.io/radius:latest | ||
| BICEP_PUBLISH_INDEX := $(BICEP_TYPES_OUTPUT_BASE)/../index.json | ||
| BICEP_PUBLISH_TARGET ?= | ||
|
|
||
| .PHONY: publish-bicep-extension | ||
| publish-bicep-extension: ## Publish the unified `radius` Bicep extension to BICEP_PUBLISH_TARGET. Requires generate-bicep-types to have been run. | ||
| @if [ -z "$(BICEP_PUBLISH_TARGET)" ]; then \ | ||
| echo "ERROR: BICEP_PUBLISH_TARGET must be set (e.g. br:biceptypes.azurecr.io/radius:latest)"; \ | ||
| exit 1; \ | ||
| fi | ||
| @if [ ! -f "$(BICEP_PUBLISH_INDEX)" ]; then \ | ||
| echo "ERROR: $(BICEP_PUBLISH_INDEX) does not exist; run 'make generate-bicep-types' first"; \ | ||
| exit 1; \ | ||
| fi | ||
| @which bicep > /dev/null || { echo "ERROR: 'bicep' CLI not found in PATH"; exit 1; } | ||
| @echo "$(ARROW) Publishing Bicep extension index $(BICEP_PUBLISH_INDEX) -> $(BICEP_PUBLISH_TARGET)" | ||
| bicep publish-extension "$(BICEP_PUBLISH_INDEX)" --target "$(BICEP_PUBLISH_TARGET)" --force | ||
|
|
||
|
|
||
| .PHONY: generate-containerinstance-client | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "resources": { | ||
| "Radius.Compute/containers@2025-08-01-preview": { | ||
| "$ref": "types.json#/125" | ||
| }, | ||
| "Radius.Compute/persistentVolumes@2025-08-01-preview": { | ||
| "$ref": "types.json#/140" | ||
| }, | ||
| "Radius.Compute/routes@2025-08-01-preview": { | ||
| "$ref": "types.json#/193" | ||
| } | ||
| }, | ||
| "resourceFunctions": {}, | ||
| "settings": { | ||
| "name": "radiusradiuscompute", | ||
| "version": "0.0.1" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the yq version be an env var similar to the other tool vars at top of the workflow?