...
1
16
17 package internalbootstrap
18
19 import (
20 flowcontrolv1 "k8s.io/api/flowcontrol/v1"
21 "k8s.io/apimachinery/pkg/runtime"
22 "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
23 "k8s.io/kubernetes/pkg/apis/flowcontrol"
24 "k8s.io/kubernetes/pkg/apis/flowcontrol/install"
25 )
26
27
28
29
30
31 var MandatoryFlowSchemas = internalizeFSes(bootstrap.MandatoryFlowSchemas)
32
33
34
35
36
37
38 var MandatoryPriorityLevelConfigurations = internalizePLs(bootstrap.MandatoryPriorityLevelConfigurations)
39
40
41
42
43 func NewAPFScheme() *runtime.Scheme {
44 scheme := runtime.NewScheme()
45 install.Install(scheme)
46 return scheme
47 }
48
49 func internalizeFSes(exts []*flowcontrolv1.FlowSchema) map[string]*flowcontrol.FlowSchema {
50 ans := make(map[string]*flowcontrol.FlowSchema, len(exts))
51 scheme := NewAPFScheme()
52 for _, ext := range exts {
53 var untyped flowcontrol.FlowSchema
54 if err := scheme.Convert(ext, &untyped, nil); err != nil {
55 panic(err)
56 }
57 ans[ext.Name] = &untyped
58 }
59 return ans
60 }
61
62 func internalizePLs(exts []*flowcontrolv1.PriorityLevelConfiguration) map[string]*flowcontrol.PriorityLevelConfiguration {
63 ans := make(map[string]*flowcontrol.PriorityLevelConfiguration, len(exts))
64 scheme := NewAPFScheme()
65 for _, ext := range exts {
66 var untyped flowcontrol.PriorityLevelConfiguration
67 if err := scheme.Convert(ext, &untyped, nil); err != nil {
68 panic(err)
69 }
70 ans[ext.Name] = &untyped
71 }
72 return ans
73 }
74
View as plain text