-
Notifications
You must be signed in to change notification settings - Fork 15
HYPERFLEET-1083 feat: add generic Resource type and Channel/Version spec schemas #51
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
kuudori marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import "./model.tsp"; | ||
| import "../../models/common/model.tsp"; | ||
|
|
||
| const exampleChannel: Channel = #{ | ||
| kind: "Channel", | ||
| id: "019466a2-1234-7abc-9def-0123456789ab", | ||
| href: "/api/hyperfleet/v1/channels/019466a2-1234-7abc-9def-0123456789ab", | ||
| name: "stable", | ||
| labels: #{ tier: "production" }, | ||
| spec: #{ | ||
| is_default: true, | ||
| enabled_regex: "^4\\.\\d+\\.\\d+$", | ||
| }, | ||
| generation: 1, | ||
| status: #{ | ||
| conditions: #[], | ||
| }, | ||
| created_time: "2025-06-01T00:00:00Z", | ||
| updated_time: "2025-06-01T10:02:00Z", | ||
| created_by: "user-123@example.com", | ||
| updated_by: "user-123@example.com", | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import "./model.tsp"; | ||
|
|
||
| const exampleChannelPatchRequest: ChannelPatchRequest = #{ | ||
| spec: #{ | ||
| is_default: false, | ||
| enabled_regex: "^4\\.17\\.\\d+$", | ||
| }, | ||
| labels: #{ tier: "staging" }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import "./model.tsp"; | ||
|
|
||
| const exampleChannelCreateRequest: ChannelCreateRequest = #{ | ||
| kind: "Channel", | ||
| name: "stable", | ||
| labels: #{ tier: "production" }, | ||
| spec: #{ | ||
| is_default: true, | ||
| enabled_regex: "^4\\.\\d+\\.\\d+$", | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import "@typespec/openapi"; | ||
| import "../../models/common/model.tsp"; | ||
| import "../../models/statuses/model.tsp"; | ||
| import "../../models/resource/model.tsp"; | ||
|
|
||
| using OpenAPI; | ||
|
|
||
| alias KindChannel = "Channel"; | ||
|
|
||
| model ChannelSpec { | ||
| /** Whether this is the default channel for new clusters */ | ||
| is_default: boolean; | ||
|
|
||
| /** Regex pattern for matching enabled version strings */ | ||
| enabled_regex: string; | ||
| } | ||
|
|
||
| model ChannelBase { | ||
| ...APIResource; | ||
|
|
||
| @minLength(1) | ||
| @maxLength(63) | ||
| @pattern("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") | ||
| name: string; | ||
|
|
||
| spec: ChannelSpec; | ||
| } | ||
|
kuudori marked this conversation as resolved.
|
||
|
|
||
| @example(exampleChannel) | ||
| model Channel { | ||
| ...ChannelBase; | ||
| ...APIMetadata; | ||
|
|
||
| @minValue(1) | ||
| generation: int32; | ||
|
|
||
| status: ResourceStatus; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| @example(exampleChannelCreateRequest) | ||
| model ChannelCreateRequest { | ||
| ...ChannelBase; | ||
| } | ||
|
|
||
| @extension("minProperties", 1) | ||
| @extension("additionalProperties", false) | ||
| @example(exampleChannelPatchRequest) | ||
| model ChannelPatchRequest { | ||
| spec?: ChannelSpec; | ||
| labels?: Record<string>; | ||
|
kuudori marked this conversation as resolved.
|
||
| } | ||
|
|
||
| model ChannelList { | ||
| ...List<Channel>; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import "./model.tsp"; | ||
|
|
||
| const exampleVersionPatchRequest: VersionPatchRequest = #{ | ||
| spec: #{ | ||
| raw_version: "4.17.12", | ||
| enabled: false, | ||
| is_default: false, | ||
| release_image: "quay.io/openshift-release-dev/ocp-release:4.17.12-multi", | ||
| }, | ||
| labels: #{ deprecated: "true" }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import "./model.tsp"; | ||
|
|
||
| const exampleVersionCreateRequest: VersionCreateRequest = #{ | ||
| kind: "Version", | ||
| name: "4.17.12", | ||
| labels: #{}, | ||
| spec: #{ | ||
| raw_version: "4.17.12", | ||
| enabled: true, | ||
| is_default: true, | ||
| release_image: "quay.io/openshift-release-dev/ocp-release:4.17.12-multi", | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import "./model.tsp"; | ||
| import "../../models/common/model.tsp"; | ||
|
|
||
| const exampleVersion: Version = #{ | ||
| kind: "Version", | ||
| id: "019466a3-5678-7abc-9def-0123456789ab", | ||
| href: "/api/hyperfleet/v1/channels/019466a2-1234-7abc-9def-0123456789ab/versions/019466a3-5678-7abc-9def-0123456789ab", | ||
| name: "4.17.12", | ||
| labels: #{}, | ||
| spec: #{ | ||
| raw_version: "4.17.12", | ||
| enabled: true, | ||
| is_default: true, | ||
| release_image: "quay.io/openshift-release-dev/ocp-release:4.17.12-multi", | ||
| }, | ||
| generation: 1, | ||
| owner_references: #{ | ||
| id: "019466a2-1234-7abc-9def-0123456789ab", | ||
| kind: "Channel", | ||
| href: "/api/hyperfleet/v1/channels/019466a2-1234-7abc-9def-0123456789ab", | ||
| }, | ||
| status: #{ | ||
| conditions: #[], | ||
| }, | ||
| created_time: "2025-06-01T00:00:00Z", | ||
| updated_time: "2025-06-01T10:02:00Z", | ||
| created_by: "user-123@example.com", | ||
| updated_by: "user-123@example.com", | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import "@typespec/openapi"; | ||
| import "@typespec/http"; | ||
| import "../../models/common/model.tsp"; | ||
| import "../../models/statuses/model.tsp"; | ||
| import "../../models/resource/model.tsp"; | ||
|
|
||
| using OpenAPI; | ||
| using Http; | ||
|
|
||
| alias KindVersion = "Version"; | ||
|
|
||
| model VersionSpec { | ||
| /** Raw version string (e.g., "4.17.12") */ | ||
| raw_version: string; | ||
|
|
||
| /** Whether this version is enabled for provisioning */ | ||
| enabled: boolean; | ||
|
|
||
| /** Whether this is the default version for its channel */ | ||
| is_default: boolean; | ||
|
|
||
| /** Container image reference for the release */ | ||
| release_image: string; | ||
|
|
||
| /** When this version reaches end of life */ | ||
| @format("date-time") end_of_life_time?: string; | ||
| } | ||
|
|
||
| model VersionBase { | ||
| ...APIResource; | ||
|
|
||
| @minLength(1) | ||
| @maxLength(63) | ||
| name: string; | ||
|
|
||
| spec: VersionSpec; | ||
| } | ||
|
Comment on lines
+10
to
+37
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. Enforce
As per coding guidelines, 🤖 Prompt for AI Agents |
||
|
|
||
| @example(exampleVersion) | ||
| model Version { | ||
| ...VersionBase; | ||
| ...APIMetadata; | ||
|
|
||
| @minValue(1) | ||
| generation: int32; | ||
|
|
||
| owner_references: ObjectReference; | ||
|
|
||
| status: ResourceStatus; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| @example(exampleVersionCreateRequest) | ||
| model VersionCreateRequest { | ||
| ...VersionBase; | ||
| } | ||
|
|
||
| @extension("minProperties", 1) | ||
| @extension("additionalProperties", false) | ||
| @example(exampleVersionPatchRequest) | ||
| model VersionPatchRequest { | ||
| spec?: VersionSpec; | ||
| labels?: Record<string>; | ||
|
kuudori marked this conversation as resolved.
|
||
| } | ||
|
|
||
| model VersionList { | ||
| ...List<Version>; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import "./model.tsp"; | ||
|
|
||
| const exampleResourcePatchRequest: ResourcePatchRequest = #{ | ||
| spec: #{}, | ||
| labels: #{ env: "staging" }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import "./model.tsp"; | ||
|
|
||
| const exampleResourceCreateRequest: ResourceCreateRequest = #{ | ||
| kind: "MyResource", | ||
| name: "my-resource-1", | ||
| spec: #{}, | ||
| labels: #{ environment: "production", team: "platform" }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import "./model.tsp"; | ||
| import "../common/model.tsp"; | ||
|
|
||
| const exampleResource: Resource = #{ | ||
| kind: "MyResource", | ||
| id: "019466a0-8f8e-7abc-9def-0123456789ab", | ||
| href: "/api/hyperfleet/v1/resources/019466a0-8f8e-7abc-9def-0123456789ab", | ||
| name: "my-resource-1", | ||
| labels: #{ environment: "production", team: "platform" }, | ||
| spec: #{}, | ||
| generation: 1, | ||
| status: #{ | ||
| conditions: #[], | ||
| }, | ||
| created_time: "2025-06-01T00:00:00Z", | ||
| updated_time: "2025-06-01T10:02:00Z", | ||
| created_by: "user-123@example.com", | ||
| updated_by: "user-123@example.com", | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.