klass8s / k8schema-generator
Generates PHP classes from Kubernetes API schema definitions
Package info
github.com/klass8s/k8schema-generator
Type:application
pkg:composer/klass8s/k8schema-generator
Requires
- php: >=8.5
- composer-runtime-api: ^2.2
- ext-ctype: *
- ext-iconv: *
- ext-json: *
- guzzlehttp/psr7: ^2.0
- knplabs/github-api: ^3.0
- nette/php-generator: ^4.2
- symfony/console: >=8.0
- symfony/dotenv: >=8.0
- symfony/flex: ^2.10
- symfony/framework-bundle: >=8.0
- symfony/http-client: >=8.0
- symfony/runtime: 8.1.*
- symfony/string: >=8.0
- symfony/yaml: >=8.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
Replaces
- symfony/polyfill-ctype: *
- symfony/polyfill-iconv: *
- symfony/polyfill-php72: *
- symfony/polyfill-php73: *
- symfony/polyfill-php74: *
- symfony/polyfill-php80: *
- symfony/polyfill-php81: *
- symfony/polyfill-php82: *
- tequila/k8schema-generator: v0.1.0
README
A command-line application that generates PHP classes from the JSON schema of the Kubernetes API. It
produces k8schema, the Kubernetes API classes that
Klass8s builds manifests from: one class per API object
(Deployment, Service, …) and per nested type, typed properties with getters and setters,
API_VERSION and KIND constants, and a jsonSerialize() that writes the object the API server
reads.
The schemas come from yannh/kubernetes-json-schema, which keeps the OpenAPI definitions of every Kubernetes release.
Usage
The generator needs PHP 8.5. From a checkout:
composer install
bin/k8schema-generator schema:fetch v1.35 var/v1.35.json
bin/k8schema-generator generate var/v1.35.json --namespace-prefix='K8Schema' --output-dir=out/src
schema:fetch downloads the definitions of the newest patch release it knows for a Kubernetes minor
(the map in K8S_JSON_SCHEMA_VERSIONS in .env, which the environment variable of the same name
overrides), and generate writes the classes under the namespace prefix into the output directory.
schema:versions [n] lists the newest patch release upstream for each of the latest n minors
(four by default).
k8schema itself is produced by its own workflow, which installs this generator at a pinned commit and regenerates one branch per Kubernetes minor; see its README.
Contributing
Bug reports and pull requests are welcome: CONTRIBUTING.md says how the generator is organised and what a pull request needs. Report a security vulnerability privately, as SECURITY.md describes.
License
k8schema-generator is released under the MIT License. The portions that come from the project it continues remain under their own MIT notice, in NOTICE.