feat: add node config generator - #144
Open
tionis wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements the “node.yaml generator” from #51 by introducing a new nylon init CLI command that generates a node config (including a freshly generated private key) and prints the corresponding public key for use in central.yaml. It also tightens key deserialization by validating decoded key lengths and updates the Getting Started guide to use the new workflow.
Changes:
- Add
nylon initcommand to generatenode.yamlwith secure file permissions and optional network/DNS/distribution/hook settings. - Reject invalid private/public keys during YAML/text deserialization by enforcing expected decoded byte length.
- Update documentation and add tests covering init behavior and key-length validation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| state/serialize.go | Adds decoded-length validation for private/public key text deserialization. |
| state/serialize_test.go | Adds regression tests ensuring wrong-length keys are rejected. |
| docs/guides/getting-started.mdx | Updates onboarding to use nylon init to generate node.yaml and keypair output guidance. |
| cmd/init.go | Implements the new init command and node-config construction/validation logic. |
| cmd/init_test.go | Adds tests for config generation, overwrite protection, dist option completeness, and validation errors. |
Comments suppressed due to low confidence (2)
cmd/init.go:116
- For better UX and consistency with other commands (e.g.,
sealtrims key files), trim whitespace from--keybefore base64-decoding. This makesnylon init --key "$(cat keyfile)"/ copy-paste less error-prone.
if opts.key != "" {
if err := privateKey.UnmarshalText([]byte(opts.key)); err != nil {
return nil, fmt.Errorf("invalid private key: %w", err)
}
}
cmd/init.go:148
- Trim whitespace from
--dist-keybefore decoding so distribution bootstrap works reliably when users copy values from files/docs.
var key state.NyPublicKey
if err := key.UnmarshalText([]byte(opts.distKey)); err != nil {
return nil, fmt.Errorf("invalid distribution key: %w", err)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This addresses #51 and adds an init command as discussed in the issue