kptdev / kpt

Automate Kubernetes Configuration Editing
https://kpt.dev
Apache License 2.0
1.71k stars 227 forks source link

Type generation from a cluster openAPI spec should be optional #570

Closed pwittrock closed 4 years ago

pwittrock commented 4 years ago

orgs will probably want to explicitly choose the types that are used, rather than have them generated ad-hoc per user.

willbeason commented 4 years ago

I assume you mean directly from a CRD (or set of CRDs)?

frankfarzan commented 4 years ago

To expand on the feature request:

We should make type generation from user-supplied cluster optional. If the user just wants to use core types, we can have pre-generated types for one or more api versions.

willbeason commented 4 years ago

Ok, so if I understand correctly, the two modes are:

  1. Generate all core types from built-in swagger definitions
  2. Generate from swagger obtained from a cluster
frankfarzan commented 4 years ago

GoogleContainerTools/kpt-functions-sdk#1 is one implementation option. Alternatively, we can just package up pre-generated *.ts files (as part of the SDK or CLI NPM packages) and avoid a call to typegen all toghether.

frankfarzan commented 4 years ago

Where the pregenerated artifacts live is also up for discussion. It could be part of the NPM package or dynamically downloaded (e.g. from a GCS bucket). We take the latter approach with the typgen Go binary itself to avoid bloating the NPM package.

frankfarzan commented 4 years ago

For context: this would eliminate having a kubernetes cluster (locally or remotely) which would simplify the onboarding process.

frankfarzan commented 4 years ago

Talked with Phani, this is the proposal:

[1] https://github.com/GoogleContainerTools/kpt-functions-sdk/blob/master/ts/create-kpt-functions/src/cmd/type_create.ts