Skip to content

Commit

Permalink
Update for backup actions
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha committed Dec 10, 2024
1 parent 8324b32 commit d28572c
Show file tree
Hide file tree
Showing 78 changed files with 11,512 additions and 90,206 deletions.
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/zeebo/xxh3 v1.0.2
go.bytebuilders.dev/catalog v0.0.9
go.bytebuilders.dev/catalog-manager v0.1.0
go.bytebuilders.dev/catalog v0.0.11-0.20241125004308-e689253557ef
go.bytebuilders.dev/catalog-manager v0.1.1
go.bytebuilders.dev/license-verifier v0.14.3
go.openviz.dev/apimachinery v0.0.7
golang.org/x/sync v0.8.0
Expand All @@ -42,17 +42,17 @@ require (
k8s.io/client-go v0.30.3
k8s.io/component-base v0.30.3
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20240709000822-3c01b740850f
k8s.io/kube-openapi v0.0.0-20240726031636-6f6746feab9c
k8s.io/kube-state-metrics/v2 v2.12.0
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
kmodules.xyz/apiversion v0.2.0
kmodules.xyz/authorizer v0.29.1
kmodules.xyz/client-go v0.30.40
kmodules.xyz/custom-resources v0.30.0
kmodules.xyz/go-containerregistry v0.0.12
kmodules.xyz/monitoring-agent-api v0.30.4
kmodules.xyz/offshoot-api v0.30.1
kmodules.xyz/resource-metadata v0.23.1-0.20241128043209-0b8d0f0a14dd
kmodules.xyz/resource-metadata v0.23.1-0.20241210123000-0a8f4eed44a9
kmodules.xyz/resource-metrics v0.30.5
kmodules.xyz/resource-metrics/utils v0.30.4
kmodules.xyz/sets v0.29.0
Expand Down Expand Up @@ -99,7 +99,7 @@ require (
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/dapr/go-sdk v1.8.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/cli v27.0.3+incompatible // indirect
github.com/docker/cli v27.1.1+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.2 // indirect
github.com/dominikbraun/graph v0.23.0 // indirect
Expand Down Expand Up @@ -224,7 +224,7 @@ require (
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
gomodules.xyz/atomic-writer v0.0.2 // indirect
gomodules.xyz/bits v0.0.0-20241102235928-e74aa78b5d38 // indirect
gomodules.xyz/bits v0.0.0-20241124114357-b668409c1b67 // indirect
gomodules.xyz/clock v0.0.0-20200817085942-06523dba733f // indirect
gomodules.xyz/encoding v0.0.8 // indirect
gomodules.xyz/flags v0.1.3 // indirect
Expand All @@ -246,7 +246,7 @@ require (
k8s.io/cli-runtime v0.30.2 // indirect
k8s.io/component-helpers v0.30.2 // indirect
k8s.io/kms v0.30.3 // indirect
kubedb.dev/apimachinery v0.49.0-rc.0 // indirect
kubedb.dev/apimachinery v0.49.0 // indirect
kubeops.dev/external-dns-operator v0.0.9 // indirect
kubeops.dev/petset v0.0.7 // indirect
kubevault.dev/apimachinery v0.19.0 // indirect
Expand All @@ -256,7 +256,7 @@ require (
sigs.k8s.io/kustomize/api v0.17.2 // indirect
sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
voyagermesh.dev/gateway-api v0.0.2-0.20241104190244-f81d0ba1a554 // indirect
voyagermesh.dev/gateway-api v0.0.2-0.20241124132233-ced3a99a7eae // indirect
voyagermesh.dev/installer v0.0.0-20241102060616-ff1e91bfcef8 // indirect

)
Expand Down
40 changes: 20 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkz
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/docker/cli v27.0.3+incompatible h1:usGs0/BoBW8MWxGeEtqPMkzOY56jZ6kYlSN5BLDioCQ=
github.com/docker/cli v27.0.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/cli v27.1.1+incompatible h1:goaZxOqs4QKxznZjjBWKONQci/MywhtRv2oNn0GkeZE=
github.com/docker/cli v27.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
Expand Down Expand Up @@ -206,8 +206,8 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4=
github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
Expand Down Expand Up @@ -558,10 +558,10 @@ github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
go.bytebuilders.dev/catalog v0.0.9 h1:Ot4HOwTTadY9AA8N/weU+mcgbJZiHPDbBYV1y+dW1rs=
go.bytebuilders.dev/catalog v0.0.9/go.mod h1:xzfRUZPNBMwmw+en9Y5o6xAq8EOfx8VXJP57oLLllBM=
go.bytebuilders.dev/catalog-manager v0.1.0 h1:/Vpl0Gq1xhQuYHUw+r6enVmTwZVSUESRcaplNTE/gOU=
go.bytebuilders.dev/catalog-manager v0.1.0/go.mod h1:AB+8YZhID2M0YzUIeVQgUy0j0/MxOG1biZnPqkxSwqw=
go.bytebuilders.dev/catalog v0.0.11-0.20241125004308-e689253557ef h1:p0/sjTEk9NGBeJxkMHXITamqX+Dwp+KwNKtQtjGoTk4=
go.bytebuilders.dev/catalog v0.0.11-0.20241125004308-e689253557ef/go.mod h1:bgVJYI6YYhklFEhtetWKM7iyle61cC6UpXV64GhIXLk=
go.bytebuilders.dev/catalog-manager v0.1.1 h1:+v2QYZkwD7ZgDojfOys3ilt6s50vEysce76whfF7UQk=
go.bytebuilders.dev/catalog-manager v0.1.1/go.mod h1:IwN9qBECmr9jY2zCcT2mS6EEhtKUzuUK4eYFMnN66hg=
go.bytebuilders.dev/license-verifier v0.14.3 h1:5BTwmFEgCjSlAs2Nzh3/7+u//VoF93xjqywrJiqmZsg=
go.bytebuilders.dev/license-verifier v0.14.3/go.mod h1:bNNaVbry3TZbu54pf57LkhjsFX94T6O62w0roiy1yiE=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand Down Expand Up @@ -778,8 +778,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomodules.xyz/atomic-writer v0.0.2 h1:UXzHZylq5bsrmsScJAx923+3NBcX3yPfqFtj6ypn9JA=
gomodules.xyz/atomic-writer v0.0.2/go.mod h1:FO58qUk5UoXwTWbrErUkFVjQARn/BqjdMCuWXkjsQy8=
gomodules.xyz/bits v0.0.0-20241102235928-e74aa78b5d38 h1:+xvJJoocHCqGoA606lMEV7/HodH78U2ecxnyxm7dG+c=
gomodules.xyz/bits v0.0.0-20241102235928-e74aa78b5d38/go.mod h1:FM4xtOoKdT4YgM9lUUCdy2J5yGlSobWjUtBG7JOhRpo=
gomodules.xyz/bits v0.0.0-20241124114357-b668409c1b67 h1:YM4Q9086GbgnTSv/roiwHlqkqOHHaItzzteY0eKpvHs=
gomodules.xyz/bits v0.0.0-20241124114357-b668409c1b67/go.mod h1:FM4xtOoKdT4YgM9lUUCdy2J5yGlSobWjUtBG7JOhRpo=
gomodules.xyz/clock v0.0.0-20200817085942-06523dba733f h1:hTyhR4r+tj1Uq7/PpFxLTzbeA0LhMVp7bEYfhkzFjdY=
gomodules.xyz/clock v0.0.0-20200817085942-06523dba733f/go.mod h1:K3m7N+nBOlf91/tpv8REUGwsAgaKFwElQCuiLhm12AQ=
gomodules.xyz/encoding v0.0.8 h1:r2Koq0BJ4HQCCjPTHuti0ItJDXqWJoLRHcm14Ayyp10=
Expand Down Expand Up @@ -917,12 +917,12 @@ k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kms v0.30.3 h1:NLg+oN45S2Y3U0WiLRzbS61AY/XrS5JBMZp531Z+Pho=
k8s.io/kms v0.30.3/go.mod h1:GrMurD0qk3G4yNgGcsCEmepqf9KyyIrTXYR2lyUOJC4=
k8s.io/kube-openapi v0.0.0-20240709000822-3c01b740850f h1:2sXuKesAYbRHxL3aE2PN6zX/gcJr22cjrsej+W784Tc=
k8s.io/kube-openapi v0.0.0-20240709000822-3c01b740850f/go.mod h1:UxDHUPsUwTOOxSU+oXURfFBcAS6JwiRXTYqYwfuGowc=
k8s.io/kube-openapi v0.0.0-20240726031636-6f6746feab9c h1:CHL3IcTrTI3csK36iwYJy36uQRic+IpSoRMNH+0I8SE=
k8s.io/kube-openapi v0.0.0-20240726031636-6f6746feab9c/go.mod h1:0CVn9SVo8PeW5/JgsBZZIFmmTk5noOM8WXf2e1tCihE=
k8s.io/kube-state-metrics/v2 v2.12.0 h1:is2KqFjpkF+tLqhNfr1sWCEvucb//S50wxzzEhXRzHI=
k8s.io/kube-state-metrics/v2 v2.12.0/go.mod h1:s1Iq7mNhtbb4fnwMw39uUOrpdIaeoyDQDWA7OZoOqhc=
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCIXHaathvJg1C3ak=
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk=
kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80=
kmodules.xyz/authorizer v0.29.1 h1:uByGGoryKbZcfiEAhjcK/Y345I9mygNQP7DVpkMbNQQ=
Expand All @@ -939,8 +939,8 @@ kmodules.xyz/monitoring-agent-api v0.30.4 h1:6CTKxYJKpWDsDYb0WRBHGFoW3xQof05d+W8
kmodules.xyz/monitoring-agent-api v0.30.4/go.mod h1:ZuTQ5uGi6H80QLsOTuuC7m58dfXDGUv0YB+s059gnr4=
kmodules.xyz/offshoot-api v0.30.1 h1:TrulAYO+oBsXe9sZZGTmNWIuI8qD2izMpgcTSPvgAmI=
kmodules.xyz/offshoot-api v0.30.1/go.mod h1:T3mpjR6fui0QzOcmQvIuANytW48fe9ytmy/1cgx6D4g=
kmodules.xyz/resource-metadata v0.23.1-0.20241128043209-0b8d0f0a14dd h1:oIRXeig2xOCbJ72Lpu4rZ8SF3eMVcRXAd1IpX8N0RLk=
kmodules.xyz/resource-metadata v0.23.1-0.20241128043209-0b8d0f0a14dd/go.mod h1:fnT2UJke3zXWJy8Vz+SnB8RKnilB6szX0v5nudD+oPg=
kmodules.xyz/resource-metadata v0.23.1-0.20241210123000-0a8f4eed44a9 h1:8eldjA/nk/SXNcq73xrix90fiV9u9eapqeo2JL0c/bg=
kmodules.xyz/resource-metadata v0.23.1-0.20241210123000-0a8f4eed44a9/go.mod h1:fnT2UJke3zXWJy8Vz+SnB8RKnilB6szX0v5nudD+oPg=
kmodules.xyz/resource-metrics v0.30.5 h1:ZhpGeR9DCz1HTrKUg/mWhr95wlFzCPRdgVAqwaggy1o=
kmodules.xyz/resource-metrics v0.30.5/go.mod h1:w9+rz7/s/kGP1GWzYSuRdCn+l7EwpesmESSEHkLBnIQ=
kmodules.xyz/resource-metrics/utils v0.30.4 h1:bJS/x0Qr7N1FFdxugFbzZ/Es6HVs4ptsFlhkmgj3jac=
Expand All @@ -949,8 +949,8 @@ kmodules.xyz/schema-checker v0.4.1 h1:V5UEjR6UMAXf307lTgw+9rDRfHLTNA8g/q9DngqYI9
kmodules.xyz/schema-checker v0.4.1/go.mod h1:BRXLB3Osuc9raHRJxHOgZFGecZ2aZumLXCHAOa5NPdA=
kmodules.xyz/sets v0.29.0 h1:ZX/qOECzUob95JhhRtngJElHSlJ1UNNdwK4hTEy+nl0=
kmodules.xyz/sets v0.29.0/go.mod h1:1oi3fR9c3SWywEjBLlHC8BBMCSz0b1/W+EofKmBoj3g=
kubedb.dev/apimachinery v0.49.0-rc.0 h1:7WLTSSoXEb8trDFW5AcDxfYJxX7j5TQU2OYijLgAfTc=
kubedb.dev/apimachinery v0.49.0-rc.0/go.mod h1:l3sl+LZXvllja1xbZTgmzHNY7hQGK/uLXjkSothH5ns=
kubedb.dev/apimachinery v0.49.0 h1:xUcUShmdoloeaYIWpDdZtET51o6aNt0YKsptJd/uEX4=
kubedb.dev/apimachinery v0.49.0/go.mod h1:jllA1R3bMRZd4uGt1vtuO6CWiX6ALDPvC8QWy/8sULs=
kubeops.dev/external-dns-operator v0.0.9 h1:lfRDtIKJR8VaJpF01CcOjnA2QcSe43WDnIcqP/ieh1c=
kubeops.dev/external-dns-operator v0.0.9/go.mod h1:4y15PI4XisC9qgDg1IQAIwH4a2aotIJ2AzAJEJFnYR0=
kubeops.dev/falco-ui-server v0.0.4 h1:47kA+B4pJTgru3P60ng9eC+c3TP8Gcq61c91FB3ZoBQ=
Expand Down Expand Up @@ -984,8 +984,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+s
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
voyagermesh.dev/gateway-api v0.0.2-0.20241104190244-f81d0ba1a554 h1:363K/SsbRp69mcHNAVuM4xVE59qDeXS4vkxE0lu6U6o=
voyagermesh.dev/gateway-api v0.0.2-0.20241104190244-f81d0ba1a554/go.mod h1:pMW02a7dAp5E8uZI3qEGS988yhzb4O88tzYaeFMu+3A=
voyagermesh.dev/gateway-api v0.0.2-0.20241124132233-ced3a99a7eae h1:uGJ1TlESAq9fMXlHIlTtgly3tUeNS/eapVzlXoFmdcU=
voyagermesh.dev/gateway-api v0.0.2-0.20241124132233-ced3a99a7eae/go.mod h1:pMW02a7dAp5E8uZI3qEGS988yhzb4O88tzYaeFMu+3A=
voyagermesh.dev/installer v0.0.0-20241102060616-ff1e91bfcef8 h1:dFbzua0lodMBm/NFaaL/NdkElKm9jHJ1VL17/T4l6w4=
voyagermesh.dev/installer v0.0.0-20241102060616-ff1e91bfcef8/go.mod h1:Ie4YBydkmwa8lN4bi+vZY7gzc02jjzpwOS9vyeEhgnU=
x-helm.dev/apimachinery v0.0.16 h1:Eb160xcdH9fMVHak5QSWYWxoaReytch+A7kk25QWjx0=
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/docker/cli/cli/config/configfile/file.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 39 additions & 23 deletions vendor/go.bytebuilders.dev/catalog-manager/pkg/gateway/expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,39 +106,55 @@ func PatchListener(cm *portmanager.ClusterManager, gw *gwapiv1.Gateway, lisName
gw.Spec.Listeners = []gwapiv1b1.Listener{}
}

for _, lis := range gw.Spec.Listeners {
var (
lisIndex = -1
listenerPort gwapiv1.PortNumber = -1
)
alreadyListenerExists := func() bool { return lisIndex != -1 }

for i, lis := range gw.Spec.Listeners {
if string(lis.Name) == lisName {
return nil // listener already exists
lisIndex = i
listenerPort = lis.Port
}
}

ports, usesNodePort, err := cm.ReservePorts(string(gw.Spec.GatewayClassName), 1)
if err != nil {
return err
}

// patch new listener

listener := GetNewListener(lisName, routeKind, ports[0].ListenerPort, https, certRefs...)

gw.Spec.Listeners = append(gw.Spec.Listeners, *listener)

if usesNodePort {
portMapping := fmt.Sprintf("%s%d", PortMappingKeyPrefix, ports[0].ListenerPort)
nodePort := fmt.Sprintf("%d", ports[0].NodePort)
if gw.Annotations == nil {
gw.SetAnnotations(map[string]string{
portMapping: nodePort,
})
} else {
gw.Annotations[portMapping] = nodePort
if !alreadyListenerExists() {
ports, usesNodePort, err := cm.AllocatePorts(string(gw.Spec.GatewayClassName), 1)
if err != nil {
return err
}
if len(ports) == 0 {
return fmt.Errorf("can't allocate ports for gatewayClass %s", gw.Spec.GatewayClassName)
}
if usesNodePort {
patchPortMappingAnnotation(gw, ports[0])
}
listenerPort = ports[0].ListenerPort
}

listener := constructListener(lisName, routeKind, listenerPort, https, certRefs...)
if alreadyListenerExists() {
gw.Spec.Listeners[lisIndex] = *listener
} else {
gw.Spec.Listeners = append(gw.Spec.Listeners, *listener)
}
return nil
}

func GetNewListener(listenerName, routeKind string, port gwapiv1.PortNumber, https bool, certRef ...gwapiv1a2.SecretObjectReference) *gwapiv1b1.Listener {
func patchPortMappingAnnotation(gw *gwapiv1.Gateway, portInfo portmanager.PortInfo) {
portMapping := fmt.Sprintf("%s%d", PortMappingKeyPrefix, portInfo.ListenerPort)
nodePort := fmt.Sprintf("%d", portInfo.NodePort)
if gw.Annotations == nil {
gw.SetAnnotations(map[string]string{
portMapping: nodePort,
})
} else {
gw.Annotations[portMapping] = nodePort
}
}

func constructListener(listenerName, routeKind string, port gwapiv1.PortNumber, https bool, certRef ...gwapiv1a2.SecretObjectReference) *gwapiv1b1.Listener {
lis := &gwapiv1b1.Listener{
Name: gwapiv1.SectionName(listenerName),
Port: port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ func GetGatewayParameter(kc client.Client, gwc *gwv1.GatewayClass) (*catgwapi.Ga
if err != nil {
return nil, err
}
if gwp.Service.PortRange == "" {
gwp.Service.PortRange = catgwapi.DefaultPortRange
}
if gwp.Service.NodeportRange == "" {
gwp.Service.NodeportRange = catgwapi.DefaultNodeportRange
}
gwp.GatewayClassName = gwc.Name
gwp.ServiceType, err = GetGatewayServiceType(context.TODO(), kc, gwc)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ package portmanager
import (
"context"
"fmt"
"strconv"
"strings"
"sync"

catgwapi "go.bytebuilders.dev/catalog/api/gateway/v1alpha1"

"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/net"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand All @@ -44,6 +47,29 @@ func (pi PortInfo) UsesNodePort() bool {
return pi.NodePort > 0
}

func (pi PortInfo) String() string {
return fmt.Sprintf("%d/%d", pi.ListenerPort, pi.NodePort)
}

func ParsePortInfo(str string) (*PortInfo, error) {
parts := strings.SplitN(str, "/", 2)
if len(parts) != 2 {
return nil, fmt.Errorf("invalid port info: %s", str)
}
lp, err := strconv.Atoi(parts[0])
if err != nil {
return nil, fmt.Errorf("invalid port info: %s", str)
}
np, err := strconv.Atoi(parts[1])
if err != nil {
return nil, fmt.Errorf("invalid port info: %s", str)
}
return &PortInfo{
ListenerPort: gwv1.PortNumber(lp),
NodePort: gwv1.PortNumber(np),
}, nil
}

type ClusterManager struct {
kc client.Reader
portManagers map[string]*GatewayClassPortManager // gwcName -> gatewayClassPortManager
Expand Down Expand Up @@ -167,15 +193,33 @@ func (cm *ClusterManager) GetGatewayClassPortManager(gatewayClassName string) *G
return cm.portManagers[gatewayClassName]
}

func (cm *ClusterManager) ReservePorts(gatewayClassName string, n int) ([]PortInfo, bool, error) {
func (cm *ClusterManager) AllocatePorts(gatewayClassName string, n int) ([]PortInfo, bool, error) {
cm.mu.Lock()
defer cm.mu.Unlock()

gm, ok := cm.portManagers[gatewayClassName]
if !ok {
return nil, false, fmt.Errorf("port manager for gateway class %q not found", gatewayClassName)
}
return gm.ReservePorts(n)
return gm.AllocatePorts(n)
}

func (cm *ClusterManager) AllocateSeedPort() (int, error) {
cm.mu.Lock()
defer cm.mu.Unlock()

ports, err := cm.svcMgr.AllocatePorts(net.ParsePortRangeOrDie("8080-65535"), 1)
if err != nil {
return 0, err
}
return ports[0], nil
}

func (cm *ClusterManager) SetSeedPortAllocated(port int) {
cm.mu.Lock()
defer cm.mu.Unlock()

cm.svcMgr.SetPortAllocated(port)
}

func (cm *ClusterManager) Print() {
Expand Down
Loading

0 comments on commit d28572c

Please sign in to comment.