Skip to content

Commit 8f7711d

Browse files
committed
OCPEDGE-2037: Nits
1 parent f4b7837 commit 8f7711d

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

pkg/components/components.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func StartComponents(cfg *config.Config, ctx context.Context) error {
4444
return err
4545
}
4646

47-
if err := startEtcdController(ctx, cfg, kubeAdminConfig); err != nil {
47+
if err := startEtcdController(ctx, kubeAdminConfig); err != nil {
4848
klog.Warningf("Failed to start etcd controller: %v", err)
4949
return err
5050
}

pkg/components/etcd.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import (
1818
)
1919

2020
const (
21-
// Secret name for etcd CA certificate
22-
etcdCASecretName = "microshift-etcd-ca"
23-
// Secret namespace
24-
etcdCASecretNamespace = "kube-system"
21+
// Resource name for etcd CA certificate
22+
etcdCAResourceName = "microshift-etcd-ca"
23+
// Resource namespace
24+
etcdCAResourceNamespace = "kube-system"
2525
)
2626

27-
func startEtcdController(ctx context.Context, cfg *config.Config, kubeconfigPath string) error {
27+
func startEtcdController(ctx context.Context, kubeconfigPath string) error {
2828
client, err := getKubernetesClient(kubeconfigPath)
2929
if err != nil {
3030
return fmt.Errorf("failed to get Kubernetes client: %w", err)
@@ -40,7 +40,7 @@ func startEtcdController(ctx context.Context, cfg *config.Config, kubeconfigPath
4040
return nil
4141
}
4242

43-
func getKubernetesClient(kubeconfigPath string) (kubernetes.Interface, error) {
43+
func getKubernetesClient(kubeconfigPath string) (*kubernetes.Clientset, error) {
4444
restConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
4545
if err != nil {
4646
return nil, err
@@ -52,27 +52,27 @@ func createClusterRole(ctx context.Context, client kubernetes.Interface) error {
5252
role := &rbacv1.Role{
5353
ObjectMeta: metav1.ObjectMeta{
5454
Name: "microshift-etcd-ca-admin",
55-
Namespace: etcdCASecretNamespace,
55+
Namespace: etcdCAResourceNamespace,
5656
},
5757
Rules: []rbacv1.PolicyRule{
5858
{
5959
APIGroups: []string{""},
6060
Resources: []string{"secrets"},
61-
ResourceNames: []string{etcdCASecretName},
61+
ResourceNames: []string{etcdCAResourceName},
6262
Verbs: []string{"*"},
6363
},
6464
},
6565
}
6666

67-
_, err := client.RbacV1().Roles(etcdCASecretNamespace).Create(ctx, role, metav1.CreateOptions{})
67+
_, err := client.RbacV1().Roles(etcdCAResourceNamespace).Create(ctx, role, metav1.CreateOptions{})
6868
if err != nil && !apierrors.IsAlreadyExists(err) {
6969
return fmt.Errorf("failed to create etcd CA admin Role: %w", err)
7070
}
7171

7272
roleBinding := &rbacv1.RoleBinding{
7373
ObjectMeta: metav1.ObjectMeta{
7474
Name: "microshift-etcd-ca-admin-binding",
75-
Namespace: etcdCASecretNamespace,
75+
Namespace: etcdCAResourceNamespace,
7676
},
7777
Subjects: []rbacv1.Subject{
7878
{
@@ -88,7 +88,7 @@ func createClusterRole(ctx context.Context, client kubernetes.Interface) error {
8888
},
8989
}
9090

91-
_, err = client.RbacV1().RoleBindings(etcdCASecretNamespace).Create(ctx, roleBinding, metav1.CreateOptions{})
91+
_, err = client.RbacV1().RoleBindings(etcdCAResourceNamespace).Create(ctx, roleBinding, metav1.CreateOptions{})
9292
if err != nil && !apierrors.IsAlreadyExists(err) {
9393
return fmt.Errorf("failed to create etcd CA admin RoleBinding: %w", err)
9494
}
@@ -119,8 +119,8 @@ func exposeEtcdCA(ctx context.Context, client kubernetes.Interface) error {
119119

120120
secret := &corev1.Secret{
121121
ObjectMeta: metav1.ObjectMeta{
122-
Name: etcdCASecretName,
123-
Namespace: etcdCASecretNamespace,
122+
Name: etcdCAResourceName,
123+
Namespace: etcdCAResourceNamespace,
124124
},
125125
Type: corev1.SecretTypeOpaque,
126126
Data: map[string][]byte{
@@ -130,7 +130,7 @@ func exposeEtcdCA(ctx context.Context, client kubernetes.Interface) error {
130130
},
131131
}
132132

133-
_, err = client.CoreV1().Secrets(etcdCASecretNamespace).Create(ctx, secret, metav1.CreateOptions{})
133+
_, err = client.CoreV1().Secrets(etcdCAResourceNamespace).Create(ctx, secret, metav1.CreateOptions{})
134134
if err != nil {
135135
return fmt.Errorf("failed to create etcd CA secret: %w", err)
136136
}

0 commit comments

Comments
 (0)