@@ -29,28 +29,31 @@ private ConfigMapHelper() {}
29
29
30
30
/**
31
31
* 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
33
34
* @param next Next processing step
34
35
* @return Step for creating config map containing scripts
35
36
*/
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 );
38
39
}
39
40
40
41
// Make this public so that it can be unit tested
41
42
public static class ScriptConfigMapStep extends Step {
42
- private final String namespace ;
43
+ private final String operatorNamespace ;
44
+ private final String domainNamespace ;
43
45
44
- public ScriptConfigMapStep (String namespace , Step next ) {
46
+ public ScriptConfigMapStep (String operatorNamespace , String domainNamespace , Step next ) {
45
47
super (next );
46
- this .namespace = namespace ;
48
+ this .operatorNamespace = operatorNamespace ;
49
+ this .domainNamespace = domainNamespace ;
47
50
}
48
51
49
52
@ Override
50
53
public NextAction apply (Packet packet ) {
51
54
V1ConfigMap cm = computeDomainConfigMap ();
52
55
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 ) {
54
57
@ Override
55
58
public NextAction onFailure (Packet packet , ApiException e , int statusCode ,
56
59
Map <String , List <String >> responseHeaders ) {
@@ -64,7 +67,7 @@ public NextAction onFailure(Packet packet, ApiException e, int statusCode,
64
67
public NextAction onSuccess (Packet packet , V1ConfigMap result , int statusCode ,
65
68
Map <String , List <String >> responseHeaders ) {
66
69
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 ) {
68
71
@ Override
69
72
public NextAction onFailure (Packet packet , ApiException e , int statusCode ,
70
73
Map <String , List <String >> responseHeaders ) {
@@ -75,23 +78,23 @@ public NextAction onFailure(Packet packet, ApiException e, int statusCode,
75
78
public NextAction onSuccess (Packet packet , V1ConfigMap result , int statusCode ,
76
79
Map <String , List <String >> responseHeaders ) {
77
80
78
- LOGGER .info (MessageKeys .CM_CREATED , namespace );
81
+ LOGGER .info (MessageKeys .CM_CREATED , domainNamespace );
79
82
packet .put (ProcessingConstants .SCRIPT_CONFIG_MAP , result );
80
83
return doNext (packet );
81
84
}
82
85
});
83
86
return doNext (create , packet );
84
87
} else if (AnnotationHelper .checkFormatAnnotation (result .getMetadata ()) && result .getData ().entrySet ().containsAll (cm .getData ().entrySet ())) {
85
88
// existing config map has correct data
86
- LOGGER .fine (MessageKeys .CM_EXISTS , namespace );
89
+ LOGGER .fine (MessageKeys .CM_EXISTS , domainNamespace );
87
90
packet .put (ProcessingConstants .SCRIPT_CONFIG_MAP , result );
88
91
return doNext (packet );
89
92
} else {
90
93
// we need to update the config map
91
94
Map <String , String > updated = result .getData ();
92
95
updated .putAll (cm .getData ());
93
96
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 ) {
95
98
@ Override
96
99
public NextAction onFailure (Packet packet , ApiException e , int statusCode ,
97
100
Map <String , List <String >> responseHeaders ) {
@@ -101,7 +104,7 @@ public NextAction onFailure(Packet packet, ApiException e, int statusCode,
101
104
@ Override
102
105
public NextAction onSuccess (Packet packet , V1ConfigMap result , int statusCode ,
103
106
Map <String , List <String >> responseHeaders ) {
104
- LOGGER .info (MessageKeys .CM_REPLACED , namespace );
107
+ LOGGER .info (MessageKeys .CM_REPLACED , domainNamespace );
105
108
packet .put (ProcessingConstants .SCRIPT_CONFIG_MAP , result );
106
109
return doNext (packet );
107
110
}
@@ -123,17 +126,12 @@ protected V1ConfigMap computeDomainConfigMap() {
123
126
124
127
V1ObjectMeta metadata = new V1ObjectMeta ();
125
128
metadata .setName (name );
126
- metadata .setNamespace (namespace );
129
+ metadata .setNamespace (domainNamespace );
127
130
128
131
AnnotationHelper .annotateWithFormat (metadata );
129
132
130
133
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 );
137
135
labels .put (LabelConstants .CREATEDBYOPERATOR_LABEL , "true" );
138
136
metadata .setLabels (labels );
139
137
0 commit comments