Skip to Content
Lynq

lynq render (CLI)

Render a LynqForm against rows from a CSV or JSON file and print the objects Lynq would apply, without a cluster or a database. Uses the same rendering code as the controllers.

lynq render prints what Lynq would create for each active row: the objects, in apply order, after every template is filled in. It needs no cluster and no database, and it runs the same rendering code as the controllers (internal/render), so its output and its errors are what a LynqNode would get.

Use it to check a LynqForm before applying it, in CI, or to see what a new column does. For the same thing in a browser, use the Playground.

Install

lynq render ships with the next release. Until then, install it from the main branch (needs Go):

go install github.com/k8s-lynq/lynq/cmd/lynq@main

Example

From examples/customer-web in the repository, with the table as a CSV file:

rows.csv
id,active,image,plan
acme,1,nginx:1.27,pro
beta,0,nginx:1.27,basic
gamma,1,nginx:1.27,basic
Terminal
$ lynq render --hub lynqhub.yaml -f lynqform.yaml --rows rows.csv --namespace customers
# LynqNode acme-web, resource app
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    lynq.sh/deletion-policy: Delete
  name: acme-web
  namespace: customers
spec:
  replicas: 1
  selector:
    matchLabels:
      app: acme-web
  template:
    metadata:
      labels:
        app: acme-web
        plan: pro
    spec:
      containers:
      - image: nginx:1.27
        name: web
        ports:
        - containerPort: 80
---
# LynqNode acme-web, resource svc
apiVersion: v1
kind: Service
metadata:
  annotations:
    lynq.sh/deletion-policy: Delete
  name: acme-web
  namespace: customers
spec:
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: acme-web
---
# LynqNode gamma-web, resource app
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    lynq.sh/deletion-policy: Delete
  name: gamma-web
  namespace: customers
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gamma-web
  template:
    metadata:
      labels:
        app: gamma-web
        plan: basic
    spec:
      containers:
      - image: nginx:1.27
        name: web
        ports:
        - containerPort: 80
---
# LynqNode gamma-web, resource svc
apiVersion: v1
kind: Service
metadata:
  annotations:
    lynq.sh/deletion-policy: Delete
  name: gamma-web
  namespace: customers
spec:
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: gamma-web
---
# row beta is inactive: no LynqNode

Real output of the CLI, regenerated on every site build by website/scripts/render-examples.mjs

beta is inactive, so it gets nothing. Each object is commented with its LynqNode and resource ID.

Rows

--rows takes a CSV file with a header row, or a JSON array of objects. Keys are column names, as in the database: the LynqHub's valueMappings and extraValueMappings map them to template variables, exactly as they do against MySQL.

In the fileRead as
CSV cellthe string as written
JSON true / false"1" / "0", as MySQL returns a BOOLEAN
JSON numberits decimal form
JSON null""

A row is active when its activate column is 1, true, TRUE, True, yes, YES or Yes — the same rule the LynqHub applies.

Flags

FlagMeaning
--hubLynqHub manifest (required)
-fLynqForm manifest; repeat for several forms (required)
--rowsrows file, .csv or .json (required)
--namespacenamespace of the LynqHub when its manifest sets none (default default). LynqNodes, and resources without targetNamespace, go here
-oyaml (default): the objects. json: the full result, including dependency levels, inactive rows and errors

What it does not show

  • Apply-time metadata. On apply Lynq adds an ownerReference (or tracking labels for cross-namespace resources and Namespaces) and its own annotations such as lynq.sh/applied-hash. lynq render shows the object before that.
  • Cluster state. Readiness, conflicts with existing objects, and policy behavior (creationPolicy, conflictPolicy) need a cluster.
  • Admission. The LynqForm is not run through the validating webhook, so a form the webhook would reject can still render here. Cycles and unknown dependIds are reported, because rendering builds the dependency graph.

Exit status

0 when every object rendered. 1 when an input cannot be read, a resource failed to render, or a resource would be skipped because a dependency failed (skipOnDependencyFailure, default true). Each of these is printed as a # comment in place of the object.

On this page