https://github.com/totegamma/yisp
YISP is a Lisp-inspired evaluation engine for YAML – useful for generating Kubernetes manifests, configuration files, and more.
https://github.com/totegamma/yisp
configuration infrastructure-as-code kubernetes lisp yaml
Last synced: 5 months ago
JSON representation
YISP is a Lisp-inspired evaluation engine for YAML – useful for generating Kubernetes manifests, configuration files, and more.
- Host: GitHub
- URL: https://github.com/totegamma/yisp
- Owner: totegamma
- License: mit
- Created: 2025-05-04T19:45:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-26T09:38:51.000Z (6 months ago)
- Last Synced: 2025-12-27T21:40:13.883Z (6 months ago)
- Topics: configuration, infrastructure-as-code, kubernetes, lisp, yaml
- Language: Go
- Homepage:
- Size: 4.61 MB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# YISP - A Lisp-inspired Functional Engine for YAML
[](https://github.com/totegamma/yisp/actions/workflows/test.yaml)
[[getting-started]](https://github.com/totegamma/yisp/blob/main/docs/getting-started.md) | [[examples]](https://github.com/totegamma/yisp/blob/main/docs/examples.md) | [[other docs]](https://github.com/totegamma/yisp/tree/main/docs)
**YISP** (suggested pronunciation: `/ˈjɪsp/`) is a lightweight evaluation engine for YAML, inspired by Lisp.
It allows you to embed logic, expressions, and includes within YAML files.
This is useful for generating structured configuration such as Kubernetes manifests, Ansible playbooks, and more.
## Installation
Download latest version from [release page](https://github.com/totegamma/yisp/releases).
or use go install:
```sh
go install github.com/totegamma/yisp@latest
```
### Create cache for k8s definitions
If you use kubernetes manifests, you have to create a cache for kubernetes definitions.
Run the following command to download the latest Kubernetes API definitions:
```sh
yisp cache-kube-schemas
```
This command will run `kubectl get --raw /openapi/v2` to fetch the OpenAPI schema and store it in the cache directory.
You have to set up kubectl before running this command, so that it can access your Kubernetes cluster.
## Syntax
In yisp, YAML documents are treated as plain data by default.
To enable evaluation, you explicitly mark expressions using the `!yisp` tag.
When a list or object is tagged with `!yisp`, its contents are recursively evaluated as yisp expressions.
To embed unevaluated YAML structures inside expressions, you can use the `!quote` tag to suppress evaluation.
### simple example:
hello_world.yaml
```yaml
mystring: !yisp
- strings.concat
- hello
- ' '
- world
```
build:
```sh
yisp build hello_world.yaml
```
result:
```yaml
mystring: hello world
```
### Define functions and call it from another file:
template.yaml:
```yaml
!yisp &mkpod
- lambda
- [!string name, !string image]
- !quote
apiVersion: v1
kind: Pod
metadata:
name: *name
spec:
containers:
- name: *name
image: *image
```
main.yaml
```yaml
!yisp
- import
- ["template", "./template.yaml"]
---
!yisp
- *template.mkpod
- mypod1
- myimage1
```
result:
```yaml
apiVersion: v1
kind: Pod
metadata:
name: mypod1
spec:
containers:
- name: mypod1
image: myimage1
```
More examples are available in `/testfiles`.
## Use yisp from Go code
```go
package main
import (
"fmt"
"github.com/totegamma/yisp/engine"
)
func main() {
e := engine.NewEngine(engine.Options{})
evaluated, err := e.EvaluateFileToYaml("test.yaml")
if err != nil {
panic(err)
}
fmt.Println("Evaluated YAML:")
fmt.Println(evaluated)
}
```
also you can use `engine.EvaluateFileToAny` to get the result as go `any` type.
## Use yisp from Kustomize
You can call yisp via KRM function callings.
```yaml
apiVersion: krm.yisp.gammalab.net/v1
kind: Yisp
metadata:
name: add-labels-transformer
annotations:
config.kubernetes.io/function: |
container:
image: ghcr.io/totegamma/yisp
spec:
allowUntypedManifest: true
yisp: |
!yisp
- lists.map
- *items
- - lambda
- [item]
- - maps.merge
- *item
- !quote
metadata:
labels:
added-by: yisp-transformer
```
[full example is here](https://github.com/totegamma/yisp/tree/main/docs/examples/krm)