crossplane-contrib / function-kcl

Crossplane Composition Functions using KCL Programming Language
Apache License 2.0
36 stars 16 forks source link

DatabaseInstance wrong value type #78

Closed aleeriz closed 5 months ago

aleeriz commented 5 months ago

What happened?

While trying to create / update a DatabaseInstance.sql.gcp.upbound.io with database flags e.g.

items = [
            {
              apiVersion: "sql.gcp.upbound.io/v1beta1"
              kind: "DatabaseInstance"
              spec: {
                forProvider: {
                  project: "test-project"
                  settings: [
                    {
                      databaseFlags: [
                        {
                          name: "log_checkpoints"
                          value: "on"
                        }
                      ]
                    }
                  ]
                }
              }
            }
        ]

The update / create fails with:

defined/compositeresourcedefinition.apiextensions.crossplane.io  cannot compose resources: cannot apply composed resource "alir-test-crossplane-db-instance": failed to create typed patch object (/alir-test-crossplane-db-instance; sql.gcp.upbound.io/v1beta1, Kind=DatabaseInstance): errors:
  .spec.forProvider.settings[0].databaseFlags[0].value: expected string, got &value.valueUnstructured{Value:true}

This does not happen without function-kcl. I saw a similar issue reported here maybe it is related: https://github.com/crossplane-contrib/provider-upjet-aws/issues/1261

What environment did it happen in?

Function version: latest Function revision: kcl-function-011644505e8f Cloud: GCP Crossplane version: 1.15.2

Peefy commented 5 months ago

The on in YAML 1.1 would be parsed to a bool value True. Can it be assigned other values for log_checkpoints"?

Peefy commented 5 months ago

Sorry, I've opened a PR to fix it in KCL https://github.com/kcl-lang/kcl/pull/1232. This is because the Rust YAML library we are using has been abandoned and has not been updated in time. We have forked and added corresponding features, and we expect to release a new KCL version today.

Peefy commented 5 months ago

Hello @aleeriz, Thank you for your feedback. I have fixed it in function-kcl v0.5.4 with the PR: https://github.com/crossplane-contrib/function-kcl/pull/79