Restructure (5): Use std libraries URL type only#583
Restructure (5): Use std libraries URL type only#583markylaing merged 11 commits intocanonical:v3from
URL type only#583Conversation
URL type onlyURL type only
URL type onlyURL type only
There was a problem hiding this comment.
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.URLinstead ofapi.URL - Changed all
Address().URL.Hostpatterns toAddress().Hostfor cleaner access - Added
net/urlimports where needed and removed unnecessaryapiimports 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>
d1c0d34 to
b548976
Compare
There was a problem hiding this comment.
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.
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.URLtype from LXD (which embeds the std libsurl.URL) is replaced with the std libsurl.URLto lower the amount of deps on LXD'ssharedpackage.But we still use it to allow fast crafting of URLs internally.
Also it simplifies many statements that require access to an URL's
Hostas there is one less level of struct nesting.