Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/build-osc-sdk.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/env bash
set -e

WHICH_SDK=$1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
ruby-version: '3.3'
- name: Write Outscale API version to use
run: echo "${{ github.event.inputs.api_version }}" > api_version
- name: check version duplication
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/check.yaml
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
Comment thread
outscale-rce marked this conversation as resolved.

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
30 changes: 16 additions & 14 deletions build.sh
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"
7 changes: 7 additions & 0 deletions hacks/Dockerfile
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" ]
40 changes: 36 additions & 4 deletions hacks/README.md
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
8 changes: 8 additions & 0 deletions hacks/outscale-go.patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
components:
schemas:
FiltersNetPeering:
properties:
ExpirationDates:
items:
format: date-time
78 changes: 78 additions & 0 deletions hacks/outscale.patch.yaml
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

49 changes: 0 additions & 49 deletions hacks/patch-nodatetime.rb

This file was deleted.

31 changes: 0 additions & 31 deletions hacks/patch-nooneof.rb

This file was deleted.

38 changes: 0 additions & 38 deletions hacks/patch-noproperties-array.rb

This file was deleted.

Loading
Loading