File tree 1 file changed +11
-4
lines changed
operator-framework/src/test/java/io/javaoperatorsdk/operator
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -70,10 +70,17 @@ public void initialize(
70
70
log .info ("Operator is running with {}" , controller .getClass ().getCanonicalName ());
71
71
}
72
72
73
- public CustomResourceDefinition loadCRDAndApplyToCluster (String classPathYaml ) {
74
- CustomResourceDefinition crd = loadYaml (CustomResourceDefinition .class , classPathYaml );
75
- k8sClient .apiextensions ().v1 ().customResourceDefinitions ().createOrReplace (crd );
76
- return crd ;
73
+ public void loadCRDAndApplyToCluster (String classPathYaml ) {
74
+ var crd = loadYaml (CustomResourceDefinition .class , classPathYaml );
75
+ if ("apiextensions.k8s.io/v1" .equals (crd .getApiVersion ())) {
76
+ k8sClient .apiextensions ().v1 ().customResourceDefinitions ().createOrReplace (crd );
77
+ } else {
78
+ var crd2 =
79
+ loadYaml (
80
+ io .fabric8 .kubernetes .api .model .apiextensions .v1beta1 .CustomResourceDefinition .class ,
81
+ classPathYaml );
82
+ k8sClient .apiextensions ().v1beta1 ().customResourceDefinitions ().createOrReplace (crd2 );
83
+ }
77
84
}
78
85
79
86
public void cleanup () {
You can’t perform that action at this time.
0 commit comments