@@ -66,15 +66,17 @@ func NewDefaultConfig() *Config {
66
66
}
67
67
68
68
type ExtraConfig struct {
69
- StorageFactory storage.StorageFactory
70
- InformerFactory informers.SharedInformerFactory
71
- InitialAPIGroupResources []* restmapper.APIGroupResources
69
+ AllowedProxySubresources map [schema.GroupResource ]sets.Set [string ]
72
70
}
73
71
74
72
type Config struct {
75
73
GenericConfig * genericapiserver.RecommendedConfig
76
74
77
- ExtraConfig ExtraConfig
75
+ StorageFactory storage.StorageFactory
76
+ InformerFactory informers.SharedInformerFactory
77
+ InitialAPIGroupResources []* restmapper.APIGroupResources
78
+
79
+ ExtraConfig * ExtraConfig
78
80
}
79
81
80
82
func (c * Config ) Complete () CompletedConfig {
@@ -83,8 +85,11 @@ func (c *Config) Complete() CompletedConfig {
83
85
}
84
86
85
87
completed := & completedConfig {
86
- GenericConfig : c .GenericConfig .Complete (),
87
- ExtraConfig : & c .ExtraConfig ,
88
+ GenericConfig : c .GenericConfig .Complete (),
89
+ StorageFactory : c .StorageFactory ,
90
+ InformerFactory : c .InformerFactory ,
91
+ InitialAPIGroupResources : c .InitialAPIGroupResources ,
92
+ ExtraConfig : c .ExtraConfig ,
88
93
}
89
94
90
95
c .GenericConfig .RequestInfoResolver = wrapRequestInfoResolverForNamespace {
@@ -96,7 +101,10 @@ func (c *Config) Complete() CompletedConfig {
96
101
type completedConfig struct {
97
102
GenericConfig genericapiserver.CompletedConfig
98
103
99
- ExtraConfig * ExtraConfig
104
+ StorageFactory storage.StorageFactory
105
+ InformerFactory informers.SharedInformerFactory
106
+ InitialAPIGroupResources []* restmapper.APIGroupResources
107
+ ExtraConfig * ExtraConfig
100
108
}
101
109
102
110
type CompletedConfig struct {
@@ -106,10 +114,10 @@ type CompletedConfig struct {
106
114
var sortedMethods = []string {"GET" , "POST" , "PUT" , "PATCH" , "DELETE" , "HEAD" , "OPTIONS" }
107
115
108
116
func (c completedConfig ) New (delegationTarget genericapiserver.DelegationTarget ) (* genericapiserver.GenericAPIServer , []string , error ) {
109
- if c .ExtraConfig . StorageFactory == nil {
117
+ if c .StorageFactory == nil {
110
118
return nil , nil , errors .New ("kubeapiserver.New() called with config.StorageFactory == nil" )
111
119
}
112
- if c .ExtraConfig . InformerFactory == nil {
120
+ if c .InformerFactory == nil {
113
121
return nil , nil , errors .New ("kubeapiserver.New() called with config.InformerFactory == nil" )
114
122
}
115
123
@@ -123,7 +131,7 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
123
131
delegate = http .NotFoundHandler ()
124
132
}
125
133
126
- restManager := NewRESTManager (c .GenericConfig .Serializer , runtime .ContentTypeJSON , c .ExtraConfig . StorageFactory , c . ExtraConfig .InitialAPIGroupResources )
134
+ restManager := NewRESTManager (c .GenericConfig .Serializer , runtime .ContentTypeJSON , c .StorageFactory , c .InitialAPIGroupResources )
127
135
discoveryManager := discovery .NewDiscoveryManager (c .GenericConfig .Serializer , restManager , delegate )
128
136
129
137
// handle root discovery request
@@ -136,15 +144,20 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
136
144
delegate : delegate ,
137
145
rest : restManager ,
138
146
discovery : discoveryManager ,
139
- clusterLister : c .ExtraConfig . InformerFactory .Cluster ().V1alpha2 ().PediaClusters ().Lister (),
147
+ clusterLister : c .InformerFactory .Cluster ().V1alpha2 ().PediaClusters ().Lister (),
140
148
}
141
149
genericserver .Handler .NonGoRestfulMux .HandlePrefix ("/api/" , resourceHandler )
142
150
genericserver .Handler .NonGoRestfulMux .HandlePrefix ("/apis/" , resourceHandler )
143
151
144
- controller := NewClusterResourceController (restManager , discoveryManager , c .ExtraConfig . InformerFactory .Cluster ().V1alpha2 ().PediaClusters ())
152
+ controller := NewClusterResourceController (restManager , discoveryManager , c .InformerFactory .Cluster ().V1alpha2 ().PediaClusters ())
145
153
146
154
methodSet := sets .New ("GET" )
147
155
for _ , rest := range proxyrest .GetSubresourceRESTs (controller ) {
156
+ allows := c .ExtraConfig .AllowedProxySubresources [rest .ParentGroupResource ()]
157
+ if allows == nil || ! allows .Has (rest .Subresource ()) {
158
+ continue
159
+ }
160
+
148
161
if err := restManager .preRegisterSubresource (subresource {
149
162
gr : rest .ParentGroupResource (),
150
163
kind : rest .ParentKind (),
0 commit comments