Skip to content

feat: add node config generator - #144

Open
tionis wants to merge 1 commit into
encodeous:mainfrom
tionis:node-yaml-editor
Open

feat: add node config generator#144
tionis wants to merge 1 commit into
encodeous:mainfrom
tionis:node-yaml-editor

Conversation

@tionis

@tionis tionis commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This addresses #51 and adds an init command as discussed in the issue

Copilot AI review requested due to automatic review settings July 28, 2026 20:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 init command to generate node.yaml with 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., seal trims key files), trim whitespace from --key before base64-decoding. This makes nylon 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-key before 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.

Comment thread cmd/init.go
Comment thread cmd/init.go
@tionis tionis changed the title Add node config generator feat: add node config generator Jul 29, 2026
@tionis
tionis force-pushed the node-yaml-editor branch from 073db00 to 5fbc1bc Compare July 29, 2026 06:49
@encodeous encodeous linked an issue Jul 29, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node.yaml generator

2 participants