[PR #1700] [MERGED] Restructure database config #2263

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

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/1700
Author: @kradalby
Created: 1/25/2024
Status: Merged
Merged: 2/9/2024
Merged by: @kradalby

Base: mainHead: db-config


📝 Commits (5)

  • d56aa6a move database config to own struct
  • 123efe9 make alias from old to new db settings
  • db96bae use new setting in tests
  • 793faab update example and changelog
  • fdbe0dc pass db config to db module, move url logic

📊 Changes

11 files changed (+183 additions, -117 deletions)

View changed files

📝 CHANGELOG.md (+12 -10)
📝 cmd/headscale/headscale_test.go (+4 -2)
📝 config-example.yaml (+19 -18)
📝 hscontrol/app.go (+7 -40)
📝 hscontrol/db/db.go (+38 -18)
📝 hscontrol/db/routes_test.go (+8 -3)
📝 hscontrol/db/suite_test.go (+9 -3)
📝 hscontrol/suite_test.go (+6 -2)
📝 hscontrol/types/common.go (+8 -2)
📝 hscontrol/types/config.go (+70 -17)
📝 integration/hsic/config.go (+2 -2)

📄 Description

This PR restructures the database part of the configuration to follow the indent style of the rest of the config. It gives a better indication for which setting belongs to sqlite and postgres.

It is intended for making adding specific features like #1583 less confusing.

The old keys are aliased to the new settings keys so this is not breaking, but marked as deprecated in the changelog so we can remove them later.

New config example:

database:
  type: sqlite3

  # SQLite config
  sqlite:
    path: /var/lib/headscale/db.sqlite

  # # Postgres config
  # postgres:
  #   # If using a Unix socket to connect to Postgres, set the socket path in the 'host' field and leave 'port' blank.
  #   type: postgres
  #   host: localhost
  #   port: 5432
  #   name: headscale
  #   user: foo
  #   pass: bar

  #   # If other 'sslmode' is required instead of 'require(true)' and 'disabled(false)', set the 'sslmode' you need
  #   # in the 'db_ssl' field. Refers to https://www.postgresql.org/docs/current/libpq-ssl.html Table 34.1.
  #   ssl: false

🔄 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/1700 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 1/25/2024 **Status:** ✅ Merged **Merged:** 2/9/2024 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `db-config` --- ### 📝 Commits (5) - [`d56aa6a`](https://github.com/juanfont/headscale/commit/d56aa6a9cb01ed7b6e9acaea34f0793561dbf7d4) move database config to own struct - [`123efe9`](https://github.com/juanfont/headscale/commit/123efe984b1fcbbbcb0bbeec1cb5ab637f2e4937) make alias from old to new db settings - [`db96bae`](https://github.com/juanfont/headscale/commit/db96baed72ec692fe03e3c8663892000abe078c2) use new setting in tests - [`793faab`](https://github.com/juanfont/headscale/commit/793faab3cb6003d2308d56e00c58f67af964ce08) update example and changelog - [`fdbe0dc`](https://github.com/juanfont/headscale/commit/fdbe0dc17f28e2a1f1d320d44e3fdc5545912cb1) pass db config to db module, move url logic ### 📊 Changes **11 files changed** (+183 additions, -117 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+12 -10) 📝 `cmd/headscale/headscale_test.go` (+4 -2) 📝 `config-example.yaml` (+19 -18) 📝 `hscontrol/app.go` (+7 -40) 📝 `hscontrol/db/db.go` (+38 -18) 📝 `hscontrol/db/routes_test.go` (+8 -3) 📝 `hscontrol/db/suite_test.go` (+9 -3) 📝 `hscontrol/suite_test.go` (+6 -2) 📝 `hscontrol/types/common.go` (+8 -2) 📝 `hscontrol/types/config.go` (+70 -17) 📝 `integration/hsic/config.go` (+2 -2) </details> ### 📄 Description This PR restructures the database part of the configuration to follow the indent style of the rest of the config. It gives a better indication for which setting belongs to `sqlite` and `postgres`. It is intended for making adding specific features like #1583 less confusing. The old keys are aliased to the new settings keys so this is not breaking, but marked as deprecated in the changelog so we can remove them later. New config example: ```yaml database: type: sqlite3 # SQLite config sqlite: path: /var/lib/headscale/db.sqlite # # Postgres config # postgres: # # If using a Unix socket to connect to Postgres, set the socket path in the 'host' field and leave 'port' blank. # type: postgres # host: localhost # port: 5432 # name: headscale # user: foo # pass: bar # # If other 'sslmode' is required instead of 'require(true)' and 'disabled(false)', set the 'sslmode' you need # # in the 'db_ssl' field. Refers to https://www.postgresql.org/docs/current/libpq-ssl.html Table 34.1. # ssl: false ``` --- <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:20:28 +01:00
adam closed this issue 2025-12-29 03:20:28 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2263