зеркало из https://github.com/Azure/ARO-RP.git
Refactor gen client code
Put client gen in script to enable generation of multiple SDKs. Signed-off-by: Petr Kotas <pkotas@redhat.com>
This commit is contained in:
Родитель
805da3e30e
Коммит
c6a2a89844
35
Makefile
35
Makefile
|
@ -15,40 +15,7 @@ clean:
|
|||
find python -type d -name __pycache__ -delete
|
||||
|
||||
client: generate
|
||||
rm -rf pkg/client python/client
|
||||
mkdir pkg/client python/client
|
||||
sha256sum swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2020-04-30/redhatopenshift.json >.sha256sum
|
||||
|
||||
sudo docker run \
|
||||
--rm \
|
||||
-v $(PWD)/pkg/client:/github.com/Azure/ARO-RP/pkg/client:z \
|
||||
-v $(PWD)/swagger:/swagger:z \
|
||||
azuresdk/autorest \
|
||||
--go \
|
||||
--license-header=MICROSOFT_APACHE_NO_VERSION \
|
||||
--namespace=redhatopenshift \
|
||||
--input-file=/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2020-04-30/redhatopenshift.json \
|
||||
--output-folder=/github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift
|
||||
|
||||
sudo docker run \
|
||||
--rm \
|
||||
-v $(PWD)/python/client:/python/client:z \
|
||||
-v $(PWD)/swagger:/swagger:z \
|
||||
azuresdk/autorest \
|
||||
--use=@microsoft.azure/autorest.python@4.0.70 \
|
||||
--python \
|
||||
--azure-arm \
|
||||
--license-header=MICROSOFT_APACHE_NO_VERSION \
|
||||
--namespace=azure.mgmt.redhatopenshift.v2020_04_30 \
|
||||
--input-file=/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/2020-04-30/redhatopenshift.json \
|
||||
--output-folder=/python/client
|
||||
|
||||
sudo chown -R $$(id -un):$$(id -gn) pkg/client python/client
|
||||
sed -i -e 's|azure/aro-rp|Azure/ARO-RP|g' pkg/client/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/models.go pkg/client/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift/redhatopenshiftapi/interfaces.go
|
||||
rm -rf python/client/azure/mgmt/redhatopenshift/v2020_04_30/aio
|
||||
>python/client/__init__.py
|
||||
|
||||
go run ./vendor/golang.org/x/tools/cmd/goimports -w -local=github.com/Azure/ARO-RP pkg/client
|
||||
hack/build-client.sh 2020-04-30 2020-10-31-preview
|
||||
|
||||
generate:
|
||||
go generate ./...
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/bash
|
||||
|
||||
function clean() {
|
||||
rm .sha256sum
|
||||
|
||||
rm -rf pkg/client
|
||||
mkdir pkg/client
|
||||
|
||||
rm -rf python/client
|
||||
mkdir -p python/client
|
||||
}
|
||||
|
||||
function checksum() {
|
||||
sha256sum swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/"$1"/redhatopenshift.json >> .sha256sum
|
||||
}
|
||||
|
||||
function generate_golang() {
|
||||
local API_VERSION=$1
|
||||
|
||||
sudo docker run \
|
||||
--rm \
|
||||
-v ${PWD}/pkg/client:/github.com/Azure/ARO-RP/pkg/client:z \
|
||||
-v ${PWD}/swagger:/swagger:z \
|
||||
azuresdk/autorest \
|
||||
--go \
|
||||
--license-header=MICROSOFT_APACHE_NO_VERSION \
|
||||
--namespace=redhatopenshift \
|
||||
--input-file=/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/"$API_VERSION"/redhatopenshift.json \
|
||||
--output-folder=/github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/"$API_VERSION"/redhatopenshift
|
||||
|
||||
sudo chown -R $(id -un):$(id -gn) pkg/client
|
||||
sed -i -e 's|azure/aro-rp|Azure/ARO-RP|g' pkg/client/services/redhatopenshift/mgmt/"$API_VERSION"/redhatopenshift/models.go pkg/client/services/redhatopenshift/mgmt/"$API_VERSION"/redhatopenshift/redhatopenshiftapi/interfaces.go
|
||||
go run ./vendor/golang.org/x/tools/cmd/goimports -w -local=github.com/Azure/ARO-RP pkg/client
|
||||
}
|
||||
|
||||
function generate_python() {
|
||||
local API_VERSION=$1
|
||||
|
||||
sudo docker run \
|
||||
--rm \
|
||||
-v ${PWD}/python/client:/python/client:z \
|
||||
-v ${PWD}/swagger:/swagger:z \
|
||||
azuresdk/autorest \
|
||||
--use=@microsoft.azure/autorest.python@4.0.70 \
|
||||
--python \
|
||||
--azure-arm \
|
||||
--license-header=MICROSOFT_APACHE_NO_VERSION \
|
||||
--namespace=azure.mgmt.redhatopenshift.v"${API_VERSION//-/_}" \
|
||||
--input-file=/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/stable/"$API_VERSION"/redhatopenshift.json \
|
||||
--output-folder=/python/client
|
||||
|
||||
sudo chown -R $(id -un):$(id -gn) python/client
|
||||
rm -rf python/client/azure/mgmt/redhatopenshift/v"${API_VERSION//-/_}"/aio
|
||||
>python/client/__init__.py
|
||||
}
|
||||
|
||||
clean
|
||||
for API in "$@"
|
||||
do
|
||||
checksum "${API}"
|
||||
generate_golang "${API}"
|
||||
generate_python "${API}"
|
||||
done
|
Загрузка…
Ссылка в новой задаче