Skip to content

Commit

Permalink
Transfer registry path via gRPC metadata (#1366)
Browse files Browse the repository at this point in the history
* add updatepath chain elements for registry

Signed-off-by: Nikita Skrynnik <[email protected]>

* add nse_test for registry updatepath

Signed-off-by: Nikita Skrynnik <[email protected]>

* add updatepath tests for nse_server

Signed-off-by: Nikita Skrynnik <[email protected]>

* add updatetoken chain element for registry

Signed-off-by: Nikita Skrynnik <[email protected]>

* clone tests for all updatetoken and updatepath chain elements

Signed-off-by: Nikita Skrynnik <[email protected]>

* add updatepath and updatetoken to all registries in sdk

Signed-off-by: Nikita Skrynnik <[email protected]>

* add path_segment and index fields to opa policy input struct

Signed-off-by: Nikita Skrynnik <[email protected]>

* debugging

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix sandbox tests

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix authorize ns_server_test

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix networkservice updatetoken TestChain

Signed-off-by: Nikita Skrynnik <[email protected]>

* add error check in updatepath chain element + fix some linter errors

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter issues

Signed-off-by: Nikita Skrynnik <[email protected]>

* add policy for spiffeID check + add test for policy and authorize registry

Signed-off-by: Nikita Skrynnik <[email protected]>

* add policy for spiffeID checking to authorize for registry

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter issues

Signed-off-by: Nikita Skrynnik <[email protected]>

* start adding sandbox test for registry authorize

Signed-off-by: Nikita Skrynnik <[email protected]>

* add grpcmetadata chain element and unit test

Signed-off-by: Nikita Skrynnik <[email protected]>

* add map to grpcmetadata + update api refs + fix some errors

Signed-off-by: Nikita Skrynnik <[email protected]>

* change authorize map name

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix opa unit tests + fix authorize unit tests + cleanup

Signed-off-by: Nikita Skrynnik <[email protected]>

* finish all registry updatepath tests

Signed-off-by: Nikita Skrynnik <[email protected]>

* add tests for updatepath server + fix refresh bug

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix some sandbox tests

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix a lot of unit tests

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix some linter issue

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix all linter issues

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix datarace in sandbox tests

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix dns test

Signed-off-by: Nikita Skrynnik <[email protected]>

* add registry authorization client to nsmgr-proxy, proxydns and registry-memory

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter

Signed-off-by: Nikita Skrynnik <[email protected]>

* remove degub logs

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix tests

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix grpcmetadata unit test

Signed-off-by: Nikita Skrynnik <[email protected]>

* reduce timeout for test

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter issues

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix grpcmetadata unit test

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix grpcmetadata tests + fix a bug in updatepath ns_client

Signed-off-by: Nikita Skrynnik <[email protected]>

* cleanup

Signed-off-by: Nikita Skrynnik <[email protected]>

* increase timeout for debug

Signed-off-by: Nikita Skrynnik <[email protected]>

* reduce timeout

Signed-off-by: Nikita Skrynnik <[email protected]>

* add Path data structure for registry

Signed-off-by: Nikita Skrynnik <[email protected]>

* rerun CI

Signed-off-by: Nikita Skrynnik <[email protected]>

* remove replace for api

Signed-off-by: Nikita Skrynnik <[email protected]>

* apply review comments

Signed-off-by: Nikita Skrynnik <[email protected]>

* rerun CI

Signed-off-by: Nikita Skrynnik <[email protected]>

* apply review comments

Signed-off-by: Nikita Skrynnik <[email protected]>

* revert changes in opainput.go

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter

Signed-off-by: Nikita Skrynnik <[email protected]>

* go mod tidy

Signed-off-by: Nikita Skrynnik <[email protected]>

* revert changes in nsmgr/server.go

Signed-off-by: Nikita Skrynnik <[email protected]>

* use spiffeid as name for path segments

Signed-off-by: Nikita Skrynnik <[email protected]>

* fix linter issue

Signed-off-by: Nikita Skrynnik <[email protected]>

* Simpilfy Path.Clone method

Signed-off-by: Nikita Skrynnik <[email protected]>

Signed-off-by: Nikita Skrynnik <[email protected]>
  • Loading branch information
NikitaSkrynnik authored Nov 29, 2022
1 parent d83bdbd commit a64652c
Show file tree
Hide file tree
Showing 57 changed files with 3,719 additions and 337 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ linters-settings:
dupl:
threshold: 150
funlen:
Lines: 110
Lines: 120
Statements: 50
goconst:
min-len: 2
Expand Down
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require (
go.opentelemetry.io/otel/trace v1.9.0
go.uber.org/atomic v1.7.0
go.uber.org/goleak v1.1.12
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7
golang.org/x/net v0.2.0
gonum.org/v1/gonum v0.6.2
google.golang.org/grpc v1.49.0
google.golang.org/protobuf v1.28.1
Expand Down Expand Up @@ -90,12 +90,11 @@ require (
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.9.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 // indirect
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
golang.org/x/tools v0.1.12 // indirect
golang.org/x/tools v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20220908141613-51c1cc9bc6d0 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
22 changes: 11 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB
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.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
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-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -503,8 +503,8 @@ golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 h1:1WGATo9HAhkWMbfyuVU0tEFP88OIkUvwaHFveQPvzCQ=
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand All @@ -523,8 +523,7 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=
golang.org/x/sync v0.0.0-20220907140024-f12130a52804/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -572,8 +571,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956 h1:XeJjHH1KiLpKGb6lvMiksZ9l0fVUh+AmGcm0nOMEBOY=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -582,8 +581,9 @@ 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.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -638,8 +638,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f
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.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM=
golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
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=
Expand Down
18 changes: 12 additions & 6 deletions pkg/networkservice/chains/nsmgr/heal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/registry"
Expand All @@ -33,7 +35,7 @@ import (
"github.com/networkservicemesh/sdk/pkg/networkservice/common/heal"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/null"
"github.com/networkservicemesh/sdk/pkg/networkservice/utils/count"
"github.com/networkservicemesh/sdk/pkg/registry/chains/client"
registryclient "github.com/networkservicemesh/sdk/pkg/registry/chains/client"
"github.com/networkservicemesh/sdk/pkg/tools/sandbox"
)

Expand Down Expand Up @@ -579,9 +581,9 @@ func testNSMGRCloseHeal(t *testing.T, withNSEExpiration bool) {
if withNSEExpiration {
// 3.1 Wait for the endpoint expiration
time.Sleep(time.Second)
c := client.NewNetworkServiceEndpointRegistryClient(ctx,
client.WithClientURL(domain.Nodes[0].NSMgr.URL),
client.WithDialOptions(sandbox.DialOptions(sandbox.WithTokenGenerator(sandbox.GenerateTestToken))...))
c := registryclient.NewNetworkServiceEndpointRegistryClient(ctx,
registryclient.WithClientURL(domain.Nodes[0].NSMgr.URL),
registryclient.WithDialOptions(sandbox.DialOptions(sandbox.WithTokenGenerator(sandbox.GenerateTestToken))...))

stream, err := c.Find(ctx, &registry.NetworkServiceEndpointQuery{
NetworkServiceEndpoint: &registry.NetworkServiceEndpoint{
Expand Down Expand Up @@ -686,6 +688,10 @@ func testForwarderShouldBeSelectedCorrectlyOnNSMgrRestart(t *testing.T, nodeNum,
require.Equal(t, pathSegmentCount, len(conn.Path.PathSegments))
require.Equal(t, expectedForwarderName, conn.GetPath().GetPathSegments()[pathSegmentCount-2].Name)

nseRegistryClient := registryclient.NewNetworkServiceEndpointRegistryClient(ctx,
registryclient.WithClientURL(sandbox.CloneURL(domain.Nodes[nodeNum].NSMgr.URL)),
registryclient.WithDialOptions(grpc.WithTransportCredentials(insecure.NewCredentials())))

for i := 0; i < 10; i++ {
request.Connection = conn.Clone()
conn, err = nsc.Request(ctx, request.Clone())
Expand All @@ -695,14 +701,14 @@ func testForwarderShouldBeSelectedCorrectlyOnNSMgrRestart(t *testing.T, nodeNum,

domain.Nodes[nodeNum].NSMgr.Restart()

_, err = domain.Nodes[nodeNum].NSMgr.NetworkServiceEndpointRegistryServer().Register(ctx, &registry.NetworkServiceEndpoint{
_, err = nseRegistryClient.Register(ctx, &registry.NetworkServiceEndpoint{
Name: nseReg.Name,
Url: nseEntry.URL.String(),
NetworkServiceNames: nseReg.NetworkServiceNames,
})
require.NoError(t, err)

_, err = domain.Nodes[nodeNum].NSMgr.NetworkServiceEndpointRegistryServer().Register(ctx, &registry.NetworkServiceEndpoint{
_, err = nseRegistryClient.Register(ctx, &registry.NetworkServiceEndpoint{
Name: expectedForwarderName,
Url: domain.Nodes[nodeNum].Forwarders[expectedForwarderName].URL.String(),
NetworkServiceNames: []string{"forwarder"},
Expand Down
37 changes: 37 additions & 0 deletions pkg/networkservice/chains/nsmgr/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ import (
registryconnect "github.com/networkservicemesh/sdk/pkg/registry/common/connect"
"github.com/networkservicemesh/sdk/pkg/registry/common/dial"
"github.com/networkservicemesh/sdk/pkg/registry/common/expire"
"github.com/networkservicemesh/sdk/pkg/registry/common/grpcmetadata"
"github.com/networkservicemesh/sdk/pkg/registry/common/localbypass"
"github.com/networkservicemesh/sdk/pkg/registry/common/memory"
registryrecvfd "github.com/networkservicemesh/sdk/pkg/registry/common/recvfd"
registrysendfd "github.com/networkservicemesh/sdk/pkg/registry/common/sendfd"
"github.com/networkservicemesh/sdk/pkg/registry/common/updatepath"
"github.com/networkservicemesh/sdk/pkg/registry/common/updatetoken"

registryadapter "github.com/networkservicemesh/sdk/pkg/registry/core/adapters"
"github.com/networkservicemesh/sdk/pkg/registry/core/chain"
Expand All @@ -79,7 +82,9 @@ type serverOptions struct {
authorizeServer networkservice.NetworkServiceServer
authorizeMonitorConnectionServer networkservice.MonitorConnectionServer
authorizeNSRegistryServer registryapi.NetworkServiceRegistryServer
authorizeNSRegistryClient registryapi.NetworkServiceRegistryClient
authorizeNSERegistryServer registryapi.NetworkServiceEndpointRegistryServer
authorizeNSERegistryClient registryapi.NetworkServiceEndpointRegistryClient
dialOptions []grpc.DialOption
dialTimeout time.Duration
regURL *url.URL
Expand Down Expand Up @@ -153,6 +158,26 @@ func WithAuthorizeNSERegistryServer(authorizeNSERegistryServer registryapi.Netwo
}
}

// WithAuthorizeNSRegistryClient sets authorization NetworkServiceRegistry chain element
func WithAuthorizeNSRegistryClient(authorizeNSRegistryClient registryapi.NetworkServiceRegistryClient) Option {
if authorizeNSRegistryClient == nil {
panic("authorizeNSRegistryClient cannot be nil")
}
return func(o *serverOptions) {
o.authorizeNSRegistryClient = authorizeNSRegistryClient
}
}

// WithAuthorizeNSERegistryClient sets authorization NetworkServiceEndpointRegistry chain element
func WithAuthorizeNSERegistryClient(authorizeNSERegistryClient registryapi.NetworkServiceEndpointRegistryClient) Option {
if authorizeNSERegistryClient == nil {
panic("authorizeNSERegistryServer cannot be nil")
}
return func(o *serverOptions) {
o.authorizeNSERegistryClient = authorizeNSERegistryClient
}
}

// WithRegistry sets URL and dial options to reach the upstream registry, if not passed memory storage will be used.
func WithRegistry(regURL *url.URL) Option {
return func(o *serverOptions) {
Expand Down Expand Up @@ -186,7 +211,9 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, options
authorizeServer: authorize.NewServer(authorize.Any()),
authorizeMonitorConnectionServer: authmonitor.NewMonitorConnectionServer(authmonitor.Any()),
authorizeNSRegistryServer: registryauthorize.NewNetworkServiceRegistryServer(registryauthorize.Any()),
authorizeNSRegistryClient: registryauthorize.NewNetworkServiceRegistryClient(registryauthorize.Any()),
authorizeNSERegistryServer: registryauthorize.NewNetworkServiceEndpointRegistryServer(registryauthorize.Any()),
authorizeNSERegistryClient: registryauthorize.NewNetworkServiceEndpointRegistryClient(registryauthorize.Any()),
name: "nsmgr-" + uuid.New().String(),
forwarderServiceName: "forwarder",
}
Expand All @@ -203,6 +230,8 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, options
clienturl.NewNetworkServiceRegistryClient(opts.regURL),
begin.NewNetworkServiceRegistryClient(),
clientconn.NewNetworkServiceRegistryClient(),
opts.authorizeNSRegistryClient,
grpcmetadata.NewNetworkServiceRegistryClient(),
dial.NewNetworkServiceRegistryClient(ctx,
dial.WithDialOptions(opts.dialOptions...),
),
Expand All @@ -212,6 +241,9 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, options
}

nsRegistry = chain.NewNetworkServiceRegistryServer(
grpcmetadata.NewNetworkServiceRegistryServer(),
updatepath.NewNetworkServiceRegistryServer(opts.name),
updatetoken.NewNetworkServiceRegistryServer(tokenGenerator),
opts.authorizeNSRegistryServer,
nsRegistry,
)
Expand All @@ -223,6 +255,8 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, options
begin.NewNetworkServiceEndpointRegistryClient(),
clienturl.NewNetworkServiceEndpointRegistryClient(opts.regURL),
clientconn.NewNetworkServiceEndpointRegistryClient(),
opts.authorizeNSERegistryClient,
grpcmetadata.NewNetworkServiceEndpointRegistryClient(),
dial.NewNetworkServiceEndpointRegistryClient(ctx,
dial.WithDialOptions(opts.dialOptions...),
),
Expand All @@ -239,7 +273,10 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, options
}

var nseRegistry = chain.NewNetworkServiceEndpointRegistryServer(
grpcmetadata.NewNetworkServiceEndpointRegistryServer(),
updatepath.NewNetworkServiceEndpointRegistryServer(opts.name),
begin.NewNetworkServiceEndpointRegistryServer(),
updatetoken.NewNetworkServiceEndpointRegistryServer(tokenGenerator),
opts.authorizeNSERegistryServer,
registryclientinfo.NewNetworkServiceEndpointRegistryServer(),
expire.NewNetworkServiceEndpointRegistryServer(ctx, time.Minute),
Expand Down
Loading

0 comments on commit a64652c

Please sign in to comment.