• Stars
    star
    139
  • Rank 253,497 (Top 6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Universal data-driven template for generating textual output, as a static binary and a library

render

Version Travis CI Github All Releases Go Report Card GoDoc

Universal data-driven templates for generating textual output. Can be used as a single static binary (no dependencies) or as a golang library.

Just some of the things to render:

  • configuration files
  • Infrastructure as Code files (e.g. CloudFormation templates)
  • Kubernetes manifests

The renderer extends go-template and Sprig functions.

If you are interested in one of the use cases, take a look at this blog post about Kubernetes resources rendering. Also see Helm compatibility.

Installation

Official binary releases

For binaries please visit the Releases Page.

The binaries are statically compiled and does not require any dependencies.

Usage

$ render --help
NAME:
   render - Universal file renderer

USAGE:
   render [global options] command [command options] [arguments...]

VERSION:
   v0.3.0

AUTHOR:
   VirtusLab

COMMANDS:
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug, -d                   run in debug mode
   --silent, -s                  run in silent mode
   --indir value                 the input directory, can't be used with --out
   --outdir value                the output directory, the same as --outdir if empty, can't be used with --in
   --in value                    the input template file, stdin if empty, can't be used with --outdir
   --out value                   the output file, stdout if empty, can't be used with --indir
   --config value                optional configuration YAML file, can be used multiple times
   --set value, --var value      additional parameters in key=value format, can be used multiple times
   --unsafe-ignore-missing-keys  do not fail on missing map key and print '<no value>' ('missingkey=invalid')
   --help, -h                    show help
   --version, -v                 print the version

Notes:

  • --in, --out take only files (not directories), --in will consume any file as long as it can be parsed
  • stdin and stdout can be used instead of --in and --out
  • --config accepts any YAML file, can be used multiple times, the values of the configs will be merged
  • --set, --var are the same (one is used in Helm, the other in Terraform), we provide both for convenience, any values set here will override values form configuration files

Command line

Example usage of render with stdin, stdout and --var:

$ echo "something {{ .value }}" | render --var "value=new"
something new

Example usage of render with --in, --out and --config:

$ echo "something {{ .value }}" > test.txt.tmpl
$ echo "value: new" > test.config.yaml
$ ./render --in test.txt.tmpl --out test.txt --config test.config.yaml
$ cat test.txt
something new

Also see a more advanced template example.

As a library

package example

import (
    "github.com/VirtusLab/render/renderer"
    "github.com/VirtusLab/render/renderer/parameters"
)

func CustomRender(template string, opts []string, params parameters.Parameters) (string, error) {
    return renderer.New(
    	renderer.WithOptions(opts...),
        renderer.WithParameters(params),
        renderer.WithSprigFunctions(),
        renderer.WithExtraFunctions(),
        renderer.WithCryptFunctions(),
    ).Render(template)
}

See also other functions.

Also see tests for more usage examples.

Notable standard and sprig functions

All syntax and functions:

Custom functions

  • render - calls the render from inside of the template, making the renderer recursive (also accepts an optional template parameters override)
  • toYaml - provides a configuration data structure fragment as a YAML format
  • fromYaml - marshalls YAML data to a data structure (supports multi-documents)
  • fromJson - marshalls JSON data to a data structure
  • jsonPath - provides data structure manipulation with JSONPath (kubectl dialect)
  • n - used with range to allow easy iteration over integers form the given start to end (inclusive)
  • gzip, ungzip - use gzip compression and extraction inside the templates, for best results use with b64enc and b64dec
  • readFile - reads a file from a path, relative paths are translated to absolute paths, based on root function or property
  • writeFile - writes a file to a path, relative paths are translated to absolute paths, based on root function or property
  • root - the root path, used for relative to absolute path translation in any file based operations; by default PWD is used
  • cidrHost - calculates a full host IP address for a given host number within a given IP network address prefix
  • cidrNetmask - converts an IPv4 address prefix given in CIDR notation into a subnet mask address
  • cidrSubnets - calculates a subnet address within given IP network address prefix
  • cidrSubnetSizes - calculates a sequence of consecutive IP address ranges within a particular CIDR prefix

See also examples and a more detailed documentation.

Cloud KMS (AWS, Amazon, Google) based cryptography functions form crypt:

  • encryptAWS - encrypts data using AWS KMS, for best results use with gzip and b64enc
  • decryptAWS - decrypts data using AWS KMS, for best results use with ungzip and b64dec
  • encryptGCP - encrypts data using GCP KMS, for best results use with gzip and b64enc
  • decryptGCP - decrypts data using GCP KMS, for best results use with ungzip and b64dec
  • encryptAzure - encrypts data using Azure Key Vault, for best results use with gzip and b64enc
  • decryptAzure - decrypts data using Azure Key Vault, for best results use with ungzip and b64dec

Helm compatibility

As of now, there is a limited Helm 2 Chart compatibility, simple Charts will render just fine.

To mimic Helm behaviour regarding to missing keys use --unsafe-ignore-missing-keys option.

There is no plan to implement full compatibility with Helm, because of unnecessary complexity that would bring.

If you need full Helm compatilble rendering see: helm-nomagic.

Limitations and future work

Planned new features

  • .renderignore files #12

Operating system support

We provide cross-compiled binaries for most platforms, but is currently used mainly with linux/amd64.

Community & Contribution

There is a dedicated channel #render on virtuslab-oss.slack.com (Invite form)

Feel free to file issues or pull requests.

Before any big pull request please consult the maintainers to ensure a common direction.

Development

git clone [email protected]:VirtusLab/render.git
cd render

make init
make all

The name

We believe in obvious names. It renders. It's a verb. It's render.

More Repositories

1

git-machete

Probably the sharpest git repository organizer & rebase/merge workflow automation tool you've ever seen
Python
828
star
2

scala-cli

Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code (and more!)
Scala
500
star
3

graphbuddy

Graph Buddy helps you to understand the code better
HTML
143
star
4

iskra

Typesafe wrapper for Apache Spark DataFrame API
Scala
129
star
5

git-machete-intellij-plugin

Probably the sharpest git repository organizer & rebase/merge workflow automation tool you've ever seen
Java
128
star
6

pandas-stubs

Pandas type stubs. Helps you type-check your code.
Python
117
star
7

unicorn

Small Slick library for type-safe id handling
Scala
112
star
8

Inkuire

Hoogle-like searches for Scala 3 and Kotlin
Scala
90
star
9

besom

Besom - a Pulumi SDK for Scala. Also, incidentally, a broom made of twigs tied round a stick. Brooms and besoms are used for protection, to ward off evil spirits, and cleansing of ritual spaces.
Scala
89
star
10

avocADO

Safe compile-time parallelization of for-comprehensions for Scala 3
Scala
83
star
11

jenkins-operator

Kubernetes native Jenkins Operator, moved to https://github.com/jenkinsci/kubernetes-operator
Go
82
star
12

scala-yaml

Scala
75
star
13

pretty-stacktraces

Scala
57
star
14

bazel-steward

A bot to keep Bazel dependencies up to date
Kotlin
56
star
15

tetrisly-react

Tetrisly offers user-friendly components designed for effortless integration. Plus, it's fully compatible with Tetrisly for Figma with a seamless design and development experience in mind.
TypeScript
39
star
16

crypt

Universal cryptographic tool with AWS KMS, GCP KMS, GnuPG and Azure Key Vault support
Go
32
star
17

infrastructure-as-types

Infrastructure as Types - modern infrastructure declaration and deployment toolkit
Scala
26
star
18

ide-probe

Scala
26
star
19

beholder

Small slick lib for create views on on database
Scala
26
star
20

akka-serialization-helper

Serialization toolbox for Akka messages, events and persistent state that helps achieve compile-time guarantee on serializability. No more errors in the runtime!
Scala
26
star
21

activator-play-advanced-slick

Typesafe Activator template for advanced play-slick project
HTML
20
star
22

kubedrainer

Simple Kubernetes Node Drainer
Go
20
star
23

strapi-plugin-content-manager-extension-hierarchical

strapi-plugin-content-manager-extension-hierarchical
JavaScript
16
star
24

contextbuddy

Platform documentation
CSS
15
star
25

scala-packager

Scala
12
star
26

using_directives

Java
12
star
27

community-build3

Scala
11
star
28

vss

Scala
10
star
29

coursier-m1

A small repo to release coursier using self-hosted Mac M1 runner
Shell
10
star
30

ReactSphere-reactive-beyond-hype

Repo for presentation on ReactSphere: Reactive beyond hype
HCL
8
star
31

akka-workshop-client

Base code for akka workshop.
Scala
8
star
32

pekko-serialization-helper

Serialization toolbox for Pekko messages, events and persistent state that helps achieve compile-time guarantee on serializability. No more errors in the runtime!
Scala
8
star
33

scala-snippet-checker

TypeScript
7
star
34

scala-compose

Scala
6
star
35

pyspark-workshop

HTML
6
star
36

codetale

CodeTale - documentation & issue tracking
Dockerfile
6
star
37

genesis

Common sbt settings for sbt-based projects
Scala
5
star
38

data_lake_navigation_atlas

Code for blogpost Navigation in the data lake using Atlas
Scala
5
star
39

kleisli-examples

Examples from blog post on Kleisli arrows
Scala
5
star
40

ddd-public-materials

All public materials for community prepared by The DDD guild from Virtuslab
Kotlin
5
star
41

scg-cli

scg-cli is a CLI tool for Semantic Code Graph analysis
Scala
5
star
42

tips

CSS
4
star
43

go-extended

Things missing or not belonging in the standard library
Go
3
star
44

mesos-on-vagrant

Just a Vagrant file and Ansible playbook for deploying Mesos cluster for testing
3
star
45

scala-workshop

Scala
3
star
46

talk-scala-akka-play

Introductory talk to Scala, Akka and Play! framework
JavaScript
3
star
47

base-types-kt

Library with common types for Kotlin supporting domain-driven functional programming
Kotlin
3
star
48

Edison-BlinkOnboard

Example Akka system for blinking LED at Intel Edison
Scala
3
star
49

jira-stats

Exports some metrics from jira via REST api - currently calculated dev days per ticket
Go
2
star
50

runscope-agent

Containerized Runscope Agent (Dockerfile)
Makefile
2
star
51

homebrew-cloud

This repository contains a collection of Homebrew formulas.
Ruby
2
star
52

scala-cli-packages

Shell
2
star
53

ide-probe-tests

Scala
2
star
54

spark_sql_under_the_hood

Code for blogpost: Spark SQL under the hood
Scala
2
star
55

homebrew-scala-cli

Ruby
1
star
56

scalacamp

ScalaCamp.pl site source code
HTML
1
star
57

homebrew-git-machete

1
star
58

gpki

Git Public Key Infrastructure
Python
1
star
59

scala-workshop-bootstrap

Shell
1
star
60

jenkins-operator-assets

Hosting Jenkins Operator assests like images or CSS files.
CSS
1
star
61

virtusity-workshop-graphql

TypeScript
1
star
62

dokka-site

Kotlin
1
star
63

kibana-rpm-packaging

1
star
64

kubectl-deploy

Simple kubectl plugin for rendering and applying Kubernetes manifests
Go
1
star
65

scala-cli.g8

Scala
1
star
66

akka-http-kubernetes.g8

Scala
1
star
67

homebrew-scala-experimental

Ruby
1
star
68

scg-scala

Scala compiler plugin for Semantic Code Graph generation
Scala
1
star
69

Ariadne-Bootloader

A little less unfinished TFTP bootloader for Arduino Leonardo Ethernet
Arduino
1
star
70

ScalaTastiesScrapper

Scala
1
star
71

aws-cli

Yet Another Dockerized AWS CLI
Makefile
1
star
72

shuttlecraft

Scala
1
star