{"id":13638810,"url":"https://github.com/dontlaugh/packer-plugin-cue","last_synced_at":"2025-04-19T21:34:47.456Z","repository":{"id":62973730,"uuid":"547535566","full_name":"dontlaugh/packer-plugin-cue","owner":"dontlaugh","description":"Render files in your Packer builds with CUE","archived":false,"fork":false,"pushed_at":"2025-03-04T21:23:59.000Z","size":193,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T19:22:30.290Z","etag":null,"topics":["cue","packer","packer-plugin","packer-provisioner"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dontlaugh.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":"2022-10-07T21:14:20.000Z","updated_at":"2025-03-04T21:24:03.000Z","dependencies_parsed_at":"2024-01-13T19:01:18.456Z","dependency_job_id":"5dd5b37a-b537-4365-885f-b0c4e4ef647e","html_url":"https://github.com/dontlaugh/packer-plugin-cue","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dontlaugh%2Fpacker-plugin-cue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dontlaugh%2Fpacker-plugin-cue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dontlaugh%2Fpacker-plugin-cue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dontlaugh%2Fpacker-plugin-cue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dontlaugh","download_url":"https://codeload.github.com/dontlaugh/packer-plugin-cue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249811081,"owners_count":21328745,"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":["cue","packer","packer-plugin","packer-provisioner"],"created_at":"2024-08-02T01:00:54.019Z","updated_at":"2025-04-19T21:34:47.449Z","avatar_url":"https://github.com/dontlaugh.png","language":"Go","funding_links":[],"categories":["Projects"],"sub_categories":[],"readme":"# packer-plugin-cue\n\nA packer plugin that writes files to the image you're provisioning, based\non values extracted from a CUE module.\n\nA Packer data provider is TODO.\n\n## Provided Plugins\n\nProvisioners:\n\n* `cue-export` - Given a module, package, and an optional CUE expression, the\n  provisioner writes a file with the scalar value or struct yielded by `cue export`.\n\n## Example Usage\n\nAdd this plugin to `required_plugins`\n\n```hcl\npacker {\n  required_plugins {\n    cue = {\n      version = \"\u003e=0.3.1\"\n      source = \"github.com/dontlaugh/cue\"\n    }\n  }\n}\n\n```\n\nWrite the data yielded by the expression `world` in package `hello` to **/tmp/some-file**\n\n```hcl\n  provisioner \"cue-export\" {\n    dir        = \".\"\n    package    = \"hello\"\n    expression = \"world\"\n    dest       = \"/tmp/some-file\"\n  }\n```\n\n## Config Attributes\n\nProvisioners:\n\n`cue-export`\n\n* dir - path to where the CUE evaluation should take place\n* module - (optional) name of module\n* package - (optional) package name, if required to disambiguate\n* expression - (optional) CUE expression that yields a specific package value\n* dest - path to destination file; Note that some Packer builders\n  will not automatically create ancestor directories.\n* tags - (optional) list of strings of the form `key=value`\n\n## Explanation\n\nLet's say you have a CUE module with a file **my_service.cue** that looks like this\n\n```cue\npackage systemd\n\nconfig_file: \"/etc/my-service/config.yaml\"\n\nunit_file: '''\n[Unit]\nDescription=My example service\n\n[Service]\nEnvironment=MY_CONFIG=\\(config_file)\nExecStart=/usr/bin/my-service\n\n[Install]\nWantedBy=multi-user.target\n'''\n```\n\nInvoking `cue export -p systemd ./my_service.cue` gives you the entire package as JSON\n\n```json\n{\n    \"config_file\": \"/etc/my-service/config.yaml\",\n    \"unit_file\": \"W1VuaXRdCkRlc2N...==\"\n}\n```\n_Note: We've elided most of the unit file's base64 string here._\n\nProviding `--out binary` and `-e unit_file` lets us select the `unit_file`\nfield and render it. The value of `config_file` is interpolated.\n\n```\n$ cue export -p systemd -e unit_file --out binary ./my_service.cue\n[Unit]\nDescription=My example service\n\n[Service]\nEnvironment=MY_CONFIG=/etc/my-service/config.yaml\nExecStart=/usr/bin/my-service\n\n[Install]\nWantedBy=multi-user.target\n```\n\nThis manner of templating files and interpolating values is useful for machine\nimage provisioning, and this plugin provides a declarative API for rendering CUE\nto files during a Packer build.\n\nThe previous examples use the `cue` CLI, which you should definitely download\nand experiment with if you are unfamiliar with CUE. This plugin, however, uses\nCUE as a Go library.\n\n### But wait, there's more!\n\nThe `cue-export` provisioner doesn't need a string or binary template to write\nfiles. If the package (with optional expression) evaluates  to a string, number,\nor struct type, this plugin does the following\n\n* String and number types are written as a single-line file to `dest`\n* Struct types must be given a `serialize` config, one of \"json\", \"yaml\",\n  or \"toml\". The entire struct will be serialized in that format.\n\nA quick example of a struct rendered to yaml\n\n```hcl\nprovisioner \"cue-export\" {\n    module     = \".\"\n    dir        = \".\"\n    package    = \"prometheus\"\n    expression = \"config_yaml\"\n    serialize  = \"yaml\"\n    dest       = \"/tmp/prometheus.yaml\"\n}\n```\n\nIf your expression evaluates to a struct and no serializer is set, it's an error.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdontlaugh%2Fpacker-plugin-cue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdontlaugh%2Fpacker-plugin-cue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdontlaugh%2Fpacker-plugin-cue/lists"}