-
Notifications
You must be signed in to change notification settings - Fork 0
♻️refactor: rework patches and breaking change handling #29
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a422a95
🚧 chore: hacks refactoring and documentation
jobs62 7eb904a
🚧 chore: fix patches and add Dockerfile
jobs62 48510af
🚧 chore: add strategic merge patch
jobs62 b009f13
♻️refactor: rework patches and breaking change handling
jobs62 07ad970
✏️fix: fix typos and spell mistakes
jobs62 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/bin/bash | ||
| #!/bin/env bash | ||
| set -e | ||
|
|
||
| WHICH_SDK=$1 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: osc-api-deploy check PR | ||
| on: | ||
| pull_request: | ||
| paths: | ||
| - outscale.yaml | ||
| - outscale-go.yaml | ||
| - outscale-c.yaml | ||
| - outscale-java.yaml | ||
|
|
||
| jobs: | ||
| breaking-change-check: | ||
| runs-on: ubuntu-24.04 | ||
| strategy: | ||
| matrix: | ||
| spec: | ||
| - outscale.yaml | ||
| - outscale-go.yaml | ||
| - outscale-c.yaml | ||
| - outscale-java.yaml | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| sparse-checkout: ${{ matrix.spec }} | ||
| path: ./base | ||
| ref: ${{ github.base_ref }} | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| sparse-checkout: ${{ matrix.spec }} | ||
| path: ./revision | ||
| - name: Checking breaking changes on ${{ matrix.spec }} | ||
| uses: oasdiff/oasdiff-action/breaking@main | ||
| with: | ||
| base: ./base/${{ matrix.spec }} | ||
| revision: ./revision/${{ matrix.spec }} | ||
| fail-on: ERR | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,24 @@ | ||
| #!/bin/bash | ||
| set -e | ||
| #!/bin/env bash | ||
|
|
||
| root=$(cd "$(dirname $0)/" && pwd) | ||
| oapi_version=$1 | ||
| set -euo pipefail | ||
|
|
||
| if [ -z "$oapi_version" ]; then | ||
| echo "please set new oapi version as argument. e.g. \"1.27.0\"" 1>&2 | ||
| if [ ! -v "1" ]; then | ||
| echo "please set new oapi version as argument. e.g. \"1.35.3\"" 1>&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| root=$(cd "$(dirname $0)/" && pwd) | ||
| oapi_version=$1 | ||
|
|
||
| oapi_yaml_url="https://raw.githubusercontent.com/outscale/osc-api/${oapi_version}/outscale.yaml" | ||
| curl --silent -o "$root/outscale-ori.yaml" "$oapi_yaml_url" | ||
| oapi_yaml="$(mktemp outscale.XXXXXX.yaml)" | ||
| curl --silent --retry 5 -o "${oapi_yaml}" "${oapi_yaml_url}" | ||
|
|
||
| mv "$root/outscale.yaml" "/tmp/outscale.yaml" | ||
| $root/hacks/patch.rb "$root/outscale-ori.yaml" "$root/old-outscale.yaml" > "$root/outscale.yaml" | ||
| $root/hacks/patch-nooneof.rb "$root/outscale-ori.yaml" > "$root/outscale-java.yaml" | ||
| $root/hacks/patch-nodatetime.rb "$root/outscale-ori.yaml" "$root/old-outscale.yaml" > "$root/outscale-go.yaml" | ||
| $root/hacks/patch-noproperties-array.rb "$root/outscale-ori.yaml" > "$root/outscale-c.yaml" | ||
| mv "/tmp/outscale.yaml" "$root/old-outscale.yaml" | ||
| cleanup() { | ||
| rm "${oapi_yaml}" || true | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| rm "$root/outscale-ori.yaml" | ||
| $root/hacks/patch.rb --nooneof --patch "${root}/hacks/outscale.patch.yaml" --input "${oapi_yaml}" > "$root/outscale.yaml" | ||
| $root/hacks/patch.rb --nooneof --nodatetime --patch "${root}/hacks/outscale-go.patch.yaml" --input "${oapi_yaml}" > "$root/outscale-go.yaml" | ||
| $root/hacks/patch.rb --noproperties-array --input "${oapi_yaml}" > "$root/outscale-c.yaml" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| FROM ruby:3.3-slim | ||
|
|
||
| WORKDIR /usr/src/app | ||
|
|
||
| COPY . . | ||
|
|
||
| CMD [ "./patch.rb" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,41 @@ | ||
| # osc-api-deploy hacks | ||
|
|
||
| 3 scripts here, those scripts are use to create outscale-go.yaml, outscale-java.yaml and outscale.yaml | ||
| ## Code generator limitations | ||
|
|
||
| patch-nodatetime.rb take 2 arguments, the API file and the old API file. (so if last api is `1.8`, you need to call `patch-nodatetime.rb osc-api.1.8.json osc-api.1.7.json`) `patch.rb` take the same argument, and `patch-nooneof.rb` only take the API file. | ||
| ### oneOf | ||
| Some openapi-generator codegens (Rust) don't handle oneOf types with identical types well. | ||
| They get confused and the produced code doesn't compile. Typescript codegen | ||
| doesn't support oneOf at all. The only use of oneOf in osc-api is the | ||
| following pattern: | ||
|
|
||
| `patch-nooneof.rb` will remove all oneof. `patch.rb` do the same, but also compare the current API to the old one, see if a type change, and if so keep the old one. `patch-nodatetime.rb` do the same as `patch.rb`, but remove all `"format": "date-time"`. | ||
| ```yaml | ||
| oneOf: | ||
| - type: string | ||
| format: date | ||
| - type: string | ||
| format: date-string | ||
| ``` | ||
| [Rust OneOf](https://github.com/OpenAPITools/openapi-generator/issues/18527) | ||
| [Rust date-time](https://github.com/OpenAPITools/openapi-generator/issues/19319) | ||
|
|
||
| nodatetime was made because go doesn't handle date-time correctly. | ||
| ### date-time | ||
| Some openapi-generator codegens (Go) have erratic implementations of | ||
| date-time and date. Go codegen transpiles date-time to time.Time | ||
| (both RFC3339, so that's ok), but doesn't implement date | ||
| (which falls back to string). Rust codegen transpiles everything to string. | ||
|
|
||
| With current patches, everything is basically passed as string. | ||
| It's suboptimal, but it's part of the prototype. | ||
|
|
||
| ### AWS v4 Signature | ||
| Typescript-fetch codegen does not support AWS v4 Signature. PR pending | ||
| for typescript-axios. | ||
|
|
||
| ## Patch | ||
| `patch.rb` is a collection of workarounds for code generator limitations. | ||
|
|
||
| - nodatetime: remove date-time format from strings | ||
| - nodate: remove date format from strings | ||
| - nooneof: substitute oneOf for the first type defined | ||
| - noproperties-array: inflate array's items definition | ||
| - patch: apply strategic merge patch in post-process. Should be last resort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| components: | ||
| schemas: | ||
| FiltersNetPeering: | ||
| properties: | ||
| ExpirationDates: | ||
| items: | ||
| format: date-time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| --- | ||
| components: | ||
| schemas: | ||
| AccessKey: | ||
| properties: | ||
| CreationDate: | ||
| format: datetime | ||
| ExpirationDate: | ||
| format: datetime | ||
| LastModificationDate: | ||
| format: datetime | ||
| AccessKeySecretKey: | ||
| properties: | ||
| CreationDate: | ||
| format: datetime | ||
| ExpirationDate: | ||
| format: datetime | ||
| LastModificationDate: | ||
| format: datetime | ||
| CreateAccessKeyRequest: | ||
| properties: | ||
| ExpirationDate: | ||
| format: datetime | ||
| UpdateAccessKeyRequest: | ||
| properties: | ||
| ExpirationDate: | ||
| format: datetime | ||
| ConsumptionEntry: | ||
| properties: | ||
| FromDate: | ||
| format: datetime | ||
| ToDate: | ||
| format: datetime | ||
| ReadConsumptionAccountRequest: | ||
| properties: | ||
| FromDate: | ||
| format: datetime | ||
| ToDate: | ||
| format: datetime | ||
| Snapshot: | ||
| properties: | ||
| CreationDate: | ||
| format: datetime | ||
| Vm: | ||
| properties: | ||
| CreationDate: | ||
| format: datetime | ||
| VmGroup: | ||
| properties: | ||
| CreationDate: | ||
| format: datetime | ||
| Volume: | ||
| properties: | ||
| CreationDate: | ||
| format: datetime | ||
| VgwTelemetry: | ||
| properties: | ||
| LastStateChangeDate: | ||
| format: datetime | ||
| BsuCreated: | ||
| properties: | ||
| LinkDate: | ||
| format: date | ||
| FiltersApiLog: | ||
| properties: | ||
| QueryDateAfter: | ||
| format: date | ||
| QueryDateBefore: | ||
| format: date | ||
| Image: | ||
| properties: | ||
| CreationDate: | ||
| format: date | ||
| Log: | ||
| properties: | ||
| QueryDate: | ||
| format: date | ||
|
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.