From 6773eb4900fe9efdbf9f7fba121c18ffeb4b0df3 Mon Sep 17 00:00:00 2001 From: Krishanx92 Date: Thu, 7 Dec 2023 21:19:13 +0530 Subject: [PATCH] Add common go lib to CC --- common-controller/go.mod | 27 +- common-controller/go.sum | 50 +- common-controller/internal/cache/datastore.go | 2 +- .../internal/cache/subscriptionDataStore.go | 2 +- .../apis/cp/v1alpha2/application_types.go | 83 -- .../cp/v1alpha2/applicationmapping_types.go | 62 - .../apis/cp/v1alpha2/groupversion_info.go | 37 - .../apis/cp/v1alpha2/subscription_types.go | 69 - .../apis/cp/v1alpha2/zz_generated.deepcopy.go | 373 ------ .../apis/dp/v1alpha1/api_conversion.go | 111 -- .../operator/apis/dp/v1alpha1/api_types.go | 196 --- .../operator/apis/dp/v1alpha1/api_webhook.go | 29 - .../apis/dp/v1alpha1/apipolicy_types.go | 140 -- .../apis/dp/v1alpha1/apipolicy_webhook.go | 91 -- .../apis/dp/v1alpha1/backend_types.go | 282 ---- .../apis/dp/v1alpha1/backend_webhook.go | 95 -- .../apis/dp/v1alpha1/backendjwt_types.go | 111 -- .../apis/dp/v1alpha1/backendjwt_webhook.go | 109 -- .../dp/v1alpha1/custom_ratelimit_policy.go | 40 - .../apis/dp/v1alpha1/groupversion_info.go | 36 - .../dp/v1alpha1/interceptorservice_types.go | 93 -- .../dp/v1alpha1/interceptorservice_webhook.go | 64 - .../apis/dp/v1alpha1/ratelimitpolicy_types.go | 116 -- .../dp/v1alpha1/ratelimitpolicy_webhook.go | 99 -- .../apis/dp/v1alpha1/resolveRatelimit.go | 50 - .../apis/dp/v1alpha1/webhook_suite_test.go | 148 --- .../apis/dp/v1alpha1/zz_generated.deepcopy.go | 1146 ----------------- .../apis/dp/v1alpha2/api_conversion.go | 21 - .../operator/apis/dp/v1alpha2/api_types.go | 202 --- .../operator/apis/dp/v1alpha2/api_webhook.go | 242 ---- .../apis/dp/v1alpha2/api_webhook_test.go | 43 - .../apis/dp/v1alpha2/apipolicy_types.go | 148 --- .../apis/dp/v1alpha2/apipolicy_webhook.go | 91 -- .../apis/dp/v1alpha2/groupversion_info.go | 37 - .../apis/dp/v1alpha2/webhook_suite_test.go | 133 -- .../apis/dp/v1alpha2/zz_generated.deepcopy.go | 400 ------ .../controllers/cp/application_controller.go | 2 +- .../cp/applicationmapping_controller.go | 2 +- .../controllers/cp/subscription_controller.go | 2 +- .../operator/controllers/cp/suite_test.go | 2 +- .../dp/ratelimitpolicy_controller.go | 4 +- .../operator/controllers/dp/suite_test.go | 2 +- .../internal/operator/operator.go | 6 +- .../internal/utils/event_utils.go | 2 +- .../internal/xds/ratelimiter_cache.go | 2 +- common-controller/internal/xds/server.go | 2 +- 46 files changed, 55 insertions(+), 4949 deletions(-) delete mode 100644 common-controller/internal/operator/apis/cp/v1alpha2/application_types.go delete mode 100644 common-controller/internal/operator/apis/cp/v1alpha2/applicationmapping_types.go delete mode 100644 common-controller/internal/operator/apis/cp/v1alpha2/groupversion_info.go delete mode 100644 common-controller/internal/operator/apis/cp/v1alpha2/subscription_types.go delete mode 100644 common-controller/internal/operator/apis/cp/v1alpha2/zz_generated.deepcopy.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/api_conversion.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/api_types.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/api_webhook.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_types.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_webhook.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/backend_types.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/backend_webhook.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_types.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_webhook.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/custom_ratelimit_policy.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/groupversion_info.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_types.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_webhook.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_types.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_webhook.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/resolveRatelimit.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/webhook_suite_test.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha1/zz_generated.deepcopy.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha2/api_conversion.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha2/api_types.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha2/api_webhook.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha2/api_webhook_test.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_types.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_webhook.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha2/groupversion_info.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha2/webhook_suite_test.go delete mode 100644 common-controller/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go diff --git a/common-controller/go.mod b/common-controller/go.mod index 6b6004480d..e2e08bed48 100644 --- a/common-controller/go.mod +++ b/common-controller/go.mod @@ -15,10 +15,10 @@ require ( require ( github.com/envoyproxy/go-control-plane v0.11.2-0.20230802074621-eea0b3bd0f81 github.com/gin-gonic/gin v1.9.1 - github.com/pelletier/go-toml v1.8.1 + github.com/pelletier/go-toml v1.9.5 github.com/redis/go-redis/v9 v9.2.1 - github.com/wso2/apk/adapter v0.0.0-20230811031118-fa0d1ec8848c - golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b + github.com/wso2/apk/adapter v0.0.0-20231207051518-6dd728943082 + github.com/wso2/apk/common-go-libs v0.0.0-20231207144612-d6543db1d9ad google.golang.org/grpc v1.58.3 ) @@ -42,7 +42,8 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.11.0 // indirect + golang.org/x/crypto v0.16.0 // indirect + golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect ) require ( @@ -66,7 +67,7 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/google/gofuzz v1.1.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/google/uuid v1.3.0 // direct github.com/imdario/mergo v0.3.12 // indirect @@ -87,13 +88,13 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/net v0.12.0 // indirect + golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.10.0 // indirect - golang.org/x/sys v0.10.0 // indirect - golang.org/x/term v0.10.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.10.0 // indirect + golang.org/x/tools v0.16.0 // indirect gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230731193218-e0aa005b6bdf // indirect @@ -104,13 +105,13 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.27.2 + k8s.io/api v0.27.2 // indirect k8s.io/apiextensions-apiserver v0.27.2 // indirect k8s.io/component-base v0.27.2 // indirect k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect - k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect + k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/common-controller/go.sum b/common-controller/go.sum index 4295e7edfb..8e2ad6fbc9 100644 --- a/common-controller/go.sum +++ b/common-controller/go.sum @@ -102,8 +102,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -148,8 +148,8 @@ github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU= github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4= -github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= -github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -168,7 +168,7 @@ github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJf github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/redis/go-redis/v9 v9.2.1 h1:WlYJg71ODF0dVspZZCpYmoF1+U1Jjk9Rwd7pq6QmlCg= github.com/redis/go-redis/v9 v9.2.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -192,6 +192,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/wso2/apk/common-go-libs v0.0.0-20231207144612-d6543db1d9ad h1:QX1W+n9VJ0mzbC5mV5F4I861VJU1hZ5gYXj4D1itQXA= +github.com/wso2/apk/common-go-libs v0.0.0-20231207144612-d6543db1d9ad/go.mod h1:fvkFU/8JJpx4Pem9srTjWmD3c89AKsyRpLyNPdQriDc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -209,11 +211,11 @@ golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= -golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= +golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -221,7 +223,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -232,8 +234,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= @@ -256,16 +258,16 @@ golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -277,8 +279,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= -golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= +golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= +golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -351,8 +353,8 @@ k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg= k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= -k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY= -k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= sigs.k8s.io/controller-runtime v0.15.0 h1:ML+5Adt3qZnMSYxZ7gAverBLNPSMQEibtzAgp0UPojU= sigs.k8s.io/controller-runtime v0.15.0/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= @@ -360,7 +362,7 @@ sigs.k8s.io/gateway-api v0.7.1 h1:Tts2jeepVkPA5rVG/iO+S43s9n7Vp7jCDhZDQYtPigQ= sigs.k8s.io/gateway-api v0.7.1/go.mod h1:Xv0+ZMxX0lu1nSSDIIPEfbVztgNZ+3cfiYrJsa2Ooso= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk= +sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/common-controller/internal/cache/datastore.go b/common-controller/internal/cache/datastore.go index 528dfdd2d1..3730bf7b39 100644 --- a/common-controller/internal/cache/datastore.go +++ b/common-controller/internal/cache/datastore.go @@ -21,7 +21,7 @@ import ( "sync" logger "github.com/sirupsen/logrus" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" + dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/common-controller/internal/cache/subscriptionDataStore.go b/common-controller/internal/cache/subscriptionDataStore.go index 2ed931957a..85d5cecd15 100644 --- a/common-controller/internal/cache/subscriptionDataStore.go +++ b/common-controller/internal/cache/subscriptionDataStore.go @@ -21,7 +21,7 @@ import ( "sync" logger "github.com/sirupsen/logrus" - cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" + cpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/cp/v1alpha2" "k8s.io/apimachinery/pkg/types" ) diff --git a/common-controller/internal/operator/apis/cp/v1alpha2/application_types.go b/common-controller/internal/operator/apis/cp/v1alpha2/application_types.go deleted file mode 100644 index e1110737c9..0000000000 --- a/common-controller/internal/operator/apis/cp/v1alpha2/application_types.go +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// ApplicationSpec defines the desired state of Application -type ApplicationSpec struct { - Name string `json:"name"` - Owner string `json:"owner"` - Organization string `json:"organization"` - Attributes map[string]string `json:"attributes,omitempty"` - SecuritySchemes SecuritySchemes `json:"securitySchemes"` -} - -// SecuritySchemes defines the supported security schemes -type SecuritySchemes struct { - // OAuth2 denotes the OAuth2 security scheme - OAuth2 *SecurityScheme `json:"oauth2,omitempty"` -} - -// SecurityScheme defines the details specific to a security scheme -type SecurityScheme struct { - Environments []Environment `json:"environments,omitempty"` -} - -// Environment defines the environment specific details related to the security scheme -type Environment struct { - EnvID string `json:"envId"` - AppID string `json:"appId"` - KeyType string `json:"keyType"` -} - -// ApplicationStatus defines the observed state of Application -type ApplicationStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// Application is the Schema for the applications API -type Application struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ApplicationSpec `json:"spec,omitempty"` - Status ApplicationStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// ApplicationList contains a list of Application -type ApplicationList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Application `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Application{}, &ApplicationList{}) -} diff --git a/common-controller/internal/operator/apis/cp/v1alpha2/applicationmapping_types.go b/common-controller/internal/operator/apis/cp/v1alpha2/applicationmapping_types.go deleted file mode 100644 index b6b880da6b..0000000000 --- a/common-controller/internal/operator/apis/cp/v1alpha2/applicationmapping_types.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// ApplicationMappingSpec defines the desired state of ApplicationMapping -type ApplicationMappingSpec struct { - ApplicationRef string `json:"applicationRef"` - SubscriptionRef string `json:"subscriptionRef"` -} - -// ApplicationMappingStatus defines the observed state of ApplicationMapping -type ApplicationMappingStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// ApplicationMapping is the Schema for the applicationmappings API -type ApplicationMapping struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ApplicationMappingSpec `json:"spec,omitempty"` - Status ApplicationMappingStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// ApplicationMappingList contains a list of ApplicationMapping -type ApplicationMappingList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ApplicationMapping `json:"items"` -} - -func init() { - SchemeBuilder.Register(&ApplicationMapping{}, &ApplicationMappingList{}) -} diff --git a/common-controller/internal/operator/apis/cp/v1alpha2/groupversion_info.go b/common-controller/internal/operator/apis/cp/v1alpha2/groupversion_info.go deleted file mode 100644 index bf97080de5..0000000000 --- a/common-controller/internal/operator/apis/cp/v1alpha2/groupversion_info.go +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package v1alpha2 contains API Schema definitions for the cp v1alpha2 API group -// +kubebuilder:object:generate=true -// +groupName=cp.wso2.com -package v1alpha2 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "cp.wso2.com", Version: "v1alpha2"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/common-controller/internal/operator/apis/cp/v1alpha2/subscription_types.go b/common-controller/internal/operator/apis/cp/v1alpha2/subscription_types.go deleted file mode 100644 index 2f2f90578e..0000000000 --- a/common-controller/internal/operator/apis/cp/v1alpha2/subscription_types.go +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// SubscriptionSpec defines the desired state of Subscription -type SubscriptionSpec struct { - SubscriptionStatus string `json:"subscriptionStatus"` - Organization string `json:"organization"` - API API `json:"api"` -} - -// API defines the API associated with the subscription -type API struct { - Name string `json:"name"` - Version string `json:"version"` -} - -// SubscriptionStatus defines the observed state of Subscription -type SubscriptionStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// Subscription is the Schema for the subscriptions API -type Subscription struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec SubscriptionSpec `json:"spec,omitempty"` - Status SubscriptionStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// SubscriptionList contains a list of Subscription -type SubscriptionList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Subscription `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Subscription{}, &SubscriptionList{}) -} diff --git a/common-controller/internal/operator/apis/cp/v1alpha2/zz_generated.deepcopy.go b/common-controller/internal/operator/apis/cp/v1alpha2/zz_generated.deepcopy.go deleted file mode 100644 index 14dea17615..0000000000 --- a/common-controller/internal/operator/apis/cp/v1alpha2/zz_generated.deepcopy.go +++ /dev/null @@ -1,373 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *API) DeepCopyInto(out *API) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new API. -func (in *API) DeepCopy() *API { - if in == nil { - return nil - } - out := new(API) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Application) DeepCopyInto(out *Application) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Application. -func (in *Application) DeepCopy() *Application { - if in == nil { - return nil - } - out := new(Application) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Application) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApplicationList) DeepCopyInto(out *ApplicationList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Application, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationList. -func (in *ApplicationList) DeepCopy() *ApplicationList { - if in == nil { - return nil - } - out := new(ApplicationList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApplicationList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApplicationMapping) DeepCopyInto(out *ApplicationMapping) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationMapping. -func (in *ApplicationMapping) DeepCopy() *ApplicationMapping { - if in == nil { - return nil - } - out := new(ApplicationMapping) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApplicationMapping) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApplicationMappingList) DeepCopyInto(out *ApplicationMappingList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ApplicationMapping, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationMappingList. -func (in *ApplicationMappingList) DeepCopy() *ApplicationMappingList { - if in == nil { - return nil - } - out := new(ApplicationMappingList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApplicationMappingList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApplicationMappingSpec) DeepCopyInto(out *ApplicationMappingSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationMappingSpec. -func (in *ApplicationMappingSpec) DeepCopy() *ApplicationMappingSpec { - if in == nil { - return nil - } - out := new(ApplicationMappingSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApplicationMappingStatus) DeepCopyInto(out *ApplicationMappingStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationMappingStatus. -func (in *ApplicationMappingStatus) DeepCopy() *ApplicationMappingStatus { - if in == nil { - return nil - } - out := new(ApplicationMappingStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApplicationSpec) DeepCopyInto(out *ApplicationSpec) { - *out = *in - if in.Attributes != nil { - in, out := &in.Attributes, &out.Attributes - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - in.SecuritySchemes.DeepCopyInto(&out.SecuritySchemes) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSpec. -func (in *ApplicationSpec) DeepCopy() *ApplicationSpec { - if in == nil { - return nil - } - out := new(ApplicationSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApplicationStatus) DeepCopyInto(out *ApplicationStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationStatus. -func (in *ApplicationStatus) DeepCopy() *ApplicationStatus { - if in == nil { - return nil - } - out := new(ApplicationStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Environment) DeepCopyInto(out *Environment) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Environment. -func (in *Environment) DeepCopy() *Environment { - if in == nil { - return nil - } - out := new(Environment) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SecurityScheme) DeepCopyInto(out *SecurityScheme) { - *out = *in - if in.Environments != nil { - in, out := &in.Environments, &out.Environments - *out = make([]Environment, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityScheme. -func (in *SecurityScheme) DeepCopy() *SecurityScheme { - if in == nil { - return nil - } - out := new(SecurityScheme) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SecuritySchemes) DeepCopyInto(out *SecuritySchemes) { - *out = *in - if in.OAuth2 != nil { - in, out := &in.OAuth2, &out.OAuth2 - *out = new(SecurityScheme) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecuritySchemes. -func (in *SecuritySchemes) DeepCopy() *SecuritySchemes { - if in == nil { - return nil - } - out := new(SecuritySchemes) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Subscription) DeepCopyInto(out *Subscription) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subscription. -func (in *Subscription) DeepCopy() *Subscription { - if in == nil { - return nil - } - out := new(Subscription) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Subscription) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SubscriptionList) DeepCopyInto(out *SubscriptionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Subscription, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionList. -func (in *SubscriptionList) DeepCopy() *SubscriptionList { - if in == nil { - return nil - } - out := new(SubscriptionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SubscriptionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SubscriptionSpec) DeepCopyInto(out *SubscriptionSpec) { - *out = *in - out.API = in.API -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionSpec. -func (in *SubscriptionSpec) DeepCopy() *SubscriptionSpec { - if in == nil { - return nil - } - out := new(SubscriptionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SubscriptionStatus) DeepCopyInto(out *SubscriptionStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionStatus. -func (in *SubscriptionStatus) DeepCopy() *SubscriptionStatus { - if in == nil { - return nil - } - out := new(SubscriptionStatus) - in.DeepCopyInto(out) - return out -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/api_conversion.go b/common-controller/internal/operator/apis/dp/v1alpha1/api_conversion.go deleted file mode 100644 index e10691e21c..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/api_conversion.go +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha2" - "sigs.k8s.io/controller-runtime/pkg/conversion" -) - -// ConvertTo converts this API CR to the Hub version (v1alpha2). -// src is v1alpha1.API and dst is v1alpha2.API. -func (src *API) ConvertTo(dstRaw conversion.Hub) error { - - dst := dstRaw.(*v1alpha2.API) - dst.ObjectMeta = src.ObjectMeta - - // Spec - dst.Spec.APIName = src.Spec.APIName - dst.Spec.APIVersion = src.Spec.APIVersion - dst.Spec.IsDefaultVersion = src.Spec.IsDefaultVersion - dst.Spec.DefinitionFileRef = src.Spec.DefinitionFileRef - dst.Spec.DefinitionPath = src.Spec.DefinitionPath - dst.Spec.APIType = src.Spec.APIType - dst.Spec.BasePath = src.Spec.BasePath - dst.Spec.Organization = src.Spec.Organization - dst.Spec.SystemAPI = src.Spec.SystemAPI - - // Convert []Property to []v1alpha2.Property - var properties []v1alpha2.Property - for _, p := range src.Spec.APIProperties { - properties = append(properties, v1alpha2.Property(p)) - } - dst.Spec.APIProperties = properties - - // Convert []EnvConfig to []v1alpha2.EnvConfig - var production []v1alpha2.EnvConfig - for _, p := range src.Spec.Production { - production = append(production, v1alpha2.EnvConfig(p)) - } - dst.Spec.Production = production - - var sandbox []v1alpha2.EnvConfig - for _, s := range src.Spec.Sandbox { - sandbox = append(sandbox, v1alpha2.EnvConfig(s)) - } - dst.Spec.Sandbox = sandbox - - // Status - dst.Status.DeploymentStatus = v1alpha2.DeploymentStatus(src.Status.DeploymentStatus) - - return nil -} - -// ConvertFrom converts from the Hub version (v1alpha2) to this version. -// src is v1alpha1.API and dst is v1alpha2.API. -func (src *API) ConvertFrom(srcRaw conversion.Hub) error { - - dst := srcRaw.(*v1alpha2.API) - src.ObjectMeta = dst.ObjectMeta - - // Spec - src.Spec.APIName = dst.Spec.APIName - src.Spec.APIVersion = dst.Spec.APIVersion - src.Spec.IsDefaultVersion = dst.Spec.IsDefaultVersion - src.Spec.DefinitionFileRef = dst.Spec.DefinitionFileRef - src.Spec.DefinitionPath = dst.Spec.DefinitionPath - src.Spec.APIType = dst.Spec.APIType - src.Spec.BasePath = dst.Spec.BasePath - src.Spec.Organization = dst.Spec.Organization - src.Spec.SystemAPI = dst.Spec.SystemAPI - - // Convert []Property to []v1alpha1.Property - var properties []Property - for _, p := range dst.Spec.APIProperties { - properties = append(properties, Property(p)) - } - src.Spec.APIProperties = properties - - // Convert []EnvConfig to []v1alpha1.EnvConfig - var production []EnvConfig - for _, p := range dst.Spec.Production { - production = append(production, EnvConfig(p)) - } - src.Spec.Production = production - - var sandbox []EnvConfig - for _, s := range dst.Spec.Sandbox { - sandbox = append(sandbox, EnvConfig(s)) - } - src.Spec.Sandbox = sandbox - - // Status - src.Status.DeploymentStatus = DeploymentStatus(dst.Status.DeploymentStatus) - - return nil -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/api_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/api_types.go deleted file mode 100644 index cc9ed6e765..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/api_types.go +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// Important: Run "make" to regenerate code after modifying this file - -// APISpec defines the desired state of API -type APISpec struct { - - // APIName is the unique name of the API - //can be used to uniquely identify an API. - // - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=60 - // +kubebuilder:validation:Pattern="^[^~!@#;:%^*()+={}|\\<>\"'',&$\\[\\]\\/]*$" - APIName string `json:"apiName"` - - // APIVersion is the version number of the API. - // - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=30 - // +kubebuilder:validation:Pattern="^[^~!@#;:%^*()+={}|\\<>\"'',&/$\\[\\]\\s+\\/]+$" - APIVersion string `json:"apiVersion"` - - // IsDefaultVersion indicates whether this API version should be used as a default API - // - // +optional - IsDefaultVersion bool `json:"isDefaultVersion"` - - // DefinitionFileRef contains the OpenAPI 3 or Swagger - // definition of the API in a ConfigMap. - // - // +optional - DefinitionFileRef string `json:"definitionFileRef"` - - // DefinitionPath contains the path to expose the API definition. - // - // +kubebuilder:default:=/api-definition - // +kubebuilder:validation:MinLength=1 - DefinitionPath string `json:"definitionPath"` - - // Production contains a list of references to HttpRoutes - // of type HttpRoute. - // xref: https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go - // - // - // +optional - // +nullable - // +kubebuilder:validation:MaxItems=1 - Production []EnvConfig `json:"production"` - - // Sandbox contains a list of references to HttpRoutes - // of type HttpRoute. - // xref: https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go - // - // - // +optional - // +nullable - // +kubebuilder:validation:MaxItems=1 - Sandbox []EnvConfig `json:"sandbox"` - - // APIType denotes the type of the API. - // Possible values could be REST, GraphQL, Async - // - // +kubebuilder:validation:Enum=REST - APIType string `json:"apiType"` - - // BasePath denotes the basepath of the API. - // e.g: /pet-store-api/1.0.6 - // - // +kubectl:validation:MaxLength=232 - // +kubebuilder:validation:Pattern=^[/][a-zA-Z0-9~/_.-]*$ - BasePath string `json:"basePath"` - - // Organization denotes the organization. - // related to the API - // - // +optional - Organization string `json:"organization"` - - // SystemAPI denotes if it is an internal system API. - // - // +optional - SystemAPI bool `json:"systemAPI"` - - // APIProperties denotes the custom properties of the API. - // - // +optional - // +nullable - APIProperties []Property `json:"apiProperties,omitempty"` -} - -// Property holds key value pair of APIProperties -type Property struct { - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` -} - -// EnvConfig contains the environment specific configuration -type EnvConfig struct { - // HTTPRouteRefs denotes the environment of the API. - HTTPRouteRefs []string `json:"httpRouteRefs"` -} - -// APIStatus defines the observed state of API -type APIStatus struct { - // DeploymentStatus denotes the deployment status of the API - // - // +optional - DeploymentStatus DeploymentStatus `json:"deploymentStatus"` -} - -// DeploymentStatus contains the status of the API deployment -type DeploymentStatus struct { - - // Status denotes the state of the API in its lifecycle. - // Possible values could be Accepted, Invalid, Deploy etc. - // - // - Status string `json:"status"` - - // Message represents a user friendly message that explains the - // current state of the API. - // - // - // +optional - Message string `json:"message"` - - // Accepted represents whether the API is accepted or not. - // - // - Accepted bool `json:"accepted"` - - // TransitionTime represents the last known transition timestamp. - // - // - TransitionTime *metav1.Time `json:"transitionTime"` - - // Events contains a list of events related to the API. - // - // - // +optional - Events []string `json:"events,omitempty"` -} - -// +genclient -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:printcolumn:name="API Name",type="string",JSONPath=".spec.apiName" -//+kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.apiVersion" -//+kubebuilder:printcolumn:name="BasePath",type="string",JSONPath=".spec.basePath" -//+kubebuilder:printcolumn:name="Organization",type="string",JSONPath=".spec.organization" -//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" - -// API is the Schema for the apis API -type API struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec APISpec `json:"spec,omitempty"` - Status APIStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// APIList contains a list of API -type APIList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []API `json:"items"` -} - -func init() { - SchemeBuilder.Register(&API{}, &APIList{}) -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/api_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/api_webhook.go deleted file mode 100644 index 67c0fc54e2..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/api_webhook.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - ctrl "sigs.k8s.io/controller-runtime" -) - -// SetupWebhookWithManager creates a new webhook builder for API -func (r *API) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_types.go deleted file mode 100644 index 3f2b90dc72..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_types.go +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1alpha2" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// APIPolicySpec defines the desired state of APIPolicy -type APIPolicySpec struct { - Default *PolicySpec `json:"default,omitempty"` - Override *PolicySpec `json:"override,omitempty"` - TargetRef gwapiv1b1.PolicyTargetReference `json:"targetRef,omitempty"` -} - -// PolicySpec contains API policies -type PolicySpec struct { - // RequestInterceptors referenced to intercetor services to be applied - // to the request flow. - // - // +optional - // +nullable - // +kubebuilder:validation:MaxItems=1 - RequestInterceptors []InterceptorReference `json:"requestInterceptors,omitempty"` - - // ResponseInterceptors referenced to intercetor services to be applied - // to the response flow. - // - // +optional - // +nullable - // +kubebuilder:validation:MaxItems=1 - ResponseInterceptors []InterceptorReference `json:"responseInterceptors,omitempty"` - - // BackendJWTPolicy holds reference to backendJWT policy configurations - BackendJWTPolicy *BackendJWTToken `json:"backendJwtPolicy,omitempty"` - - // CORS policy to be applied to the API. - CORSPolicy *CORSPolicy `json:"cORSPolicy,omitempty"` -} - -// BackendJWTToken holds backend JWT token information -type BackendJWTToken struct { - // Name holds the name of the BackendJWT resource. - Name string `json:"name,omitempty"` -} - -// CORSPolicy holds CORS policy information -type CORSPolicy struct { - // AllowCredentials indicates whether the request can include user credentials like - // cookies, HTTP authentication or client side SSL certificates. - // - // +optional - AccessControlAllowCredentials bool `json:"accessControlAllowCredentials,omitempty"` - - // AccessControlAllowHeaders indicates which headers can be used - // during the actual request. - // - // +optional - AccessControlAllowHeaders []string `json:"accessControlAllowHeaders,omitempty"` - - // AccessControlAllowMethods indicates which methods can be used - // during the actual request. - // - // +optional - AccessControlAllowMethods []string `json:"accessControlAllowMethods,omitempty"` - - // AccessControlAllowOrigins indicates which origins can be used - // during the actual request. - // - // +optional - AccessControlAllowOrigins []string `json:"accessControlAllowOrigins,omitempty"` - - // AccessControlExposeHeaders indicates which headers can be exposed - // as part of the response by listing their names. - // - // +optional - AccessControlExposeHeaders []string `json:"accessControlExposeHeaders,omitempty"` - - // AccessControlMaxAge indicates how long the results of a preflight request - // can be cached in a preflight result cache. - // - // +optional - AccessControlMaxAge *int `json:"accessControlMaxAge,omitempty"` -} - -// InterceptorReference holds InterceptorService reference using name and namespace -type InterceptorReference struct { - // Name is the referced CR's name of InterceptorService resource. - Name string `json:"name"` -} - -// APIPolicyStatus defines the observed state of APIPolicy -type APIPolicyStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// APIPolicy is the Schema for the apipolicies API -type APIPolicy struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec APIPolicySpec `json:"spec,omitempty"` - Status APIPolicyStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// APIPolicyList contains a list of APIPolicy -type APIPolicyList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []APIPolicy `json:"items"` -} - -func init() { - SchemeBuilder.Register(&APIPolicy{}, &APIPolicyList{}) -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_webhook.go deleted file mode 100644 index 8129246847..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_webhook.go +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - constants "github.com/wso2/apk/common-controller/internal/operator/constant" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/validation/field" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "sigs.k8s.io/gateway-api/apis/v1beta1" -) - -// SetupWebhookWithManager creates a new webhook builder for APIPolicy -func (r *APIPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1alpha1-apipolicy,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apipolicies,verbs=create;update,versions=v1alpha1,name=mapipolicy.kb.io,admissionReviewVersions=v1 - -var _ webhook.Defaulter = &APIPolicy{} - -// Default implements webhook.Defaulter so a webhook will be registered for the type -func (r *APIPolicy) Default() {} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1alpha1-apipolicy,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apipolicies,verbs=create;update,versions=v1alpha1,name=vapipolicy.kb.io,admissionReviewVersions=v1 - -var _ webhook.Validator = &APIPolicy{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (r *APIPolicy) ValidateCreate() (admission.Warnings, error) { - return nil, r.ValidatePolicy() -} - -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (r *APIPolicy) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - return nil, r.ValidatePolicy() -} - -// ValidatePolicy validates the APIPolicy -func (r *APIPolicy) ValidatePolicy() error { - var allErrs field.ErrorList - - if r.Spec.TargetRef.Name == "" { - allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("targetRef").Child("name"), "Name is required")) - } - if !(r.Spec.TargetRef.Kind == constants.KindAPI || r.Spec.TargetRef.Kind == constants.KindResource || - r.Spec.TargetRef.Kind == constants.KindGateway) { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("targetRef").Child("kind"), r.Spec.TargetRef.Kind, - "Invalid Kind is provided")) - } - if r.Spec.TargetRef.Namespace != nil && r.Spec.TargetRef.Namespace != (*v1beta1.Namespace)(&r.Namespace) { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("targetRef").Child("namespace"), r.Spec.TargetRef.Namespace, - "namespace cross reference is not allowed")) - } - if len(allErrs) > 0 { - return apierrors.NewInvalid( - schema.GroupKind{Group: "dp.wso2.com", Kind: "APIPolicy"}, - r.Name, allErrs) - } - return nil -} - -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (r *APIPolicy) ValidateDelete() (admission.Warnings, error) { - // TODO(user): fill in your validation logic upon object deletion. - return nil, nil -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/backend_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/backend_types.go deleted file mode 100644 index bb3b1c3aac..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/backend_types.go +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// BackendProtocolType defines the backend protocol type. -type BackendProtocolType string - -const ( - // HTTPProtocol is the http protocol - HTTPProtocol BackendProtocolType = "http" - // HTTPSProtocol is the https protocol - HTTPSProtocol BackendProtocolType = "https" - // WSProtocol is the ws protocol - WSProtocol BackendProtocolType = "ws" - // WSSProtocol is the wss protocol - WSSProtocol BackendProtocolType = "wss" -) - -// BackendSpec defines the desired state of Backend -type BackendSpec struct { - // Services holds hosts and ports - // - // +kubebuilder:validation:MinItems=1 - // +kubebuilder:validation:MaxItems=1 - Services []Service `json:"services,omitempty"` - - // Protocol defines the backend protocol - // - // +optional - // +kubebuilder:validation:Enum=http;https;ws;wss - // +kubebuilder:default=http - Protocol BackendProtocolType `json:"protocol"` - - // BasePath defines the base path of the backend - // +optional - BasePath string `json:"basePath"` - - // TLS defines the TLS configurations of the backend - TLS *TLSConfig `json:"tls,omitempty"` - - // Security defines the security configurations of the backend - Security *SecurityConfig `json:"security,omitempty"` - - // CircuitBreaker defines the circuit breaker configurations - CircuitBreaker *CircuitBreaker `json:"circuitBreaker,omitempty"` - - // Timeout configuration for the backend - Timeout *Timeout `json:"timeout,omitempty"` - - // Retry configuration for the backend - Retry *RetryConfig `json:"retry,omitempty"` - - // HealthCheck configuration for the backend tcp health check - HealthCheck *HealthCheck `json:"healthCheck,omitempty"` -} - -// HealthCheck defines the health check configurations -type HealthCheck struct { - - // Timeout is the time to wait for a health check response. - // If the timeout is reached the health check attempt will be considered a failure. - // - // +kubebuilder:default=1 - // +optional - Timeout uint32 `json:"timeout,omitempty"` - - // Interval is the time between health check attempts in seconds. - // - // +kubebuilder:default=30 - // +optional - Interval uint32 `json:"interval,omitempty"` - - // UnhealthyThreshold is the number of consecutive health check failures required - // before a backend is marked unhealthy. - // - // +kubebuilder:default=2 - // +optional - UnhealthyThreshold uint32 `json:"unhealthyThreshold,omitempty"` - - // HealthyThreshold is the number of healthy health checks required before a host is marked healthy. - // Note that during startup, only a single successful health check is required to mark a host healthy. - // - // +kubebuilder:default=2 - // +optional - HealthyThreshold uint32 `json:"healthyThreshold,omitempty"` -} - -// Timeout defines the timeout configurations -type Timeout struct { - // UpstreamResponseTimeout spans between the point at which the entire downstream request (i.e. end-of-stream) has been processed and - // when the upstream response has been completely processed. - // A value of 0 will disable the route’s timeout. - // - // +kubebuilder:default=15 - UpstreamResponseTimeout uint32 `json:"upstreamResponseTimeout"` - - // DownstreamRequestIdleTimeout bounds the amount of time the request's stream may be idle. - // A value of 0 will completely disable the route's idle timeout. - // - // +kubebuilder:default=300 - // +optional - DownstreamRequestIdleTimeout uint32 `json:"downstreamRequestIdleTimeout"` -} - -// CircuitBreaker defines the circuit breaker configurations -type CircuitBreaker struct { - - // MaxConnections is the maximum number of connections that will make to the upstream cluster. - // - // +kubebuilder:default=1024 - // +optional - MaxConnections uint32 `json:"maxConnections"` - - // MaxPendingRequests is the maximum number of pending requests that will allow to the upstream cluster. - // - // +kubebuilder:default=1024 - // +optional - MaxPendingRequests uint32 `json:"maxPendingRequests"` - - // MaxRequests is the maximum number of parallel requests that will make to the upstream cluster. - // - // +kubebuilder:default=1024 - // +optional - MaxRequests uint32 `json:"maxRequests"` - - // MaxRetries is the maximum number of parallel retries that will allow to the upstream cluster. - // - // +kubebuilder:default=3 - // +optional - MaxRetries uint32 `json:"maxRetries"` - - // MaxConnectionPools is the maximum number of parallel connection pools that will allow to the upstream cluster. - // If not specified, the default is unlimited. - // - // +optional - // +kubebuilder:validation:Minimum=1 - MaxConnectionPools uint32 `json:"maxConnectionPools"` -} - -// RetryConfig defines retry configurations -type RetryConfig struct { - - // Count defines the number of retries. - // If exceeded, TooEarly(425 response code) response will be sent to the client. - // - // +kubebuilder:default=1 - Count uint32 `json:"count"` - - // BaseIntervalMillis is exponential retry back off and it defines the base interval between retries in milliseconds. - // maximum interval is 10 times of the BaseIntervalMillis - // - // +kubebuilder:default=25 - // +kubebuilder:validation:Minimum=1 - // +optional - BaseIntervalMillis uint32 `json:"baseIntervalMillis"` - - // StatusCodes defines the list of status codes to retry - // - // +optional - StatusCodes []uint32 `json:"statusCodes,omitempty"` -} - -// Service holds host and port information for the service -type Service struct { - // Host is the hostname of the service - // - // +kubebuilder:validation:MinLength=1 - Host string `json:"host"` - - // Port of the service - Port uint32 `json:"port"` -} - -// TLSConfig defines enpoint TLS configurations -type TLSConfig struct { - // CertificateInline is the Inline Certificate entry - CertificateInline *string `json:"certificateInline,omitempty"` - - // SecretRef denotes the reference to the Secret that contains the Certificate - SecretRef *RefConfig `json:"secretRef,omitempty"` - - // ConfigMapRef denotes the reference to the ConfigMap that contains the Certificate - ConfigMapRef *RefConfig `json:"configMapRef,omitempty"` - - // AllowedCNs is the list of allowed Subject Alternative Names (SANs) - // - // +optional - AllowedSANs []string `json:"allowedSANs,omitempty"` -} - -// RefConfig holds a config for a secret or a configmap -type RefConfig struct { - // Name of the secret or configmap - // - // +kubebuilder:validation:MinLength=1 - Name string `json:"name"` - - // Key of the secret or configmap - // - // +kubebuilder:validation:MinLength=1 - Key string `json:"key"` -} - -// SecurityConfig defines enpoint security configurations -type SecurityConfig struct { - // Basic security configuration - Basic *BasicSecurityConfig `json:"basic,omitempty"` -} - -// BasicSecurityConfig defines basic security configurations -type BasicSecurityConfig struct { - // SecretRef to credentials - SecretRef SecretRef `json:"secretRef"` -} - -// SecretRef to credentials -type SecretRef struct { - // Name of the secret - // - // +kubebuilder:validation:MinLength=1 - Name string `json:"name"` - - // Namespace of the secret - // - // +kubebuilder:validation:MinLength=1 - UsernameKey string `json:"usernameKey"` - - // Key of the secret - // - // +kubebuilder:validation:MinLength=1 - PasswordKey string `json:"passwordKey"` -} - -// BackendStatus defines the observed state of Backend -type BackendStatus struct{} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// Backend is the Schema for the backends API -type Backend struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec BackendSpec `json:"spec,omitempty"` - Status BackendStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// BackendList contains a list of Backend -type BackendList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Backend `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Backend{}, &BackendList{}) -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/backend_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/backend_webhook.go deleted file mode 100644 index 63290ef3b5..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/backend_webhook.go +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/validation/field" - ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" -) - -// log is for logging in this package. -var backendlog = logf.Log.WithName("backend-resource") - -// SetupWebhookWithManager sets up and registers the backend webhook with the manager. -func (r *Backend) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1alpha1-backend,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=backends,verbs=create;update,versions=v1alpha1,name=mbackend.kb.io,admissionReviewVersions=v1 - -var _ webhook.Defaulter = &Backend{} - -// Default implements webhook.Defaulter so a webhook will be registered for the type -func (r *Backend) Default() { - backendlog.Info("default", "name", r.Name) - - // TODO(user): fill in your defaulting logic. -} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1alpha1-backend,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=backends,verbs=create;update,versions=v1alpha1,name=vbackend.kb.io,admissionReviewVersions=v1 - -var _ webhook.Validator = &Backend{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (r *Backend) ValidateCreate() (admission.Warnings, error) { - return nil, r.validateBackendSpec() -} - -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (r *Backend) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - return nil, r.validateBackendSpec() -} - -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (r *Backend) ValidateDelete() (admission.Warnings, error) { - backendlog.Info("validate delete", "name", r.Name) - - // TODO(user): fill in your validation logic upon object deletion. - return nil, nil -} - -func (r *Backend) validateBackendSpec() error { - var allErrs field.ErrorList - retryConfig := r.Spec.Retry - if retryConfig != nil { - for _, statusCode := range retryConfig.StatusCodes { - if statusCode > 598 || statusCode < 401 { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("retry").Child("statusCodes"), - retryConfig.StatusCodes, "status code should be between 401 and 598")) - } - } - } - - if len(allErrs) > 0 { - return apierrors.NewInvalid( - schema.GroupKind{Group: "dp.wso2.com", Kind: "Backend"}, - r.Name, allErrs) - } - return nil -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_types.go deleted file mode 100644 index b4a8677369..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_types.go +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// BackendJWTSpec defines the desired state of BackendJWT -type BackendJWTSpec struct { - // Encoding of the JWT token - // - // +optional - // +kubebuilder:default=Base64 - // +kubebuilder:validation:Enum=Base64;Base64url - Encoding string `json:"encoding,omitempty"` - - // Header of the JWT token - // - // +optional - // +kubebuilder:default=X-JWT-Assertion - // +kubebuilder:validation:MinLength=1 - Header string `json:"header,omitempty"` - - // Signing algorithm of the JWT token - // - // +optional - // +kubebuilder:default=SHA256withRSA - // +kubeBuilder:validation:Enum=SHA256withRSA;SHA384withRSA;SHA512withRSA;SHA256withECDSA;SHA384withECDSA;SHA512withECDSA;SHA256withHMAC;SHA384withHMAC;SHA512withHMAC - SigningAlgorithm string `json:"signingAlgorithm,omitempty"` - - // TokenTTL time to live for the backend JWT token in seconds - // - // +optional - // +kubebuilder:default=3600 - TokenTTL uint32 `json:"tokenTTL,omitempty"` - - // CustomClaims holds custom claims that needs to be added to the jwt - // - // +optional - // +nullable - CustomClaims []CustomClaim `json:"customClaims,omitempty"` -} - -// CustomClaim holds custom claim information -type CustomClaim struct { - // Claim name - // - // +kubebuilder:validation:MinLength=1 - Claim string `json:"claim,omitempty"` - - // Claim value - // - // +kubebuilder:validation:MinLength=1 - Value string `json:"value,omitempty"` - - // Claim type - // - // +kubebuilder:default=string - // +kubebuilder:validation:Enum=string;int;float;bool;long;date - Type string `json:"type"` -} - -// BackendJWTStatus defines the observed state of BackendJWT -type BackendJWTStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// BackendJWT is the Schema for the backendjwts API -type BackendJWT struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec BackendJWTSpec `json:"spec,omitempty"` - Status BackendJWTStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// BackendJWTList contains a list of BackendJWT -type BackendJWTList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []BackendJWT `json:"items"` -} - -func init() { - SchemeBuilder.Register(&BackendJWT{}, &BackendJWTList{}) -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_webhook.go deleted file mode 100644 index b4d05ed36a..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_webhook.go +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - "strconv" - "time" - - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/validation/field" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" -) - -// SetupWebhookWithManager creates a new webhook builder for BackendJWT -func (r *BackendJWT) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1alpha1-backendjwt,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=backendjwts,verbs=create;update,versions=v1alpha1,name=mbackendjwt.kb.io,admissionReviewVersions=v1 - -var _ webhook.Defaulter = &BackendJWT{} - -// Default implements webhook.Defaulter so a webhook will be registered for the type -func (r *BackendJWT) Default() { - // TODO(user): fill in your defaulting logic. -} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1alpha1-backendjwt,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=backendjwts,verbs=create;update,versions=v1alpha1,name=vbackendjwt.kb.io,admissionReviewVersions=v1 - -var _ webhook.Validator = &BackendJWT{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (r *BackendJWT) ValidateCreate() (admission.Warnings, error) { - // TODO(user): fill in your validation logic upon object creation. - return nil, r.validateJWTClaims() -} - -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (r *BackendJWT) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - // TODO(user): fill in your validation logic upon object update. - return nil, r.validateJWTClaims() -} - -func (r *BackendJWT) validateJWTClaims() error { - var allErrs field.ErrorList - claims := r.Spec.CustomClaims - for _, claim := range claims { - valType := claim.Type - switch valType { - case "int": - if _, err := strconv.Atoi(claim.Value); err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("customClaims"), claim, "Provided value is not an integer")) - } - case "float": - if _, err := strconv.ParseFloat(claim.Value, 64); err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("customClaims"), claim, "Provided value is not a float")) - } - case "bool": - if _, err := strconv.ParseBool(claim.Value); err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("customClaims"), claim, "Provided value is not a boolean")) - } - case "date": - if _, err := time.Parse(time.RFC3339, claim.Value); err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("customClaims"), claim, "Provided value is not a date")) - } - case "long": - if _, err := strconv.ParseInt(claim.Value, 10, 64); err != nil { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("customClaims"), claim, "Provided value is not a long")) - } - } - } - - if len(allErrs) > 0 { - return apierrors.NewInvalid( - schema.GroupKind{Group: "dp.wso2.com", Kind: "BackendJWT"}, - r.Name, allErrs) - } - return nil -} - -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (r *BackendJWT) ValidateDelete() (admission.Warnings, error) { - // TODO(user): fill in your validation logic upon object deletion. - return nil, nil -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/custom_ratelimit_policy.go b/common-controller/internal/operator/apis/dp/v1alpha1/custom_ratelimit_policy.go deleted file mode 100644 index 638c98d86b..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/custom_ratelimit_policy.go +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -// CustomRateLimitPolicyDef defines the desired state of CustomPolicy -type CustomRateLimitPolicyDef struct { - Key string `json:"key,omitempty"` - Value string `json:"value,omitempty"` - RequestsPerUnit uint32 `json:"requestsPerUnit,omitempty"` - - Unit string `json:"unit,omitempty"` - // RateLimit RateLimit `json:"rateLimit,omitempty"` - Organization string `json:"organization,omitempty"` -} - -// ParseCustomRateLimitPolicy parses the custom rate limit policy -func ParseCustomRateLimitPolicy(customRateLimitCR RateLimitPolicy) *CustomRateLimitPolicyDef { - return &CustomRateLimitPolicyDef{ - Key: customRateLimitCR.Spec.Override.Custom.Key, - Value: customRateLimitCR.Spec.Override.Custom.Value, - RequestsPerUnit: customRateLimitCR.Spec.Override.Custom.RequestsPerUnit, - Unit: customRateLimitCR.Spec.Override.Custom.Unit, - Organization: customRateLimitCR.Spec.Override.Custom.Organization, - } -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/groupversion_info.go b/common-controller/internal/operator/apis/dp/v1alpha1/groupversion_info.go deleted file mode 100644 index c08917800e..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1alpha1 contains API Schema definitions for the dp v1alpha1 API group -// +kubebuilder:object:generate=true -// +groupName=dp.wso2.com -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "dp.wso2.com", Version: "v1alpha1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_types.go deleted file mode 100644 index a68574b0d9..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_types.go +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// BackendReference refers to a Backend resource as the interceptor service. -type BackendReference struct { - // Name is the name of the Backend resource. - // - // +kubebuilder:validation:MinLength=1 - Name string `json:"name"` -} - -// InterceptorInclusion defines the type of data which can be included in the interceptor request/response path -type InterceptorInclusion string - -const ( - // InterceptorInclusionRequestHeaders is the type to include request headers - InterceptorInclusionRequestHeaders InterceptorInclusion = "request_headers" - // InterceptorInclusionRequestBody is the type to include request body - InterceptorInclusionRequestBody InterceptorInclusion = "request_body" - // InterceptorInclusionRequestTrailers is the type to include request trailers - InterceptorInclusionRequestTrailers InterceptorInclusion = "request_trailers" - // InterceptorInclusionResponseHeaders is the type to include response headers - InterceptorInclusionResponseHeaders InterceptorInclusion = "response_headers" - // InterceptorInclusionResponseBody is the type to include response body - InterceptorInclusionResponseBody InterceptorInclusion = "response_body" - // InterceptorInclusionResponseTrailers is the type to include response trailers - InterceptorInclusionResponseTrailers InterceptorInclusion = "response_trailers" - // InterceptorInclusionInvocationContext is the type to include invocation context - InterceptorInclusionInvocationContext InterceptorInclusion = "invocation_context" -) - -// InterceptorServiceSpec defines the desired state of InterceptorService -type InterceptorServiceSpec struct { - BackendRef BackendReference `json:"backendRef"` - - // Includes defines the types of data which should be included when calling the interceptor service - // - // +optional - // +kubebuilder:validation:MaxItems=4 - // +nullable - Includes []InterceptorInclusion `json:"includes,omitempty"` -} - -// InterceptorServiceStatus defines the observed state of InterceptorService -type InterceptorServiceStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// InterceptorService is the Schema for the interceptorservices API -type InterceptorService struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec InterceptorServiceSpec `json:"spec,omitempty"` - Status InterceptorServiceStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// InterceptorServiceList contains a list of InterceptorService -type InterceptorServiceList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []InterceptorService `json:"items"` -} - -func init() { - SchemeBuilder.Register(&InterceptorService{}, &InterceptorServiceList{}) -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_webhook.go deleted file mode 100644 index 235b658c9e..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_webhook.go +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" -) - -// SetupWebhookWithManager creates a new webhook builder for InterceptorService -func (r *InterceptorService) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1alpha1-interceptorservice,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=interceptorservices,verbs=create;update,versions=v1alpha1,name=minterceptorservice.kb.io,admissionReviewVersions=v1 - -var _ webhook.Defaulter = &InterceptorService{} - -// Default implements webhook.Defaulter so a webhook will be registered for the type -func (r *InterceptorService) Default() {} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1alpha1-interceptorservice,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=interceptorservices,verbs=create;update,versions=v1alpha1,name=vinterceptorservice.kb.io,admissionReviewVersions=v1 - -var _ webhook.Validator = &InterceptorService{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (r *InterceptorService) ValidateCreate() (admission.Warnings, error) { - // TODO(user): fill in your validation logic upon object creation. - return nil, nil -} - -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (r *InterceptorService) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - // TODO(user): fill in your validation logic upon object update. - return nil, nil -} - -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (r *InterceptorService) ValidateDelete() (admission.Warnings, error) { - // TODO(user): fill in your validation logic upon object deletion. - return nil, nil -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_types.go deleted file mode 100644 index 310734e833..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_types.go +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1alpha2" -) - -// RateLimitPolicySpec defines the desired state of RateLimitPolicy -type RateLimitPolicySpec struct { - Default *RateLimitAPIPolicy `json:"default,omitempty"` - Override *RateLimitAPIPolicy `json:"override,omitempty"` - TargetRef gwapiv1b1.PolicyTargetReference `json:"targetRef,omitempty"` -} - -// RateLimitAPIPolicy defines the desired state of Policy -type RateLimitAPIPolicy struct { - - // API level ratelimit policy - // - // +optional - API *APIRateLimitPolicy `json:"api,omitempty"` - - // Custom ratelimit policy - // - // +optional - Custom *CustomRateLimitPolicy `json:"custom,omitempty"` -} - -// APIRateLimitPolicy defines the desired state of APIPolicy -type APIRateLimitPolicy struct { - // RequestPerUnit is the number of requests allowed per unit time - // - // +kubeBuilder:validation:Minimum=1 - RequestsPerUnit uint32 `json:"requestsPerUnit,omitempty"` - - // Unit is the unit of the requestsPerUnit - // - // +kubebuilder:validation:Enum=Minute;Hour;Day - Unit string `json:"unit,omitempty"` -} - -// CustomRateLimitPolicy defines the desired state of CustomPolicy -type CustomRateLimitPolicy struct { - // RequestPerUnit is the number of requests allowed per unit time - // - // +kubeBuilder:validation:Minimum=1 - RequestsPerUnit uint32 `json:"requestsPerUnit,omitempty"` - - // Unit is the unit of the requestsPerUnit - // - // +kubebuilder:validation:Enum=Minute;Hour;Day - Unit string `json:"unit,omitempty"` - - // Key is the key of the custom policy - // - // +kubebuilder:validation:MinLength=1 - Key string `json:"key,omitempty"` - - // Value is the value of the custom policy - // - // +optional - Value string `json:"value,omitempty"` - - // Organization is the organization of the policy - // - // +kubeBuilder:validation:MinLength=1 - Organization string `json:"organization,omitempty"` -} - -// RateLimitPolicyStatus defines the observed state of RateLimitPolicy -type RateLimitPolicyStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// RateLimitPolicy is the Schema for the ratelimitpolicies API -type RateLimitPolicy struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec RateLimitPolicySpec `json:"spec,omitempty"` - Status RateLimitPolicyStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// RateLimitPolicyList contains a list of RateLimitPolicy -type RateLimitPolicyList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []RateLimitPolicy `json:"items"` -} - -func init() { - SchemeBuilder.Register(&RateLimitPolicy{}, &RateLimitPolicyList{}) -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_webhook.go deleted file mode 100644 index 55fb5a1c0b..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_webhook.go +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - constants "github.com/wso2/apk/common-controller/internal/operator/constant" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/validation/field" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "sigs.k8s.io/gateway-api/apis/v1beta1" -) - -// SetupWebhookWithManager creates a new webhook builder for RateLimitPolicy -func (r *RateLimitPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1alpha1-ratelimitpolicy,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=ratelimitpolicies,verbs=create;update,versions=v1alpha1,name=mratelimitpolicy.kb.io,admissionReviewVersions=v1 - -var _ webhook.Defaulter = &RateLimitPolicy{} - -// Default implements webhook.Defaulter so a webhook will be registered for the type -func (r *RateLimitPolicy) Default() { - // TODO(user): fill in your defaulting logic. -} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1alpha1-ratelimitpolicy,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=ratelimitpolicies,verbs=create;update,versions=v1alpha1,name=vratelimitpolicy.kb.io,admissionReviewVersions=v1 - -var _ webhook.Validator = &RateLimitPolicy{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (r *RateLimitPolicy) ValidateCreate() (admission.Warnings, error) { - - // TODO(user): fill in your validation logic upon object creation. - return nil, r.ValidatePolicies() -} - -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (r *RateLimitPolicy) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - - // TODO(user): fill in your validation logic upon object update. - return nil, r.ValidatePolicies() -} - -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (r *RateLimitPolicy) ValidateDelete() (admission.Warnings, error) { - - // TODO(user): fill in your validation logic upon object deletion. - return nil, nil -} - -// ValidatePolicies validates the policies in the RateLimitPolicy -func (r *RateLimitPolicy) ValidatePolicies() error { - var allErrs field.ErrorList - if r.Spec.TargetRef.Name == "" { - allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("targetRef").Child("name"), - "Name is required")) - } - if !(r.Spec.TargetRef.Kind == constants.KindAPI || r.Spec.TargetRef.Kind == constants.KindResource || - r.Spec.TargetRef.Kind == constants.KindGateway) { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("targetRef").Child("kind"), - r.Spec.TargetRef.Kind, "Invalid Kind is provided")) - } - if r.Spec.TargetRef.Namespace != nil && r.Spec.TargetRef.Namespace != (*v1beta1.Namespace)(&r.Namespace) { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("targetRef").Child("namespace"), - r.Spec.TargetRef.Namespace, "namespace cross reference is not allowed")) - } - - if len(allErrs) > 0 { - return apierrors.NewInvalid( - schema.GroupKind{Group: "dp.wso2.com", Kind: "RateLimitPolicy"}, - r.Name, allErrs) - } - return nil -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/resolveRatelimit.go b/common-controller/internal/operator/apis/dp/v1alpha1/resolveRatelimit.go deleted file mode 100644 index e3787acc0e..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/resolveRatelimit.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1alpha1 - -import ( - gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" -) - -// ResolveRateLimitAPIPolicy defines the desired state of Policy -type ResolveRateLimitAPIPolicy struct { - API ResolveRateLimit `json:"api,omitempty"` - Resources []ResolveResource `json:"resourceList,omitempty"` - Organization string `json:"organization,omitempty"` - BasePath string `json:"basePath,omitempty"` - UUID string `json:"uuid,omitempty"` - Environment string `json:"environment,omitempty"` -} - -// ResolveRateLimit is the rate limit value for the applied policy -type ResolveRateLimit struct { - // RequestPerUnit is the number of requests allowed per unit time - // - RequestsPerUnit uint32 `json:"requestsPerUnit,omitempty"` - - // Unit is the unit of the requestsPerUnit - // - // +kubebuilder:validation:Enum=Minute;Hour;Day - Unit string `json:"unit,omitempty"` -} - -// ResolveResource defines the desired state of Resource -type ResolveResource struct { - ResourceRatelimit ResolveRateLimit `json:"resourceRatelimit,omitempty"` - Path string `json:"path,omitempty"` - PathMatchType gwapiv1b1.PathMatchType `json:"pathMatchType,omitempty"` - Method string `json:"method,omitempty"` -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/webhook_suite_test.go b/common-controller/internal/operator/apis/dp/v1alpha1/webhook_suite_test.go deleted file mode 100644 index 5c56602cad..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/webhook_suite_test.go +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha1 - -import ( - "context" - "crypto/tls" - "fmt" - "net" - "path/filepath" - "testing" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - admissionv1beta1 "k8s.io/api/admission/v1beta1" - //+kubebuilder:scaffold:imports - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/rest" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestAPIs(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Webhook Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: false, - WebhookInstallOptions: envtest.WebhookInstallOptions{ - Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, - }, - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - scheme := runtime.NewScheme() - err = AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - err = admissionv1beta1.AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - //+kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - - // start webhook server using Manager - webhookInstallOptions := &testEnv.WebhookInstallOptions - mgr, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme, - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - LeaderElection: false, - MetricsBindAddress: "0", - }) - Expect(err).NotTo(HaveOccurred()) - - err = (&API{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - err = (&APIPolicy{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - err = (&RateLimitPolicy{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - err = (&InterceptorService{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - err = (&Backend{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - err = (&BackendJWT{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - //+kubebuilder:scaffold:webhook - - go func() { - defer GinkgoRecover() - err = mgr.Start(ctx) - Expect(err).NotTo(HaveOccurred()) - }() - - // wait for the webhook server to get ready - dialer := &net.Dialer{Timeout: time.Second} - addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort) - Eventually(func() error { - conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true}) - if err != nil { - return err - } - conn.Close() - return nil - }).Should(Succeed()) - -}) - -var _ = AfterSuite(func() { - cancel() - By("tearing down the test environment") - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/common-controller/internal/operator/apis/dp/v1alpha1/zz_generated.deepcopy.go b/common-controller/internal/operator/apis/dp/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index b5fb3eaf34..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,1146 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *API) DeepCopyInto(out *API) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new API. -func (in *API) DeepCopy() *API { - if in == nil { - return nil - } - out := new(API) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *API) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIList) DeepCopyInto(out *APIList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]API, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIList. -func (in *APIList) DeepCopy() *APIList { - if in == nil { - return nil - } - out := new(APIList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *APIList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIPolicy) DeepCopyInto(out *APIPolicy) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicy. -func (in *APIPolicy) DeepCopy() *APIPolicy { - if in == nil { - return nil - } - out := new(APIPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *APIPolicy) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIPolicyList) DeepCopyInto(out *APIPolicyList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]APIPolicy, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicyList. -func (in *APIPolicyList) DeepCopy() *APIPolicyList { - if in == nil { - return nil - } - out := new(APIPolicyList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *APIPolicyList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIPolicySpec) DeepCopyInto(out *APIPolicySpec) { - *out = *in - if in.Default != nil { - in, out := &in.Default, &out.Default - *out = new(PolicySpec) - (*in).DeepCopyInto(*out) - } - if in.Override != nil { - in, out := &in.Override, &out.Override - *out = new(PolicySpec) - (*in).DeepCopyInto(*out) - } - in.TargetRef.DeepCopyInto(&out.TargetRef) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicySpec. -func (in *APIPolicySpec) DeepCopy() *APIPolicySpec { - if in == nil { - return nil - } - out := new(APIPolicySpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIPolicyStatus) DeepCopyInto(out *APIPolicyStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicyStatus. -func (in *APIPolicyStatus) DeepCopy() *APIPolicyStatus { - if in == nil { - return nil - } - out := new(APIPolicyStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIRateLimitPolicy) DeepCopyInto(out *APIRateLimitPolicy) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIRateLimitPolicy. -func (in *APIRateLimitPolicy) DeepCopy() *APIRateLimitPolicy { - if in == nil { - return nil - } - out := new(APIRateLimitPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APISpec) DeepCopyInto(out *APISpec) { - *out = *in - if in.Production != nil { - in, out := &in.Production, &out.Production - *out = make([]EnvConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Sandbox != nil { - in, out := &in.Sandbox, &out.Sandbox - *out = make([]EnvConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.APIProperties != nil { - in, out := &in.APIProperties, &out.APIProperties - *out = make([]Property, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APISpec. -func (in *APISpec) DeepCopy() *APISpec { - if in == nil { - return nil - } - out := new(APISpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIStatus) DeepCopyInto(out *APIStatus) { - *out = *in - in.DeploymentStatus.DeepCopyInto(&out.DeploymentStatus) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIStatus. -func (in *APIStatus) DeepCopy() *APIStatus { - if in == nil { - return nil - } - out := new(APIStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Backend) DeepCopyInto(out *Backend) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Backend. -func (in *Backend) DeepCopy() *Backend { - if in == nil { - return nil - } - out := new(Backend) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Backend) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendJWT) DeepCopyInto(out *BackendJWT) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendJWT. -func (in *BackendJWT) DeepCopy() *BackendJWT { - if in == nil { - return nil - } - out := new(BackendJWT) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BackendJWT) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendJWTList) DeepCopyInto(out *BackendJWTList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]BackendJWT, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendJWTList. -func (in *BackendJWTList) DeepCopy() *BackendJWTList { - if in == nil { - return nil - } - out := new(BackendJWTList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BackendJWTList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendJWTSpec) DeepCopyInto(out *BackendJWTSpec) { - *out = *in - if in.CustomClaims != nil { - in, out := &in.CustomClaims, &out.CustomClaims - *out = make([]CustomClaim, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendJWTSpec. -func (in *BackendJWTSpec) DeepCopy() *BackendJWTSpec { - if in == nil { - return nil - } - out := new(BackendJWTSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendJWTStatus) DeepCopyInto(out *BackendJWTStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendJWTStatus. -func (in *BackendJWTStatus) DeepCopy() *BackendJWTStatus { - if in == nil { - return nil - } - out := new(BackendJWTStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendJWTToken) DeepCopyInto(out *BackendJWTToken) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendJWTToken. -func (in *BackendJWTToken) DeepCopy() *BackendJWTToken { - if in == nil { - return nil - } - out := new(BackendJWTToken) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendList) DeepCopyInto(out *BackendList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Backend, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendList. -func (in *BackendList) DeepCopy() *BackendList { - if in == nil { - return nil - } - out := new(BackendList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BackendList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendReference) DeepCopyInto(out *BackendReference) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendReference. -func (in *BackendReference) DeepCopy() *BackendReference { - if in == nil { - return nil - } - out := new(BackendReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendSpec) DeepCopyInto(out *BackendSpec) { - *out = *in - if in.Services != nil { - in, out := &in.Services, &out.Services - *out = make([]Service, len(*in)) - copy(*out, *in) - } - if in.TLS != nil { - in, out := &in.TLS, &out.TLS - *out = new(TLSConfig) - (*in).DeepCopyInto(*out) - } - if in.Security != nil { - in, out := &in.Security, &out.Security - *out = new(SecurityConfig) - (*in).DeepCopyInto(*out) - } - if in.CircuitBreaker != nil { - in, out := &in.CircuitBreaker, &out.CircuitBreaker - *out = new(CircuitBreaker) - **out = **in - } - if in.Timeout != nil { - in, out := &in.Timeout, &out.Timeout - *out = new(Timeout) - **out = **in - } - if in.Retry != nil { - in, out := &in.Retry, &out.Retry - *out = new(RetryConfig) - (*in).DeepCopyInto(*out) - } - if in.HealthCheck != nil { - in, out := &in.HealthCheck, &out.HealthCheck - *out = new(HealthCheck) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendSpec. -func (in *BackendSpec) DeepCopy() *BackendSpec { - if in == nil { - return nil - } - out := new(BackendSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendStatus) DeepCopyInto(out *BackendStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendStatus. -func (in *BackendStatus) DeepCopy() *BackendStatus { - if in == nil { - return nil - } - out := new(BackendStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BasicSecurityConfig) DeepCopyInto(out *BasicSecurityConfig) { - *out = *in - out.SecretRef = in.SecretRef -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BasicSecurityConfig. -func (in *BasicSecurityConfig) DeepCopy() *BasicSecurityConfig { - if in == nil { - return nil - } - out := new(BasicSecurityConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CORSPolicy) DeepCopyInto(out *CORSPolicy) { - *out = *in - if in.AccessControlAllowHeaders != nil { - in, out := &in.AccessControlAllowHeaders, &out.AccessControlAllowHeaders - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.AccessControlAllowMethods != nil { - in, out := &in.AccessControlAllowMethods, &out.AccessControlAllowMethods - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.AccessControlAllowOrigins != nil { - in, out := &in.AccessControlAllowOrigins, &out.AccessControlAllowOrigins - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.AccessControlExposeHeaders != nil { - in, out := &in.AccessControlExposeHeaders, &out.AccessControlExposeHeaders - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.AccessControlMaxAge != nil { - in, out := &in.AccessControlMaxAge, &out.AccessControlMaxAge - *out = new(int) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CORSPolicy. -func (in *CORSPolicy) DeepCopy() *CORSPolicy { - if in == nil { - return nil - } - out := new(CORSPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CircuitBreaker) DeepCopyInto(out *CircuitBreaker) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CircuitBreaker. -func (in *CircuitBreaker) DeepCopy() *CircuitBreaker { - if in == nil { - return nil - } - out := new(CircuitBreaker) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomClaim) DeepCopyInto(out *CustomClaim) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomClaim. -func (in *CustomClaim) DeepCopy() *CustomClaim { - if in == nil { - return nil - } - out := new(CustomClaim) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomRateLimitPolicy) DeepCopyInto(out *CustomRateLimitPolicy) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRateLimitPolicy. -func (in *CustomRateLimitPolicy) DeepCopy() *CustomRateLimitPolicy { - if in == nil { - return nil - } - out := new(CustomRateLimitPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CustomRateLimitPolicyDef) DeepCopyInto(out *CustomRateLimitPolicyDef) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRateLimitPolicyDef. -func (in *CustomRateLimitPolicyDef) DeepCopy() *CustomRateLimitPolicyDef { - if in == nil { - return nil - } - out := new(CustomRateLimitPolicyDef) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { - *out = *in - if in.TransitionTime != nil { - in, out := &in.TransitionTime, &out.TransitionTime - *out = (*in).DeepCopy() - } - if in.Events != nil { - in, out := &in.Events, &out.Events - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentStatus. -func (in *DeploymentStatus) DeepCopy() *DeploymentStatus { - if in == nil { - return nil - } - out := new(DeploymentStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *EnvConfig) DeepCopyInto(out *EnvConfig) { - *out = *in - if in.HTTPRouteRefs != nil { - in, out := &in.HTTPRouteRefs, &out.HTTPRouteRefs - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvConfig. -func (in *EnvConfig) DeepCopy() *EnvConfig { - if in == nil { - return nil - } - out := new(EnvConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HealthCheck) DeepCopyInto(out *HealthCheck) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthCheck. -func (in *HealthCheck) DeepCopy() *HealthCheck { - if in == nil { - return nil - } - out := new(HealthCheck) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InterceptorReference) DeepCopyInto(out *InterceptorReference) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InterceptorReference. -func (in *InterceptorReference) DeepCopy() *InterceptorReference { - if in == nil { - return nil - } - out := new(InterceptorReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InterceptorService) DeepCopyInto(out *InterceptorService) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InterceptorService. -func (in *InterceptorService) DeepCopy() *InterceptorService { - if in == nil { - return nil - } - out := new(InterceptorService) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *InterceptorService) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InterceptorServiceList) DeepCopyInto(out *InterceptorServiceList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]InterceptorService, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InterceptorServiceList. -func (in *InterceptorServiceList) DeepCopy() *InterceptorServiceList { - if in == nil { - return nil - } - out := new(InterceptorServiceList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *InterceptorServiceList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InterceptorServiceSpec) DeepCopyInto(out *InterceptorServiceSpec) { - *out = *in - out.BackendRef = in.BackendRef - if in.Includes != nil { - in, out := &in.Includes, &out.Includes - *out = make([]InterceptorInclusion, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InterceptorServiceSpec. -func (in *InterceptorServiceSpec) DeepCopy() *InterceptorServiceSpec { - if in == nil { - return nil - } - out := new(InterceptorServiceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InterceptorServiceStatus) DeepCopyInto(out *InterceptorServiceStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InterceptorServiceStatus. -func (in *InterceptorServiceStatus) DeepCopy() *InterceptorServiceStatus { - if in == nil { - return nil - } - out := new(InterceptorServiceStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PolicySpec) DeepCopyInto(out *PolicySpec) { - *out = *in - if in.RequestInterceptors != nil { - in, out := &in.RequestInterceptors, &out.RequestInterceptors - *out = make([]InterceptorReference, len(*in)) - copy(*out, *in) - } - if in.ResponseInterceptors != nil { - in, out := &in.ResponseInterceptors, &out.ResponseInterceptors - *out = make([]InterceptorReference, len(*in)) - copy(*out, *in) - } - if in.BackendJWTPolicy != nil { - in, out := &in.BackendJWTPolicy, &out.BackendJWTPolicy - *out = new(BackendJWTToken) - **out = **in - } - if in.CORSPolicy != nil { - in, out := &in.CORSPolicy, &out.CORSPolicy - *out = new(CORSPolicy) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicySpec. -func (in *PolicySpec) DeepCopy() *PolicySpec { - if in == nil { - return nil - } - out := new(PolicySpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Property) DeepCopyInto(out *Property) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Property. -func (in *Property) DeepCopy() *Property { - if in == nil { - return nil - } - out := new(Property) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RateLimitAPIPolicy) DeepCopyInto(out *RateLimitAPIPolicy) { - *out = *in - if in.API != nil { - in, out := &in.API, &out.API - *out = new(APIRateLimitPolicy) - **out = **in - } - if in.Custom != nil { - in, out := &in.Custom, &out.Custom - *out = new(CustomRateLimitPolicy) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RateLimitAPIPolicy. -func (in *RateLimitAPIPolicy) DeepCopy() *RateLimitAPIPolicy { - if in == nil { - return nil - } - out := new(RateLimitAPIPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RateLimitPolicy) DeepCopyInto(out *RateLimitPolicy) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RateLimitPolicy. -func (in *RateLimitPolicy) DeepCopy() *RateLimitPolicy { - if in == nil { - return nil - } - out := new(RateLimitPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *RateLimitPolicy) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RateLimitPolicyList) DeepCopyInto(out *RateLimitPolicyList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]RateLimitPolicy, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RateLimitPolicyList. -func (in *RateLimitPolicyList) DeepCopy() *RateLimitPolicyList { - if in == nil { - return nil - } - out := new(RateLimitPolicyList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *RateLimitPolicyList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RateLimitPolicySpec) DeepCopyInto(out *RateLimitPolicySpec) { - *out = *in - if in.Default != nil { - in, out := &in.Default, &out.Default - *out = new(RateLimitAPIPolicy) - (*in).DeepCopyInto(*out) - } - if in.Override != nil { - in, out := &in.Override, &out.Override - *out = new(RateLimitAPIPolicy) - (*in).DeepCopyInto(*out) - } - in.TargetRef.DeepCopyInto(&out.TargetRef) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RateLimitPolicySpec. -func (in *RateLimitPolicySpec) DeepCopy() *RateLimitPolicySpec { - if in == nil { - return nil - } - out := new(RateLimitPolicySpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RateLimitPolicyStatus) DeepCopyInto(out *RateLimitPolicyStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RateLimitPolicyStatus. -func (in *RateLimitPolicyStatus) DeepCopy() *RateLimitPolicyStatus { - if in == nil { - return nil - } - out := new(RateLimitPolicyStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RefConfig) DeepCopyInto(out *RefConfig) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RefConfig. -func (in *RefConfig) DeepCopy() *RefConfig { - if in == nil { - return nil - } - out := new(RefConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResolveRateLimit) DeepCopyInto(out *ResolveRateLimit) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResolveRateLimit. -func (in *ResolveRateLimit) DeepCopy() *ResolveRateLimit { - if in == nil { - return nil - } - out := new(ResolveRateLimit) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResolveRateLimitAPIPolicy) DeepCopyInto(out *ResolveRateLimitAPIPolicy) { - *out = *in - out.API = in.API - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = make([]ResolveResource, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResolveRateLimitAPIPolicy. -func (in *ResolveRateLimitAPIPolicy) DeepCopy() *ResolveRateLimitAPIPolicy { - if in == nil { - return nil - } - out := new(ResolveRateLimitAPIPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResolveResource) DeepCopyInto(out *ResolveResource) { - *out = *in - out.ResourceRatelimit = in.ResourceRatelimit -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResolveResource. -func (in *ResolveResource) DeepCopy() *ResolveResource { - if in == nil { - return nil - } - out := new(ResolveResource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RetryConfig) DeepCopyInto(out *RetryConfig) { - *out = *in - if in.StatusCodes != nil { - in, out := &in.StatusCodes, &out.StatusCodes - *out = make([]uint32, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RetryConfig. -func (in *RetryConfig) DeepCopy() *RetryConfig { - if in == nil { - return nil - } - out := new(RetryConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SecretRef) DeepCopyInto(out *SecretRef) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretRef. -func (in *SecretRef) DeepCopy() *SecretRef { - if in == nil { - return nil - } - out := new(SecretRef) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SecurityConfig) DeepCopyInto(out *SecurityConfig) { - *out = *in - if in.Basic != nil { - in, out := &in.Basic, &out.Basic - *out = new(BasicSecurityConfig) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityConfig. -func (in *SecurityConfig) DeepCopy() *SecurityConfig { - if in == nil { - return nil - } - out := new(SecurityConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Service) DeepCopyInto(out *Service) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Service. -func (in *Service) DeepCopy() *Service { - if in == nil { - return nil - } - out := new(Service) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TLSConfig) DeepCopyInto(out *TLSConfig) { - *out = *in - if in.CertificateInline != nil { - in, out := &in.CertificateInline, &out.CertificateInline - *out = new(string) - **out = **in - } - if in.SecretRef != nil { - in, out := &in.SecretRef, &out.SecretRef - *out = new(RefConfig) - **out = **in - } - if in.ConfigMapRef != nil { - in, out := &in.ConfigMapRef, &out.ConfigMapRef - *out = new(RefConfig) - **out = **in - } - if in.AllowedSANs != nil { - in, out := &in.AllowedSANs, &out.AllowedSANs - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSConfig. -func (in *TLSConfig) DeepCopy() *TLSConfig { - if in == nil { - return nil - } - out := new(TLSConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Timeout) DeepCopyInto(out *Timeout) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Timeout. -func (in *Timeout) DeepCopy() *Timeout { - if in == nil { - return nil - } - out := new(Timeout) - in.DeepCopyInto(out) - return out -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/api_conversion.go b/common-controller/internal/operator/apis/dp/v1alpha2/api_conversion.go deleted file mode 100644 index 5a1953e138..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha2/api_conversion.go +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -// Hub marks this type as a conversion hub. -func (*API) Hub() {} diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/api_types.go b/common-controller/internal/operator/apis/dp/v1alpha2/api_types.go deleted file mode 100644 index 9d21a2f04b..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha2/api_types.go +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// APISpec defines the desired state of API -type APISpec struct { - - // APIName is the unique name of the API - //can be used to uniquely identify an API. - // - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=60 - // +kubebuilder:validation:Pattern="^[^~!@#;:%^*()+={}|\\<>\"'',&$\\[\\]\\/]*$" - APIName string `json:"apiName"` - - // APIVersion is the version number of the API. - // - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=30 - // +kubebuilder:validation:Pattern="^[^~!@#;:%^*()+={}|\\<>\"'',&/$\\[\\]\\s+\\/]+$" - APIVersion string `json:"apiVersion"` - - // IsDefaultVersion indicates whether this API version should be used as a default API - // - // +optional - IsDefaultVersion bool `json:"isDefaultVersion"` - - // DefinitionFileRef contains the OpenAPI 3 or Swagger - // definition of the API in a ConfigMap. - // - // +optional - DefinitionFileRef string `json:"definitionFileRef"` - - // DefinitionPath contains the path to expose the API definition. - // - // +kubebuilder:default:=/api-definition - // +kubebuilder:validation:MinLength=1 - DefinitionPath string `json:"definitionPath"` - - // Production contains a list of references to HttpRoutes - // of type HttpRoute. - // xref: https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go - // - // - // +optional - // +nullable - // +kubebuilder:validation:MaxItems=1 - Production []EnvConfig `json:"production"` - - // Sandbox contains a list of references to HttpRoutes - // of type HttpRoute. - // xref: https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go - // - // - // +optional - // +nullable - // +kubebuilder:validation:MaxItems=1 - Sandbox []EnvConfig `json:"sandbox"` - - // APIType denotes the type of the API. - // Possible values could be REST, GraphQL, Async - // - // +kubebuilder:validation:Enum=REST - APIType string `json:"apiType"` - - // BasePath denotes the basepath of the API. - // e.g: /pet-store-api/1.0.6 - // - // +kubectl:validation:MaxLength=232 - // +kubebuilder:validation:Pattern=^[/][a-zA-Z0-9~/_.-]*$ - BasePath string `json:"basePath"` - - // Organization denotes the organization. - // related to the API - // - // +optional - Organization string `json:"organization"` - - // SystemAPI denotes if it is an internal system API. - // - // +optional - SystemAPI bool `json:"systemAPI"` - - // APIProperties denotes the custom properties of the API. - // - // +optional - // +nullable - APIProperties []Property `json:"apiProperties,omitempty"` - - // Environment denotes the environment of the API. - // - // +optional - // +nullable - Environment string `json:"environment,omitempty"` -} - -// Property holds key value pair of APIProperties -type Property struct { - Name string `json:"name,omitempty"` - Value string `json:"value,omitempty"` -} - -// EnvConfig contains the environment specific configuration -type EnvConfig struct { - // HTTPRouteRefs denotes the environment of the API. - HTTPRouteRefs []string `json:"httpRouteRefs"` -} - -// APIStatus defines the observed state of API -type APIStatus struct { - // DeploymentStatus denotes the deployment status of the API - // - // +optional - DeploymentStatus DeploymentStatus `json:"deploymentStatus"` -} - -// DeploymentStatus contains the status of the API deployment -type DeploymentStatus struct { - - // Status denotes the state of the API in its lifecycle. - // Possible values could be Accepted, Invalid, Deploy etc. - // - // - Status string `json:"status"` - - // Message represents a user friendly message that explains the - // current state of the API. - // - // - // +optional - Message string `json:"message"` - - // Accepted represents whether the API is accepted or not. - // - // - Accepted bool `json:"accepted"` - - // TransitionTime represents the last known transition timestamp. - // - // - TransitionTime *metav1.Time `json:"transitionTime"` - - // Events contains a list of events related to the API. - // - // - // +optional - Events []string `json:"events,omitempty"` -} - -// +genclient -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:storageversion -//+kubebuilder:printcolumn:name="API Name",type="string",JSONPath=".spec.apiName" -//+kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.apiVersion" -//+kubebuilder:printcolumn:name="BasePath",type="string",JSONPath=".spec.basePath" -//+kubebuilder:printcolumn:name="Organization",type="string",JSONPath=".spec.organization" -//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" - -// API is the Schema for the apis API -type API struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec APISpec `json:"spec,omitempty"` - Status APIStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// APIList contains a list of API -type APIList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []API `json:"items"` -} - -func init() { - SchemeBuilder.Register(&API{}, &APIList{}) -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/api_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha2/api_webhook.go deleted file mode 100644 index f2d92f6426..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha2/api_webhook.go +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -import ( - "context" - "errors" - "fmt" - "strings" - - "github.com/wso2/apk/adapter/pkg/logging" - "github.com/wso2/apk/common-controller/internal/config" - "github.com/wso2/apk/common-controller/internal/loggers" - "github.com/wso2/apk/common-controller/internal/utils" - "golang.org/x/exp/slices" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/validation/field" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" -) - -var c client.Client - -// SetupWebhookWithManager creates a new webhook builder for API -func (r *API) SetupWebhookWithManager(mgr ctrl.Manager) error { - - c = mgr.GetClient() - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1alpha2-api,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apis,verbs=create;update,versions=v1alpha2,name=mapi.kb.io,admissionReviewVersions=v1 - -var _ webhook.Defaulter = &API{} - -// Default implements webhook.Defaulter so a webhook will be registered for the type -func (r *API) Default() { - // TODO(user): fill in your defaulting logic. -} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1alpha2-api,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apis,verbs=create;update,versions=v1alpha2,name=vapi.kb.io,admissionReviewVersions=v1 - -var _ webhook.Validator = &API{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (r *API) ValidateCreate() (admission.Warnings, error) { - return nil, r.validateAPI() -} - -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (r *API) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - return nil, r.validateAPI() -} - -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (r *API) ValidateDelete() (admission.Warnings, error) { - - // TODO(user): fill in your validation logic upon object deletion. - return nil, nil -} - -// validateAPI validate api crd fields -func (r *API) validateAPI() error { - - var allErrs field.ErrorList - conf := config.ReadConfigs() - namespaces := conf.CommonController.Operator.Namespaces - if len(namespaces) > 0 { - if !slices.Contains(namespaces, r.Namespace) { - loggers.LoggerAPK.Debugf("API validation Skipped for namespace: %v", r.Namespace) - return nil - } - } - - if r.Spec.BasePath == "" { - allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("basePath"), "API basePath is required")) - } else if errMsg := validateAPIBasePathFormat(r.Spec.BasePath, r.Spec.APIVersion); errMsg != "" { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("basePath"), r.Spec.BasePath, errMsg)) - } else if err := r.validateAPIBasePathExistsAndDefaultVersion(); err != nil { - allErrs = append(allErrs, err) - } - - // Organization value should not be empty as it required when applying ratelimit policy - if r.Spec.Organization == "" { - allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("organization"), "Organization can not be empty")) - } - - if !(len(r.Spec.Production) > 0 && r.Spec.Production[0].HTTPRouteRefs != nil && len(r.Spec.Production[0].HTTPRouteRefs) > 0) && !(len(r.Spec.Sandbox) > 0 && r.Spec.Sandbox[0].HTTPRouteRefs != nil && len(r.Spec.Sandbox[0].HTTPRouteRefs) > 0) { - allErrs = append(allErrs, field.Required(field.NewPath("spec"), - "both API production and sandbox endpoint references cannot be empty")) - } - - var prodHTTPRoute1, sandHTTPRoute1 []string - if len(r.Spec.Production) > 0 { - prodHTTPRoute1 = r.Spec.Production[0].HTTPRouteRefs - } - if len(r.Spec.Sandbox) > 0 { - sandHTTPRoute1 = r.Spec.Sandbox[0].HTTPRouteRefs - } - - if isEmptyStringsInArray(prodHTTPRoute1) { - allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("production").Child("httpRouteRefs"), - "API production endpoint reference cannot be empty")) - } - - if isEmptyStringsInArray(sandHTTPRoute1) { - allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("sandbox").Child("httpRouteRefs"), - "API sandbox endpoint reference cannot be empty")) - } - - if len(allErrs) > 0 { - return apierrors.NewInvalid( - schema.GroupKind{Group: "dp.wso2.com", Kind: "API"}, - r.Name, allErrs) - } - - return nil -} - -func isEmptyStringsInArray(strings []string) bool { - for _, str := range strings { - if str == "" { - return true - } - } - return false -} - -func (r *API) validateAPIBasePathExistsAndDefaultVersion() *field.Error { - - apiList, err := retrieveAPIList() - if err != nil { - return field.InternalError(field.NewPath("spec").Child("basePath"), - errors.New("unable to list APIs for API basePath validation")) - - } - currentAPIBasePathWithoutVersion := getBasePathWithoutVersion(r.Spec.BasePath) - incomingAPIEnvironment := utils.GetEnvironment(r.Spec.Environment) - for _, api := range apiList { - if (types.NamespacedName{Namespace: r.Namespace, Name: r.Name} != - types.NamespacedName{Namespace: api.Namespace, Name: api.Name}) { - - existingAPIEnvironment := utils.GetEnvironment(api.Spec.Environment) - if api.Spec.Organization == r.Spec.Organization && api.Spec.BasePath == r.Spec.BasePath && - incomingAPIEnvironment == existingAPIEnvironment { - return &field.Error{ - Type: field.ErrorTypeDuplicate, - Field: field.NewPath("spec").Child("basePath").String(), - BadValue: r.Spec.BasePath, - Detail: "an API has been already created for the basePath"} - } - if r.Spec.IsDefaultVersion { - targetAPIBasePathWithoutVersion := getBasePathWithoutVersion(api.Spec.BasePath) - targetAPIBasePathWithVersion := api.Spec.BasePath - if api.Spec.IsDefaultVersion { - if targetAPIBasePathWithoutVersion == currentAPIBasePathWithoutVersion { - return &field.Error{ - Type: field.ErrorTypeForbidden, - Field: field.NewPath("spec").Child("isDefaultVersion").String(), - BadValue: r.Spec.BasePath, - Detail: "this API already has a default version"} - } - - } - if targetAPIBasePathWithVersion == currentAPIBasePathWithoutVersion { - return &field.Error{ - Type: field.ErrorTypeForbidden, - Field: field.NewPath("spec").Child("isDefaultVersion").String(), - BadValue: r.Spec.BasePath, - Detail: fmt.Sprintf("api: %s's basePath path is colliding with default path", r.Name)} - } - } - } - } - return nil -} - -func retrieveAPIList() ([]API, error) { - ctx := context.Background() - conf := config.ReadConfigs() - namespaces := conf.CommonController.Operator.Namespaces - var apis []API - if namespaces == nil { - apiList := &APIList{} - if err := c.List(ctx, apiList, &client.ListOptions{}); err != nil { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2605, logging.CRITICAL, "Unable to list APIs: %v", err.Error())) - return nil, err - } - apis = make([]API, len(apiList.Items)) - copy(apis[:], apiList.Items[:]) - } else { - for _, namespace := range namespaces { - apiList := &APIList{} - if err := c.List(ctx, apiList, &client.ListOptions{Namespace: namespace}); err != nil { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2605, logging.CRITICAL, "Unable to list APIs: %v", err.Error())) - return nil, err - } - apis = append(apis, apiList.Items...) - } - } - return apis, nil -} - -func validateAPIBasePathFormat(basePath string, apiVersion string) string { - if !strings.HasSuffix("/"+basePath, apiVersion) { - return "API basePath value should contain the /{APIVersion} at end." - } - return "" -} - -// getBasePathWithoutVersion returns the basePath without version -func getBasePathWithoutVersion(basePath string) string { - lastIndex := strings.LastIndex(basePath, "/") - if lastIndex != -1 { - return basePath[:lastIndex] - } - return basePath -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/api_webhook_test.go b/common-controller/internal/operator/apis/dp/v1alpha2/api_webhook_test.go deleted file mode 100644 index a994829ee7..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha2/api_webhook_test.go +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestValidateAPIBasePath(t *testing.T) { - type getAPITestItem struct { - pass bool - message string - basePath string - } - dataItems := []getAPITestItem{ - { - basePath: "/base", - pass: false, - message: "API basePath value should contain the /{APIVersion} at end.", - }, - } - for _, item := range dataItems { - err := validateAPIBasePathFormat(item.basePath, "v1") - assert.Equal(t, item.pass, err == "", item.message) - } -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_types.go b/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_types.go deleted file mode 100644 index 4bb4008a45..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_types.go +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1alpha2" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// APIPolicySpec defines the desired state of APIPolicy -type APIPolicySpec struct { - Default *PolicySpec `json:"default,omitempty"` - Override *PolicySpec `json:"override,omitempty"` - TargetRef gwapiv1b1.PolicyTargetReference `json:"targetRef,omitempty"` -} - -// PolicySpec contains API policies -type PolicySpec struct { - // RequestInterceptors referenced to intercetor services to be applied - // to the request flow. - // - // +optional - // +nullable - // +kubebuilder:validation:MaxItems=1 - RequestInterceptors []InterceptorReference `json:"requestInterceptors,omitempty"` - - // ResponseInterceptors referenced to intercetor services to be applied - // to the response flow. - // - // +optional - // +nullable - // +kubebuilder:validation:MaxItems=1 - ResponseInterceptors []InterceptorReference `json:"responseInterceptors,omitempty"` - - // BackendJWTPolicy holds reference to backendJWT policy configurations - BackendJWTPolicy *BackendJWTToken `json:"backendJwtPolicy,omitempty"` - - // CORS policy to be applied to the API. - CORSPolicy *CORSPolicy `json:"cORSPolicy,omitempty"` - - // SubscriptionValidation denotes whether subscription validation is enabled for the API - // - // +kubebuilder:default:=false - // +optional - SubscriptionValidation bool `json:"subscriptionValidation,omitempty"` -} - -// BackendJWTToken holds backend JWT token information -type BackendJWTToken struct { - // Name holds the name of the BackendJWT resource. - Name string `json:"name,omitempty"` -} - -// CORSPolicy holds CORS policy information -type CORSPolicy struct { - // AllowCredentials indicates whether the request can include user credentials like - // cookies, HTTP authentication or client side SSL certificates. - // - // +optional - AccessControlAllowCredentials bool `json:"accessControlAllowCredentials,omitempty"` - - // AccessControlAllowHeaders indicates which headers can be used - // during the actual request. - // - // +optional - AccessControlAllowHeaders []string `json:"accessControlAllowHeaders,omitempty"` - - // AccessControlAllowMethods indicates which methods can be used - // during the actual request. - // - // +optional - AccessControlAllowMethods []string `json:"accessControlAllowMethods,omitempty"` - - // AccessControlAllowOrigins indicates which origins can be used - // during the actual request. - // - // +optional - AccessControlAllowOrigins []string `json:"accessControlAllowOrigins,omitempty"` - - // AccessControlExposeHeaders indicates which headers can be exposed - // as part of the response by listing their names. - // - // +optional - AccessControlExposeHeaders []string `json:"accessControlExposeHeaders,omitempty"` - - // AccessControlMaxAge indicates how long the results of a preflight request - // can be cached in a preflight result cache. - // - // +optional - AccessControlMaxAge *int `json:"accessControlMaxAge,omitempty"` -} - -// InterceptorReference holds InterceptorService reference using name and namespace -type InterceptorReference struct { - // Name is the referced CR's name of InterceptorService resource. - Name string `json:"name"` -} - -// APIPolicyStatus defines the observed state of APIPolicy -type APIPolicyStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +genclient -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:storageversion - -// APIPolicy is the Schema for the apipolicies API -type APIPolicy struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec APIPolicySpec `json:"spec,omitempty"` - Status APIPolicyStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// APIPolicyList contains a list of APIPolicy -type APIPolicyList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []APIPolicy `json:"items"` -} - -func init() { - SchemeBuilder.Register(&APIPolicy{}, &APIPolicyList{}) -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_webhook.go deleted file mode 100644 index 997b29c8ce..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_webhook.go +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -import ( - constants "github.com/wso2/apk/common-controller/internal/operator/constant" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/validation/field" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "sigs.k8s.io/gateway-api/apis/v1beta1" -) - -// SetupWebhookWithManager creates a new webhook builder for APIPolicy -func (r *APIPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1alpha2-apipolicy,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apipolicies,verbs=create;update,versions=v1alpha2,name=mapipolicy.kb.io,admissionReviewVersions=v1 - -var _ webhook.Defaulter = &APIPolicy{} - -// Default implements webhook.Defaulter so a webhook will be registered for the type -func (r *APIPolicy) Default() {} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1alpha2-apipolicy,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apipolicies,verbs=create;update,versions=v1alpha2,name=vapipolicy.kb.io,admissionReviewVersions=v1 - -var _ webhook.Validator = &APIPolicy{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (r *APIPolicy) ValidateCreate() (admission.Warnings, error) { - return nil, r.ValidatePolicy() -} - -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (r *APIPolicy) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - return nil, r.ValidatePolicy() -} - -// ValidatePolicy validates the APIPolicy -func (r *APIPolicy) ValidatePolicy() error { - var allErrs field.ErrorList - - if r.Spec.TargetRef.Name == "" { - allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("targetRef").Child("name"), "Name is required")) - } - if !(r.Spec.TargetRef.Kind == constants.KindAPI || r.Spec.TargetRef.Kind == constants.KindResource || - r.Spec.TargetRef.Kind == constants.KindGateway) { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("targetRef").Child("kind"), r.Spec.TargetRef.Kind, - "Invalid Kind is provided")) - } - if r.Spec.TargetRef.Namespace != nil && r.Spec.TargetRef.Namespace != (*v1beta1.Namespace)(&r.Namespace) { - allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("targetRef").Child("namespace"), r.Spec.TargetRef.Namespace, - "namespace cross reference is not allowed")) - } - if len(allErrs) > 0 { - return apierrors.NewInvalid( - schema.GroupKind{Group: "dp.wso2.com", Kind: "APIPolicy"}, - r.Name, allErrs) - } - return nil -} - -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (r *APIPolicy) ValidateDelete() (admission.Warnings, error) { - // TODO(user): fill in your validation logic upon object deletion. - return nil, nil -} diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/groupversion_info.go b/common-controller/internal/operator/apis/dp/v1alpha2/groupversion_info.go deleted file mode 100644 index 5ee8176785..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha2/groupversion_info.go +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package v1alpha2 contains API Schema definitions for the dp v1alpha2 API group -// +kubebuilder:object:generate=true -// +groupName=dp.wso2.com -package v1alpha2 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "dp.wso2.com", Version: "v1alpha2"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/webhook_suite_test.go b/common-controller/internal/operator/apis/dp/v1alpha2/webhook_suite_test.go deleted file mode 100644 index a43cff45ae..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha2/webhook_suite_test.go +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1alpha2 - -import ( - "context" - "crypto/tls" - "fmt" - "net" - "path/filepath" - "testing" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - admissionv1beta1 "k8s.io/api/admission/v1beta1" - //+kubebuilder:scaffold:imports - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/rest" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestAPIs(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Webhook Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: false, - WebhookInstallOptions: envtest.WebhookInstallOptions{ - Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, - }, - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - scheme := runtime.NewScheme() - err = AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - err = admissionv1beta1.AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - //+kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - - // start webhook server using Manager - webhookInstallOptions := &testEnv.WebhookInstallOptions - mgr, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme, - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - LeaderElection: false, - MetricsBindAddress: "0", - }) - Expect(err).NotTo(HaveOccurred()) - - err = (&APIPolicy{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - //+kubebuilder:scaffold:webhook - - go func() { - defer GinkgoRecover() - err = mgr.Start(ctx) - Expect(err).NotTo(HaveOccurred()) - }() - - // wait for the webhook server to get ready - dialer := &net.Dialer{Timeout: time.Second} - addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort) - Eventually(func() error { - conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true}) - if err != nil { - return err - } - conn.Close() - return nil - }).Should(Succeed()) - -}) - -var _ = AfterSuite(func() { - cancel() - By("tearing down the test environment") - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go b/common-controller/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go deleted file mode 100644 index 4289c0ab5e..0000000000 --- a/common-controller/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go +++ /dev/null @@ -1,400 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *API) DeepCopyInto(out *API) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new API. -func (in *API) DeepCopy() *API { - if in == nil { - return nil - } - out := new(API) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *API) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIList) DeepCopyInto(out *APIList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]API, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIList. -func (in *APIList) DeepCopy() *APIList { - if in == nil { - return nil - } - out := new(APIList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *APIList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIPolicy) DeepCopyInto(out *APIPolicy) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicy. -func (in *APIPolicy) DeepCopy() *APIPolicy { - if in == nil { - return nil - } - out := new(APIPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *APIPolicy) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIPolicyList) DeepCopyInto(out *APIPolicyList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]APIPolicy, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicyList. -func (in *APIPolicyList) DeepCopy() *APIPolicyList { - if in == nil { - return nil - } - out := new(APIPolicyList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *APIPolicyList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIPolicySpec) DeepCopyInto(out *APIPolicySpec) { - *out = *in - if in.Default != nil { - in, out := &in.Default, &out.Default - *out = new(PolicySpec) - (*in).DeepCopyInto(*out) - } - if in.Override != nil { - in, out := &in.Override, &out.Override - *out = new(PolicySpec) - (*in).DeepCopyInto(*out) - } - in.TargetRef.DeepCopyInto(&out.TargetRef) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicySpec. -func (in *APIPolicySpec) DeepCopy() *APIPolicySpec { - if in == nil { - return nil - } - out := new(APIPolicySpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIPolicyStatus) DeepCopyInto(out *APIPolicyStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicyStatus. -func (in *APIPolicyStatus) DeepCopy() *APIPolicyStatus { - if in == nil { - return nil - } - out := new(APIPolicyStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APISpec) DeepCopyInto(out *APISpec) { - *out = *in - if in.Production != nil { - in, out := &in.Production, &out.Production - *out = make([]EnvConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Sandbox != nil { - in, out := &in.Sandbox, &out.Sandbox - *out = make([]EnvConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.APIProperties != nil { - in, out := &in.APIProperties, &out.APIProperties - *out = make([]Property, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APISpec. -func (in *APISpec) DeepCopy() *APISpec { - if in == nil { - return nil - } - out := new(APISpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIStatus) DeepCopyInto(out *APIStatus) { - *out = *in - in.DeploymentStatus.DeepCopyInto(&out.DeploymentStatus) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIStatus. -func (in *APIStatus) DeepCopy() *APIStatus { - if in == nil { - return nil - } - out := new(APIStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BackendJWTToken) DeepCopyInto(out *BackendJWTToken) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendJWTToken. -func (in *BackendJWTToken) DeepCopy() *BackendJWTToken { - if in == nil { - return nil - } - out := new(BackendJWTToken) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CORSPolicy) DeepCopyInto(out *CORSPolicy) { - *out = *in - if in.AccessControlAllowHeaders != nil { - in, out := &in.AccessControlAllowHeaders, &out.AccessControlAllowHeaders - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.AccessControlAllowMethods != nil { - in, out := &in.AccessControlAllowMethods, &out.AccessControlAllowMethods - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.AccessControlAllowOrigins != nil { - in, out := &in.AccessControlAllowOrigins, &out.AccessControlAllowOrigins - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.AccessControlExposeHeaders != nil { - in, out := &in.AccessControlExposeHeaders, &out.AccessControlExposeHeaders - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.AccessControlMaxAge != nil { - in, out := &in.AccessControlMaxAge, &out.AccessControlMaxAge - *out = new(int) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CORSPolicy. -func (in *CORSPolicy) DeepCopy() *CORSPolicy { - if in == nil { - return nil - } - out := new(CORSPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { - *out = *in - if in.TransitionTime != nil { - in, out := &in.TransitionTime, &out.TransitionTime - *out = (*in).DeepCopy() - } - if in.Events != nil { - in, out := &in.Events, &out.Events - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentStatus. -func (in *DeploymentStatus) DeepCopy() *DeploymentStatus { - if in == nil { - return nil - } - out := new(DeploymentStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *EnvConfig) DeepCopyInto(out *EnvConfig) { - *out = *in - if in.HTTPRouteRefs != nil { - in, out := &in.HTTPRouteRefs, &out.HTTPRouteRefs - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvConfig. -func (in *EnvConfig) DeepCopy() *EnvConfig { - if in == nil { - return nil - } - out := new(EnvConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InterceptorReference) DeepCopyInto(out *InterceptorReference) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InterceptorReference. -func (in *InterceptorReference) DeepCopy() *InterceptorReference { - if in == nil { - return nil - } - out := new(InterceptorReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PolicySpec) DeepCopyInto(out *PolicySpec) { - *out = *in - if in.RequestInterceptors != nil { - in, out := &in.RequestInterceptors, &out.RequestInterceptors - *out = make([]InterceptorReference, len(*in)) - copy(*out, *in) - } - if in.ResponseInterceptors != nil { - in, out := &in.ResponseInterceptors, &out.ResponseInterceptors - *out = make([]InterceptorReference, len(*in)) - copy(*out, *in) - } - if in.BackendJWTPolicy != nil { - in, out := &in.BackendJWTPolicy, &out.BackendJWTPolicy - *out = new(BackendJWTToken) - **out = **in - } - if in.CORSPolicy != nil { - in, out := &in.CORSPolicy, &out.CORSPolicy - *out = new(CORSPolicy) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicySpec. -func (in *PolicySpec) DeepCopy() *PolicySpec { - if in == nil { - return nil - } - out := new(PolicySpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Property) DeepCopyInto(out *Property) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Property. -func (in *Property) DeepCopy() *Property { - if in == nil { - return nil - } - out := new(Property) - in.DeepCopyInto(out) - return out -} diff --git a/common-controller/internal/operator/controllers/cp/application_controller.go b/common-controller/internal/operator/controllers/cp/application_controller.go index 2f7090bd3c..826825e047 100644 --- a/common-controller/internal/operator/controllers/cp/application_controller.go +++ b/common-controller/internal/operator/controllers/cp/application_controller.go @@ -23,10 +23,10 @@ import ( "github.com/wso2/apk/adapter/pkg/logging" "github.com/wso2/apk/common-controller/internal/cache" "github.com/wso2/apk/common-controller/internal/loggers" - cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" constants "github.com/wso2/apk/common-controller/internal/operator/constant" "github.com/wso2/apk/common-controller/internal/server" "github.com/wso2/apk/common-controller/internal/utils" + cpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/cp/v1alpha2" k8error "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" diff --git a/common-controller/internal/operator/controllers/cp/applicationmapping_controller.go b/common-controller/internal/operator/controllers/cp/applicationmapping_controller.go index 3466670909..c24c71466b 100644 --- a/common-controller/internal/operator/controllers/cp/applicationmapping_controller.go +++ b/common-controller/internal/operator/controllers/cp/applicationmapping_controller.go @@ -39,9 +39,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" constants "github.com/wso2/apk/common-controller/internal/operator/constant" "github.com/wso2/apk/common-controller/internal/utils" + cpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/cp/v1alpha2" ) // ApplicationMappingReconciler reconciles a ApplicationMapping object diff --git a/common-controller/internal/operator/controllers/cp/subscription_controller.go b/common-controller/internal/operator/controllers/cp/subscription_controller.go index eb29003e89..117c9f2c12 100644 --- a/common-controller/internal/operator/controllers/cp/subscription_controller.go +++ b/common-controller/internal/operator/controllers/cp/subscription_controller.go @@ -37,7 +37,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/source" - cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" + cpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/cp/v1alpha2" ) // SubscriptionReconciler reconciles a Subscription object diff --git a/common-controller/internal/operator/controllers/cp/suite_test.go b/common-controller/internal/operator/controllers/cp/suite_test.go index 767f73915e..f412660305 100644 --- a/common-controller/internal/operator/controllers/cp/suite_test.go +++ b/common-controller/internal/operator/controllers/cp/suite_test.go @@ -31,7 +31,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" + cpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/cp/v1alpha2" //+kubebuilder:scaffold:imports ) diff --git a/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go b/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go index e6e075a525..2b35b1fe4a 100644 --- a/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go +++ b/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go @@ -42,11 +42,11 @@ import ( cache "github.com/wso2/apk/common-controller/internal/cache" "github.com/wso2/apk/common-controller/internal/config" loggers "github.com/wso2/apk/common-controller/internal/loggers" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" - dpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha2" constants "github.com/wso2/apk/common-controller/internal/operator/constant" "github.com/wso2/apk/common-controller/internal/utils" xds "github.com/wso2/apk/common-controller/internal/xds" + dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" + dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" ) // RateLimitPolicyReconciler reconciles a RateLimitPolicy object diff --git a/common-controller/internal/operator/controllers/dp/suite_test.go b/common-controller/internal/operator/controllers/dp/suite_test.go index 0738790e30..fd1ec07c35 100644 --- a/common-controller/internal/operator/controllers/dp/suite_test.go +++ b/common-controller/internal/operator/controllers/dp/suite_test.go @@ -30,7 +30,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" + dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" //+kubebuilder:scaffold:imports ) diff --git a/common-controller/internal/operator/operator.go b/common-controller/internal/operator/operator.go index 8518f327f3..bd973ae28b 100644 --- a/common-controller/internal/operator/operator.go +++ b/common-controller/internal/operator/operator.go @@ -35,11 +35,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" - cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" - dpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha2" cpcontrollers "github.com/wso2/apk/common-controller/internal/operator/controllers/cp" dpcontrollers "github.com/wso2/apk/common-controller/internal/operator/controllers/dp" + cpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/cp/v1alpha2" + dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" + dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" //+kubebuilder:scaffold:imports ) diff --git a/common-controller/internal/utils/event_utils.go b/common-controller/internal/utils/event_utils.go index afe593178b..bdc68be02f 100644 --- a/common-controller/internal/utils/event_utils.go +++ b/common-controller/internal/utils/event_utils.go @@ -7,8 +7,8 @@ import ( apkmgt "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/service/apkmgt" "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription" "github.com/wso2/apk/common-controller/internal/loggers" - cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" constants "github.com/wso2/apk/common-controller/internal/operator/constant" + cpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/cp/v1alpha2" ) // SendAppDeletionEvent sends an application creation event to the enforcer diff --git a/common-controller/internal/xds/ratelimiter_cache.go b/common-controller/internal/xds/ratelimiter_cache.go index a540cbc163..cdef678374 100644 --- a/common-controller/internal/xds/ratelimiter_cache.go +++ b/common-controller/internal/xds/ratelimiter_cache.go @@ -30,8 +30,8 @@ import ( logger "github.com/sirupsen/logrus" "github.com/wso2/apk/adapter/pkg/logging" "github.com/wso2/apk/common-controller/internal/loggers" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" constants "github.com/wso2/apk/common-controller/internal/operator/constant" + dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" ) // Constants relevant to the route related ratelimit configurations diff --git a/common-controller/internal/xds/server.go b/common-controller/internal/xds/server.go index af86e60b5b..b65e5719c3 100644 --- a/common-controller/internal/xds/server.go +++ b/common-controller/internal/xds/server.go @@ -33,7 +33,7 @@ import ( wso2_cache "github.com/wso2/apk/adapter/pkg/discovery/protocol/cache/v3" eventhubTypes "github.com/wso2/apk/adapter/pkg/eventhub/types" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" + dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" ) // EnvoyInternalAPI struct use to hold envoy resources and adapter internal resources