diff --git a/.golangci.yml b/.golangci.yml index 665e57207..87e15023a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -106,3 +106,14 @@ linters-settings: - golang.org/x/net/context: recommendations: - context + - github.com/kong/kubernetes-ingress-controller/v3: + recommendations: + - github.com/kong/kubernetes-configuration + - github.com/kong/gateway-operator: + recommendations: + - github.com/kong/kubernetes-configuration + importas: + no-unaliased: true + alias: + - pkg: github.com/kong/kubernetes-configuration/api/configuration/v1 + alias: kcv1 \ No newline at end of file diff --git a/go.mod b/go.mod index bd8450d1f..3db19f98e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/kong/deck -go 1.23.0 +go 1.23.2 replace github.com/yudai/gojsondiff v1.0.0 => github.com/Kong/gojsondiff v1.3.0 @@ -22,16 +22,17 @@ require ( github.com/stretchr/testify v1.9.0 golang.org/x/sync v0.8.0 k8s.io/api v0.31.2 - k8s.io/apiextensions-apiserver v0.31.0 + k8s.io/apiextensions-apiserver v0.31.2 k8s.io/apimachinery v0.31.2 - k8s.io/client-go v0.31.0 + k8s.io/client-go v0.31.2 k8s.io/code-generator v0.31.2 - sigs.k8s.io/gateway-api v1.1.0 + sigs.k8s.io/gateway-api v1.2.0 sigs.k8s.io/yaml v1.4.0 ) require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/Kong/sdk-konnect-go v0.1.6 // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/avast/retry-go/v4 v4.6.0 // indirect @@ -44,6 +45,7 @@ require ( github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/emicklei/go-restful/v3 v3.12.0 // indirect + github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect github.com/fatih/camelcase v1.0.0 // indirect @@ -98,7 +100,7 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/cli-runtime v0.31.0 // indirect - k8s.io/component-base v0.31.0 // indirect + k8s.io/component-base v0.31.2 // indirect k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect k8s.io/kubectl v0.31.0 // indirect sigs.k8s.io/kind v0.24.0 // indirect @@ -145,7 +147,7 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kong/go-slugify v1.0.0 // indirect - github.com/kong/kubernetes-ingress-controller/v3 v3.3.1 + github.com/kong/kubernetes-configuration v0.0.46 github.com/kong/kubernetes-testing-framework v0.47.2 github.com/kong/semver/v4 v4.0.1 // indirect github.com/lithammer/fuzzysearch v1.1.8 // indirect @@ -198,7 +200,7 @@ require ( k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f // indirect k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect - sigs.k8s.io/controller-runtime v0.19.0 // indirect + sigs.k8s.io/controller-runtime v0.19.1 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) diff --git a/go.sum b/go.sum index d76c0dea6..11ad319b8 100644 --- a/go.sum +++ b/go.sum @@ -16,6 +16,8 @@ github.com/Kong/go-diff v1.2.2 h1:KKKaqHc8IxuguFVIZMNt3bi6YuC/t9r7BGD8bOOpSgM= github.com/Kong/go-diff v1.2.2/go.mod h1:nlvdwVZQk3Rm+tbI0cDmKFrOjghtcZTrZBp+UruvvA8= github.com/Kong/gojsondiff v1.3.2 h1:qIOVq2mUXt+NXy8Be5gRUee9TP3Ve0MbQSafg9bXKZE= github.com/Kong/gojsondiff v1.3.2/go.mod h1:DiIxtU59q4alK7ecP+7k56C5UjgOviJ5gQVR2esEhYw= +github.com/Kong/sdk-konnect-go v0.1.6 h1:e0wSujJVVo16y2qOrKvzg6/4sMPc/FLK70eSt80HnXE= +github.com/Kong/sdk-konnect-go v0.1.6/go.mod h1:ipu67aQNnwDzu/LXKePG46cVqkkZnAHKWpsbhTEI8xE= github.com/Kong/yaml v1.0.0 h1:OWOxtLEamLYKZzcrfoH76imAwSi9FgSZapxg1Kh6IBA= github.com/Kong/yaml v1.0.0/go.mod h1:gVzJ3lyC0UdO7kZxmCpwn0Vj20y/02cFnDpHBirGrSQ= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= @@ -98,6 +100,8 @@ github.com/emicklei/go-restful/v3 v3.12.0 h1:y2DdzBAURM29NFF94q6RaY4vjIH1rtwDapw github.com/emicklei/go-restful/v3 v3.12.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 h1:R/ZjJpjQKsZ6L/+Gf9WHbt31GG8NMVcpRqUE+1mMIyo= +github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM= @@ -249,8 +253,8 @@ github.com/kong/go-kong v0.60.0 h1:CVrLXRLVE+Gl4IZ3tdvpO7xNDz3c9YLTmra/HvT4oM8= github.com/kong/go-kong v0.60.0/go.mod h1:t1eMY8GRS6778uQNzxgzRgnA3YKBXSZOEvYbNocH/aA= github.com/kong/go-slugify v1.0.0 h1:vCFAyf2sdoSlBtLcrmDWUFn0ohlpKiKvQfXZkO5vSKY= github.com/kong/go-slugify v1.0.0/go.mod h1:dbR2h3J2QKXQ1k0aww6cN7o4cIcwlWflr6RKRdcoaiw= -github.com/kong/kubernetes-ingress-controller/v3 v3.3.1 h1:uWlcwz5oAnVyUZdtDV9p2l9CdlHhLNTKey3AcHF/Jxs= -github.com/kong/kubernetes-ingress-controller/v3 v3.3.1/go.mod h1:2CBAJ7/J+FyAFn7Y8OLoTO3ApM+qiGIgNLbCyy98Vqk= +github.com/kong/kubernetes-configuration v0.0.46 h1:dIxVu9dOtGi9aY2prTlQ1CkiSu8Fk/0oal9m9iiUdSk= +github.com/kong/kubernetes-configuration v0.0.46/go.mod h1:Bk0H032d+aPgVYakc7C9Zo5nLwiXXm9thKUWF8vvisA= github.com/kong/kubernetes-testing-framework v0.47.2 h1:+2Z9anTpbV/hwNeN+NFQz53BMU+g3QJydkweBp3tULo= github.com/kong/kubernetes-testing-framework v0.47.2/go.mod h1:DJ5btl/srdIM03tg3f+jS9Izu7xkRkciAM69Ptqun1I= github.com/kong/semver/v4 v4.0.1 h1:DIcNR8W3gfx0KabFBADPalxxsp+q/5COwIFkkhrFQ2Y= @@ -481,8 +485,8 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -606,15 +610,15 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f h1:b1Ln/PG8orm0SsBbHZWke8dDp2lrCD4jSmfglFpTZbk= +google.golang.org/genproto/googleapis/api v0.0.0-20240725223205-93522f1f2a9f/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf h1:liao9UHurZLtiEwBgT9LMOnKYsHze6eA6w1KQCMVN2Q= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= +google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -660,18 +664,18 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.31.2 h1:3wLBbL5Uom/8Zy98GRPXpJ254nEFpl+hwndmk9RwmL0= k8s.io/api v0.31.2/go.mod h1:bWmGvrGPssSK1ljmLzd3pwCQ9MgoTsRCuK35u6SygUk= -k8s.io/apiextensions-apiserver v0.31.0 h1:fZgCVhGwsclj3qCw1buVXCV6khjRzKC5eCFt24kyLSk= -k8s.io/apiextensions-apiserver v0.31.0/go.mod h1:b9aMDEYaEe5sdK+1T0KU78ApR/5ZVp4i56VacZYEHxk= +k8s.io/apiextensions-apiserver v0.31.2 h1:W8EwUb8+WXBLu56ser5IudT2cOho0gAKeTOnywBLxd0= +k8s.io/apiextensions-apiserver v0.31.2/go.mod h1:i+Geh+nGCJEGiCGR3MlBDkS7koHIIKWVfWeRFiOsUcM= k8s.io/apimachinery v0.31.2 h1:i4vUt2hPK56W6mlT7Ry+AO8eEsyxMD1U44NR22CLTYw= k8s.io/apimachinery v0.31.2/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= k8s.io/cli-runtime v0.31.0 h1:V2Q1gj1u3/WfhD475HBQrIYsoryg/LrhhK4RwpN+DhA= k8s.io/cli-runtime v0.31.0/go.mod h1:vg3H94wsubuvWfSmStDbekvbla5vFGC+zLWqcf+bGDw= -k8s.io/client-go v0.31.0 h1:QqEJzNjbN2Yv1H79SsS+SWnXkBgVu4Pj3CJQgbx0gI8= -k8s.io/client-go v0.31.0/go.mod h1:Y9wvC76g4fLjmU0BA+rV+h2cncoadjvjjkkIGoTLcGU= +k8s.io/client-go v0.31.2 h1:Y2F4dxU5d3AQj+ybwSMqQnpZH9F30//1ObxOKlTI9yc= +k8s.io/client-go v0.31.2/go.mod h1:NPa74jSVR/+eez2dFsEIHNa+3o09vtNaWwWwb1qSxSs= k8s.io/code-generator v0.31.2 h1:xLWxG0HEpMSHfcM//3u3Ro2Hmc6AyyLINQS//Z2GEOI= k8s.io/code-generator v0.31.2/go.mod h1:eEQHXgBU/m7LDaToDoiz3t97dUUVyOblQdwOr8rivqc= -k8s.io/component-base v0.31.0 h1:/KIzGM5EvPNQcYgwq5NwoQBaOlVFrghoVGr8lG6vNRs= -k8s.io/component-base v0.31.0/go.mod h1:TYVuzI1QmN4L5ItVdMSXKvH7/DtvIuas5/mm8YT3rTo= +k8s.io/component-base v0.31.2 h1:Z1J1LIaC0AV+nzcPRFqfK09af6bZ4D1nAOpWsy9owlA= +k8s.io/component-base v0.31.2/go.mod h1:9PeyyFN/drHjtJZMCTkSpQJS3U9OXORnHQqMLDz0sUQ= k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 h1:NGrVE502P0s0/1hudf8zjgwki1X/TByhmAoILTarmzo= k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70/go.mod h1:VH3AT8AaQOqiGjMF9p0/IM1Dj+82ZwjfxUP1IxaHE+8= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= @@ -682,10 +686,10 @@ k8s.io/kubectl v0.31.0 h1:kANwAAPVY02r4U4jARP/C+Q1sssCcN/1p9Nk+7BQKVg= k8s.io/kubectl v0.31.0/go.mod h1:pB47hhFypGsaHAPjlwrNbvhXgmuAr01ZBvAIIUaI8d4= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q= -sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= -sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM= -sigs.k8s.io/gateway-api v1.1.0/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs= +sigs.k8s.io/controller-runtime v0.19.1 h1:Son+Q40+Be3QWb+niBXAg2vFiYWolDjjRfO8hn/cxOk= +sigs.k8s.io/controller-runtime v0.19.1/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= +sigs.k8s.io/gateway-api v1.2.0 h1:LrToiFwtqKTKZcZtoQPTuo3FxhrrhTgzQG0Te+YGSo8= +sigs.k8s.io/gateway-api v1.2.0/go.mod h1:EpNfEXNjiYfUJypf0eZ0P5iXA9ekSGWaS1WgPaM42X0= 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/kind v0.24.0 h1:g4y4eu0qa+SCeKESLpESgMmVFBebL0BDa6f777OIWrg= diff --git a/kong2kic/consumer.go b/kong2kic/consumer.go index d0b30e203..0f4821f11 100644 --- a/kong2kic/consumer.go +++ b/kong2kic/consumer.go @@ -4,7 +4,7 @@ import ( "log" "github.com/kong/go-database-reconciler/pkg/file" - kicv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" + kcv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -16,7 +16,7 @@ func populateKICConsumers(content *file.Content, file *KICContent) error { continue } username := *consumer.Username - kongConsumer := kicv1.KongConsumer{ + kongConsumer := kcv1.KongConsumer{ TypeMeta: metav1.TypeMeta{ APIVersion: KICAPIVersion, Kind: "KongConsumer", diff --git a/kong2kic/consumer_credentials.go b/kong2kic/consumer_credentials.go index 55760f019..51e6c1163 100644 --- a/kong2kic/consumer_credentials.go +++ b/kong2kic/consumer_credentials.go @@ -4,7 +4,7 @@ import ( "strconv" "github.com/kong/go-database-reconciler/pkg/file" - kicv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" + kcv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" k8scorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -43,7 +43,7 @@ func createCredentialSecret(consumerUsername, credentialType string, dataFields } // Functions to populate different credential types -func populateKICKeyAuthSecrets(consumer *file.FConsumer, kongConsumer *kicv1.KongConsumer, file *KICContent) { +func populateKICKeyAuthSecrets(consumer *file.FConsumer, kongConsumer *kcv1.KongConsumer, file *KICContent) { for _, keyAuth := range consumer.KeyAuths { dataFields := map[string]*string{ "key": keyAuth.Key, @@ -54,7 +54,7 @@ func populateKICKeyAuthSecrets(consumer *file.FConsumer, kongConsumer *kicv1.Kon } } -func populateKICHMACSecrets(consumer *file.FConsumer, kongConsumer *kicv1.KongConsumer, file *KICContent) { +func populateKICHMACSecrets(consumer *file.FConsumer, kongConsumer *kcv1.KongConsumer, file *KICContent) { for _, hmacAuth := range consumer.HMACAuths { dataFields := map[string]*string{ "username": hmacAuth.Username, @@ -66,7 +66,7 @@ func populateKICHMACSecrets(consumer *file.FConsumer, kongConsumer *kicv1.KongCo } } -func populateKICJWTAuthSecrets(consumer *file.FConsumer, kongConsumer *kicv1.KongConsumer, file *KICContent) { +func populateKICJWTAuthSecrets(consumer *file.FConsumer, kongConsumer *kcv1.KongConsumer, file *KICContent) { for _, jwtAuth := range consumer.JWTAuths { dataFields := map[string]*string{ "key": jwtAuth.Key, @@ -80,7 +80,7 @@ func populateKICJWTAuthSecrets(consumer *file.FConsumer, kongConsumer *kicv1.Kon } } -func populateKICBasicAuthSecrets(consumer *file.FConsumer, kongConsumer *kicv1.KongConsumer, file *KICContent) { +func populateKICBasicAuthSecrets(consumer *file.FConsumer, kongConsumer *kcv1.KongConsumer, file *KICContent) { for _, basicAuth := range consumer.BasicAuths { dataFields := map[string]*string{ "username": basicAuth.Username, @@ -92,7 +92,7 @@ func populateKICBasicAuthSecrets(consumer *file.FConsumer, kongConsumer *kicv1.K } } -func populateKICOAuth2CredSecrets(consumer *file.FConsumer, kongConsumer *kicv1.KongConsumer, file *KICContent) { +func populateKICOAuth2CredSecrets(consumer *file.FConsumer, kongConsumer *kcv1.KongConsumer, file *KICContent) { for _, oauth2Cred := range consumer.Oauth2Creds { dataFields := map[string]*string{ "name": oauth2Cred.Name, @@ -110,7 +110,7 @@ func populateKICOAuth2CredSecrets(consumer *file.FConsumer, kongConsumer *kicv1. } } -func populateKICACLGroupSecrets(consumer *file.FConsumer, kongConsumer *kicv1.KongConsumer, file *KICContent) { +func populateKICACLGroupSecrets(consumer *file.FConsumer, kongConsumer *kcv1.KongConsumer, file *KICContent) { for _, aclGroup := range consumer.ACLGroups { dataFields := map[string]*string{ "group": aclGroup.Group, @@ -121,7 +121,7 @@ func populateKICACLGroupSecrets(consumer *file.FConsumer, kongConsumer *kicv1.Ko } } -func populateKICMTLSAuthSecrets(consumer *file.FConsumer, kongConsumer *kicv1.KongConsumer, file *KICContent) { +func populateKICMTLSAuthSecrets(consumer *file.FConsumer, kongConsumer *kcv1.KongConsumer, file *KICContent) { for _, mtlsAuth := range consumer.MTLSAuths { dataFields := map[string]*string{ "subject_name": mtlsAuth.SubjectName, diff --git a/kong2kic/consumer_group.go b/kong2kic/consumer_group.go index a39f30666..2543e20af 100644 --- a/kong2kic/consumer_group.go +++ b/kong2kic/consumer_group.go @@ -6,20 +6,20 @@ import ( "github.com/kong/go-database-reconciler/pkg/file" "github.com/kong/go-kong/kong" - kicv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" - kicv1beta1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1beta1" + kcv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" + kcv1beta1 "github.com/kong/kubernetes-configuration/api/configuration/v1beta1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // Helper function to populate consumer group plugins -func createConsumerGroupKongPlugin(plugin *kong.ConsumerGroupPlugin, ownerName string) (*kicv1.KongPlugin, error) { +func createConsumerGroupKongPlugin(plugin *kong.ConsumerGroupPlugin, ownerName string) (*kcv1.KongPlugin, error) { if plugin.Name == nil { log.Println("Plugin name is empty. Please provide a name for the plugin.") return nil, nil } pluginName := *plugin.Name - kongPlugin := &kicv1.KongPlugin{ + kongPlugin := &kcv1.KongPlugin{ TypeMeta: metav1.TypeMeta{ APIVersion: "configuration.konghq.com/v1", Kind: "KongPlugin", @@ -51,7 +51,7 @@ func populateKICConsumerGroups(content *file.Content, kicContent *KICContent) er } groupName := *consumerGroup.Name - kongConsumerGroup := kicv1beta1.KongConsumerGroup{ + kongConsumerGroup := kcv1beta1.KongConsumerGroup{ TypeMeta: metav1.TypeMeta{ APIVersion: "configuration.konghq.com/v1beta1", Kind: "KongConsumerGroup", diff --git a/kong2kic/global_plugin.go b/kong2kic/global_plugin.go index b5ab3fa39..427fdacdd 100644 --- a/kong2kic/global_plugin.go +++ b/kong2kic/global_plugin.go @@ -7,21 +7,21 @@ import ( "github.com/kong/go-database-reconciler/pkg/file" "github.com/kong/go-kong/kong" - kicv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" + kcv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) func populateKICKongClusterPlugins(content *file.Content, file *KICContent) error { // Global Plugins map to KongClusterPlugins - // iterate content.Plugins and copy them into kicv1.KongPlugin manifests - // add the kicv1.KongPlugin to the KICContent.KongClusterPlugins slice + // iterate content.Plugins and copy them into kcv1.KongPlugin manifests + // add the kcv1.KongPlugin to the KICContent.KongClusterPlugins slice for _, plugin := range content.Plugins { // skip this plugin instance if it is a kongconsumergroup plugin. // It is a kongconsumergroup plugin if it has a consumer_group property if plugin.ConsumerGroup != nil { continue } - var kongClusterPlugin kicv1.KongClusterPlugin + var kongClusterPlugin kcv1.KongClusterPlugin kongClusterPlugin.APIVersion = KICAPIVersion kongClusterPlugin.Kind = "KongClusterPlugin" kongClusterPlugin.ObjectMeta.Annotations = map[string]string{IngressClass: ClassName} @@ -54,7 +54,7 @@ func populateKICKongClusterPlugins(content *file.Content, file *KICContent) erro protocols[i] = *protocol } } - kongClusterPlugin.Protocols = kicv1.StringsToKongProtocols(protocols) + kongClusterPlugin.Protocols = kcv1.StringsToKongProtocols(protocols) } // add konghq.com/tags annotation if plugin.Tags is not nil diff --git a/kong2kic/route.go b/kong2kic/route.go index 5f8796d9b..bc45fbf25 100644 --- a/kong2kic/route.go +++ b/kong2kic/route.go @@ -8,7 +8,7 @@ import ( "github.com/kong/go-database-reconciler/pkg/file" "github.com/kong/go-kong/kong" - kicv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" + kcv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" k8snetv1 "k8s.io/api/networking/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -192,7 +192,7 @@ func addPluginsToRoute( continue } pluginName := *plugin.Name - kongPlugin := kicv1.KongPlugin{ + kongPlugin := kcv1.KongPlugin{ TypeMeta: metav1.TypeMeta{ APIVersion: KICAPIVersion, Kind: KongPluginKind, @@ -224,7 +224,7 @@ func addPluginsToRoute( protocols = append(protocols, *protocol) } } - kongPlugin.Protocols = kicv1.StringsToKongProtocols(protocols) + kongPlugin.Protocols = kcv1.StringsToKongProtocols(protocols) } if plugin.Tags != nil { var tags []string diff --git a/kong2kic/types.go b/kong2kic/types.go index d264662e9..99be8602f 100644 --- a/kong2kic/types.go +++ b/kong2kic/types.go @@ -4,8 +4,8 @@ import ( "encoding/json" "github.com/kong/go-database-reconciler/pkg/file" - kicv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" - kicv1beta1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1beta1" + kcv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" + kcv1beta1 "github.com/kong/kubernetes-configuration/api/configuration/v1beta1" k8scorev1 "k8s.io/api/core/v1" k8snetv1 "k8s.io/api/networking/v1" k8sgwapiv1 "sigs.k8s.io/gateway-api/apis/v1" @@ -15,16 +15,16 @@ import ( // KICContent represents a serialized Kong state for KIC. // +k8s:deepcopy-gen=true type KICContent struct { - KongIngresses []kicv1.KongIngress `json:"kongIngresses,omitempty" yaml:",omitempty"` - KongPlugins []kicv1.KongPlugin `json:"kongPlugins,omitempty" yaml:",omitempty"` - KongClusterPlugins []kicv1.KongClusterPlugin `json:"clusterPlugins,omitempty" yaml:",omitempty"` - Ingresses []k8snetv1.Ingress `json:"ingresses,omitempty" yaml:",omitempty"` - Services []k8scorev1.Service `json:"services,omitempty" yaml:",omitempty"` - Secrets []k8scorev1.Secret `json:"secrets,omitempty" yaml:",omitempty"` - KongConsumers []kicv1.KongConsumer `json:"consumers,omitempty" yaml:",omitempty"` - KongConsumerGroups []kicv1beta1.KongConsumerGroup `json:"consumerGroups,omitempty" yaml:",omitempty"` - HTTPRoutes []k8sgwapiv1.HTTPRoute `json:"httpRoutes,omitempty" yaml:",omitempty"` - KongUpstreamPolicies []kicv1beta1.KongUpstreamPolicy `json:"upstreamPolicies,omitempty" yaml:",omitempty"` + KongIngresses []kcv1.KongIngress `json:"kongIngresses,omitempty" yaml:",omitempty"` + KongPlugins []kcv1.KongPlugin `json:"kongPlugins,omitempty" yaml:",omitempty"` + KongClusterPlugins []kcv1.KongClusterPlugin `json:"clusterPlugins,omitempty" yaml:",omitempty"` + Ingresses []k8snetv1.Ingress `json:"ingresses,omitempty" yaml:",omitempty"` + Services []k8scorev1.Service `json:"services,omitempty" yaml:",omitempty"` + Secrets []k8scorev1.Secret `json:"secrets,omitempty" yaml:",omitempty"` + KongConsumers []kcv1.KongConsumer `json:"consumers,omitempty" yaml:",omitempty"` + KongConsumerGroups []kcv1beta1.KongConsumerGroup `json:"consumerGroups,omitempty" yaml:",omitempty"` + HTTPRoutes []k8sgwapiv1.HTTPRoute `json:"httpRoutes,omitempty" yaml:",omitempty"` + KongUpstreamPolicies []kcv1beta1.KongUpstreamPolicy `json:"upstreamPolicies,omitempty" yaml:",omitempty"` } func (k KICContent) marshalKICContentToFormat(format string) ([]byte, error) { diff --git a/kong2kic/upstream.go b/kong2kic/upstream.go index b27af4bcc..8a7d64e4c 100644 --- a/kong2kic/upstream.go +++ b/kong2kic/upstream.go @@ -6,8 +6,8 @@ import ( "github.com/kong/go-database-reconciler/pkg/file" "github.com/kong/go-kong/kong" - kicv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" - kicv1beta1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1beta1" + kcv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" + kcv1beta1 "github.com/kong/kubernetes-configuration/api/configuration/v1beta1" k8scorev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -26,23 +26,23 @@ func findMatchingUpstream(serviceHost *string, upstreams []file.FUpstream) *file } // Helper function to convert HTTP statuses -func convertHTTPStatuses(statuses []int) []kicv1beta1.HTTPStatus { +func convertHTTPStatuses(statuses []int) []kcv1beta1.HTTPStatus { if statuses == nil { return nil } - result := make([]kicv1beta1.HTTPStatus, len(statuses)) + result := make([]kcv1beta1.HTTPStatus, len(statuses)) for i, status := range statuses { - result[i] = kicv1beta1.HTTPStatus(status) + result[i] = kcv1beta1.HTTPStatus(status) } return result } // Helper function to populate active healthcheck -func populateActiveHealthcheck(active *kong.ActiveHealthcheck) *kicv1beta1.KongUpstreamActiveHealthcheck { +func populateActiveHealthcheck(active *kong.ActiveHealthcheck) *kcv1beta1.KongUpstreamActiveHealthcheck { if active == nil { return nil } - return &kicv1beta1.KongUpstreamActiveHealthcheck{ + return &kcv1beta1.KongUpstreamActiveHealthcheck{ Type: active.Type, Concurrency: active.Concurrency, HTTPPath: active.HTTPPath, @@ -56,11 +56,11 @@ func populateActiveHealthcheck(active *kong.ActiveHealthcheck) *kicv1beta1.KongU } // Helper function to populate passive healthcheck -func populatePassiveHealthcheck(passive *kong.PassiveHealthcheck) *kicv1beta1.KongUpstreamPassiveHealthcheck { +func populatePassiveHealthcheck(passive *kong.PassiveHealthcheck) *kcv1beta1.KongUpstreamPassiveHealthcheck { if passive == nil { return nil } - return &kicv1beta1.KongUpstreamPassiveHealthcheck{ + return &kcv1beta1.KongUpstreamPassiveHealthcheck{ Type: passive.Type, Healthy: populateHealthcheckHealthy(passive.Healthy), Unhealthy: populateHealthcheckUnhealthy(passive.Unhealthy), @@ -68,11 +68,11 @@ func populatePassiveHealthcheck(passive *kong.PassiveHealthcheck) *kicv1beta1.Ko } // Helper function to populate healthcheck healthy settings -func populateHealthcheckHealthy(healthy *kong.Healthy) *kicv1beta1.KongUpstreamHealthcheckHealthy { +func populateHealthcheckHealthy(healthy *kong.Healthy) *kcv1beta1.KongUpstreamHealthcheckHealthy { if healthy == nil { return nil } - return &kicv1beta1.KongUpstreamHealthcheckHealthy{ + return &kcv1beta1.KongUpstreamHealthcheckHealthy{ Interval: healthy.Interval, Successes: healthy.Successes, HTTPStatuses: convertHTTPStatuses(healthy.HTTPStatuses), @@ -80,11 +80,11 @@ func populateHealthcheckHealthy(healthy *kong.Healthy) *kicv1beta1.KongUpstreamH } // Helper function to populate healthcheck unhealthy settings -func populateHealthcheckUnhealthy(unhealthy *kong.Unhealthy) *kicv1beta1.KongUpstreamHealthcheckUnhealthy { +func populateHealthcheckUnhealthy(unhealthy *kong.Unhealthy) *kcv1beta1.KongUpstreamHealthcheckUnhealthy { if unhealthy == nil { return nil } - return &kicv1beta1.KongUpstreamHealthcheckUnhealthy{ + return &kcv1beta1.KongUpstreamHealthcheckUnhealthy{ HTTPFailures: unhealthy.HTTPFailures, TCPFailures: unhealthy.TCPFailures, Timeouts: unhealthy.Timeouts, @@ -112,7 +112,7 @@ func populateKICUpstreamPolicy( } // Create KongUpstreamPolicy - kongUpstreamPolicy := kicv1beta1.KongUpstreamPolicy{ + kongUpstreamPolicy := kcv1beta1.KongUpstreamPolicy{ TypeMeta: metav1.TypeMeta{ APIVersion: KICAPIVersionV1Beta1, Kind: UpstreamPolicyKind, @@ -140,7 +140,7 @@ func populateKICUpstreamPolicy( } // Helper function to populate KongUpstreamPolicy Spec -func populateKongUpstreamPolicySpec(upstream *file.FUpstream, policy *kicv1beta1.KongUpstreamPolicy) { +func populateKongUpstreamPolicySpec(upstream *file.FUpstream, policy *kcv1beta1.KongUpstreamPolicy) { if upstream.Algorithm != nil { policy.Spec.Algorithm = upstream.Algorithm } @@ -150,8 +150,8 @@ func populateKongUpstreamPolicySpec(upstream *file.FUpstream, policy *kicv1beta1 if upstream.Algorithm != nil && *upstream.Algorithm == "consistent-hashing" { if upstream.HashOn != nil { - policy.Spec.HashOn = &kicv1beta1.KongUpstreamHash{ - Input: (*kicv1beta1.HashInput)(upstream.HashOn), + policy.Spec.HashOn = &kcv1beta1.KongUpstreamHash{ + Input: (*kcv1beta1.HashInput)(upstream.HashOn), Header: upstream.HashOnHeader, Cookie: upstream.HashOnCookie, CookiePath: upstream.HashOnCookiePath, @@ -160,8 +160,8 @@ func populateKongUpstreamPolicySpec(upstream *file.FUpstream, policy *kicv1beta1 } } if upstream.HashFallback != nil { - policy.Spec.HashOnFallback = &kicv1beta1.KongUpstreamHash{ - Input: (*kicv1beta1.HashInput)(upstream.HashFallback), + policy.Spec.HashOnFallback = &kcv1beta1.KongUpstreamHash{ + Input: (*kcv1beta1.HashInput)(upstream.HashFallback), Header: upstream.HashFallbackHeader, QueryArg: upstream.HashFallbackQueryArg, URICapture: upstream.HashFallbackURICapture, @@ -175,7 +175,7 @@ func populateKongUpstreamPolicySpec(upstream *file.FUpstream, policy *kicv1beta1 if upstream.Healthchecks.Threshold != nil { threshold = int(*upstream.Healthchecks.Threshold) } - policy.Spec.Healthchecks = &kicv1beta1.KongUpstreamHealthcheck{ + policy.Spec.Healthchecks = &kcv1beta1.KongUpstreamHealthcheck{ Threshold: &threshold, Active: populateActiveHealthcheck(upstream.Healthchecks.Active), Passive: populatePassiveHealthcheck(upstream.Healthchecks.Passive), @@ -202,7 +202,7 @@ func populateKICUpstream( } // Create KongIngress - kongIngress := kicv1.KongIngress{ + kongIngress := kcv1.KongIngress{ TypeMeta: metav1.TypeMeta{ APIVersion: KICAPIVersion, Kind: IngressKind, @@ -211,7 +211,7 @@ func populateKICUpstream( Name: calculateSlug(*service.Name + "-upstream"), Annotations: map[string]string{IngressClass: ClassName}, }, - Upstream: &kicv1.KongIngressUpstream{ + Upstream: &kcv1.KongIngressUpstream{ HostHeader: upstream.HostHeader, Algorithm: upstream.Algorithm, Slots: upstream.Slots, diff --git a/kong2kic/utils.go b/kong2kic/utils.go index 6b0ba3308..ac867244a 100644 --- a/kong2kic/utils.go +++ b/kong2kic/utils.go @@ -7,7 +7,7 @@ import ( "github.com/kong/go-database-reconciler/pkg/file" "github.com/kong/go-kong/kong" - kicv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" + kcv1 "github.com/kong/kubernetes-configuration/api/configuration/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -37,13 +37,13 @@ func addPluginToAnnotations(pluginName string, annotations map[string]string) { } // Helper function to create a KongPlugin from a plugin -func createKongPlugin(plugin *file.FPlugin, ownerName string) (*kicv1.KongPlugin, error) { +func createKongPlugin(plugin *file.FPlugin, ownerName string) (*kcv1.KongPlugin, error) { if plugin.Name == nil { log.Println("Plugin name is empty. Please provide a name for the plugin.") return nil, nil } pluginName := *plugin.Name - kongPlugin := &kicv1.KongPlugin{ + kongPlugin := &kcv1.KongPlugin{ TypeMeta: metav1.TypeMeta{ APIVersion: KICAPIVersion, Kind: KongPluginKind, @@ -78,7 +78,7 @@ func createKongPlugin(plugin *file.FPlugin, ownerName string) (*kicv1.KongPlugin protocols = append(protocols, *protocol) } } - kongPlugin.Protocols = kicv1.StringsToKongProtocols(protocols) + kongPlugin.Protocols = kcv1.StringsToKongProtocols(protocols) } // Transform the plugin config