openapi2crd

command module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

openapi2crd

openapi2crd is a CLI to generate Kubernetes Custom Resource Definition (CRD) resources from OpenAPI 3.0.

Install

Download the appropriate version for your platform from Releases. You may want to install the binary to somewhere in your system's PATH such as /usr/local/bin.

Alternatively, if you have go 1.13 or later then you can also use go get. This will put crdoc in $(go env GOPATH)/bin:

go get github.com/mesh-for-data/openapi2crd

Usage

  1. Create an input directory with YAML files of CustomResourceDefinition resources without schema information (see example/input).
  2. Create an OpenAPI 3.0 document with components.schemas (see example/spec.yaml)
    • The document must include a schema with the name identical to the kind of each input CustomResourceDefinition.
    • The document must comply with the listed limitations
  3. Invoke openapi2crd command:
    openapi2crd SPEC_FILE --input INPUT_DIR --output OUTPUT_FILE
    

An output YAML file will be generated in the specified output location (see example/output/output.yaml)

Limitations

Only structural schemas are allowed with the following exceptions:

  1. You can use $ref to internal or external schema as long as the referenced definition adheres to the listed limitations.
  2. You can use oneOf that contains just a list of $refs. This will be translated to an object with optional properties.

Acknowledgements

The work is inspired by https://github.com/ant31/crd-validation and https://github.com/kubeflow/crd-validation.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL