You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I finally got round to trying to use the new API introduced to address #2561 for real yesterday. Sorry it has taken so long. Sadly, it seems there's a bug.
What did you expect to see?
I expected the CRD to be loaded from the file specified via the new withAdditionalCRD() method
What did you see instead? Under which circumstances?
The file is not loaded and I got an IllegalStateException, exactly as before. For example:
java.lang.IllegalStateException: Cannot apply CRD yaml: /META-INF/fabric8/tests.crd.example-v1.yml
at io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension.applyCrd(LocallyRunOperatorExtension.java:143)
at io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension.applyCrd(LocallyRunOperatorExtension.java:115)
at io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension.applyCrd(LocallyRunOperatorExtension.java:270)
at io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension.before(LocallyRunOperatorExtension.java:231)
at io.javaoperatorsdk.operator.junit.AbstractOperatorExtension.beforeEachImpl(AbstractOperatorExtension.java:133)
at io.javaoperatorsdk.operator.junit.AbstractOperatorExtension.beforeEach(AbstractOperatorExtension.java:79)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.IllegalStateException: Cannot find CRD at /META-INF/fabric8/tests.crd.example-v1.yml
at io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension.applyCrd(LocallyRunOperatorExtension.java:131)
... 7 more
Additional context
Taking a closer look at the code on main I found the test io.javaoperatorsdk.operator.CRDMappingInTestExtensionITinitially failed in the same way as my usage when I ran it in the IDE. When I then compiled with maven it worked. That's because the CRDMappingInTestExtensionIT.TestCR is being picked up by the Fabric8 crd-generator-maven-plugin, which generates a CRD and puts it in target/classes/META-INF/fabric8/tests.crd.example-v1.yml. It's that file which is picked up by LocallyRunOperatorExtension.applyCrd(), the one passed via LocallyRunOperatorExtension.withAdditionalCRD("src/test/resources/crd/test.crd") is basically ignored.
The other way you can tell there's a problem is that the only caller of private static void applyCrd(InputStream is, String path, KubernetesClient client) is public static void applyCrd(String resourceTypeName, KubernetesClient client), which hard codes the path to use as String path = "/META-INF/fabric8/" + resourceTypeName + "-v1.yml";. In other words, the LocallyRunOperatorExtension is still making the same assumption as it was when #2561 was originally raised.
The text was updated successfully, but these errors were encountered:
Bug Report
What did you do?
I finally got round to trying to use the new API introduced to address #2561 for real yesterday. Sorry it has taken so long. Sadly, it seems there's a bug.
What did you expect to see?
I expected the CRD to be loaded from the file specified via the new
withAdditionalCRD()
methodWhat did you see instead? Under which circumstances?
The file is not loaded and I got an IllegalStateException, exactly as before. For example:
Additional context
Taking a closer look at the code on
main
I found the testio.javaoperatorsdk.operator.CRDMappingInTestExtensionIT
initially failed in the same way as my usage when I ran it in the IDE. When I then compiled with maven it worked. That's because theCRDMappingInTestExtensionIT.TestCR
is being picked up by the Fabric8crd-generator-maven-plugin
, which generates a CRD and puts it intarget/classes/META-INF/fabric8/tests.crd.example-v1.yml
. It's that file which is picked up byLocallyRunOperatorExtension.applyCrd()
, the one passed viaLocallyRunOperatorExtension.withAdditionalCRD("src/test/resources/crd/test.crd")
is basically ignored.The other way you can tell there's a problem is that the only caller of
private static void applyCrd(InputStream is, String path, KubernetesClient client)
ispublic static void applyCrd(String resourceTypeName, KubernetesClient client)
, which hard codes the path to use asString path = "/META-INF/fabric8/" + resourceTypeName + "-v1.yml";
. In other words, theLocallyRunOperatorExtension
is still making the same assumption as it was when #2561 was originally raised.The text was updated successfully, but these errors were encountered: