{"id":13581430,"url":"https://github.com/subchen/frep","last_synced_at":"2026-01-14T15:53:17.379Z","repository":{"id":9557271,"uuid":"60189087","full_name":"subchen/frep","owner":"subchen","description":"Generate file using template from environment, arguments, json/yaml/toml config files","archived":false,"fork":false,"pushed_at":"2023-03-06T22:37:01.000Z","size":12600,"stargazers_count":158,"open_issues_count":7,"forks_count":41,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-08-14T10:39:50.812Z","etag":null,"topics":["frep","golang","replace-text","sed","template-engine"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/subchen.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":"2016-06-01T15:29:42.000Z","updated_at":"2025-05-26T08:55:31.000Z","dependencies_parsed_at":"2024-06-18T20:15:57.396Z","dependency_job_id":"9a5883a6-d0b9-40a7-873a-1ff80234de1f","html_url":"https://github.com/subchen/frep","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/subchen/frep","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subchen%2Ffrep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subchen%2Ffrep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subchen%2Ffrep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subchen%2Ffrep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/subchen","download_url":"https://codeload.github.com/subchen/frep/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subchen%2Ffrep/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28425520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T15:24:48.085Z","status":"ssl_error","status_checked_at":"2026-01-14T15:23:41.940Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["frep","golang","replace-text","sed","template-engine"],"created_at":"2024-08-01T15:02:01.589Z","updated_at":"2026-01-14T15:53:17.360Z","avatar_url":"https://github.com/subchen.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Build Status](https://github.com/subchen/frep/actions/workflows/build.yml/badge.svg)](https://github.com/subchen/frep/actions/workflows/build.yml)\n[![License](http://img.shields.io/badge/License-Apache_2-red.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)\n\n\n# frep\n\nGenerate file using template from environment, arguments, json/yaml/toml config files.\n\n```\nNAME:\n   frep - Generate file using template\n\nUSAGE:\n   frep [options] input-file[:output-file] ...\n\nVERSION:\n   1.3.x\n\nAUTHORS:\n   Guoqiang Chen \u003csubchen@gmail.com\u003e\n\nOPTIONS:\n   -e, --env name=value    set variable name=value, can be passed multiple times\n       --json jsonstring   load variables from json object string\n       --load file         load variables from json/yaml/toml file\n       --no-sys-env        exclude system environments, default false\n       --overwrite         overwrite if destination file exists\n       --dryrun            just output result to console instead of file\n       --strict            exit on any error during template processing\n       --delims value      template tag delimiters (default: {{:}})\n       --missing           handling of missing vars, one of: default/invalid, zero, error (default: default)\n       --help              print this usage\n       --version           print version information\n\nEXAMPLES:\n   frep nginx.conf.in -e webroot=/usr/share/nginx/html -e port=8080\n   frep nginx.conf.in:/etc/nginx.conf -e webroot=/usr/share/nginx/html -e port=8080\n   frep nginx.conf.in --json '{\"webroot\": \"/usr/share/nginx/html\", \"port\": 8080}'\n   frep nginx.conf.in --load config.json --overwrite\n   echo \"{{ .Env.PATH }}\"  | frep -\n```\n\n## Downloads\n\nv1.3.13 Release: https://github.com/subchen/frep/releases/tag/v1.3.13\n\n- Linux\n\n    ```\n    curl -fSL https://github.com/subchen/frep/releases/download/v1.3.13/frep-1.3.13-linux-amd64 -o /usr/local/bin/frep\n    chmod +x /usr/local/bin/frep\n\n    # centos / redhat\n    yum install https://github.com/subchen/frep/releases/download/v1.3.13/frep-1.3.13-204.x86_64.rpm\n\n    # ubuntu\n    curl -fSL https://github.com/subchen/frep/releases/download/v1.3.13/frep_1.3.13-204_amd64.deb -o frep_1.3.13-204_amd64.deb\n    dpkg -i frep_1.3.13-204_amd64.deb\n    ```\n\n- macOS\n\n    ```\n    brew install subchen/tap/frep\n    ```\n\n- Windows\n\n    ```\n    wget https://github.com/subchen/frep/releases/download/v1.3.13/frep-1.3.13-windows-amd64.exe\n    ```\n\n## Docker\n\nYou can run frep using docker container\n\n```\ndocker run -it --rm subchen/frep --help\n```\n\n\n## Examples\n\n### Load template variables\n\n- Load from environment\n\n    ```\n    export webroot=/usr/share/nginx/html\n    export port=8080\n    frep nginx.conf.in\n    ```\n\n- Load from arguments\n\n    ```\n    frep nginx.conf.in -e webroot=/usr/share/nginx/html -e port=8080\n    ```\n\n- Load from JSON String\n\n    ```\n    frep nginx.conf.in --json '{\"webroot\": \"/usr/share/nginx/html\", \"port\": 8080}'\n    ```\n\n- Load from JSON file\n\n    ```\n    cat \u003e config.json \u003c\u003c EOF\n    {\n      \"webroot\": \"/usr/share/nginx/html\",\n      \"port\": 8080,\n      \"servers\": [\n        \"127.0.0.1:8081\",\n        \"127.0.0.1:8082\"\n      ]\n    }\n    EOF\n\n    frep nginx.conf.in --load config.json\n    ```\n\n- Load from YAML file\n\n    ```\n    cat \u003e config.yaml \u003c\u003c EOF\n    webroot: /usr/share/nginx/html\n    port: 8080\n    servers:\n      - 127.0.0.1:8081\n      - 127.0.0.1:8082\n    EOF\n\n    frep nginx.conf.in --load config.yaml\n    ```\n\n- Load from TOML file\n\n    ```\n    cat \u003e config.toml \u003c\u003c EOF\n    webroot = /usr/share/nginx/html\n    port = 8080\n    servers = [\n       \"127.0.0.1:8081\",\n       \"127.0.0.1:8082\"\n    ]\n    EOF\n\n    frep nginx.conf.in --load config.toml\n    ```\n\n### Input/Output\n\n- Input from file\n\n    ```\n    // input file: nginx.conf\n    frep nginx.conf.in\n    ```\n\n- Input from console(stdin)\n\n    ```\n    // input from stdin pipe\n    echo \"{{ .Env.PATH }}\" | frep -\n    ```\n\n- Output to default file (Removed last file ext)\n\n    ```\n    // output file: nginx.conf\n    frep nginx.conf.in --overwrite\n    ```\n\n- Output to the specified file\n\n    ```\n    // output file: /etc/nginx.conf\n    frep nginx.conf.in:/etc/nginx.conf --overwrite -e port=8080\n    ```\n\n- Output to console(stdout)\n\n    ```\n    frep nginx.conf.in --dryrun\n    frep nginx.conf.in:-\n    ```\n\n- Output multiple files\n\n    ```\n    frep nginx.conf.in redis.conf.in ...\n    ```\n\n## Template\n\nTemplates use Golang [text/template](http://golang.org/pkg/text/template/).\n\nYou can access environment variables within a template\n\n```\nEnv.PATH = {{ .Env.PATH }}\n```\n\nIf your template file uses `{{` and `}}` as part of it's syntax,\nyou can change the template escape characters using the `--delims`.\n\n```\nfrep --delims \"\u003c%:%\u003e\" ...\n```\n\nThere are some built-in functions as well: Masterminds/sprig v2.22.0\n- github: https://github.com/Masterminds/sprig\n- doc: http://masterminds.github.io/sprig/\n\nMore [funcs](https://github.com/subchen/frep/blob/master/func.go) added:\n- toJson\n- toYaml\n- toToml\n- toBool\n- fileSize\n- fileLastModified\n- fileGetBytes\n- fileGetString\n- fileExists\n- include\n- countRune\n- pipeline compatible regex functions from sprig \n    - reReplaceAll\n    - reReplaceAllLiteral\n    - reSplit\n- awsSecret\n- awsParameterStore\n\nSample of nginx.conf.in\n\n```\nserver {\n    listen {{ .port }} default_server;\n\n    root {{ .webroot | default \"/usr/share/nginx/html\" }};\n    index index.html index.htm;\n\n    location /api {\n        {{ include \"shared/log.nginx\" | indent 8 | trim }}\n        proxy_pass http://backend;\n    }\n}\n\nupstream backend {\n    ip_hash;\n{{- range .servers }}\n    server {{.}};\n{{- end }}\n}\n```\n\nSample using secrets, first of all take into account that in order to use the secret functionality you need to have a proper AWS configuration in place and permissions enough to read secrets from AWS Secrets Manager. More details of how to configure AWSCLI can be found at https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html \n\nOnce you have all the requirements just create a template like this one:\n\n```\n# application.conf\nmysql_host: {{ .mysql_host }}\nmysql_user: {{ .mysql_user }}\nmysql_pass: {{ awsSecret \"application/mysql/password\" }}\n```\nIn above example `mysql_host` and `mysql_user` will be filled as usual by using `frep` config file or environment variables but `mysql_pass` will be fetch straight from AWS Secrets Manager by looking at secret name `application/mysql/password`\n\nIf you have multiple items in a single secret you can retrieve an specific key by specifying the key you want in template, for example:\n\n```\n# application.conf\nmysql_host: {{ .mysql_host }}\nmysql_user: {{ .mysql_user }}\nmysql_pass: {{ awsSecret \"application/mysql/password\" }}\n\nexternal_api_client: {{ awsSecret \"application/external_api\" \"client_id\" }}\nexternal_api_secret: {{ awsSecret \"application/external_api\" \"secret_key\" }}\n```\n\nSample using AWS Parameter Store, first of all take into account that in order to use the ssm functionality you need to have a proper AWS configuration in place and permissions enough to read parameters from AWS Parameter Store. More details of how to configure AWSCLI can be found at https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html \n\nOnce you have all the requirements just create a template like this one:\n\n```\n# application.conf\nmysql_host: {{ .mysql_host }}\nmysql_user: {{ .mysql_user }}\nmysql_pass: {{ awsSecret \"application/mysql/password\" }}\nmysql_dns: {{ awsParameterStore \"application/mysql/dns\" }}\n```\nIn above example `mysql_dns` will be filled as usual by using `frep` config file or environment variables but `mysql_pass` will be fetch straight from AWS Parameter Store by looking at `application/mysql/dns`\n\nSSM Limitation: You can get parameter from ParameterStore just in textplain.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubchen%2Ffrep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubchen%2Ffrep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubchen%2Ffrep/lists"}