Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use specific types for Machine #371

Merged
merged 7 commits into from
Mar 2, 2022

Conversation

kradalby
Copy link
Collaborator

@kradalby kradalby commented Mar 1, 2022

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 commit removes the need for datatypes.JSON and makes the code a bit
cleaner by allowing us to use proper types throughout the code when it
comes to hostinfo and other datatypes on the machine object.

This allows us to remove alot of unmarshal/marshal operations and remove
a lot of obsolete error checks.

This following commits will clean away a lot of untyped data and
uneccessary error checks.
@kradalby kradalby marked this pull request as ready for review March 2, 2022 08:17
@kradalby kradalby requested a review from juanfont as a code owner March 2, 2022 08:17
@kradalby kradalby changed the title Use specific database types for Machine Use specific types for Machine Mar 2, 2022
// check all over the code.
type HostInfo tailcfg.Hostinfo

func (hi *HostInfo) Scan(destination interface{}) error {
Copy link
Owner

Choose a reason for hiding this comment

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

I absolutely love this

@kradalby kradalby merged commit 9a8f605 into juanfont:main Mar 2, 2022
@kradalby kradalby deleted the use-specific-database-typess branch March 2, 2022 11:14
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.

2 participants