forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
82 lines (60 loc) · 2.13 KB
/
model.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package clientcontext
import (
"context"
"github.com/kyma-project/kyma/components/connector-service/internal/certificates"
"github.com/sirupsen/logrus"
)
type clientContextKey string
// CtxEnabledType type defines if context is enabled
type CtxEnabledType bool
// LookupEnabledType type defines if headers must be specified
type LookupEnabledType bool
const (
// ApplicationHeader is key representing Application in headers
ApplicationHeader = "Application"
// ApplicationContextKey is the key value for storing Application in context
ApplicationContextKey clientContextKey = "ApplicationContext"
// ApiURLsKey is the key value for storing API hosts in context
ApiURLsKey clientContextKey = "ApiURLs"
// ClusterContextKey is the key value for storing cluster data in context
ClusterContextKey clientContextKey = "ClusterContext"
// TenantHeader is key representing Tenant in headers
TenantHeader = "Tenant"
// GroupHeader is key representing Group in headers
GroupHeader = "Group"
// GroupEmpty represents empty value for Group
GroupEmpty = ""
// TenantEmpty represents empty value for Tenant
TenantEmpty = ""
// ApplicationEmpty represents empty value for Application
ApplicationEmpty = ""
// LookupEnabled represents value for required fetch from Runtime
LookupEnabled LookupEnabledType = true
// LookupDisabled represents value for not required fetch from Runtime
LookupDisabled LookupEnabledType = false
)
type ClientContextService interface {
GetRuntimeUrls() *RuntimeURLs
GetLogger() *logrus.Entry
}
type ClientCertContextService interface {
ClientContextService
ClientContext() ClientContextService
GetSubject() certificates.CSRSubject
}
type ContextExtender interface {
ExtendContext(ctx context.Context) context.Context
}
type RuntimeURLs struct {
EventsInfoURL string `json:"eventsInfoUrl"`
EventsURL string `json:"eventsUrl"`
MetadataURL string `json:"metadataUrl"`
}
type ApiURLs struct {
EventsBaseURL string
MetadataBaseURL string
}
// ExtendContext extends provided context with ApiURLs
func (r ApiURLs) ExtendContext(ctx context.Context) context.Context {
return context.WithValue(ctx, ApiURLsKey, r)
}