Skip to content

Restructure (5): Use std libraries URL type only#583

Merged
markylaing merged 11 commits intocanonical:v3from
roosterfish:restructure_url_type
Jan 19, 2026
Merged

Restructure (5): Use std libraries URL type only#583
markylaing merged 11 commits intocanonical:v3from
roosterfish:restructure_url_type

Conversation

@roosterfish
Copy link
Contributor

@roosterfish roosterfish commented Jan 16, 2026

This is the fifth PR taken from a single commit in #534.
The final package layout will be different but to allow reviewing the changes in smaller chunks I will split this PR by its commits.

In this PR the opinionated api.URL type from LXD (which embeds the std libs url.URL) is replaced with the std libs url.URL to lower the amount of deps on LXD's shared package.
But we still use it to allow fast crafting of URLs internally.

Also it simplifies many statements that require access to an URL's Host as there is one less level of struct nesting.

@roosterfish roosterfish requested a review from Copilot January 16, 2026 09:42
@roosterfish roosterfish changed the title Restructure (5): Use std libraries URL type only Restructure (5): Use std librarie's URL type only Jan 16, 2026
@roosterfish roosterfish changed the title Restructure (5): Use std librarie's URL type only Restructure (5): Use std libraries URL type only Jan 16, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces the opinionated api.URL type from LXD (which embeds the standard library's url.URL) with direct use of the standard library's *url.URL type throughout the codebase. This change reduces dependencies on LXD's shared package and simplifies code by removing one level of struct nesting when accessing URL properties like Host.

Changes:

  • Updated function signatures and struct fields to use *url.URL instead of api.URL
  • Changed all Address().URL.Host patterns to Address().Host for cleaner access
  • Added net/url imports where needed and removed unnecessary api imports in some files

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/state/state.go Changed Address() interface method and implementation to return *url.URL
internal/rest/rest.go Updated authentication call to use simplified .Host access
internal/rest/resources/truststore.go Updated trust operations to use simplified .Host access, but missed one instance
internal/rest/resources/tokens.go Updated token issuance to use simplified .Host access
internal/rest/resources/heartbeat.go Updated heartbeat operations to use simplified .Host access
internal/rest/resources/daemon.go Updated server address validation to use simplified .Host access
internal/rest/resources/cluster.go Updated cluster operations to use simplified .Host access
internal/rest/resources/api_1.0.go Updated API endpoint to use simplified .Host access
internal/endpoints/network.go Changed Network struct to use *url.URL, updated imports
internal/db/dqlite.go Changed database operations to use *url.URL, updated method signatures
internal/db/db_test.go Updated test to construct *url.URL from api.URL
internal/daemon/daemon.go Changed Address() method to return *url.URL, updated all callers
example/api/extended.go Updated example code to use simplified .Host access

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@roosterfish roosterfish marked this pull request as ready for review January 16, 2026 11:04
Copy link
Contributor

@markylaing markylaing left a comment

Choose a reason for hiding this comment

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

LGTM thanks :)

@markylaing markylaing merged commit 4a8e174 into canonical:v3 Jan 19, 2026
11 checks passed
@roosterfish roosterfish deleted the restructure_url_type branch January 19, 2026 13:23
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