Skip to content

Commit 17ab4a9

Browse files
rh-amarinclaude
andcommitted
HYPERFLEET-1103 - feat: restructure TypeSpec sources into core and shared
- Move GCP-specific models out of this repo (now in hyperfleet-api-spec-gcp) - Restructure sources into core/ (core-specific) and shared/ (cross-provider) - Add generic Resource model and CRUD service (from main reconciliation) - Add force-delete endpoints for clusters, nodepools, and resources (internal) - Add ResourceStatusesInternal for adapter resource status reporting - Simplify build script: single provider (core only), openapi output only - Add npm sub-path exports to enable downstream package imports Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> chore: fix CI/CD workflow path for version extraction main.tsp moved from core/main.tsp to root main.tsp as part of restructuring. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a769d48 commit 17ab4a9

61 files changed

Lines changed: 430 additions & 13045 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,20 @@ jobs:
2424
- name: Install dependencies
2525
run: npm ci
2626

27-
- name: Build all schemas
28-
run: |
29-
./build-schema.sh core
30-
./build-schema.sh core --swagger
31-
./build-schema.sh gcp
32-
./build-schema.sh gcp --swagger
27+
- name: Build core schema
28+
run: ./build-schema.sh
3329

3430
- name: Check schema consistency
3531
run: |
3632
if ! git diff --exit-code schemas/; then
3733
echo "Committed schemas are out of sync with TypeSpec sources."
38-
echo "Run './build-schema.sh core --swagger && ./build-schema.sh gcp --swagger' and commit the results."
34+
echo "Run './build-schema.sh' and commit the results."
3935
exit 1
4036
fi
4137
42-
- name: Lint OpenAPI schemas
38+
- name: Lint OpenAPI schema
4339
run: |
44-
npx spectral lint schemas/core/openapi.yaml schemas/gcp/openapi.yaml --format github-actions --fail-severity warn
40+
npx spectral lint schemas/core/openapi.yaml --format github-actions --fail-severity warn
4541
4642
- name: Check version bump
4743
env:

.github/workflows/release.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,14 @@ jobs:
4949
echo "skip=false" >> "$GITHUB_OUTPUT"
5050
fi
5151
52-
- name: Build all schemas
52+
- name: Build core schema
5353
if: steps.check_tag.outputs.skip == 'false'
54-
run: |
55-
./build-schema.sh core
56-
./build-schema.sh core --swagger
57-
./build-schema.sh gcp
58-
./build-schema.sh gcp --swagger
54+
run: ./build-schema.sh
5955

6056
- name: Prepare release assets
6157
if: steps.check_tag.outputs.skip == 'false'
6258
run: |
6359
cp schemas/core/openapi.yaml core-openapi.yaml
64-
cp schemas/core/swagger.yaml core-swagger.yaml
65-
cp schemas/gcp/openapi.yaml gcp-openapi.yaml
66-
cp schemas/gcp/swagger.yaml gcp-swagger.yaml
6760
6861
- name: Create release tag
6962
if: steps.check_tag.outputs.skip == 'false'
@@ -85,8 +78,5 @@ jobs:
8578
prerelease: false
8679
files: |
8780
core-openapi.yaml
88-
core-swagger.yaml
89-
gcp-openapi.yaml
90-
gcp-swagger.yaml
9181
env:
9282
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.0.18] - 2026-05-26
11+
12+
### Changed
13+
14+
- Restructured TypeSpec sources into `core/` and `shared/` directories (HYPERFLEET-1103)
15+
- Removed GCP provider from core repository; GCP contracts now live in a dedicated `hyperfleet-api-spec-gcp` repository (HYPERFLEET-1103)
16+
- `build-schema.sh` simplified: no provider argument required, generates core OpenAPI only
17+
- CI/CD workflows updated to reflect new `main.tsp` location at repository root
18+
1019
## [1.0.17] - 2026-05-21
1120

1221
### Added
@@ -170,7 +179,8 @@ First official stable release of the HyperFleet API specification.
170179
- Interactive API documentation
171180

172181
<!-- Links -->
173-
[Unreleased]: https://github.com/openshift-hyperfleet/hyperfleet-api-spec/compare/v1.0.17...HEAD
182+
[Unreleased]: https://github.com/openshift-hyperfleet/hyperfleet-api-spec/compare/v1.0.18...HEAD
183+
[1.0.18]: https://github.com/openshift-hyperfleet/hyperfleet-api-spec/compare/v1.0.17...v1.0.18
174184
[1.0.17]: https://github.com/openshift-hyperfleet/hyperfleet-api-spec/compare/v1.0.16...v1.0.17
175185
[1.0.16]: https://github.com/openshift-hyperfleet/hyperfleet-api-spec/compare/v1.0.15...v1.0.16
176186
[1.0.15]: https://github.com/openshift-hyperfleet/hyperfleet-api-spec/compare/v1.0.14...v1.0.15

CLAUDE.md

Lines changed: 47 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,51 @@
11
# HyperFleet API Spec - AI Agent Context
22

3-
This repository generates OpenAPI specifications from TypeSpec definitions. It supports multiple provider variants (core, GCP) using a shared codebase with provider-specific type aliases.
3+
This repository generates the HyperFleet core OpenAPI specification from TypeSpec definitions. The GCP-specific contract lives in [hyperfleet-api-spec-gcp](https://github.com/openshift-hyperfleet/hyperfleet-api-spec-gcp), which imports shared models from this repo as the `hyperfleet` npm package.
44

55
## Quick Reference
66

77
**Build commands:**
88
```bash
9-
npm run build:core # Generate core OpenAPI spec
10-
npm run build:gcp # Generate GCP OpenAPI spec
11-
npm run build:all # Generate all variants with Swagger
9+
npm run build # Generate core OpenAPI spec
10+
./build-schema.sh # Same, via script directly
1211
```
1312

1413
**Validation workflow:**
1514
```bash
1615
npm install # Install dependencies
17-
./build-schema.sh gcp # Build GCP OpenAPI 3.0
18-
./build-schema.sh gcp --swagger # Build GCP OpenAPI 2.0 (Swagger)
19-
./build-schema.sh core # Build core OpenAPI 3.0
20-
./build-schema.sh core --swagger # Build core OpenAPI 2.0 (Swagger)
21-
ls -l schemas/*/openapi.yaml # Confirm outputs exist
16+
./build-schema.sh # Build core OpenAPI 3.0
17+
ls -l schemas/core/openapi.yaml # Confirm output exists
2218
```
2319

2420
## Key Concepts
2521

26-
### Provider Variants via Aliases
22+
### Repository Layout
2723

28-
The repo uses a single `main.tsp` but generates different specs per provider:
29-
30-
```typescript
31-
// aliases-core.tsp
32-
alias ClusterSpec = Record<unknown>; // Generic
33-
34-
// aliases-gcp.tsp
35-
alias ClusterSpec = GCPClusterSpec; // Provider-specific
3624
```
37-
38-
The `aliases.tsp` symlink determines which provider types are active. The `build-schema.sh` script automatically re-links this during builds. The symlink is tracked in git and should always point to `aliases-core.tsp` by default. Do not remove it from version control or add it to `.gitignore`.
25+
shared/ # Cross-provider models and services (published as the `hyperfleet` npm package)
26+
core/ # Core-only models and internal services
27+
main.tsp # Entry point — imports shared + core
28+
schemas/core/ # Generated output (committed)
29+
```
3930

4031
**When adding new models:**
41-
- Shared models → `models/`
42-
- Provider-specific `models-{provider}/`
43-
- Always update alias files if you introduce provider-specific types
32+
- Cross-provider models → `shared/models/`
33+
- Core-only models `core/models/`
34+
- GCP-specific → separate repo (`hyperfleet-api-spec-gcp`)
4435

4536
### Public vs Internal APIs
4637

4738
Status endpoints are split:
48-
- `services/statuses.tsp` - GET operations (external clients)
49-
- `services/statuses-internal.tsp` - PUT operations (internal adapters only)
39+
- `shared/services/statuses.tsp` - GET operations (external clients)
40+
- `core/services/statuses-internal.tsp` - PUT operations (internal adapters only) and resource force-delete
5041

5142
The split allows generating different API contracts per audience. Only `statuses.tsp` is imported by default.
5243

5344
## Code Style
5445

5546
### TypeSpec Conventions
5647

57-
**Imports first, namespace second:**
48+
**Imports first, namespace second** (applies to service and model files; example `const` files do not declare a namespace):
5849
```typescript
5950
import "@typespec/http";
6051
import "../models/common/model.tsp";
@@ -79,33 +70,30 @@ interface Clusters {
7970
### File Organization
8071

8172
```
82-
models/{resource}/
73+
shared/models/{resource}/
8374
├── model.tsp # Shared model definitions
8475
└── interfaces.tsp # Optional: shared interfaces
8576
86-
models-{provider}/{resource}/
87-
└── model.tsp # Provider-specific models
77+
shared/services/
78+
└── {resource}.tsp # Shared service endpoints
8879
89-
services/
90-
└── {resource}.tsp # Service endpoints
80+
core/models/{resource}/
81+
└── model.tsp # Core-specific models
82+
83+
core/services/
84+
└── {resource}-internal.tsp # Internal-only endpoints
9185
```
9286

9387
## Boundaries
9488

9589
**DO NOT:**
96-
- Modify generated files in `schemas/` or `tsp-output/` directly
90+
- Modify generated files in `schemas/` or `tsp-output-core/` directly
9791
- Add dependencies without checking TypeSpec version compatibility
9892
- Auto-generate documentation - it degrades agent performance per research
99-
- Use `--swagger` flag unless you need OpenAPI 2.0 for legacy tools
10093
- Commit `node_modules/` or build artifacts
10194

10295
**DO:**
103-
- Run builds in this order before committing schema changes:
104-
1. `./build-schema.sh gcp`
105-
2. `./build-schema.sh gcp --swagger`
106-
3. `./build-schema.sh core`
107-
4. `./build-schema.sh core --swagger`
108-
- Test both provider variants when modifying shared models
96+
- Run `./build-schema.sh` and commit `schemas/core/openapi.yaml` with your changes
10997
- Keep TypeSpec files focused (one resource per service file)
11098
- Use semantic versioning for releases (automated on merge to main)
11199

@@ -114,7 +102,7 @@ services/
114102
### Add a new endpoint to existing service
115103

116104
```typescript
117-
// services/clusters.tsp
105+
// shared/services/clusters.tsp
118106
namespace HyperFleet;
119107

120108
@route("/clusters")
@@ -131,7 +119,7 @@ interface Clusters {
131119

132120
1. Create model:
133121
```typescript
134-
// models/health/model.tsp
122+
// shared/models/health/model.tsp
135123
import "@typespec/http";
136124

137125
model HealthStatus {
@@ -143,7 +131,7 @@ model HealthStatus {
143131

144132
2. Create service:
145133
```typescript
146-
// services/health.tsp
134+
// shared/services/health.tsp
147135
import "@typespec/http";
148136
import "../models/health/model.tsp";
149137
import "../models/common/model.tsp";
@@ -158,35 +146,14 @@ interface Health {
158146

159147
3. Import in `main.tsp`:
160148
```typescript
161-
import "./services/health.tsp";
149+
import "./shared/services/health.tsp";
162150
```
163151

164-
4. Build: `npm run build:core`
152+
4. Build: `npm run build`
165153

166154
### Add provider-specific fields
167155

168-
```typescript
169-
// models-gcp/cluster/model.tsp
170-
model GCPClusterSpec {
171-
projectId: string;
172-
region: string;
173-
network?: GCPNetwork;
174-
}
175-
176-
model GCPNetwork {
177-
vpcId: string;
178-
subnetId: string;
179-
}
180-
```
181-
182-
Update alias:
183-
```typescript
184-
// aliases-gcp.tsp
185-
import "./models-gcp/cluster/model.tsp";
186-
alias ClusterSpec = GCPClusterSpec;
187-
```
188-
189-
Build: `npm run build:gcp`
156+
Provider-specific models live in the provider's own repository (e.g., `hyperfleet-api-spec-gcp`). See that repo for examples of how to extend core shared models.
190157

191158
## Version Bump and Changelog
192159

@@ -202,36 +169,29 @@ When bumping the version in `main.tsp`, always update `CHANGELOG.md`:
202169
Before submitting changes:
203170

204171
- [ ] Dependencies installed: `npm install`
205-
- [ ] GCP variant builds: `./build-schema.sh gcp`
206-
- [ ] GCP Swagger builds: `./build-schema.sh gcp --swagger`
207-
- [ ] Core variant builds: `./build-schema.sh core`
208-
- [ ] Core Swagger builds: `./build-schema.sh core --swagger`
209-
- [ ] Schema files generated: `ls schemas/*/openapi.yaml`
172+
- [ ] Core schema builds: `./build-schema.sh`
173+
- [ ] Schema file generated: `ls schemas/core/openapi.yaml`
210174
- [ ] No TypeSpec compilation errors (check output)
211-
- [ ] Schemas pass linting: `spectral lint schemas/core/openapi.yaml schemas/gcp/openapi.yaml`
212-
- [ ] Changes committed including schema updates
175+
- [ ] Schema passes linting: `spectral lint schemas/core/openapi.yaml`
176+
- [ ] Changes committed including schema update
213177
- [ ] PR description references related issue
214178

215179
## Build System Details
216180

217181
**The build-schema.sh script:**
218-
1. Validates provider parameter (core, gcp, etc.)
219-
2. Re-links `aliases.tsp``aliases-{provider}.tsp`
220-
3. Runs `node_modules/.bin/tsp compile main.tsp`
221-
4. Copies output to `schemas/{provider}/openapi.yaml`
222-
5. (Optional) Converts to OpenAPI 2.0 with `--swagger` flag
182+
1. Extracts the version from `main.tsp` and syncs it into `package.json`
183+
2. Runs `node_modules/.bin/tsp compile main.tsp --output-dir tsp-output-core`
184+
3. Moves output to `schemas/core/openapi.yaml`
223185

224186
**Output locations:**
225-
- TypeSpec: `tsp-output/schema/openapi.yaml` (temporary)
226-
- Final: `schemas/{provider}/openapi.yaml` (committed)
187+
- TypeSpec temp: `tsp-output-core/schema/openapi.yaml` (auto-deleted)
188+
- Final: `schemas/core/openapi.yaml` (committed)
227189

228-
## VS Code Extension Notes
190+
**Version sync:** `package.json` version is kept in lockstep with `main.tsp` automatically on every build. The CI consistency check (`git diff --exit-code`) enforces that both are committed together.
229191

230-
The TypeSpec extension may show false errors:
231-
- Non-active provider models appear undefined (expected)
232-
- Duplicate type warnings from multiple alias files (expected)
192+
## VS Code Extension Notes
233193

234-
Both the CLI and "Emit from TypeSpec" command work correctly despite warnings.
194+
The TypeSpec extension may show false errors for models resolved only at compile time. Both the CLI and "Emit from TypeSpec" command work correctly.
235195

236196
## Dependencies
237197

@@ -257,9 +217,9 @@ Releases are **fully automated** via GitHub Actions (`.github/workflows/release.
257217
On every push to `main`, the release workflow:
258218
1. Extracts the version from the `@info` decorator in `main.tsp`
259219
2. Skips if a tag for that version already exists
260-
3. Builds all four schema variants (core/gcp OpenAPI 3.0 + Swagger 2.0)
220+
3. Builds the core OpenAPI schema
261221
4. Creates an annotated Git tag (`vX.Y.Z`)
262-
5. Publishes a GitHub Release with all four artifacts attached
222+
5. Publishes a GitHub Release with `core-openapi.yaml` attached
263223

264224
The CI workflow (`.github/workflows/ci.yml`) enforces that the version in `main.tsp` is bumped from the latest release tag before a PR can be merged.
265225

0 commit comments

Comments
 (0)