Skip to content

Commit 7627f5c

Browse files
Rakshith-Rmergify[bot]
authored andcommitted
sidecar: add identity service
Signed-off-by: Rakshith R <rar@redhat.com>
1 parent 9ba0277 commit 7627f5c

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

sidecar/internal/service/identity.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
Copyright 2021 The Kubernetes-CSI-Addons Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package service
18+
19+
import (
20+
"context"
21+
22+
"github.com/csi-addons/spec/lib/go/identity"
23+
"google.golang.org/grpc"
24+
)
25+
26+
// IdentityServer struct of sidecar with supported methods of CSI
27+
// identity server spec and also containing client to csi driver.
28+
type IdentityServer struct {
29+
*identity.UnimplementedIdentityServer
30+
identityClient identity.IdentityClient
31+
}
32+
33+
// NewIdentityServer creates a new IdentityServer which handles the Identity
34+
// Service requests from the CSI-Addons specification.
35+
func NewIdentityServer(client *grpc.ClientConn) *IdentityServer {
36+
return &IdentityServer{
37+
identityClient: identity.NewIdentityClient(client),
38+
}
39+
}
40+
41+
func (is *IdentityServer) RegisterService(server grpc.ServiceRegistrar) {
42+
identity.RegisterIdentityServer(server, is)
43+
}
44+
45+
// GetIdentity returns available capabilities from the driver.
46+
func (is *IdentityServer) GetIdentity(
47+
ctx context.Context,
48+
req *identity.GetIdentityRequest) (*identity.GetIdentityResponse, error) {
49+
return is.identityClient.GetIdentity(ctx, req)
50+
}
51+
52+
// GetCapabilities returns available capabilities from the driver.
53+
func (is *IdentityServer) GetCapabilities(
54+
ctx context.Context,
55+
req *identity.GetCapabilitiesRequest) (*identity.GetCapabilitiesResponse, error) {
56+
return is.identityClient.GetCapabilities(ctx, req)
57+
}
58+
59+
// Probe is called by the CO plugin to validate that the CSI-Addons Node is
60+
// still healthy.
61+
func (is *IdentityServer) Probe(
62+
ctx context.Context,
63+
req *identity.ProbeRequest) (*identity.ProbeResponse, error) {
64+
return is.identityClient.Probe(ctx, req)
65+
}

sidecar/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/csi-addons/kubernetes-csi-addons/sidecar/internal/client"
2424
"github.com/csi-addons/kubernetes-csi-addons/sidecar/internal/csiaddonsnode"
2525
"github.com/csi-addons/kubernetes-csi-addons/sidecar/internal/server"
26+
"github.com/csi-addons/kubernetes-csi-addons/sidecar/internal/service"
2627

2728
"k8s.io/client-go/rest"
2829
"k8s.io/klog/v2"
@@ -65,6 +66,7 @@ func main() {
6566
}
6667

6768
sidecarServer := server.NewSidecarServer(*controllerEndpoint)
69+
sidecarServer.RegisterService(service.NewIdentityServer(csiClient.Client))
6870

6971
sidecarServer.Start()
7072
}

0 commit comments

Comments
 (0)