Skip to content

Commit 4cfcf05

Browse files
committed
Fix lint warnings in pkg/controller/bootstrap
1 parent aa5fda2 commit 4cfcf05

File tree

4 files changed

+33
-35
lines changed

4 files changed

+33
-35
lines changed

cmd/kube-controller-manager/app/bootstrap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
)
2626

2727
func startBootstrapSignerController(ctx ControllerContext) (http.Handler, bool, error) {
28-
bsc, err := bootstrap.NewBootstrapSigner(
28+
bsc, err := bootstrap.NewSigner(
2929
ctx.ClientBuilder.ClientOrDie("bootstrap-signer"),
3030
ctx.InformerFactory.Core().V1().Secrets(),
3131
ctx.InformerFactory.Core().V1().ConfigMaps(),
32-
bootstrap.DefaultBootstrapSignerOptions(),
32+
bootstrap.DefaultSignerOptions(),
3333
)
3434
if err != nil {
3535
return nil, true, fmt.Errorf("error creating BootstrapSigner controller: %v", err)

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ pkg/cloudprovider/providers/photon
7474
pkg/cloudprovider/providers/vsphere
7575
pkg/controller
7676
pkg/controller/apis/config/v1alpha1
77-
pkg/controller/bootstrap
7877
pkg/controller/certificates
7978
pkg/controller/certificates/approver
8079
pkg/controller/certificates/signer

pkg/controller/bootstrap/bootstrapsigner.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import (
3939
"k8s.io/kubernetes/pkg/util/metrics"
4040
)
4141

42-
// BootstrapSignerOptions contains options for the BootstrapSigner
43-
type BootstrapSignerOptions struct {
42+
// SignerOptions contains options for the Signer
43+
type SignerOptions struct {
4444
// ConfigMapNamespace is the namespace of the ConfigMap
4545
ConfigMapNamespace string
4646

@@ -59,18 +59,17 @@ type BootstrapSignerOptions struct {
5959
SecretResync time.Duration
6060
}
6161

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{
6665
ConfigMapNamespace: api.NamespacePublic,
6766
ConfigMapName: bootstrapapi.ConfigMapClusterInfo,
6867
TokenSecretNamespace: api.NamespaceSystem,
6968
}
7069
}
7170

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 {
7473
client clientset.Interface
7574
configMapKey string
7675
configMapName string
@@ -90,9 +89,9 @@ type BootstrapSigner struct {
9089
configMapSynced cache.InformerSynced
9190
}
9291

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{
9695
client: cl,
9796
configMapKey: options.ConfigMapNamespace + "/" + options.ConfigMapName,
9897
configMapName: options.ConfigMapName,
@@ -153,7 +152,7 @@ func NewBootstrapSigner(cl clientset.Interface, secrets informers.SecretInformer
153152
}
154153

155154
// 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{}) {
157156
// Shut down queues
158157
defer utilruntime.HandleCrash()
159158
defer e.syncQueue.ShutDown()
@@ -168,11 +167,11 @@ func (e *BootstrapSigner) Run(stopCh <-chan struct{}) {
168167
klog.V(1).Infof("Shutting down")
169168
}
170169

171-
func (e *BootstrapSigner) pokeConfigMapSync() {
170+
func (e *Signer) pokeConfigMapSync() {
172171
e.syncQueue.Add(e.configMapKey)
173172
}
174173

175-
func (e *BootstrapSigner) serviceConfigMapQueue() {
174+
func (e *Signer) serviceConfigMapQueue() {
176175
key, quit := e.syncQueue.Get()
177176
if quit {
178177
return
@@ -184,7 +183,7 @@ func (e *BootstrapSigner) serviceConfigMapQueue() {
184183

185184
// signConfigMap computes the signatures on our latest cached objects and writes
186185
// back if necessary.
187-
func (e *BootstrapSigner) signConfigMap() {
186+
func (e *Signer) signConfigMap() {
188187
origCM := e.getConfigMap()
189188

190189
if origCM == nil {
@@ -241,15 +240,15 @@ func (e *BootstrapSigner) signConfigMap() {
241240
}
242241
}
243242

244-
func (e *BootstrapSigner) updateConfigMap(cm *v1.ConfigMap) {
243+
func (e *Signer) updateConfigMap(cm *v1.ConfigMap) {
245244
_, err := e.client.CoreV1().ConfigMaps(cm.Namespace).Update(cm)
246245
if err != nil && !apierrors.IsConflict(err) && !apierrors.IsNotFound(err) {
247246
klog.V(3).Infof("Error updating ConfigMap: %v", err)
248247
}
249248
}
250249

251250
// getConfigMap gets the ConfigMap we are interested in
252-
func (e *BootstrapSigner) getConfigMap() *v1.ConfigMap {
251+
func (e *Signer) getConfigMap() *v1.ConfigMap {
253252
configMap, err := e.configMapLister.ConfigMaps(e.configMapNamespace).Get(e.configMapName)
254253

255254
// If we can't get the configmap just return nil. The resync will eventually
@@ -264,7 +263,7 @@ func (e *BootstrapSigner) getConfigMap() *v1.ConfigMap {
264263
return configMap
265264
}
266265

267-
func (e *BootstrapSigner) listSecrets() []*v1.Secret {
266+
func (e *Signer) listSecrets() []*v1.Secret {
268267
secrets, err := e.secretLister.Secrets(e.secretNamespace).List(labels.Everything())
269268
if err != nil {
270269
utilruntime.HandleError(err)
@@ -282,7 +281,7 @@ func (e *BootstrapSigner) listSecrets() []*v1.Secret {
282281

283282
// getTokens returns a map of tokenID->tokenSecret. It ensures the token is
284283
// valid for signing.
285-
func (e *BootstrapSigner) getTokens() map[string]string {
284+
func (e *Signer) getTokens() map[string]string {
286285
ret := map[string]string{}
287286
secretObjs := e.listSecrets()
288287
for _, secret := range secretObjs {

pkg/controller/bootstrap/bootstrapsigner_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ func init() {
3939

4040
const testTokenID = "abc123"
4141

42-
func newBootstrapSigner() (*BootstrapSigner, *fake.Clientset, coreinformers.SecretInformer, coreinformers.ConfigMapInformer, error) {
43-
options := DefaultBootstrapSignerOptions()
42+
func newSigner() (*Signer, *fake.Clientset, coreinformers.SecretInformer, coreinformers.ConfigMapInformer, error) {
43+
options := DefaultSignerOptions()
4444
cl := fake.NewSimpleClientset()
4545
informers := informers.NewSharedInformerFactory(fake.NewSimpleClientset(), controller.NoResyncPeriodFunc())
4646
secrets := informers.Core().V1().Secrets()
4747
configMaps := informers.Core().V1().ConfigMaps()
48-
bsc, err := NewBootstrapSigner(cl, secrets, configMaps, options)
48+
bsc, err := NewSigner(cl, secrets, configMaps, options)
4949
if err != nil {
5050
return nil, nil, nil, nil, err
5151
}
@@ -70,18 +70,18 @@ func newConfigMap(tokenID, signature string) *v1.ConfigMap {
7070
}
7171

7272
func TestNoConfigMap(t *testing.T) {
73-
signer, cl, _, _, err := newBootstrapSigner()
73+
signer, cl, _, _, err := newSigner()
7474
if err != nil {
75-
t.Fatalf("error creating BootstrapSigner: %v", err)
75+
t.Fatalf("error creating Signer: %v", err)
7676
}
7777
signer.signConfigMap()
7878
verifyActions(t, []core.Action{}, cl.Actions())
7979
}
8080

8181
func TestSimpleSign(t *testing.T) {
82-
signer, cl, secrets, configMaps, err := newBootstrapSigner()
82+
signer, cl, secrets, configMaps, err := newSigner()
8383
if err != nil {
84-
t.Fatalf("error creating BootstrapSigner: %v", err)
84+
t.Fatalf("error creating Signer: %v", err)
8585
}
8686

8787
cm := newConfigMap("", "")
@@ -103,9 +103,9 @@ func TestSimpleSign(t *testing.T) {
103103
}
104104

105105
func TestNoSignNeeded(t *testing.T) {
106-
signer, cl, secrets, configMaps, err := newBootstrapSigner()
106+
signer, cl, secrets, configMaps, err := newSigner()
107107
if err != nil {
108-
t.Fatalf("error creating BootstrapSigner: %v", err)
108+
t.Fatalf("error creating Signer: %v", err)
109109
}
110110

111111
cm := newConfigMap(testTokenID, "eyJhbGciOiJIUzI1NiIsImtpZCI6ImFiYzEyMyJ9..QSxpUG7Q542CirTI2ECPSZjvBOJURUW5a7XqFpNI958")
@@ -121,9 +121,9 @@ func TestNoSignNeeded(t *testing.T) {
121121
}
122122

123123
func TestUpdateSignature(t *testing.T) {
124-
signer, cl, secrets, configMaps, err := newBootstrapSigner()
124+
signer, cl, secrets, configMaps, err := newSigner()
125125
if err != nil {
126-
t.Fatalf("error creating BootstrapSigner: %v", err)
126+
t.Fatalf("error creating Signer: %v", err)
127127
}
128128

129129
cm := newConfigMap(testTokenID, "old signature")
@@ -145,9 +145,9 @@ func TestUpdateSignature(t *testing.T) {
145145
}
146146

147147
func TestRemoveSignature(t *testing.T) {
148-
signer, cl, _, configMaps, err := newBootstrapSigner()
148+
signer, cl, _, configMaps, err := newSigner()
149149
if err != nil {
150-
t.Fatalf("error creating BootstrapSigner: %v", err)
150+
t.Fatalf("error creating Signer: %v", err)
151151
}
152152

153153
cm := newConfigMap(testTokenID, "old signature")

0 commit comments

Comments
 (0)