{"id":42609116,"url":"https://github.com/jucardi/infuse","last_synced_at":"2026-01-29T02:21:12.453Z","repository":{"id":37663503,"uuid":"130750000","full_name":"jucardi/infuse","owner":"jucardi","description":"Easy templates parser with command line, can also be imported in other go projects.","archived":false,"fork":false,"pushed_at":"2023-02-15T08:32:34.000Z","size":3172,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-28T17:33:42.306Z","etag":null,"topics":["cli","go-template","golang","handlebars","mustache","template","template-engine","template-library","templates"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jucardi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-04-23T20:01:30.000Z","updated_at":"2022-11-10T22:12:20.000Z","dependencies_parsed_at":"2024-06-19T17:11:47.629Z","dependency_job_id":"0805352e-cb09-4f37-b75b-02be35eaa9c7","html_url":"https://github.com/jucardi/infuse","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/jucardi/infuse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jucardi%2Finfuse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jucardi%2Finfuse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jucardi%2Finfuse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jucardi%2Finfuse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jucardi","download_url":"https://codeload.github.com/jucardi/infuse/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jucardi%2Finfuse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28860814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T22:56:21.783Z","status":"online","status_checked_at":"2026-01-29T02:00:06.714Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cli","go-template","golang","handlebars","mustache","template","template-engine","template-library","templates"],"created_at":"2026-01-29T02:21:11.886Z","updated_at":"2026-01-29T02:21:12.444Z","avatar_url":"https://github.com/jucardi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Infuse - the global template parser\n\nInfuse is a CLI tool and a go library that can be imported in other Go projects. Its main purpose is to handle template parsing for different template formats in a generic way.\n\n## Getting started\n\nIf interested in downloading the code and using it as a dependency in another Go project, simply do\n\n```bash\ngo get github.com/jucardi/infuse\n```\n\n## The command line tool\n\nThe command line tool is a convenient terminal command that allows to parse a template, passing the a JSON or YAML representation to be used as values within the template.\n\n\n### How to install it\n\nThere are a few options to install the CLI tool.\n\n#### Download the release file\n\n##### For UNIX (Mac and Linux)\n\n1) Download the binary\n\n    ```bash\n    sudo curl -L https://github.com/jucardi/infuse/releases/download/v1.0.12/infuse-$(uname -s)-$(uname -m) -o /usr/local/bin/infuse\n    ```\n\n2) Apply executable permissions\n\n    ```bash\n    sudo chmod +x /usr/local/bin/infuse\n    ```\n\n3) Test the installation\n\n    ```bash\n    infuse --help\n    ```\n\n#### Install using Go\n\n```bash\ngo get -u github.com/jucardi/infuse/cmd/infuse\n```\n\n#### Installing the CLI from the source code directory\n\nUsing `make` run\n\n```bash\nmake install\n```\n\nThis `make` recipe will compile the binary for your local architecture and place it under `$GOPATH/bin` via `go install`\n\n#### Building the CLI binaries from code\n\nUsing `make` run\n\n```bash\nmake compile-all\n```\n\nThis `make` recipe will build the binaries for Linux, Mac and Windows under the `build` directory.\n\n### Uninstallation\n\n#### If installed using the first method (downloading the release)\n\n```bash\nsudo rm /usr/local/bin/infuse\n```\n\n#### If installed using Go\n\n```bash\nrm $GOPATH/bin/infuse\n```\n\n### Usage\n\n```bash\ninfuse [flags] [template file]\n```\n\n#### Flags\n\nAll the flags are optional, including the data input. Infuse supports using a template to parse declared environment variables, so they can also be used as data to be parsed in.\n\n##### Data Input flags\n\nThe input flags indicate how the data to be parsed into the templates is read. Note that only one input type allowed (-f, -s, -u). May change in future releases to allow merging multiple data sources.\n\n- **`-f` or `--file`:** *A JSON or YAML file to use as an input for the data to be parsed*\n- **`-u` or `--url`:** *A URL for HTTP GET to a JSON or a YAML file. Useful to parse data from config servers*\n- **`-s` or `--string`:** *A JSON or YAML string representation*\n\n##### Target flags\n\nThe target flags indicate where the parsed template will be output\n\n- **`-o` or `--output`:** *Indicate an output file. If not specified, the resulting template will be printed to StdOut*\n\n##### Template definitions flags\n\nThe template definition flags allow auxiliary template files to be loaded so they can be used in the primary template.\n\n- **`-d` or `--definition`:** *File path of another template to be imported and used by the primary template to be parsed. This flag can be used multiple times to load multiple template definitions*\n- **`-p` or `--pattern`:** *Search pattern to load multiple template definitions, for example `-p ./templates/*`*\n\n### Examples\n\n```bash\ninfuse -f service-config.yml -o docker-compose.yml -d global/mongo.tmpl -d global/redis.tmpl docker-compose.tmpl\n```\n\n```bash\ninfuse -u http://config-server.local/something/service-config.json -o docker-compose.yml -p global/* docker-compose.tmpl\n```\n\n```bash\ninfuse -o something.config something.tmpl\n```\n\n#### When are template definitions useful?\n\nWhen defining certain global templates that can be reused in other primary templates.\n\nFor example, a `docker-compose.yml` that defines a service stack where one of the containers is a database definition. The database definition can be a separate template and be imported in the `docker-compose.yml` file when generating the service stack definition.\n\nGiven the following files:\n\n**service-config.yml** - *The configuration for a specific service*\n\n```yaml\nname: some-service\nversion: RC-1.0.0\nport: 1234\ndevelop_mode: true\nresources:\n  replicas: 3\n  cpus: '0.5'\n  memory: 512M\ndb:\n  port: 4321\n```\n\n**service.tmpl** - *Primary template that defines a service stack. Generic and can be used for multiple microservices, provided the right configuration*\n\n```yaml\nversion: \"3.3\"\nservices:\n  api:\n    image: registry.local/services/{{ .name }}:{{ .version }}\n    ports:\n      - '{{ .port }}:{{ .port }}'\n    healthcheck:\n      test: curl -f http://localhost:{{ .port }}{{ .health_uri | default \"/health\" }} || echo 1\n      interval: 5s\n      timeout: 20s\n      retries: 3\n    networks:\n      - {{ .name }}-net\n    deploy:\n      replicas: {{ .resources.replicas | default 2 }}\n      placement:\n        constraints:\n          - node.role == worker\n          - node.labels.workertype == services\n      resources:\n        limits:\n          cpus: {{ .resources.cpus }}\n          memory: {{ .resources.memory }}\n      restart_policy:\n        condition: any\n{{ if .db }}\n{{ template \"mongo.tmpl\" . }}\n{{ end }}\n\nnetworks:\n  {{ .name }}-net:\n```\n\n**mongo.tmpl** - *Template used as definition to be imported. It defines a generic mongo database config which can be reused in other templates*\n\n```yaml\n  mongo:\n    image: mongo:latest\n{{ if .develop_mode }}\n    ports:\n      - {{ .db.port }}:27017\n{{ end }}\n    volumes:\n      - {{ .name }}-mongodb:/data/db\n    networks:\n      - {{ .name }}-net\n    deploy:\n      replicas: 1\n      placement:\n        constraints:\n          - node.role == worker\n          - node.labels.workertype == dbe\n      restart_policy:\n        condition: any\n\nvolumes:\n  {{ .name }}-mongodb:\n    driver: local-persist\n    driver_opts:\n      mountpoint: /mnt/db-data/{{ .name }}-mongodb\n\n```\n\n## The template library\n\n### Custom helpers\n\n- `default`: Indicates a default value if the input data does not contain a specific value.\n\n    Usage:\n    ```html\n    {{ .some_value | default \"something\" }}\n    ```\n    If `some_value` is not defined, the value `something` will be used.\n\n- `map`: Helps define a `map` object which can be passed as the data object for another template definition\n\n    Usage:\n    ```html\n    {{- $someObj := map \"X\" \"chuck\" \"Y\" \"norris\" \"Z\" 1234 \"something\" .something -}}\n    ```\n    In this case, a new dictionary is being created and set to an object called `$someObj`. The number of members in the map definition must be an even number, since the definition will be done as `key`, `value`, `key`, `value`...\n\n    For this example, the equivalent JSON object will be\n    ```json\n    {\n        \"X\": \"chuck\",\n        \"Y\": \"norris\",\n        \"Z\": 1234,\n        \"something\": \"[the value for the 'something' key in the original data input]\"\n    }\n    ```\n\n- `dict`: Is an alias of `map`, stands for \"dictionary\"\n\n- `template`: Indicates a loaded template definition.\n\n    Usage:\n    ```html\n    {{ template \"template_name\" $dataObj }}\n    ```\n    If using the CLI, the template name will always match the file name of the template definition. `$dataObj` is the object that contains the data that will be used in the sub-template. If using the original data object, simply pass `.` instead of `$dataObj`, or if the data object is a sub-key of the original input, pass `.sub_key` instead\n\n- `env`: Reads an environment value and parses it into the template\n\n    Usage:\n    ```\n    {{ env \"SOME_ENVIRONMENT_VARIABLE\" }}\n    ```\n    If `SOME_ENVITONMENT_VARIABLE=something` the result of the example above will be `something`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjucardi%2Finfuse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjucardi%2Finfuse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjucardi%2Finfuse/lists"}