Skip to content
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

Invalid typescript code for victoriametrics operator CRDs #133

Closed
onyxet opened this issue May 14, 2024 · 1 comment · Fixed by #135
Closed

Invalid typescript code for victoriametrics operator CRDs #133

onyxet opened this issue May 14, 2024 · 1 comment · Fixed by #135
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@onyxet
Copy link

onyxet commented May 14, 2024

What happened?

Hi there!

I used crd2pulumi for type generation from victoria-metrics-operator.
After generation I'm unable to use any custom kind because of gazillion errors like:

  TSError: ⨯ Unable to compile TypeScript:
    components/apps/crds/victoriametrics-operator/types/input.ts(6036,13): error TS1131: Property or signature expected.
    components/apps/crds/victoriametrics-operator/types/input.ts(6036,14): error TS1109: Expression expected.
    components/apps/crds/victoriametrics-operator/types/input.ts(6036,15): error TS1109: Expression expected.
    components/apps/crds/victoriametrics-operator/types/input.ts(6041,27): error TS1109: Expression expected.
    components/apps/crds/victoriametrics-operator/types/input.ts(6046,33): error TS1109: Expression expected.
    components/apps/crds/victoriametrics-operator/types/input.ts(6051,23): error TS1109: Expression expected.
    components/apps/crds/victoriametrics-operator/types/input.ts(6055,19): error TS1109: Expression expected.
    components/apps/crds/victoriametrics-operator/types/input.ts(6060,28): error TS1109: Expression expected.
    components/apps/crds/victoriametrics-operator/types/input.ts(26665,1): error TS1128: Declaration or statement expected.
    components/apps/crds/victoriametrics-operator/types/input.ts(6036,24): error TS2339: Property 'Input' does not exist on type 'typeof import("/node_modules/@pulumi/pulumi/index")'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6041,13): error TS2304: Cannot find name 'inhibit_rules'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6041,36): error TS2339: Property 'Input' does not exist on type 'typeof import("/node_modules/@pulumi/pulumi/index")'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6041,79): error TS2724: '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member named 'VMAlertmanagerConfigSpecInhibitRulesArgs'. Did you mean 'VMAlertmanagerConfigSpecArgs'?
    components/apps/crds/victoriametrics-operator/types/input.ts(6046,13): error TS2304: Cannot find name 'mute_time_intervals'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6046,42): error TS2339: Property 'Input' does not exist on type 'typeof import("/node_modules/@pulumi/pulumi/index")'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6046,85): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecMuteTimeIntervalsArgs'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6051,13): error TS2304: Cannot find name 'receivers'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6051,32): error TS2339: Property 'Input' does not exist on type 'typeof import("/node_modules/@pulumi/pulumi/index")'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6051,75): error TS2724: '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member named 'VMAlertmanagerConfigSpecReceiversArgs'. Did you mean 'VMAlertmanagerConfigSpecArgs'?
    components/apps/crds/victoriametrics-operator/types/input.ts(6055,13): error TS2304: Cannot find name 'route'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6055,28): error TS2339: Property 'Input' does not exist on type 'typeof import("/node_modules/@pulumi/pulumi/index")'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6055,58): error TS2724: '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member named 'VMAlertmanagerConfigSpecRouteArgs'. Did you mean 'VMAlertmanagerConfigSpecArgs'?
    components/apps/crds/victoriametrics-operator/types/input.ts(6060,13): error TS2304: Cannot find name 'time_intervals'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6060,37): error TS2339: Property 'Input' does not exist on type 'typeof import("/node_modules/@pulumi/pulumi/index")'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6060,80): error TS2724: '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member named 'VMAlertmanagerConfigSpecTimeIntervalsArgs'. Did you mean 'VMAlertmanagerConfigSpecArgs'?
    components/apps/crds/victoriametrics-operator/types/input.ts(6098,79): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecMuteTimeIntervalsTimeIntervalsArgs'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6122,71): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecMuteTimeIntervalsTimeIntervalsTimesArgs'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6152,81): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecReceiversDiscordConfigsArgs'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6156,79): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecReceiversEmailConfigsArgs'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6157,81): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecReceiversMsteamsConfigsArgs'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6165,82): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecReceiversOpsgenieConfigsArgs'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6169,83): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecReceiversPagerdutyConfigsArgs'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6173,82): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecReceiversPushoverConfigsArgs'.
    components/apps/crds/victoriametrics-operator/types/input.ts(6177,79): error TS2694: Namespace '"/components/apps/crds/victoriametrics-operator/types/input".operator.v1beta1' has no exported member 'VMAlertmanagerConfigSpecReceiversSlackConfigsArgs'.

Example

  1. Сlone crds
  2. use crd2pulumi --nodejsName victoriametrics --nodejsPath ../victoriametrics victoria-metrics-operator.yaml
  3. In your code import and use custom resource
    import { operator } from "../crds/victoriametrics-operator/"
    ...
    const certManagerAlerts = new operator.v1beta1.VMRule("cert-manager-alerts", {
      apiVersion: "operator.victoriametrics.com/v1beta1",
      kind: "VMRule",
      metadata: {
        name: "cert-manager",
        namespace: "cert-manager",
      },
      spec: {
        rules: {
           ....
        },
      },
    })

Output of pulumi about

pulumi about

CLI          
Version      3.107.0
Go Version   go1.22.0
Go Compiler  gc

Plugins
NAME        VERSION
cloudflare  5.27.0
command     0.9.2
gcp         7.20.0
github      6.2.0
kubernetes  4.11.0
kubernetes  4.11.0
nodejs      unknown
postgresql  3.11.0
random      4.16.1

Host     
OS       darwin
Version  14.4.1
Arch     arm64

This project is written in nodejs: executable='<REDUCTED>/.nvm/versions/node/v20.11.1/bin/node' version='v20.11.1'

Current Stack: <REDUCTED>

TYPE                                                         URN
<REDUCTED>

Found no pending operations associated with <REDUCTED>

Backend        
Name           MacBook-Pro.local
URL            gs://<REDUCTED>
User           <REDUCTED>
Organizations  
Token type     personal

Dependencies:
NAME                              VERSION
eslint-config-prettier            9.1.0
prettier                          3.2.5
ts-jest                           29.1.2
typescript-eslint                 7.8.0
@kubernetes/client-node           0.20.0
@pulumi/postgresql                3.11.0
@pulumi/pulumi                    3.114.0
dotenv                            16.4.5
typescript                        5.4.5
@typescript-eslint/parser         7.8.0
eslint                            8.57.0
jest                              29.7.0
@pulumi/gcp                       7.20.0
@pulumi/github                    6.2.0
@pulumi/kubernetes                4.11.0
@types/jest                       29.5.12
@types/uuid                       9.0.8
@google-cloud/container           5.12.0
@pulumi/cloudflare                5.27.0
@pulumi/random                    4.16.1
@types/js-yaml                    4.0.9
@pulumi/command                   0.9.2
@types/node                       18.19.31
@typescript-eslint/eslint-plugin  7.8.0
uuid                              9.0.1

Additional context

I also get invalid ts code for kafka-operator mentioned here

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@onyxet onyxet added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels May 14, 2024
@blampe blampe removed the needs-triage Needs attention from the triage team label May 14, 2024
blampe added a commit that referenced this issue May 14, 2024
The VictoriaMetrics CRD includes a property like this:

```yaml
properties:
  '-':
    type: string
```

which breaks codegen because the property name camel cases to "", and as
a result we generates a bunch of unnamed functions.

This PR modifies our logic to ignore unnamed properties like this.

We also bump pu/pu and apimachinery for good measure.

Fixes #133.
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label May 14, 2024
@pulumi-bot
Copy link

This issue has been addressed in PR #135 and shipped in release v1.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants