Add multi-file merge support to manifest-to-bicep generate command#11914
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
Extends the manifest-to-bicep generate subcommand to accept multiple manifest files that share a namespace, merging their Types into a single Bicep extension output. This supports the per-type manifest file layout introduced by the automated resource-type registration work, while remaining backward compatible for single-file usage.
Changes:
- Update
generatecommand to accept<manifest1> [manifest2 ...] <output>and treat the last positional arg as the output directory. - Add
mergeManifestFiles()that validates namespace consistency, rejects duplicate type names, and re-serializes a mergedResourceProviderforGenerateFromString. - Add unit tests and YAML test fixtures (
containers.yaml,routes.yaml,secrets.yaml).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| bicep-tools/cmd/manifest-to-bicep/main.go | Accept multi-file args, refactor RunGenerate signature, add mergeManifestFiles helper. |
| bicep-tools/cmd/manifest-to-bicep/main_test.go | New tests for single-file, multi-file merge, namespace mismatch, missing file, empty list, duplicate type. |
| bicep-tools/cmd/manifest-to-bicep/testdata/containers.yaml | Test fixture for Radius.Compute/containers. |
| bicep-tools/cmd/manifest-to-bicep/testdata/routes.yaml | Test fixture for Radius.Compute/routes. |
| bicep-tools/cmd/manifest-to-bicep/testdata/secrets.yaml | Test fixture for Radius.Security/secrets used in namespace-mismatch test. |
1207c92 to
5e9c5c2
Compare
d1f4e55 to
9bf82db
Compare
Update the existing 'generate' subcommand of manifest-to-bicep to accept multiple manifest files. When given multiple YAML manifests with the same namespace, their Types maps are merged into a single output (types.json, index.json, index.md). This supports per-type manifest files (e.g. containers.yaml, routes.yaml) as introduced by the automated resource type registration design, where each file defines a single resource type within a namespace. Backward compatible: single-file usage works exactly as before. Part of: unified Bicep extension publishing (PR 1/4) Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
386dac7 to
4d7f930
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11914 +/- ##
==========================================
+ Coverage 51.71% 51.80% +0.08%
==========================================
Files 726 726
Lines 45608 57559 +11951
==========================================
+ Hits 23587 29817 +6230
- Misses 19795 25519 +5724
+ Partials 2226 2223 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
## Overview Today, resource types from `resource-types-contrib` (e.g. `Radius.Compute/containers`, `Radius.Security/secrets`) are published as separate Bicep extensions (`radiusCompute`, `radiusData`, `radiusSecurity`), requiring users to configure multiple entries in `bicepconfig.json` and use different `extension` directives depending on the namespace. This PR is part of a series that consolidates them into the existing `radius` Bicep extension so users have a single `extension radius` for all Radius-authored types. Specifically, this PR wires up the build pipeline so that contrib resource type manifests (maintained via [`make update-resource-types`](#11911)) are included in the unified `radius` extension alongside the existing TypeSpec/Swagger-generated types. ## What this PR does 1. **`generate-bicep-types-contrib` Makefile target** -- reads `deploy/manifest/defaults.yaml` to discover which contrib namespaces to include and passes all per-type manifests for each namespace to `manifest-to-bicep generate` for merging into `types.json` + `index.json` + `index.md`. Creates empty `docs/` directories so the [doc generation script](https://github.com/radius-project/docs/blob/main/.github/scripts/generate_resource_references.py) doesn't crash (contrib resource type docs tracked in [#11918](#11918)). 2. **`publish-bicep-extension` Makefile target** -- wraps `bicep publish-extension` for local testability. 3. **Shared `index-builder.ts` module** -- extracts `buildTypeIndex()` from `generate.ts` into a shared module so both the autorest pipeline and the new `rebuild-index` CLI can use it without code duplication. 4. **`rebuild-index.ts` CLI wrapper** -- standalone entry point that rebuilds the unified `index.json`/`index.md` after contrib `types.json` files are added to the generated tree. 5. **Extended `generate-bicep-types` target** -- now calls `generate-bicep-types-contrib` then `rebuild-index` after the existing autorest step, so the full pipeline produces one unified extension. 6. **Removed contrib extension references** -- `radiusCompute`, `radiusData`, `radiusSecurity` removed from `bicepconfig.json`, `install-bicep.sh`, and `pkg/cli/setup` since these namespaces are now part of the single `radius` extension. 7. **Updated functional test workflows** -- added `yq` install step to `functional-test-noncloud.yaml` and `functional-test-cloud.yaml` before the `make generate-bicep-types` step, since the new `generate-bicep-types-contrib` target requires `yq` to parse `defaults.yaml`. ## How the build pipeline works after this PR ``` make generate-bicep-types | +--> Step 1: autorest pipeline (existing, unchanged) | Generates types from Swagger/TypeSpec for Applications.Core, Applications.Dapr, etc. | Output: generated/radius/applications.core/.../types.json, etc. | +--> Step 2: generate-bicep-types-contrib (new) | Reads defaults.yaml, runs manifest-to-bicep generate per namespace | Output: generated/radius/radius.compute/.../types.json, etc. | +--> Step 3: rebuild-index (new) Walks the full generated/ tree, builds unified index.json + index.md Output: generated/index.json (covers all namespaces from both steps) ``` ## CI impact The `generate-bicep-types-contrib` step requires `yq` to parse `defaults.yaml`. Workflows that call `make generate-bicep-types` need `yq` installed beforehand. This PR adds the install step to the two affected workflows (`functional-test-noncloud.yaml` and `functional-test-cloud.yaml`), using the same pattern as `verify-resource-types.yaml` from [#11911](#11911). ## Test plan - `go test ./pkg/cli/setup/...` -- verifies updated bicepconfig template - TypeScript build: `pnpm -C hack/bicep-types-radius/src/generator run build` -- verifies the refactored generate.ts and new index-builder.ts compile cleanly ## Dependencies - [Add multi-file merge support to manifest-to-bicep generate command](#11914) (merged) - [Automated default resource type registration](#11911) (merged -- provides `defaults.yaml` and per-type manifest files) ## Changes - `build/generate.mk`: New `generate-yq-installed`, `generate-bicep-types-contrib`, and `publish-bicep-extension` targets - `hack/bicep-types-radius/src/generator/src/index-builder.ts`: New shared module exporting `buildTypeIndex()` - `hack/bicep-types-radius/src/generator/src/cmd/generate.ts`: Refactored to import `buildTypeIndex` from the shared module instead of defining it inline - `hack/bicep-types-radius/src/generator/src/cmd/rebuild-index.ts`: New thin CLI wrapper that parses args and calls the shared `buildTypeIndex()` - `hack/bicep-types-radius/src/generator/package.json`: Added `rebuild-index` script entry - `bicepconfig.json`, `build/install-bicep.sh`, `pkg/cli/setup/application.go`, `pkg/cli/setup/application_test.go`: Removed contrib extension references - `.github/workflows/functional-test-noncloud.yaml`: Added `yq` install step before `make generate-bicep-types` - `.github/workflows/functional-test-cloud.yaml`: Added `yq` install step before `make generate-bicep-types` - `hack/bicep-types-radius/generated/`: Regenerated `index.json` and added contrib type definitions for `Radius.Compute`, `Radius.Data`, and `Radius.Security` (3 new namespace directories with `types.json`, `index.json`, `index.md`, and empty `docs/` placeholder) ## Part of Unified Bicep extension publishing (PR 2/4). See [design note](#11892). --------- Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
…adius-project#11914) ## Overview Update the existing `generate` subcommand of `manifest-to-bicep` to accept multiple manifest files. When given multiple YAML manifests with the same namespace, their `Types` maps are merged into a single output (`types.json`, `index.json`, `index.md`). This supports per-type manifest files (e.g. `containers.yaml`, `routes.yaml`) as introduced by the [automated resource type registration design](radius-project#11911), where each file defines a single resource type within a namespace. Backward compatible: single-file usage works exactly as before. ## Changes - `bicep-tools/cmd/manifest-to-bicep/main.go`: Updated `generate` to accept `<manifest1> [manifest2...] <output>` (last arg is always output dir). Added `mergeManifestFiles()` that validates same namespace and rejects duplicate types. - `bicep-tools/cmd/manifest-to-bicep/main_test.go`: Added tests for single-file, multi-file merge, namespace mismatch, nonexistent file, empty manifest list, and duplicate type detection. - `bicep-tools/cmd/manifest-to-bicep/testdata/`: Added test manifest files for `Radius.Compute` (containers, routes) and `Radius.Security` (secrets). ## Usage Single file (backward compatible): ```bash go run ./bicep-tools/cmd/manifest-to-bicep generate containers.yaml /tmp/out ``` Multiple files (merge into one output): ```bash go run ./bicep-tools/cmd/manifest-to-bicep generate containers.yaml routes.yaml persistentVolumes.yaml /tmp/out ``` ## Test plan - `go test ./bicep-tools/cmd/manifest-to-bicep/` - 6 tests covering single-file generation, multi-file merge, namespace mismatch rejection, nonexistent file handling, empty input, and duplicate type detection. ## Part of Unified Bicep extension publishing (PR 1/4). See [design doc](radius-project#11892). ## Dependencies - [Automated default resource type registration](radius-project#11911) (provides `defaults.yaml` and per-type manifest files that this command consumes) --------- Signed-off-by: Karishma Chawla <kachawla@microsoft.com> Signed-off-by: Reshma Abdul Rahim <reshmarahim.abdul@microsoft.com>
…11915) ## Overview Today, resource types from `resource-types-contrib` (e.g. `Radius.Compute/containers`, `Radius.Security/secrets`) are published as separate Bicep extensions (`radiusCompute`, `radiusData`, `radiusSecurity`), requiring users to configure multiple entries in `bicepconfig.json` and use different `extension` directives depending on the namespace. This PR is part of a series that consolidates them into the existing `radius` Bicep extension so users have a single `extension radius` for all Radius-authored types. Specifically, this PR wires up the build pipeline so that contrib resource type manifests (maintained via [`make update-resource-types`](radius-project#11911)) are included in the unified `radius` extension alongside the existing TypeSpec/Swagger-generated types. ## What this PR does 1. **`generate-bicep-types-contrib` Makefile target** -- reads `deploy/manifest/defaults.yaml` to discover which contrib namespaces to include and passes all per-type manifests for each namespace to `manifest-to-bicep generate` for merging into `types.json` + `index.json` + `index.md`. Creates empty `docs/` directories so the [doc generation script](https://github.com/radius-project/docs/blob/main/.github/scripts/generate_resource_references.py) doesn't crash (contrib resource type docs tracked in [radius-project#11918](radius-project#11918)). 2. **`publish-bicep-extension` Makefile target** -- wraps `bicep publish-extension` for local testability. 3. **Shared `index-builder.ts` module** -- extracts `buildTypeIndex()` from `generate.ts` into a shared module so both the autorest pipeline and the new `rebuild-index` CLI can use it without code duplication. 4. **`rebuild-index.ts` CLI wrapper** -- standalone entry point that rebuilds the unified `index.json`/`index.md` after contrib `types.json` files are added to the generated tree. 5. **Extended `generate-bicep-types` target** -- now calls `generate-bicep-types-contrib` then `rebuild-index` after the existing autorest step, so the full pipeline produces one unified extension. 6. **Removed contrib extension references** -- `radiusCompute`, `radiusData`, `radiusSecurity` removed from `bicepconfig.json`, `install-bicep.sh`, and `pkg/cli/setup` since these namespaces are now part of the single `radius` extension. 7. **Updated functional test workflows** -- added `yq` install step to `functional-test-noncloud.yaml` and `functional-test-cloud.yaml` before the `make generate-bicep-types` step, since the new `generate-bicep-types-contrib` target requires `yq` to parse `defaults.yaml`. ## How the build pipeline works after this PR ``` make generate-bicep-types | +--> Step 1: autorest pipeline (existing, unchanged) | Generates types from Swagger/TypeSpec for Applications.Core, Applications.Dapr, etc. | Output: generated/radius/applications.core/.../types.json, etc. | +--> Step 2: generate-bicep-types-contrib (new) | Reads defaults.yaml, runs manifest-to-bicep generate per namespace | Output: generated/radius/radius.compute/.../types.json, etc. | +--> Step 3: rebuild-index (new) Walks the full generated/ tree, builds unified index.json + index.md Output: generated/index.json (covers all namespaces from both steps) ``` ## CI impact The `generate-bicep-types-contrib` step requires `yq` to parse `defaults.yaml`. Workflows that call `make generate-bicep-types` need `yq` installed beforehand. This PR adds the install step to the two affected workflows (`functional-test-noncloud.yaml` and `functional-test-cloud.yaml`), using the same pattern as `verify-resource-types.yaml` from [radius-project#11911](radius-project#11911). ## Test plan - `go test ./pkg/cli/setup/...` -- verifies updated bicepconfig template - TypeScript build: `pnpm -C hack/bicep-types-radius/src/generator run build` -- verifies the refactored generate.ts and new index-builder.ts compile cleanly ## Dependencies - [Add multi-file merge support to manifest-to-bicep generate command](radius-project#11914) (merged) - [Automated default resource type registration](radius-project#11911) (merged -- provides `defaults.yaml` and per-type manifest files) ## Changes - `build/generate.mk`: New `generate-yq-installed`, `generate-bicep-types-contrib`, and `publish-bicep-extension` targets - `hack/bicep-types-radius/src/generator/src/index-builder.ts`: New shared module exporting `buildTypeIndex()` - `hack/bicep-types-radius/src/generator/src/cmd/generate.ts`: Refactored to import `buildTypeIndex` from the shared module instead of defining it inline - `hack/bicep-types-radius/src/generator/src/cmd/rebuild-index.ts`: New thin CLI wrapper that parses args and calls the shared `buildTypeIndex()` - `hack/bicep-types-radius/src/generator/package.json`: Added `rebuild-index` script entry - `bicepconfig.json`, `build/install-bicep.sh`, `pkg/cli/setup/application.go`, `pkg/cli/setup/application_test.go`: Removed contrib extension references - `.github/workflows/functional-test-noncloud.yaml`: Added `yq` install step before `make generate-bicep-types` - `.github/workflows/functional-test-cloud.yaml`: Added `yq` install step before `make generate-bicep-types` - `hack/bicep-types-radius/generated/`: Regenerated `index.json` and added contrib type definitions for `Radius.Compute`, `Radius.Data`, and `Radius.Security` (3 new namespace directories with `types.json`, `index.json`, `index.md`, and empty `docs/` placeholder) ## Part of Unified Bicep extension publishing (PR 2/4). See [design note](radius-project#11892). --------- Signed-off-by: Karishma Chawla <kachawla@microsoft.com> Signed-off-by: Reshma Abdul Rahim <reshmarahim.abdul@microsoft.com>
Overview
Update the existing
generatesubcommand ofmanifest-to-bicepto accept multiple manifest files. When given multiple YAML manifests with the same namespace, theirTypesmaps are merged into a single output (types.json,index.json,index.md).This supports per-type manifest files (e.g.
containers.yaml,routes.yaml) as introduced by the automated resource type registration design, where each file defines a single resource type within a namespace.Backward compatible: single-file usage works exactly as before.
Changes
bicep-tools/cmd/manifest-to-bicep/main.go: Updatedgenerateto accept<manifest1> [manifest2...] <output>(last arg is always output dir). AddedmergeManifestFiles()that validates same namespace and rejects duplicate types.bicep-tools/cmd/manifest-to-bicep/main_test.go: Added tests for single-file, multi-file merge, namespace mismatch, nonexistent file, empty manifest list, and duplicate type detection.bicep-tools/cmd/manifest-to-bicep/testdata/: Added test manifest files forRadius.Compute(containers, routes) andRadius.Security(secrets).Usage
Single file (backward compatible):
Multiple files (merge into one output):
Test plan
go test ./bicep-tools/cmd/manifest-to-bicep/- 6 tests covering single-file generation, multi-file merge, namespace mismatch rejection, nonexistent file handling, empty input, and duplicate type detection.Part of
Unified Bicep extension publishing (PR 1/4). See design doc.
Dependencies
defaults.yamland per-type manifest files that this command consumes)