1
1
package io .javaoperatorsdk .operator .glue .conditions ;
2
2
3
+ import org .slf4j .Logger ;
4
+ import org .slf4j .LoggerFactory ;
5
+
3
6
import io .fabric8 .kubernetes .api .model .GenericKubernetesResource ;
4
7
import io .javaoperatorsdk .operator .api .reconciler .Context ;
5
8
import io .javaoperatorsdk .operator .api .reconciler .dependent .DependentResource ;
9
12
10
13
public class QuteCondition implements Condition <GenericKubernetesResource , Glue > {
11
14
15
+ private static final Logger LOG = LoggerFactory .getLogger (QuteCondition .class );
16
+
12
17
private final GenericTemplateHandler genericTemplateHandler ;
13
18
private final String template ;
14
19
@@ -20,7 +25,17 @@ public QuteCondition(GenericTemplateHandler genericTemplateHandler, String templ
20
25
@ Override
21
26
public boolean isMet (DependentResource <GenericKubernetesResource , Glue > dependentResource ,
22
27
Glue primary , Context <Glue > context ) {
23
- // TODO
24
- return false ;
28
+
29
+ LOG .debug ("Evaluating condition with template: {}" , template );
30
+
31
+ var data = GenericTemplateHandler .createDataWithResources (primary , context );
32
+ data .put ("target" , GenericTemplateHandler
33
+ .convertToValue (dependentResource .getSecondaryResource (primary , context )));
34
+
35
+ var res = genericTemplateHandler .processTemplate (data , template , false );
36
+
37
+ LOG .debug ("Qute condition result: {}" , res );
38
+
39
+ return "true" .equalsIgnoreCase (res .trim ());
25
40
}
26
41
}
0 commit comments