-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Re-merge SDK structs into main repo #10895
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
Comments
Looks good. But there are also some others we need to disuccss. |
interesting idear, I'll look into this later |
They would be tagged whenever Gitea is tagged, so that the structs will always match their Gitea version counterpart. I think maybe I mis-worded by using the term "SDK". This proposes to re-merge the structs, not the whole |
Effectively this would mean moving https://github.com/go-gitea/gitea/tree/master/modules/structs out into a base directory and naming it appropriately (I've chosen Then in |
to follow your deom ... we could select witch struct we want to profide in the submodder if we redefine it in this way? type SDK struct sdk.SDK so we still have track what is exposed and wat dont but dont have to make pulls like this: |
need more discusion ... |
There would be no need to update the structs manually in the client. You'd just update the module. But anyone else who wants to use the sdk has the option to target a tag that would match their targeted version. |
as for your example PR, technically a PR would still need to be made to update the module. However, it would at least automatically sync the structs, rather than the SDK not supporting a specific struct until it's manually PRd. |
@jolheiser OK. I misunderstand that. If we only move structs there, it looks good. |
To clarify something that came up in Discord, the client can still have their own struct that embeds an API struct (or has it as a field) if they need further functionality for the client. e.g. type Issue struct {
gitea.Issue
// For some reason we need to assign a client-specific ID to an Issue
ClientID int
} |
I have prepared some sample repositories
submod represents the main Gitea repo. It has an
sdk
package that is also a go module.submodder represents the Gitea
go-sdk
repo. It uses thesdk
fromsubmod
without pulling in the entire project.Because of the
replace
directive in submod's go.mod, it uses thesdk
package in place of the import given.I did some testing, and it seems that it does not run into the same vendor issues we did before, as I can update the
sdk
package insubmod
and then rungo mod vendor
and pick up changes.e.g. vendoring seems to understand we want to use the
sdk
package directly rather than fetching some latest tag.If I missed something, let me know, but imo it would be a huge benefit to not have to copy over structs every time we make a change to the API.
Yes, this will mean a duplication in the sense that our
vendor
directory will contain the same files as thesdk
package, but in the scheme of things I don't know that it would add much size.As an aside, we could maybe consider the feasibility of removing vendor and instead only providing the output of
go mod vendor
in release downloads, similar to how we are now doingnode_modules
The text was updated successfully, but these errors were encountered: