Skip to content

Commit

Permalink
Add conrtibuting instruction for adding a Cue schema
Browse files Browse the repository at this point in the history
Signed-off-by: santoshkal <ksantosh@intelops.dev>
  • Loading branch information
santoshkal committed Nov 17, 2023
1 parent e181f16 commit 840b0ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions CONTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,37 @@ git checkout <your_branch_name>
git merge main
```

## Contributing by adding a Cue schema to the project

Genval leverages upstream Kubernetes and CRD APIs for validation and configuration generation. For technologies not currently supported, users can extend Genval's capabilities by adding Cue schemas.

The workflow for adding a Cue schema is as follows:

- Clone the repository by following the steps outlined [above](#set-up-your-local-development-environment) and navigate to the `genval` directory.
- Identify the technology and the package URL that exposes the APIs you want to add schemas for. In the following example, we'll import schemas for [TektonCD](https://tekton.dev/docs/):

```shell
$ go get github.com/tektoncd/pipeline/pkg/apis/...
# This downloads the Go types for the API.
$ cue get go github.com/tektoncd/pipeline/pkg/apis/...
# This imports the Go types into Cue schemas for TektonCD within the 'cue.mod' directory.
```
Once the APIs are imported into Cue, you can reference them in your definitions for TektonCD, similar to import statements in Golang:

```shell
package tekton

import "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"

#Pipeline: v1beta1.#Pipeline & {
apiVersion: string | *"tekton.dev/v1beta1"
kind: string | *"Pipeline"
...

```

Now, you can easily reference the Cue schemas for #Pipeline by utilizing the imported schemas as v1beta1.#Pipeline.



## All the best! 🥇
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ The above command will validate a Deployment manifests using the provided `.cue`

For a detailed workflow illustrating the capabilities of Cue and Genval for validating and generating Kubernetes configurations, you can refer to [this document](./cmd/cueval/example.md).
The workflow for adding a Cue schema for Kubernetes CRDs is failry easy, and demostrated in the [CONTRIBUTION.md document](./CONTRIBUTION.md/#contributing-by-adding-a-cue-schema-to-the-project).

### Templates

Expand Down

0 comments on commit 840b0ee

Please sign in to comment.