@@ -39,8 +39,8 @@ import (
39
39
"k8s.io/kubernetes/pkg/util/metrics"
40
40
)
41
41
42
- // BootstrapSignerOptions contains options for the BootstrapSigner
43
- type BootstrapSignerOptions struct {
42
+ // SignerOptions contains options for the Signer
43
+ type SignerOptions struct {
44
44
// ConfigMapNamespace is the namespace of the ConfigMap
45
45
ConfigMapNamespace string
46
46
@@ -59,18 +59,17 @@ type BootstrapSignerOptions struct {
59
59
SecretResync time.Duration
60
60
}
61
61
62
- // DefaultBootstrapSignerOptions returns a set of default options for creating a
63
- // BootstrapSigner
64
- func DefaultBootstrapSignerOptions () BootstrapSignerOptions {
65
- return BootstrapSignerOptions {
62
+ // DefaultSignerOptions returns a set of default options for creating a Signer.
63
+ func DefaultSignerOptions () SignerOptions {
64
+ return SignerOptions {
66
65
ConfigMapNamespace : api .NamespacePublic ,
67
66
ConfigMapName : bootstrapapi .ConfigMapClusterInfo ,
68
67
TokenSecretNamespace : api .NamespaceSystem ,
69
68
}
70
69
}
71
70
72
- // BootstrapSigner is a controller that signs a ConfigMap with a set of tokens.
73
- type BootstrapSigner struct {
71
+ // Signer is a controller that signs a ConfigMap with a set of tokens.
72
+ type Signer struct {
74
73
client clientset.Interface
75
74
configMapKey string
76
75
configMapName string
@@ -90,9 +89,9 @@ type BootstrapSigner struct {
90
89
configMapSynced cache.InformerSynced
91
90
}
92
91
93
- // NewBootstrapSigner returns a new *BootstrapSigner .
94
- func NewBootstrapSigner (cl clientset.Interface , secrets informers.SecretInformer , configMaps informers.ConfigMapInformer , options BootstrapSignerOptions ) (* BootstrapSigner , error ) {
95
- e := & BootstrapSigner {
92
+ // NewSigner returns a new *Signer .
93
+ func NewSigner (cl clientset.Interface , secrets informers.SecretInformer , configMaps informers.ConfigMapInformer , options SignerOptions ) (* Signer , error ) {
94
+ e := & Signer {
96
95
client : cl ,
97
96
configMapKey : options .ConfigMapNamespace + "/" + options .ConfigMapName ,
98
97
configMapName : options .ConfigMapName ,
@@ -153,7 +152,7 @@ func NewBootstrapSigner(cl clientset.Interface, secrets informers.SecretInformer
153
152
}
154
153
155
154
// Run runs controller loops and returns when they are done
156
- func (e * BootstrapSigner ) Run (stopCh <- chan struct {}) {
155
+ func (e * Signer ) Run (stopCh <- chan struct {}) {
157
156
// Shut down queues
158
157
defer utilruntime .HandleCrash ()
159
158
defer e .syncQueue .ShutDown ()
@@ -168,11 +167,11 @@ func (e *BootstrapSigner) Run(stopCh <-chan struct{}) {
168
167
klog .V (1 ).Infof ("Shutting down" )
169
168
}
170
169
171
- func (e * BootstrapSigner ) pokeConfigMapSync () {
170
+ func (e * Signer ) pokeConfigMapSync () {
172
171
e .syncQueue .Add (e .configMapKey )
173
172
}
174
173
175
- func (e * BootstrapSigner ) serviceConfigMapQueue () {
174
+ func (e * Signer ) serviceConfigMapQueue () {
176
175
key , quit := e .syncQueue .Get ()
177
176
if quit {
178
177
return
@@ -184,7 +183,7 @@ func (e *BootstrapSigner) serviceConfigMapQueue() {
184
183
185
184
// signConfigMap computes the signatures on our latest cached objects and writes
186
185
// back if necessary.
187
- func (e * BootstrapSigner ) signConfigMap () {
186
+ func (e * Signer ) signConfigMap () {
188
187
origCM := e .getConfigMap ()
189
188
190
189
if origCM == nil {
@@ -241,15 +240,15 @@ func (e *BootstrapSigner) signConfigMap() {
241
240
}
242
241
}
243
242
244
- func (e * BootstrapSigner ) updateConfigMap (cm * v1.ConfigMap ) {
243
+ func (e * Signer ) updateConfigMap (cm * v1.ConfigMap ) {
245
244
_ , err := e .client .CoreV1 ().ConfigMaps (cm .Namespace ).Update (cm )
246
245
if err != nil && ! apierrors .IsConflict (err ) && ! apierrors .IsNotFound (err ) {
247
246
klog .V (3 ).Infof ("Error updating ConfigMap: %v" , err )
248
247
}
249
248
}
250
249
251
250
// getConfigMap gets the ConfigMap we are interested in
252
- func (e * BootstrapSigner ) getConfigMap () * v1.ConfigMap {
251
+ func (e * Signer ) getConfigMap () * v1.ConfigMap {
253
252
configMap , err := e .configMapLister .ConfigMaps (e .configMapNamespace ).Get (e .configMapName )
254
253
255
254
// If we can't get the configmap just return nil. The resync will eventually
@@ -264,7 +263,7 @@ func (e *BootstrapSigner) getConfigMap() *v1.ConfigMap {
264
263
return configMap
265
264
}
266
265
267
- func (e * BootstrapSigner ) listSecrets () []* v1.Secret {
266
+ func (e * Signer ) listSecrets () []* v1.Secret {
268
267
secrets , err := e .secretLister .Secrets (e .secretNamespace ).List (labels .Everything ())
269
268
if err != nil {
270
269
utilruntime .HandleError (err )
@@ -282,7 +281,7 @@ func (e *BootstrapSigner) listSecrets() []*v1.Secret {
282
281
283
282
// getTokens returns a map of tokenID->tokenSecret. It ensures the token is
284
283
// valid for signing.
285
- func (e * BootstrapSigner ) getTokens () map [string ]string {
284
+ func (e * Signer ) getTokens () map [string ]string {
286
285
ret := map [string ]string {}
287
286
secretObjs := e .listSecrets ()
288
287
for _ , secret := range secretObjs {
0 commit comments