crossplane / upjet

A code generation framework and runtime for Crossplane providers
Apache License 2.0
293 stars 84 forks source link

Example Manifests formatted as JSON in the scraped provider metadata #29

Closed ulucinar closed 11 months ago

ulucinar commented 2 years ago

What problem are you facing?

As discussed here, the scraped provider metadata document embeds converted (from HCL to JSON) resource example manifests as JSON strings:

...
              manifest: |-
                {
                  "country_code": "US",
                  "data_residency_location": "United States",
                  "display_name": "example-b2c-tenant",
                  "domain_name": "exampleb2ctenant.onmicrosoft.com",
                  "resource_group_name": "example-rg",
                  "sku_name": "PremiumP1"
                }

We can consider embedding them as YAML.

How could Terrajet help solve your problem?

As explained here, we hit some issues while doing so as this requires conversion from JSON to YAML and then back to JSON. Using sigs.k8s.io/yaml as the JSON2YAML convertor and as YAML encoder solves the tab character issue mentioned in that comment, as the sigs.k8s.io/yaml library does not encode the multiline YAML values with a preceding tab char as multiline YAML but rather a quoted (single-line) YAML string with special chars escaped. However, the JSON libraries cannot cope with the embedded map[interface{}]interface{} values by the YAML decoder (when unmarshaling from the provider doc to a map[string]interface{}. We can have a deeper look into this.

luebken commented 2 years ago

@ulucinar Could you explain what the impact would be? Do we have a idea on these examples would relate and even enhance our current examples from the docs?

ulucinar commented 11 months ago

Let's revisit this if there are parties requesting.