forked from doomshrine/cosi-driver-sample-s3-inmemory
/
identity.go
37 lines (30 loc) · 796 Bytes
/
identity.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Package identity
package identity
import (
"context"
"github.com/go-logr/logr"
cosi "sigs.k8s.io/container-object-storage-interface-spec"
)
// Server implements cosi.IdentityServer interface.
type Server struct {
log logr.Logger
name string
}
// Interface guards.
var _ cosi.IdentityServer = (*Server)(nil)
// New returns identitu.Server with name set to the "name" argument.
func New(name string, logger logr.Logger) *Server {
if name == "" {
panic("empty name")
}
return &Server{
log: logger,
name: name,
}
}
// DriverGetInfo call is meant to retrieve the unique provisioner Identity.
func (s *Server) DriverGetInfo(_ context.Context, _ *cosi.DriverGetInfoRequest) (*cosi.DriverGetInfoResponse, error) {
return &cosi.DriverGetInfoResponse{
Name: s.name,
}, nil
}