{"id":20636585,"url":"https://github.com/lbovet/yglu","last_synced_at":"2025-04-07T10:19:27.947Z","repository":{"id":47148971,"uuid":"232189583","full_name":"lbovet/yglu","owner":"lbovet","description":"Yglu ᕄ !? - YAML glue for structural templating and processing","archived":false,"fork":false,"pushed_at":"2025-03-09T18:40:46.000Z","size":348,"stargazers_count":93,"open_issues_count":7,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-03T16:05:51.802Z","etag":null,"topics":["devops","functional","igloo","kubernetes","python","structural","templating","yaml","yaql"],"latest_commit_sha":null,"homepage":"https://yglu.io","language":"Python","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/lbovet.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":"2020-01-06T21:34:32.000Z","updated_at":"2025-03-13T22:24:26.000Z","dependencies_parsed_at":"2024-11-16T15:11:32.655Z","dependency_job_id":"12b39272-5865-4dc3-8e43-61fd85eb270c","html_url":"https://github.com/lbovet/yglu","commit_stats":{"total_commits":158,"total_committers":4,"mean_commits":39.5,"dds":0.03164556962025311,"last_synced_commit":"7ecc3b7b7e1ea705623663b1ace113ea1aebd33a"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbovet%2Fyglu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbovet%2Fyglu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbovet%2Fyglu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbovet%2Fyglu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lbovet","download_url":"https://codeload.github.com/lbovet/yglu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247631834,"owners_count":20970069,"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":["devops","functional","igloo","kubernetes","python","structural","templating","yaml","yaql"],"created_at":"2024-11-16T15:11:27.223Z","updated_at":"2025-04-07T10:19:27.934Z","avatar_url":"https://github.com/lbovet.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: yglu ReadMe\n---\n\n# Yglu ᕄ !?\n\n[![Build Status](https://travis-ci.org/lbovet/yglu.svg?branch=master)](https://travis-ci.org/lbovet/yglu)\n[![PyPI version](https://badge.fury.io/py/yglu.svg)](https://badge.fury.io/py/yglu)\n\n\u003cp align=\"center\"\u003e\u003cb\u003e\u003ca href=\"https://yglu.io/\"\u003e* Try Yglu Online *\u003c/a\u003e\u003c/b\u003e\u003c/p\u003e\n\n\nYglu is [YAML](https://yaml.org/) augmented with an advanced expression language. Unlike usual text templating, Yglu relies on the YAML structure and leverages its tag system combined with the [YAQL](https://yaql.readthedocs.io/en/latest/) query language.\n\nThis association enables templating and functional processing a bit like if YAML nodes were spreadsheet cells.\n\nYglu input documents are pure and valid YAML using [tags](https://yaml.org/spec/1.2/spec.html#id2784064) for computed nodes.\n\n\u003ctable\u003e\u003ctr\u003e\n\u003ctd width=\"440\"\u003e\ninput\n\u003cpre lang=\"yaml\"\u003e\na: 1\nb: !? .a + 1\n!if .b = 2:\n  c: 3  \u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd width=\"440\"\u003e\noutput\n\u003cpre lang=\"yaml\"\u003e\na: 1\nb: 2\nc: 3\n \u003c/pre\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\u003c/table\u003e\n\n\u003ctable\u003e\u003ctr\u003e\n\u003ctd width=\"440\"\u003e\ninput\n\u003cpre lang=\"yaml\"\u003e\nnames: !-\n  - 'nginx:1.16'\n  - 'node:13.6'\n  - 'couchbase:9.3'\nimage: !()\n  !? $.split(':')[0]:\n    version: !? $.split(':')[1]\nimages: !?\n  $_.names\n    .select(($_.image)($))\n    .aggregate($1.mergeWith($2), {})\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd width=\"440\"\u003e\noutput\n\u003cpre lang=\"yaml\"\u003e\nimages:\n  nginx:\n    version: '1.16'\n  node:\n    version: '13.6'\n  couchbase:\n    version: '9.3'\n    \u0026nbsp;\n    \u0026nbsp;\n    \u0026nbsp;\n    \u0026nbsp;  \u003c/pre\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\u003c/table\u003e\n\nIn the example above, the `names` sequence is hidden, `image` is a function (like a template block) and `images` is an expression which iterates through all names, applies the image function to each one and aggregates the individual results by merging them together as a mapping.\n\nAs such an operation is often needed, Yglu provides a `!for` tag for merging a sequence iterated over a function:\n\n\u003ctable\u003e\u003ctr\u003e\n\u003ctd width=\"440\"\u003e\ninput\n\u003cpre lang=\"yaml\"\u003e\nnames: !-\n  - 'nginx:1.16'\n  - 'node:13.6'\n  - 'couchbase:9.3'\nimages:\n  !for .names: !()\n    !? $.split(':')[0]:\n      version: !? $.split(':')[1]\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd width=\"440\"\u003e\noutput\n\u003cpre lang=\"yaml\"\u003e\nimages:\n  nginx:\n    version: '1.16'\n  node:\n    version: '13.6'\n  couchbase:\n    version: '9.3'\n    \u0026nbsp;\u003c/pre\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\u003c/table\u003e\n\nSee the test [samples](https://github.com/lbovet/yglu/tree/master/tests/samples) for more examples.\n\n\u003cp align=\"center\"\u003e\u003cb\u003e\u003ca href=\"https://yglu.io/\"\u003e* Try Yglu Online *\u003c/a\u003e\u003c/b\u003e\u003c/p\u003e\n\n## Install\n\n```\npip3 install yglu\n```\n\n## Run\n\n```\nUsage: yglu [options] [\u003cfilename\u003e]\n\nOptions:\n  -v - -version          Print version and exit.\n  -h - -help             Print help and exit.\n```\n\n## Tags\n\nTags specify an alteration of the document structure.\n\n| **Tag**\u0026nbsp;\u0026nbsp;\u0026nbsp;| **Description** |\n|-----------|-----------------|\n| `!?`      | Evaluate an expression. The result can be a scalar, mapping or sequence. Can also be used in mapping keys. |\n| `!-`      | Hide the node in the output but keep it accessible from expressions. Can be an expression. |\n| `!()`     | Make the node reusable in expressions as a function. |\n| `!if`     | Conditional merge. See [if.yml](https://github.com/lbovet/yglu/tree/master/tests/samples/if.yml). |\n| `!for`    | Merge the results of a function applied to all items of a sequence . See [for.yml](https://github.com/lbovet/yglu/tree/master/tests/samples/for.yml). |\n| `!apply`  | Apply a function or function block to a block. See [function.yml](https://github.com/lbovet/yglu/tree/master/tests/samples/function.yml). |\n\n\n## Expressions\n\nExpressions are written in [YAQL](https://yaql.readthedocs.io/en/latest/).\n\nThey are evaluated in a context with the following variables defined:\n\n| **Variable**| **Description** |\n|-------------|-----------------|\n| `$_`        | Refers to the current document root. Can be omitted at the beginning of the expression if it starts with a dot. |\n| `$`         | Implicit argument of functions. |\n| `$env`      | Gives access to environment variables. Disabled by default. Set the `$YGLU_ENABLE_ENV` environment variable to enable this feature. |\n| `$this`     | Refers to the current function block node in order to access its children nodes. See [function.yml](https://github.com/lbovet/yglu/tree/master/tests/samples/function.yml) |\n\n## Built-in Functions\n\nIn addition to the [standard YAQL library](https://yaql.readthedocs.io/en/latest/standard_library.html#), Yglu defines the following functions:\n\n| **Function**         | **Description** |\n|----------------------|-----------------|\n| `$import(filename)`  | Imports another document in the current node. By default, it is only permitted to import files from within the directory hierarchy of the input file. Set `$YGLU_IMPORT_ALLOW` to a list of permitted directories. |\n\n## Vaguely related projects\n\n* [YAMLScript](https://yamlscript.org)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbovet%2Fyglu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flbovet%2Fyglu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbovet%2Fyglu/lists"}