[PR #371] [MERGED] Use specific types for Machine #1409

Closed
opened 2025-12-29 02:29:58 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/371
Author: @kradalby
Created: 3/1/2022
Status: Merged
Merged: 3/2/2022
Merged by: @kradalby

Base: mainHead: use-specific-database-typess


📝 Commits (7)

  • 8a95fe5 Use specific types for all fields on machine (no datatypes.json)
  • 6477e6a Use new machine types
  • 49cd761 Use new machine types in tests
  • 5b16901 Resolve merge conflict
  • c80e364 Remove always nil error
  • 0835bff Update changelog
  • a0a56d4 Merge branch 'main' into use-specific-database-typess

📊 Changes

12 files changed (+204 additions, -357 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 acls.go (+6 -21)
📝 acls_test.go (+84 -61)
📝 db.go (+76 -0)
📝 go.mod (+2 -5)
📝 go.sum (+0 -47)
📝 grpcv1.go (+3 -22)
📝 machine.go (+23 -123)
📝 machine_test.go (+2 -14)
📝 poll.go (+2 -19)
📝 routes.go (+3 -36)
📝 routes_test.go (+2 -9)

📄 Description

This PR swaps out the use of datatypes.JSON in the Machine model with the actual types they represent.

This allows us to use stronger types throughout the code and remove a lot of unmarshal/marshal operations and therefor get rid of a lot of unnecessary error checks.

This should make the code shorter, simpler and easier to maintain. And "harder" to make errors with proper typing.

  • read the CONTRIBUTING guidelines
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

🔄 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/371 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 3/1/2022 **Status:** ✅ Merged **Merged:** 3/2/2022 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `use-specific-database-typess` --- ### 📝 Commits (7) - [`8a95fe5`](https://github.com/juanfont/headscale/commit/8a95fe517a433d5f6df938a5d1f091e996d84d5e) Use specific types for all fields on machine (no datatypes.json) - [`6477e6a`](https://github.com/juanfont/headscale/commit/6477e6a5837b90ba2eb6002ae1137f8ded62042c) Use new machine types - [`49cd761`](https://github.com/juanfont/headscale/commit/49cd761bf62851a62f4f61b2e610b7f66cef0059) Use new machine types in tests - [`5b16901`](https://github.com/juanfont/headscale/commit/5b169010be494d20eda95e34ea795b1cc04dc0c3) Resolve merge conflict - [`c80e364`](https://github.com/juanfont/headscale/commit/c80e364f02e2dee7cab996ad13f14a82a7e65fff) Remove always nil error - [`0835bff`](https://github.com/juanfont/headscale/commit/0835bffc3c711901f45f3aac54f0f2a3c4ef9d57) Update changelog - [`a0a56d4`](https://github.com/juanfont/headscale/commit/a0a56d43f8b25848be814b469a38c8321e0b60de) Merge branch 'main' into use-specific-database-typess ### 📊 Changes **12 files changed** (+204 additions, -357 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `acls.go` (+6 -21) 📝 `acls_test.go` (+84 -61) 📝 `db.go` (+76 -0) 📝 `go.mod` (+2 -5) 📝 `go.sum` (+0 -47) 📝 `grpcv1.go` (+3 -22) 📝 `machine.go` (+23 -123) 📝 `machine_test.go` (+2 -14) 📝 `poll.go` (+2 -19) 📝 `routes.go` (+3 -36) 📝 `routes_test.go` (+2 -9) </details> ### 📄 Description This PR swaps out the use of `datatypes.JSON` in the `Machine` model with the actual types they represent. This allows us to use stronger types throughout the code and remove a lot of unmarshal/marshal operations and therefor get rid of a lot of unnecessary error checks. This should make the code shorter, simpler and easier to maintain. And "harder" to make errors with proper typing. <!-- Please tick if the following things apply. You… --> - [x] read the [CONTRIBUTING guidelines](README.md#user-content-contributing) - [x] added unit tests - [x] added integration tests - [x] updated documentation if needed - [x] updated CHANGELOG.md <!-- If applicable, please reference the issue using `Fixes #XXX` and add tests to cover your new code. --> --- <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 02:29:58 +01:00
adam closed this issue 2025-12-29 02:29:58 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#1409