chore: move components in separate packages #484

Closed
opened 2025-12-29 02:18:56 +01:00 by adam · 4 comments
Owner

Originally created by @uhthomas on GitHub (Apr 21, 2023).

Hey!

I'd like to a discussion on whether it would be desirable to refactor some of the code located at the root of the project into packages. The upstream tailscale repository makes extensive use of packages and it might be nice to do the same here.

Why

  • Moving these files from the root of the repository could make make the project a little be "cleaner" and allow for more obvious separation of concerns (i.e what is/isn't related to the API?).
  • It might also be nice to move some of the html templates from static Go strings to HTML files embedded with //go:embed, as they would be more discoverable and easier to edit.
  • There are currently 78 files, 48 of which are Go files, at the root of the repository. Reducing this number may make the repository easier to quickly view.

Just quickly, some ideas on what could move where:

  • noise.go could move into a package noise. It has a single dependency on the Headscale struct but should be otherwise safe to move around.

  • machine.go could move into its own package.

  • integration tests could move into their own package as not to pollute the main API package.

  • swagger.go has no dependency on headscale at all and should be fine to live in its own package.

  • utils.go could be split into multiple packages as it seems to cover quite a wide surface area.

... etc.


What are your thoughts? Happy to lead this if you're interested, or we can close this an forget about it if not.

Originally created by @uhthomas on GitHub (Apr 21, 2023). Hey! I'd like to a discussion on whether it would be desirable to refactor some of the code located at the root of the project into packages. The upstream [tailscale](https://github.com/tailscale/tailscale) repository makes extensive use of packages and it might be nice to do the same here. ### Why - Moving these files from the root of the repository could make make the project a little be "cleaner" and allow for more obvious separation of concerns (i.e what is/isn't related to the API?). - It might also be nice to move some of the html templates from static Go strings to HTML files embedded with `//go:embed`, as they would be more discoverable and easier to edit. - There are currently 78 files, 48 of which are Go files, at the root of the repository. Reducing this number may make the repository easier to quickly view. Just quickly, some ideas on what could move where: - [noise.go](https://github.com/juanfont/headscale/blob/a5afe4bd06223f71a44ea7d42e9fb2ba3d178154/noise.go) could move into a package `noise`. It has a single dependency on the `Headscale` struct but should be otherwise safe to move around. - [machine.go](https://github.com/juanfont/headscale/blob/a5afe4bd06223f71a44ea7d42e9fb2ba3d178154/machne.go) could move into its own package. - integration tests could move into their own package as not to pollute the main API package. - [swagger.go](https://github.com/juanfont/headscale/blob/a5afe4bd06223f71a44ea7d42e9fb2ba3d178154/swagger.go) has no dependency on headscale at all and should be fine to live in its own package. - [utils.go](https://github.com/juanfont/headscale/blob/a5afe4bd06223f71a44ea7d42e9fb2ba3d178154/utils.go) could be split into multiple packages as it seems to cover quite a wide surface area. ... etc. --- What are your thoughts? Happy to lead this if you're interested, or we can close this an forget about it if not.
adam added the bug label 2025-12-29 02:18:56 +01:00
adam closed this issue 2025-12-29 02:18:56 +01:00
Author
Owner

@juanfont commented on GitHub (Apr 23, 2023):

@uhthomas hey, first and foremost, thanks for offering to help :)

@kradalby and I have talked about this exact same topic already a couple of times, and we are planning an in-person meeting in the next few weeks to iterate faster in some stuff - including this.

We can have a talk on other topics that need help, if you would like to :)

@juanfont commented on GitHub (Apr 23, 2023): @uhthomas hey, first and foremost, thanks for offering to help :) @kradalby and I have talked about this exact same topic already a couple of times, and we are planning an in-person meeting in the next few weeks to iterate faster in some stuff - including this. We can have a talk on other topics that need help, if you would like to :)
Author
Owner

@uhthomas commented on GitHub (May 2, 2023):

Cool! Glad we're aligned with the direction of this project! Let me know what I can do to help :)

@uhthomas commented on GitHub (May 2, 2023): Cool! Glad we're aligned with the direction of this project! Let me know what I can do to help :)
Author
Owner

@almereyda commented on GitHub (Sep 13, 2023):

Is this superseded by #1473, or will it pick up from there?

@almereyda commented on GitHub (Sep 13, 2023): Is this superseded by #1473, or will it pick up from there?
Author
Owner

@kradalby commented on GitHub (Sep 14, 2023):

Superseded, I'm going to close this, thanks.

@kradalby commented on GitHub (Sep 14, 2023): Superseded, I'm going to close this, thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#484