kcl-lang / modules

KCL Community Modules. View on Artifact Hub: https://artifacthub.io/packages/search?org=kcl&sort=relevance&page=1
https://kcl-lang.io
Apache License 2.0
18 stars 22 forks source link

Build crossplane from helm package #233

Closed dansrogers closed 2 months ago

dansrogers commented 2 months ago

Crossplane unfortunately doesn't have packaged CRDs, so you can't just read them out of the helm repository.

Instead this creates a cluster with kind, then installs the helm chart, then dumps all crds that helm chart created, then deletes the cluster.

Right now this dumps all the CRDs, but for a more complex use case, you can install all the dependencies first, then check what CRDs are created, then install the target package, then dump the crds, ignore those that already existed.

Example of how to run the command: bash -x scripts/helm_to_kcl.sh https://charts.crossplane.io/stable/crossplane-1.17.0.tgz crossplane v1.17.0

1. Please confirm that you have read the document before PR submitted

2. Contact Information(Optional)

If it is convenient, please provide your contact information so we can reach you when processing the PR:

dansrogers commented 2 months ago

So part of my PR commit message was lost -- apologies.

This commit actually has two issues I don't know how to resolve and could use some feedback.

This actually removes a bunch of schemas that are included in doc.crds.dev and at least two are ones that perhaps should be included.

The first is that the original implementation based on content at doc.crds.dev contains schemas for meta.pkg.crossplane.io -- these are not actually CRDs, they are package configuration files -- I think it's reasonable to include them, I just haven't been able to locate those schemas, and they'll never be retrievable from kubectl get crds, so I'll need to incorporate a different technique, or maybe include them statically. It's not clear how to include a static file though. I can't just check it into one of the directories -- the script removes directories, as deleting all the directory contents and regenerating it, is the only way to detect when api versions change or apis are removed.

The second is that docs.crds.dev for crossplane actually included two crossplane provider packages as well, helm, and resource-noop. I think it's reasonable to remove those from this package. crossplane-provider-helm is already a module, and crossplane-provider-noop is straightforward to add if it's desired by the community.