Skip to content

Commit

Permalink
use null server for no op case
Browse files Browse the repository at this point in the history
Signed-off-by: Periyasamy Palanisamy <[email protected]>
  • Loading branch information
pperiyasamy committed Sep 1, 2021
1 parent 7fa97f8 commit ccbc7ab
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,44 +173,35 @@ func main() {
// ********************************************************************************
sriovTokens := tokens.FromEnv(os.Environ())

var additionalFunc endpoint.Option
if len(sriovTokens) == 0 {
additionalFunc = endpoint.WithAdditionalFunctionality(
onidle.NewServer(ctx, cancel, config.IdleTimeout),
point2pointipam.NewServer(ipnet),
recvfd.NewServer(),
mechanisms.NewServer(map[string]networkservice.NetworkServiceServer{
kernelmech.MECHANISM: kernel.NewServer(),
noop.MECHANISM: null.NewServer(),
}),
dnscontext.NewServer(config.DNSConfigs...),
sendfd.NewServer(),
)
} else if len(sriovTokens) == 1 {
var tokenServer networkservice.NetworkServiceServer
switch len(sriovTokens) {
case 0:
tokenServer = null.NewServer()
case 1:
var tokenKey string
for tokenKey = range sriovTokens {
break
}
additionalFunc = endpoint.WithAdditionalFunctionality(
tokenServer = token.NewServer(tokenKey)
default:
log.FromContext(ctx).Fatalf("endpoint must be configured with none or only one sriov resource")
}
responderEndpoint := endpoint.NewServer(ctx,
spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime),
endpoint.WithName(config.Name),
endpoint.WithAuthorizeServer(authorize.NewServer()),
endpoint.WithAdditionalFunctionality(
onidle.NewServer(ctx, cancel, config.IdleTimeout),
point2pointipam.NewServer(ipnet),
recvfd.NewServer(),
token.NewServer(tokenKey),
mechanisms.NewServer(map[string]networkservice.NetworkServiceServer{
kernelmech.MECHANISM: kernel.NewServer(),
noop.MECHANISM: null.NewServer(),
}),
tokenServer,
dnscontext.NewServer(config.DNSConfigs...),
sendfd.NewServer(),
)
} else {
log.FromContext(ctx).Fatalf("endpoint must be configured with none or only one sriov resource")
}
responderEndpoint := endpoint.NewServer(ctx,
spiffejwt.TokenGeneratorFunc(source, config.MaxTokenLifetime),
endpoint.WithName(config.Name),
endpoint.WithAuthorizeServer(authorize.NewServer()),
additionalFunc,
),
)
// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 5: create grpc server and register icmp-server")
Expand Down

0 comments on commit ccbc7ab

Please sign in to comment.