Initial user stanza support & architecture review - #7
navaneeth-dev wants to merge 19 commits into
Conversation
Signed-off-by: Navaneeth <me@rizexor.com>
Signed-off-by: Navaneeth <me@rizexor.com>
Signed-off-by: Navaneeth <me@rizexor.com>
Signed-off-by: Navaneeth <me@rizexor.com>
Signed-off-by: Navaneeth <me@rizexor.com>
Signed-off-by: Navaneeth <me@rizexor.com>
Signed-off-by: Navaneeth <me@rizexor.com>
There was a problem hiding this comment.
🟢 Approval recommended
The changes are cohesive, well-tested with clear rejection semantics, and CI is in place to enforce build/vet/test for the new CLI and transpiler logic.
Pull request overview
Adds an initial bt CLI and a strict cloud-config → Butane transpiler focused on the Cluster API worker users subset, with validation and unit tests, aligning with the repo’s goal of a minimal but correct conversion path for Cluster API provisioning.
Changes:
- Introduce a Cobra-based
btCLI that reads cloud-config from a file or stdin and writes Butane YAML to stdout or an output file (atomic write). - Implement strict transpilation for the supported
userssubset, rejecting unsupported fields, YAML aliases/anchors, multiple documents, and missing#cloud-configheaders, and validating the generated Butane viabutane.TranslateBytes. - Add unit tests plus fixture documentation and GitHub Actions CI for build/vet/test.
File summaries
| File | Description |
|---|---|
| README.md | Documents bt usage, supported users fields, and current limitations. |
| main.go | Adds the bt Cobra CLI, input handling, and atomic output writing. |
| main_test.go | Tests CLI stdin→stdout behavior and output file permissions. |
| internal/transpile/transpile.go | Implements strict parsing/validation and Butane generation + validation. |
| internal/transpile/users.go | Parses and validates the supported users fields and maps them to Butane passwd.users. |
| internal/transpile/transpile_test.go | Adds fixture-driven unit tests for success and rejection cases. |
| internal/transpile/testdata/README.md | Documents the provenance and purpose of fixtures. |
| internal/transpile/testdata/cluster-api-supported-user.yaml | Success fixture covering supported users fields. |
| internal/transpile/testdata/cluster-api-groups.yaml | Rejection fixture for groups-related fields. |
| internal/transpile/testdata/cluster-api-deferred-fields.yaml | Rejection fixture for deferred/unsupported account-policy fields. |
| go.mod | Introduces module definition and dependencies. |
| go.sum | Adds dependency checksums. |
| .github/workflows/ci.yml | Adds CI workflow to build, vet, and test on push/PR. |
Review details
- Files reviewed: 12/13 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The standalone Butane module is deprecated. Use the public Butane packages shipped in Ignition v2.27.0 and raise the Go version to the dependency's required Go 1.25. Signed-off-by: Navaneeth <me@rizexor.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The Jinja template rejection logic can be bypassed when the directive appears after #cloud-config, contradicting the documented “rejected” behavior.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
internal/transpile/transpile.go:104
- validateCloudConfigHeader() returns as soon as it sees
#cloud-config, so a## template: jinjaline that appears after the header would not be rejected even though the README states Jinja templates are rejected. This can lead to silently accepting templated configs depending on directive placement.
- Files reviewed: 12/13 changed files
- Comments generated: 0 new
- Review effort level: Lite
elmiko
left a comment
There was a problem hiding this comment.
i think this is looking nice for an initial configuration. i have a question about the combined error return from the Transpile function.
also, i'm curious if you plan to make a test file for the users.go, or will it be tested through the transpile_test.go ?
Represent validation failures as typed problems so callers can inspect paths and source locations without parsing the human-readable error message. Signed-off-by: Navaneeth <me@rizexor.com>
|
Refactored to |
Keep document-level checks in transpile_test.go and group user-specific behavior in users_test.go while preserving the public Transpile test seam. Signed-off-by: Navaneeth <me@rizexor.com>
|
Is there a public Go lib to validate Butane? Currently using https://pkg.go.dev/github.com/coreos/ignition but last update is 2 years back? |
Signed-off-by: Navaneeth <me@rizexor.com>
d84a46a to
ee3b4eb
Compare
Update the shared fixture helper after testdata was renamed to testcases so users tests resolve the existing fixture files again. Signed-off-by: Navaneeth <me@rizexor.com>
that's a good question, i'm not sure. perhaps @tormath1 knows? |
elmiko
left a comment
There was a problem hiding this comment.
i think this is looking good, no further comments from my side.
/lgtm
Given the very recent merge of Butane into Ignition (https://github.com/coreos/ignition/pull/2235/changes#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17R18), I think the best way to proceed is to import the module as: As you actually did, you need to add 'v2' suffix to your link to get the current doc: https://pkg.go.dev/github.com/coreos/ignition/v2 |
tormath1
left a comment
There was a problem hiding this comment.
Thanks, it looks good for a first iteration. :)
Co-authored-by: Mathieu Tortuyaux <mathieu.tortuyaux@gmail.com> Signed-off-by: Navaneeth Rao <me@rizexor.com>
Co-authored-by: Mathieu Tortuyaux <mathieu.tortuyaux@gmail.com> Signed-off-by: Navaneeth Rao <me@rizexor.com>
Move the library from internal/transpile to the module root so Cluster API and other consumers can import it. Move the bt executable to cmd/bt and keep fixtures with the root package tests. Signed-off-by: Navaneeth <me@rizexor.com>
Use Go 1.27 for local builds and CI through the version declared in go.mod. Signed-off-by: Navaneeth <me@rizexor.com>
Build output with the Ignition v2 Flatcar and passwd types. Use the YAML zero-value omission option to avoid emitting unsupported empty sections. Signed-off-by: Navaneeth <me@rizexor.com>
Inspect only the first input line because Jinja, cloud-config, and invalid input exhaust the supported header states. Cover a leading blank line as an invalid header. Signed-off-by: Navaneeth <me@rizexor.com>
Check dependency sources into vendor and force CI build, vet, and test commands to use them without downloading modules. Signed-off-by: Navaneeth <me@rizexor.com>
|
Done |
Summary
btCobra CLI for converting cloud-config YAML to Butane YAMLuserssubset: name, password hash, GECOS, home directory, shell, and SSH authorized keysTesting