But now I've hit the most bizarre issue I've ever seen when creating an instance of a class, in this case a KEDA ClusterTriggerAuthentication (I'm aware that the KEDA spec already exists in this repo - I was generating the same thing to sanity check my wrapper):
Making this even more confusing, if I dig into model.mjs where the base model class is defined, it appears to be working fine (console logs added by me just so I have an output to show - it's visible in the debugger too):
export class Model {
constructor(data) {
if (data) {
setDefinedProps(data, this);
}
console.log(Object.keys(this)) // ['apiVersion', 'kind', 'metadata', 'spec']
console.log(Object.values(this)) // ['keda.sh/v1alpha1', 'ClusterTriggerAuthentication', {…}, {…}] << It has values here!
}
toJSON() {
const result = {};
setDefinedProps(this, result);
return result;
}
validate() {
// Use `setValidateFunc` to set the validate function
}
}
alright, so the base class sets them fine. What about the constructor of the ClusterTriggerAuthentication?
Now I'm not going to lie, I'm quite tired and may be being a complete numpty, and am definitely using your library in an unintended way so you have no reason to support this use-case.
But if you can see an obvious error in what I'm doing, please point it out. Does ESM import/export do something crazy with setDefinedProps? Am I just missing something really obvious because I'm tired?
If you're willing to take a look at this but need a reproduction repo, let me know and I'll see if I can. I do totally understand if this is way out of scope for your project, though.
Either way, I will get this to work, but perhaps I'll just call out to the CLI version rather than calling generate directly in my code...
Describe the bug I've been attempting to get @kubernetes-models/crd-generate working when wrapped in an ESM project.
This involved a couple of minor patches to fix CommonJS interop:
and a couple of very specific resolutions in
package.json
(the patch refers to the patch above):So far, so good. I'm able to generate the code as expected:
But now I've hit the most bizarre issue I've ever seen when creating an instance of a class, in this case a KEDA
ClusterTriggerAuthentication
(I'm aware that the KEDA spec already exists in this repo - I was generating the same thing to sanity check my wrapper):wut.
Making this even more confusing, if I dig into
model.mjs
where the base model class is defined, it appears to be working fine (console logs added by me just so I have an output to show - it's visible in the debugger too):alright, so the base class sets them fine. What about the constructor of the
ClusterTriggerAuthentication
?Now I'm not going to lie, I'm quite tired and may be being a complete numpty, and am definitely using your library in an unintended way so you have no reason to support this use-case.
But if you can see an obvious error in what I'm doing, please point it out. Does ESM import/export do something crazy with setDefinedProps? Am I just missing something really obvious because I'm tired?
If you're willing to take a look at this but need a reproduction repo, let me know and I'll see if I can. I do totally understand if this is way out of scope for your project, though.
Either way, I will get this to work, but perhaps I'll just call out to the CLI version rather than calling
generate
directly in my code...