{"id":13638765,"url":"https://github.com/errordeveloper/kuegen","last_synced_at":"2025-10-10T12:05:52.113Z","repository":{"id":46371244,"uuid":"259679123","full_name":"errordeveloper/kuegen","owner":"errordeveloper","description":"A simple (experimental) tool for generating Kubernetes manifest from templates based on CUE","archived":false,"fork":false,"pushed_at":"2022-11-21T10:38:42.000Z","size":5521,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-08T18:52:23.639Z","etag":null,"topics":["cuelang","gitops","kubernetes","kubernetes-configuration"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/errordeveloper.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}},"created_at":"2020-04-28T15:37:26.000Z","updated_at":"2024-08-22T00:31:32.000Z","dependencies_parsed_at":"2022-09-19T00:02:15.745Z","dependency_job_id":null,"html_url":"https://github.com/errordeveloper/kuegen","commit_stats":null,"previous_names":["errordeveloper/kue"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errordeveloper%2Fkuegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errordeveloper%2Fkuegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errordeveloper%2Fkuegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errordeveloper%2Fkuegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/errordeveloper","download_url":"https://codeload.github.com/errordeveloper/kuegen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233546479,"owners_count":18692226,"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":["cuelang","gitops","kubernetes","kubernetes-configuration"],"created_at":"2024-08-02T01:00:53.123Z","updated_at":"2025-10-10T12:05:47.086Z","avatar_url":"https://github.com/errordeveloper.png","language":"Go","readme":"# kuegen\n\n`kuegen` is a simple config generator based on [CUE](https://cuelang.org).\n\n`kuegen` is able to evaluate a CUE module as a template with a set of parameters\nand will write output manifests for each set of parameters as JSON or YAML.\nEach out manifest can be written to a single file as a list a list of resources,\nor to multiple files with a single resource in each file.\n\n`kuegen` establishes a very simple convention. It expects a CUE module to have\nthe following keys:\n\n- `template` – contains data that will be evaluated with the given parameters\n- `parameters` – contains a schema of the parameters (including default value)\n- `instances` – contain one or more sets of parameters and output path\n\n`kuegen` assumes that all objects to be handled are presented as Kubernetes-style\nobjects. This does allow for arbitrary schema to be used inside an object, e.g.\na nested YAML config in a `ConfigMap` can be templated with CUE, but it will need\nto be a `ConfigMap` or another Kubernetes envelope and not a standalone file of\nan arbitrary format.\n\n## Example 1\n\nHere is a simple module that defines a template for one namespace resource:\n\n_`main.cue`_:\n```\npackage example1\n\n#ExampleTemplate :: {\n\tapiVersion: \"v1\"\n\tkind:       \"Namespace\"\n\tmetadata: {\n\t\tname: parameters.name\n\t\tlabels: name: parameters.name\n\t}\n}\n\n#ExampleParameters :: {\n\tname: string\n}\n\nparameters: #ExampleParameters\ntemplate:   #ExampleTemplate\n\ninstances: [\n\t{\n\t\tparameters: {\n\t\t\tname: \"bar\"\n\t\t}\n\t\toutput: \"bar.json\"\n\t},\n\t{\n\t\tparameters: {\n\t\t\tname: \"baz\"\n\t\t}\n\t\toutput: \"baz.json\"\n\t},\n]\n```\n\nIn this case everything is in a single file (`main.cue`), but multiple files can be\nused for larger modules.\n\nThis module be evaluated by running:\n\n```\n$ kuegen -input-directory ./examples/1\n2021/10/20 14:31:02 writing bar.json\n2021/10/20 14:31:02 writing baz.json\n$ cat bar.json\n{\n  \"apiVersion\": \"v1\",\n  \"kind\": \"Namespace\",\n  \"metadata\": {\n    \"labels\": {\n      \"name\": \"bar\"\n    },\n    \"name\": \"bar\"\n  }\n}\n$ cat baz.json\n{\n  \"apiVersion\": \"v1\",\n  \"kind\": \"Namespace\",\n  \"metadata\": {\n    \"labels\": {\n      \"name\": \"baz\"\n    },\n    \"name\": \"baz\"\n  }\n}\n$\n```\n\n## Example 2\n\nInstances can be specified using JSON syntax also, which is convenient in some cases.\nThe JSON filename has to be `instances.json` and it must be located in the module's directory.\n\n_`template.cue`_:\n```\npackage example2\n\n#ExampleTemplate :: {\n\tapiVersion: \"v1\"\n\tkind:       \"Namespace\"\n\tmetadata: {\n\t\tname: parameters.name\n\t\tlabels: name: parameters.name\n\t}\n}\n\n#ExampleParameters :: {\n\tname: string\n}\n\nparameters: #ExampleParameters\ntemplate:   #ExampleTemplate\n```\n\n_`instances.json`_:\n\n```\n{\n    \"instances\": [\n        {\n            \"parameters\": {\n                \"name\": \"bar\"\n            },\n            \"output\": \"bar.json\"\n        },\n        {\n            \"parameters\": {\n                \"name\": \"baz\"\n            },\n            \"output\": \"baz.json\"\n        }\n    ]\n}\n```\n\nIn this example the output will be the same as in _Example 1_.\n\n## Example 3\n\nOutput manifest can be written to sepatare files when:\n- value of `output` contains `%s`; AND\n- `template` is a list (i.e. `kind: List`)\n\n_`instances.json`_:\n```\n{\n    \"instances\": [\n        {\n            \"parameters\": {\n                \"name\": \"foo\"\n            },\n            \"output\": \"%s.yaml\"\n        },\n        {\n            \"parameters\": {\n                \"name\": \"foo\"\n            },\n            \"output\": \"%s.json\"\n        }\n    ]\n}\n```\n\nEvaluating this will result in `00000-foo-namespace.yaml` and `00000-foo-namespace.json` being written.\nThe first digits in the filenames are based on the index of the object in the list, and are included in\norder to preserve the order. Second segment is the name of the object and the third is its kind, if the\nobject is namespaced, name will be prefixed by that namespace.\nMore specifically, `%s` is substituted with either `\u003cindex\u003e-\u003cname\u003e-\u003ckind\u003e` or `\u003cindex\u003e-\u003cnamespace\u003e-\u003cname\u003e-\u003ckind\u003e`.\nSuffix given in the name of the output file will be used to determine encoding format.\n\nIf `-output-directory` flag is specified, the manifests will be written there instead of the current working\ndirectory. The output path may contain directory names, which will be treated as relative to the directory that\nwas set with the `-output-directory` flag.\n","funding_links":[],"categories":["kubernetes","Projects"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferrordeveloper%2Fkuegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferrordeveloper%2Fkuegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferrordeveloper%2Fkuegen/lists"}