forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
info_server.go
36 lines (29 loc) · 1.08 KB
/
info_server.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
package info
import (
"context"
"github.com/argoproj/argo"
infopkg "github.com/argoproj/argo/pkg/apiclient/info"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo/server/auth"
)
type infoServer struct {
managedNamespace string
links []*wfv1.Link
}
func (i *infoServer) GetUserInfo(ctx context.Context, _ *infopkg.GetUserInfoRequest) (*infopkg.GetUserInfoResponse, error) {
claims := auth.GetClaimSet(ctx)
if claims != nil {
return &infopkg.GetUserInfoResponse{Subject: claims.Sub, Issuer: claims.Iss}, nil
}
return &infopkg.GetUserInfoResponse{}, nil
}
func (i *infoServer) GetInfo(context.Context, *infopkg.GetInfoRequest) (*infopkg.InfoResponse, error) {
return &infopkg.InfoResponse{ManagedNamespace: i.managedNamespace, Links: i.links}, nil
}
func (i *infoServer) GetVersion(context.Context, *infopkg.GetVersionRequest) (*wfv1.Version, error) {
version := argo.GetVersion()
return &version, nil
}
func NewInfoServer(managedNamespace string, links []*wfv1.Link) infopkg.InfoServiceServer {
return &infoServer{managedNamespace, links}
}