Skip to content

Commit a10b1d5

Browse files
committed
allow loading of other k8s API implementations
Refactor to move all code generated from swagger spec into a separate module, named `ApiImpl`. `KuberContext` now optionally takes a module reference to load APIs from. It defaults to the one bundled in Kuber.jl - `ApiImpl`, but can be replaced with a different module when `KuberContext` is constructed. This will let Kuber.jl be used with code generated for a different Kubernetes API version, or for a spec with custom APIs (e.g. for CRDs).
1 parent 6cba2f1 commit a10b1d5

File tree

782 files changed

+98
-77
lines changed

Some content is hidden

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

782 files changed

+98
-77
lines changed

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignore:
2+
- "src/ApiImpl"

gen/genapialiases.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ end
127127

128128
function main()
129129
DIR = dirname(@__FILE__)
130-
gen_aliases(joinpath(DIR, "../src/api"), joinpath(DIR, "../src/apialiases.jl"))
130+
gen_aliases(joinpath(DIR, "../src/ApiImpl/api"), joinpath(DIR, "../src/ApiImpl/apialiases.jl"))
131131
end
132132

133133
main()

gen/generate.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ if [ $# -ne 1 ]; then
77
echo " - package directory is writable."
88
echo " - CSTParser v2.1.0 is installed."
99
echo "Note:"
10-
echo " - your current 'src/api' folder in the package will be renamed to 'src/api_bak'"
11-
echo " - existing 'src/api_bak' folder if any will be deleted"
10+
echo " - your current 'src/ApiImpl/api' folder in the package will be renamed to 'src/ApiImpl/api_bak'"
11+
echo " - existing 'src/ApiImpl/api_bak' folder if any will be deleted"
1212
echo "Ref:"
1313
echo " - API conventions: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md"
1414
echo " - API: https://kubernetes.io/docs/concepts/overview/kubernetes-api/"
@@ -40,17 +40,17 @@ echo "Swagger is at $SWAGGERDIR"
4040
echo "Generating into $TEMPGENDIR, moving into $GENDIR"
4141
mkdir -p ${TEMPGENDIR}
4242
${SWAGGERDIR}/plugin/generate.sh -i ${SPECDIR}/${SPECFILE} -o ${TEMPGENDIR} -c ${DIR}/config.json
43-
rm -rf ${GENDIR}/src/api_bak
44-
mv ${GENDIR}/src/api ${GENDIR}/src/api_bak
45-
mkdir ${GENDIR}/src/api
46-
mv ${TEMPGENDIR}/src/* ${GENDIR}/src/api/
43+
rm -rf ${GENDIR}/src/ApiImpl/api_bak
44+
mv ${GENDIR}/src/ApiImpl/api ${GENDIR}/src/ApiImpl/api_bak
45+
mkdir ${GENDIR}/src/ApiImpl/api
46+
mv ${TEMPGENDIR}/src/* ${GENDIR}/src/ApiImpl/api/
4747
rm ${TEMPGENDIR}/LICENSE
4848
rm -r ${TEMPGENDIR}
4949

5050
${JULIA} ${DIR}/genapialiases.jl
5151
${JULIA} ${DIR}/gentypealiases.jl
5252

5353
# the following models are not generated correctly by Swagger, hand code them for now
54-
cp ${DIR}/model_IoK8sApimachineryPkgApisMetaV1Time.jl ${GENDIR}/src/api/
55-
cp ${DIR}/model_IoK8sApimachineryPkgUtilIntstrIntOrString.jl ${GENDIR}/src/api/
56-
cp ${DIR}/model_IoK8sApimachineryPkgApisMetaV1WatchEvent.jl ${GENDIR}/src/api/
54+
cp ${DIR}/model_IoK8sApimachineryPkgApisMetaV1Time.jl ${GENDIR}/src/ApiImpl/api/
55+
cp ${DIR}/model_IoK8sApimachineryPkgUtilIntstrIntOrString.jl ${GENDIR}/src/ApiImpl/api/
56+
cp ${DIR}/model_IoK8sApimachineryPkgApisMetaV1WatchEvent.jl ${GENDIR}/src/ApiImpl/api/

gen/gentypealiases.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ end
202202

203203
function main()
204204
DIR = dirname(@__FILE__)
205-
gen_aliases(joinpath(DIR, "../src/api"), joinpath(DIR, "../src/typealiases.jl"))
205+
gen_aliases(joinpath(DIR, "../src/ApiImpl/api"), joinpath(DIR, "../src/ApiImpl/typealiases.jl"))
206206
end
207207

208208
main()

src/ApiImpl/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api_bak

src/ApiImpl/ApiImpl.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module ApiImpl
2+
3+
using Swagger
4+
5+
include("api/Kubernetes.jl")
6+
using .Kubernetes
7+
import .Kubernetes: getAPIVersions
8+
9+
import Base: convert, get, put!, delete!, show
10+
import Swagger: SwaggerModel
11+
12+
include("typealiases.jl")
13+
include("apialiases.jl")
14+
15+
end # module
File renamed without changes.

0 commit comments

Comments
 (0)