@@ -29,28 +29,31 @@ private ConfigMapHelper() {}
2929
3030 /**
3131 * Factory for {@link Step} that creates config map containing scripts
32- * @param namespace Namespace
32+ * @param operatorNamespace the operator's namespace
33+ * @param domainNamespace the domain's namespace
3334 * @param next Next processing step
3435 * @return Step for creating config map containing scripts
3536 */
36- public static Step createScriptConfigMapStep (String namespace , Step next ) {
37- return new ScriptConfigMapStep (namespace , next );
37+ public static Step createScriptConfigMapStep (String operatorNamespace , String domainNamespace , Step next ) {
38+ return new ScriptConfigMapStep (operatorNamespace , domainNamespace , next );
3839 }
3940
4041 // Make this public so that it can be unit tested
4142 public static class ScriptConfigMapStep extends Step {
42- private final String namespace ;
43+ private final String operatorNamespace ;
44+ private final String domainNamespace ;
4345
44- public ScriptConfigMapStep (String namespace , Step next ) {
46+ public ScriptConfigMapStep (String operatorNamespace , String domainNamespace , Step next ) {
4547 super (next );
46- this .namespace = namespace ;
48+ this .operatorNamespace = operatorNamespace ;
49+ this .domainNamespace = domainNamespace ;
4750 }
4851
4952 @ Override
5053 public NextAction apply (Packet packet ) {
5154 V1ConfigMap cm = computeDomainConfigMap ();
5255 CallBuilderFactory factory = ContainerResolver .getInstance ().getContainer ().getSPI (CallBuilderFactory .class );
53- Step read = factory .create ().readConfigMapAsync (cm .getMetadata ().getName (), namespace , new ResponseStep <V1ConfigMap >(next ) {
56+ Step read = factory .create ().readConfigMapAsync (cm .getMetadata ().getName (), domainNamespace , new ResponseStep <V1ConfigMap >(next ) {
5457 @ Override
5558 public NextAction onFailure (Packet packet , ApiException e , int statusCode ,
5659 Map <String , List <String >> responseHeaders ) {
@@ -64,7 +67,7 @@ public NextAction onFailure(Packet packet, ApiException e, int statusCode,
6467 public NextAction onSuccess (Packet packet , V1ConfigMap result , int statusCode ,
6568 Map <String , List <String >> responseHeaders ) {
6669 if (result == null ) {
67- Step create = factory .create ().createConfigMapAsync (namespace , cm , new ResponseStep <V1ConfigMap >(next ) {
70+ Step create = factory .create ().createConfigMapAsync (domainNamespace , cm , new ResponseStep <V1ConfigMap >(next ) {
6871 @ Override
6972 public NextAction onFailure (Packet packet , ApiException e , int statusCode ,
7073 Map <String , List <String >> responseHeaders ) {
@@ -75,23 +78,23 @@ public NextAction onFailure(Packet packet, ApiException e, int statusCode,
7578 public NextAction onSuccess (Packet packet , V1ConfigMap result , int statusCode ,
7679 Map <String , List <String >> responseHeaders ) {
7780
78- LOGGER .info (MessageKeys .CM_CREATED , namespace );
81+ LOGGER .info (MessageKeys .CM_CREATED , domainNamespace );
7982 packet .put (ProcessingConstants .SCRIPT_CONFIG_MAP , result );
8083 return doNext (packet );
8184 }
8285 });
8386 return doNext (create , packet );
8487 } else if (AnnotationHelper .checkFormatAnnotation (result .getMetadata ()) && result .getData ().entrySet ().containsAll (cm .getData ().entrySet ())) {
8588 // existing config map has correct data
86- LOGGER .fine (MessageKeys .CM_EXISTS , namespace );
89+ LOGGER .fine (MessageKeys .CM_EXISTS , domainNamespace );
8790 packet .put (ProcessingConstants .SCRIPT_CONFIG_MAP , result );
8891 return doNext (packet );
8992 } else {
9093 // we need to update the config map
9194 Map <String , String > updated = result .getData ();
9295 updated .putAll (cm .getData ());
9396 cm .setData (updated );
94- Step replace = factory .create ().replaceConfigMapAsync (cm .getMetadata ().getName (), namespace , cm , new ResponseStep <V1ConfigMap >(next ) {
97+ Step replace = factory .create ().replaceConfigMapAsync (cm .getMetadata ().getName (), domainNamespace , cm , new ResponseStep <V1ConfigMap >(next ) {
9598 @ Override
9699 public NextAction onFailure (Packet packet , ApiException e , int statusCode ,
97100 Map <String , List <String >> responseHeaders ) {
@@ -101,7 +104,7 @@ public NextAction onFailure(Packet packet, ApiException e, int statusCode,
101104 @ Override
102105 public NextAction onSuccess (Packet packet , V1ConfigMap result , int statusCode ,
103106 Map <String , List <String >> responseHeaders ) {
104- LOGGER .info (MessageKeys .CM_REPLACED , namespace );
107+ LOGGER .info (MessageKeys .CM_REPLACED , domainNamespace );
105108 packet .put (ProcessingConstants .SCRIPT_CONFIG_MAP , result );
106109 return doNext (packet );
107110 }
@@ -123,17 +126,12 @@ protected V1ConfigMap computeDomainConfigMap() {
123126
124127 V1ObjectMeta metadata = new V1ObjectMeta ();
125128 metadata .setName (name );
126- metadata .setNamespace (namespace );
129+ metadata .setNamespace (domainNamespace );
127130
128131 AnnotationHelper .annotateWithFormat (metadata );
129132
130133 Map <String , String > labels = new HashMap <>();
131- // This config map is a singleton that is shared by all the domains
132- // We need to add a domain uid label so that it can be located as
133- // related to the operator. However, we don't have a specific domain uid
134- // to set as the value. So, just set it to an empty string. That way,
135- // someone seleting on just the weblogic.domainUID label will find it.
136- labels .put (LabelConstants .DOMAINUID_LABEL , "" );
134+ labels .put (LabelConstants .OPERATORNAME_LABEL , operatorNamespace );
137135 labels .put (LabelConstants .CREATEDBYOPERATOR_LABEL , "true" );
138136 metadata .setLabels (labels );
139137
0 commit comments