[PR #2109] [MERGED] Only load needed part of configuration #2503

Closed
opened 2025-12-29 03:21:33 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/2109
Author: @kradalby
Created: 9/6/2024
Status: Merged
Merged: 9/7/2024
Merged by: @kradalby

Base: mainHead: kradalby/cli-only-config


📝 Commits (6)

  • 3d2979c Only load needed part of configuration
  • d0e74f6 only check for update with cli
  • 42f9cdc update changelog
  • 9a09cee improve errors and streamline cli error output
  • 8abf7f8 fix tests expecting stdout err
  • 7e60424 update changelog

📊 Changes

18 files changed (+196 additions, -324 deletions)

View changed files

📝 .gitignore (+1 -0)
📝 CHANGELOG.md (+2 -0)
📝 cmd/headscale/cli/api_key.go (+4 -29)
📝 cmd/headscale/cli/configtest.go (+1 -1)
📝 cmd/headscale/cli/debug.go (+1 -13)
📝 cmd/headscale/cli/nodes.go (+8 -26)
📝 cmd/headscale/cli/policy.go (+12 -15)
📝 cmd/headscale/cli/preauthkeys.go (+3 -25)
📝 cmd/headscale/cli/root.go (+7 -9)
📝 cmd/headscale/cli/routes.go (+4 -36)
📝 cmd/headscale/cli/serve.go (+1 -1)
📝 cmd/headscale/cli/users.go (+4 -18)
📝 cmd/headscale/cli/utils.go (+16 -11)
📝 cmd/headscale/headscale_test.go (+0 -58)
📝 hscontrol/grpcv1.go (+4 -4)
📝 hscontrol/types/config.go (+61 -49)
📝 hscontrol/types/config_test.go (+58 -10)
📝 integration/cli_test.go (+9 -19)

📄 Description

Currently all configuration was loaded and validated regardless of what
the CLI was doing, if you did a nodes ls or serve the whole thing would
be loaded and validated which caused a machine that were doing only CLI
stuff to need the full config, or at least a bunch that would throw errors.

This commit cleans up and splits this so that only the subset needed for
running the CLI (unix socket or remote gRPC) is required when running
all commands except for serve.

When serve is ran, the normal chain with validations and loading of the
whole config is ran.

This means that deprecation warnings for the server config will only be shown
in the server log.

This should be a nice quality of life improvements for users running headscale
as a remote CLI, split config or Nix users with the module updates for 0.23.0 (https://github.com/NixOS/nixpkgs/pull/340054).

Signed-off-by: Kristoffer Dalby kristoffer@tailscale.com

Summary by CodeRabbit

  • New Features

    • Enhanced command-line interface (CLI) functionality, requiring minimal configuration for all commands except serve.
    • Improved configuration management with a streamlined approach using the viper package.
  • Bug Fixes

    • Adjusted client initialization methods across multiple commands to enhance flexibility and reduce errors.
  • Documentation

    • Updated CHANGELOG.md to reflect significant improvements and changes in functionality.
  • Tests

    • Introduced new tests for TLS configuration validation to ensure compliance with expected settings.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/2109 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 9/6/2024 **Status:** ✅ Merged **Merged:** 9/7/2024 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `kradalby/cli-only-config` --- ### 📝 Commits (6) - [`3d2979c`](https://github.com/juanfont/headscale/commit/3d2979c740a2923b474fa7295cdd222be407bb22) Only load needed part of configuration - [`d0e74f6`](https://github.com/juanfont/headscale/commit/d0e74f648afbd74b69810283d2121263c86c60ea) only check for update with cli - [`42f9cdc`](https://github.com/juanfont/headscale/commit/42f9cdc528f6375cfa272a3b6fa848bfba3882c3) update changelog - [`9a09cee`](https://github.com/juanfont/headscale/commit/9a09cee5b2c7cca3f21c6837fce01d6ed7aa94bc) improve errors and streamline cli error output - [`8abf7f8`](https://github.com/juanfont/headscale/commit/8abf7f888c01f9b39378bb71d58fd74867f1c57a) fix tests expecting stdout err - [`7e60424`](https://github.com/juanfont/headscale/commit/7e6042499ef8aa42a43a8a474f857bb9ce81109f) update changelog ### 📊 Changes **18 files changed** (+196 additions, -324 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+1 -0) 📝 `CHANGELOG.md` (+2 -0) 📝 `cmd/headscale/cli/api_key.go` (+4 -29) 📝 `cmd/headscale/cli/configtest.go` (+1 -1) 📝 `cmd/headscale/cli/debug.go` (+1 -13) 📝 `cmd/headscale/cli/nodes.go` (+8 -26) 📝 `cmd/headscale/cli/policy.go` (+12 -15) 📝 `cmd/headscale/cli/preauthkeys.go` (+3 -25) 📝 `cmd/headscale/cli/root.go` (+7 -9) 📝 `cmd/headscale/cli/routes.go` (+4 -36) 📝 `cmd/headscale/cli/serve.go` (+1 -1) 📝 `cmd/headscale/cli/users.go` (+4 -18) 📝 `cmd/headscale/cli/utils.go` (+16 -11) 📝 `cmd/headscale/headscale_test.go` (+0 -58) 📝 `hscontrol/grpcv1.go` (+4 -4) 📝 `hscontrol/types/config.go` (+61 -49) 📝 `hscontrol/types/config_test.go` (+58 -10) 📝 `integration/cli_test.go` (+9 -19) </details> ### 📄 Description Currently all configuration was loaded and validated regardless of what the CLI was doing, if you did a `nodes ls` or `serve` the whole thing would be loaded and validated which caused a machine that were doing only CLI stuff to need the full config, or at least a bunch that would throw errors. This commit cleans up and splits this so that only the subset needed for running the CLI (unix socket or remote gRPC) is required when running all commands except for `serve`. When `serve` is ran, the normal chain with validations and loading of the whole config is ran. This means that deprecation warnings for the server config will only be shown in the server log. This should be a nice quality of life improvements for users running headscale as a remote CLI, split config or Nix users with the module updates for 0.23.0 (https://github.com/NixOS/nixpkgs/pull/340054). Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced command-line interface (CLI) functionality, requiring minimal configuration for all commands except `serve`. - Improved configuration management with a streamlined approach using the `viper` package. - **Bug Fixes** - Adjusted client initialization methods across multiple commands to enhance flexibility and reduce errors. - **Documentation** - Updated CHANGELOG.md to reflect significant improvements and changes in functionality. - **Tests** - Introduced new tests for TLS configuration validation to ensure compliance with expected settings. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 03:21:33 +01:00
adam closed this issue 2025-12-29 03:21:33 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2503