@@ -18,13 +18,13 @@ import (
1818)
1919
2020const (
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