{"id":17645550,"url":"https://github.com/sgaunet/envtemplate","last_synced_at":"2025-03-10T18:31:05.467Z","repository":{"id":65795463,"uuid":"595633352","full_name":"sgaunet/envtemplate","owner":"sgaunet","description":"Simple templating (for config files and the like) from environment variables in an easy-to-ship binary ","archived":true,"fork":false,"pushed_at":"2025-02-16T12:38:51.000Z","size":67,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T21:42:16.364Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sgaunet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-31T13:50:11.000Z","updated_at":"2025-02-16T12:39:21.000Z","dependencies_parsed_at":"2023-11-21T21:27:36.815Z","dependency_job_id":"1f80934f-6170-44df-a837-835a3753cd1c","html_url":"https://github.com/sgaunet/envtemplate","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgaunet%2Fenvtemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgaunet%2Fenvtemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgaunet%2Fenvtemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgaunet%2Fenvtemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgaunet","download_url":"https://codeload.github.com/sgaunet/envtemplate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242902530,"owners_count":20204122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-23T10:57:12.722Z","updated_at":"2025-03-10T18:31:05.461Z","avatar_url":"https://github.com/sgaunet.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/sgaunet/envtemplate)](https://goreportcard.com/report/github.com/sgaunet/envtemplate)\n[![GitHub release](https://img.shields.io/github/release/sgaunet/envtemplate.svg)](https://github.com/sgaunet/envtemplate/releases/latest)\n![GitHub Downloads](https://img.shields.io/github/downloads/sgaunet/envtemplate/total)\n![Test Coverage](https://raw.githubusercontent.com/wiki/sgaunet/envtemplate/coverage-badge.svg)\n[![GoDoc](https://godoc.org/github.com/sgaunet/envtemplate?status.svg)](https://godoc.org/github.com/sgaunet/envtemplate)\n[![License](https://img.shields.io/github/license/sgaunet/envtemplate.svg)](LICENSE)\n\n[Forked from https://github.com/orls/envtemplate](https://github.com/orls/envtemplate)\n\nWhy forking the project ?\n\n* Want a different CLI (add some flags)\n* Author does not seem to be active\n* Want binary for multiple architectures and a docker image to copy the binary from in multi stage build\n\n**This project** is now **archived**, please consider using [gomplate](https://github.com/hairyhenderson/gomplate) instead. It's more feature rich and actively maintained.\n\n# envtemplate\n\nA super-lightweight tool for templating config files from environment variables – and nothing else.\n\n## Usage\n\n`$ envtemplate -i my-template-file \u003e my-output-file`\n\nor\n\n```bash\n$ cat test/input1.txt | envtemplate\nHello sylvain! Your home dir is /home/sylvain.\n```\n\nUsage:\n\n```bash\nenvtemplate -h\n  -h    Print help\n  -i string\n        File to encrypt/decrypt\n  -v    Get version\n```\n\nTemplating is done by the [go template package](https://golang.org/pkg/text/template/), where the only configured variables are the process's environment variables.\n\nFor example, a simple template might look like:\n\n```\nHello {{ .USER }}! {{ if .HOME }}Your home dir is {{ .HOME }}.{{ else }}You don't appear to have a home dir set.{{ end }}\n```\n\nThere is an indent function:\n\n```\n$ cat test/input2.txt \n{{ indent 4 .MULTILINE }}\n$ export MULTILINE=\"ligne1\nligne2\nligne3\"\n$ go run . -i test/input2.txt \n    ligne1\n    ligne2\n    ligne3\n```\n\n## Demo\n\n![demo](doc/demo.gif)\n\n## Install\n\n### homebrew\n\n```bash\nbrew tap sgaunet/homebrew-tools\nbrew install sgaunet/tools/envtemplate\n```\n\n### from source\n\nAssuming a working go installation, just  `git clone`, `cd` and `go build`. A binary named `envtemplate` should appear.\n\n### prebuilt binary\n\nA binary is attached to each [github release](https://github.com/sgaunet/envtemplate/releases). If you're happy to trust that, just fetch it with curl/similar (being sure to follow redirects):\n\n`curl -L https://github.com/sgaunet/envtemplate/releases/download/0.1.0/envtemplate \u003e /usr/bin/envtemplate \u0026\u0026 chmod +x /usr/bin/nvtemplate`\n\n## Why?\n\nThis was borne out of frustration with using regular shell techniques – heredocs, `sed`, and similar – in various docker image-building and container-runtime configuration arrangements; for many config file formats (hi, nginx!) it starts to become unwieldy to manage conditional blocks, escaping, etc.\n\nIt is a kind of hybrid of [gotpl](https://github.com/tsg/gotpl) and [envtpl](https://github.com/andreasjansson/envtpl). In the target environment of docker container management, it's useful to:\n\n- have small, easily-installable binary tools\n    - ...ruling out `envtpl`; the extra docker image bloat of a python+pip install is.... far from zero\n- provide variables directly as env vars\n    - ...ruling out `gotpl`, which takes a yml file, needing extra pre-processing if env vars are your only means of configuring.\n\nIt shares some spiritual affinity to [confd](https://github.com/kelseyhightower/confd), in the way that a butter knife shares some spiritual affinity to a swiss-army knife.\n\nIf you want config pulled from remote datastores, or from yml files, or already have python in the relevant envs and like jinja syntax, then those projects may be better fits.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgaunet%2Fenvtemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgaunet%2Fenvtemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgaunet%2Fenvtemplate/lists"}