@@ -36,16 +36,16 @@ import (
3636)
3737
3838// Create the Deployment and Service objects for a Semeru Compiler used by a Websphere Liberty Application 
39- func  (r  * ReconcileWebSphereLiberty ) reconcileLTPAKeysSharing (instance  * wlv1.WebSphereLibertyApplication ,  defaultMeta  metav1. ObjectMeta ) (error , string , string ) {
39+ func  (r  * ReconcileWebSphereLiberty ) reconcileLTPAKeysSharing (instance  * wlv1.WebSphereLibertyApplication ) (error , string , string ) {
4040	var  ltpaSecretName  string 
4141	var  err  error 
4242	if  r .isLTPAKeySharingEnabled (instance ) {
43- 		err , ltpaSecretName  =  r .generateLTPAKeys (instance ,  defaultMeta )
43+ 		err , ltpaSecretName  =  r .generateLTPAKeys (instance )
4444		if  err  !=  nil  {
4545			return  err , "Failed to generate the shared LTPA Keys file" , ltpaSecretName 
4646		}
4747	} else  {
48- 		err  :=  r .deleteLTPAKeysResources (instance ,  defaultMeta )
48+ 		err  :=  r .deleteLTPAKeysResources (instance )
4949		if  err  !=  nil  {
5050			return  err , "Failed to delete LTPA Keys Resource" , ltpaSecretName 
5151		}
@@ -58,7 +58,7 @@ func (r *ReconcileWebSphereLiberty) getOrSetLTPAKeysSharingLeader(instance *wlv1
5858	ltpaServiceAccount  :=  & corev1.ServiceAccount {}
5959	ltpaServiceAccount .Name  =  OperatorShortName  +  "-ltpa" 
6060	ltpaServiceAccount .Namespace  =  instance .GetNamespace ()
61- 	ltpaServiceAccount .Labels  =  instance . GetLabels ( )
61+ 	ltpaServiceAccount .Labels  =  lutils . GetRequiredLabels ( ltpaServiceAccount . Name ,  "" )
6262	err  :=  r .GetClient ().Get (context .TODO (), types.NamespacedName {Name : ltpaServiceAccount .Name , Namespace : ltpaServiceAccount .Namespace }, ltpaServiceAccount )
6363	if  err  !=  nil  {
6464		if  kerrors .IsNotFound (err ) {
@@ -105,7 +105,7 @@ func (r *ReconcileWebSphereLiberty) restartLTPAKeysGeneration(instance *wlv1.Web
105105}
106106
107107// Generates the LTPA keys file and returns the name of the Secret storing its metadata 
108- func  (r  * ReconcileWebSphereLiberty ) generateLTPAKeys (instance  * wlv1.WebSphereLibertyApplication ,  defaultMeta  metav1. ObjectMeta ) (error , string ) {
108+ func  (r  * ReconcileWebSphereLiberty ) generateLTPAKeys (instance  * wlv1.WebSphereLibertyApplication ) (error , string ) {
109109	// Don't generate LTPA keys if this instance is not the leader 
110110	err , ltpaKeySharingLeaderName , isLTPAKeySharingLeader , ltpaServiceAccountName  :=  r .getOrSetLTPAKeysSharingLeader (instance )
111111	if  err  !=  nil  {
@@ -116,29 +116,29 @@ func (r *ReconcileWebSphereLiberty) generateLTPAKeys(instance *wlv1.WebSphereLib
116116	ltpaXMLSecret  :=  & corev1.Secret {}
117117	ltpaXMLSecret .Name  =  OperatorShortName  +  lutils .LTPAServerXMLSuffix 
118118	ltpaXMLSecret .Namespace  =  instance .GetNamespace ()
119- 	ltpaXMLSecret .Labels  =  instance . GetLabels ( )
119+ 	ltpaXMLSecret .Labels  =  lutils . GetRequiredLabels ( ltpaXMLSecret . Name ,  "" )
120120
121121	generateLTPAKeysJob  :=  & v1.Job {}
122122	generateLTPAKeysJob .Name  =  OperatorShortName  +  "-managed-ltpa-keys-generation" 
123123	generateLTPAKeysJob .Namespace  =  instance .GetNamespace ()
124- 	generateLTPAKeysJob .Labels  =  instance . GetLabels ( )
124+ 	generateLTPAKeysJob .Labels  =  lutils . GetRequiredLabels ( generateLTPAKeysJob . Name ,  "" )
125125
126126	deletePropagationBackground  :=  metav1 .DeletePropagationBackground 
127127
128128	ltpaJobRequest  :=  & corev1.ConfigMap {}
129129	ltpaJobRequest .Name  =  OperatorShortName  +  "-managed-ltpa-job-request" 
130130	ltpaJobRequest .Namespace  =  instance .GetNamespace ()
131- 	ltpaJobRequest .Labels  =  instance . GetLabels ( )
131+ 	ltpaJobRequest .Labels  =  lutils . GetRequiredLabels ( ltpaJobRequest . Name ,  "" )
132132
133133	ltpaKeysCreationScriptConfigMap  :=  & corev1.ConfigMap {}
134134	ltpaKeysCreationScriptConfigMap .Name  =  OperatorShortName  +  "-managed-ltpa-script" 
135135	ltpaKeysCreationScriptConfigMap .Namespace  =  instance .GetNamespace ()
136- 	ltpaKeysCreationScriptConfigMap .Labels  =  instance . GetLabels ( )
136+ 	ltpaKeysCreationScriptConfigMap .Labels  =  lutils . GetRequiredLabels ( ltpaKeysCreationScriptConfigMap . Name ,  "" )
137137
138138	ltpaSecret  :=  & corev1.Secret {}
139139	ltpaSecret .Name  =  OperatorShortName  +  "-managed-ltpa" 
140140	ltpaSecret .Namespace  =  instance .GetNamespace ()
141- 	ltpaSecret .Labels  =  instance . GetLabels ( )
141+ 	ltpaSecret .Labels  =  lutils . GetRequiredLabels ( ltpaSecret . Name ,  "" )
142142	// If the LTPA Secret does not exist, run the Kubernetes Job to generate the shared ltpa.keys file and Secret 
143143	err  =  r .GetClient ().Get (context .TODO (), types.NamespacedName {Name : ltpaSecret .Name , Namespace : ltpaSecret .Namespace }, ltpaSecret )
144144	if  err  !=  nil  &&  kerrors .IsNotFound (err ) {
@@ -185,7 +185,7 @@ func (r *ReconcileWebSphereLiberty) generateLTPAKeys(instance *wlv1.WebSphereLib
185185					Resources : []string {"secrets" },
186186				},
187187			}
188- 			ltpaRole .Labels  =  instance . GetLabels ( )
188+ 			ltpaRole .Labels  =  lutils . GetRequiredLabels ( ltpaRole . Name ,  "" )
189189			r .CreateOrUpdate (ltpaRole , instance , func () error  {
190190				return  nil 
191191			})
@@ -205,16 +205,12 @@ func (r *ReconcileWebSphereLiberty) generateLTPAKeys(instance *wlv1.WebSphereLib
205205				Kind :     "Role" ,
206206				Name :     ltpaRole .Name ,
207207			}
208- 			ltpaRoleBinding .Labels  =  instance . GetLabels ( )
208+ 			ltpaRoleBinding .Labels  =  lutils . GetRequiredLabels ( ltpaRoleBinding . Name ,  "" )
209209			r .CreateOrUpdate (ltpaRoleBinding , instance , func () error  {
210210				return  nil 
211211			})
212212
213213			// Create a ConfigMap to store the controllers/assets/create_ltpa_keys.sh script 
214- 			ltpaKeysCreationScriptConfigMap  :=  & corev1.ConfigMap {}
215- 			ltpaKeysCreationScriptConfigMap .Name  =  OperatorShortName  +  "-managed-ltpa-script" 
216- 			ltpaKeysCreationScriptConfigMap .Namespace  =  instance .GetNamespace ()
217- 			ltpaKeysCreationScriptConfigMap .Labels  =  instance .GetLabels ()
218214			err  =  r .GetClient ().Get (context .TODO (), types.NamespacedName {Name : ltpaKeysCreationScriptConfigMap .Name , Namespace : ltpaKeysCreationScriptConfigMap .Namespace }, ltpaKeysCreationScriptConfigMap )
219215			if  err  !=  nil  &&  kerrors .IsNotFound (err ) {
220216				ltpaKeysCreationScriptConfigMap .Data  =  make (map [string ]string )
@@ -291,7 +287,7 @@ func (r *ReconcileWebSphereLiberty) isLTPAKeySharingEnabled(instance *wlv1.WebSp
291287}
292288
293289// Deletes resources used to create the LTPA keys file 
294- func  (r  * ReconcileWebSphereLiberty ) deleteLTPAKeysResources (instance  * wlv1.WebSphereLibertyApplication ,  defaultMeta  metav1. ObjectMeta ) error  {
290+ func  (r  * ReconcileWebSphereLiberty ) deleteLTPAKeysResources (instance  * wlv1.WebSphereLibertyApplication ) error  {
295291	// Don't delete LTPA keys resources if this instance is not the leader 
296292	err , _ , isLTPAKeySharingLeader , ltpaServiceAccountName  :=  r .getOrSetLTPAKeysSharingLeader (instance )
297293	if  err  !=  nil  {
0 commit comments