-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve: simpler api for adding additional CRD file #2574
Conversation
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
@@ -28,7 +28,7 @@ public class CRDMappingInTestExtensionIT { | |||
LocallyRunOperatorExtension operator = | |||
LocallyRunOperatorExtension.builder() | |||
.withReconciler(new TestReconciler()) | |||
.withCRDMapping("tests.crd.example", "src/test/crd/test.crd") | |||
.withAdditionalCRD("src/test/resources/crd/test.crd") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was explicitly not put in resources
to check that the file could be accessed from a "random" part of the file system, not just from the classpath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, isn't it trivial? I would rather stick with this, but no strong opinion, if you insist I can change it back.
@@ -138,6 +144,17 @@ private static void applyCrd(InputStream is, String path, KubernetesClient clien | |||
} | |||
} | |||
|
|||
public static CustomResourceDefinition parseCrd(String path, KubernetesClient client) { | |||
try (InputStream is = new FileInputStream(path)) { | |||
return (CustomResourceDefinition) client.load(new ByteArrayInputStream(is.readAllBytes())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should handle better weird cases: if there are more than just one resource in the file, if the CRD is not a v1 spec, if the resource in the file is not a CRD are the most obvious cases where this might fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update it to handle more CRD in file. I don't think we should support other CRD version that v1, note that this is not the resource definition version inside, CRD api version itself is stable for very long time. (In actual kubernetes release oldel versions are not even supported)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but the APT version of the CRD generator generates v1beta1 as well (and in fact, you can see that these versions are generated in our tests). It would actually be useful not to generate the v1beta1 version to save some time on the tests since we have a lot of CRDs to generate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agree, we should fix that, thus not generate those anymore.
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros a_meszaros@apple.com