-
-
Notifications
You must be signed in to change notification settings - Fork 377
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
feature(publish): Allow to remove components from a published repository #1350
feature(publish): Allow to remove components from a published repository #1350
Conversation
The change is incomplete. Documentation, man page and bash completion must be added. The current implementation should be a basis for a discussion. Maybe someone has a better idea to achieve the described result without the need to introduce a new subcommand for the publish group. But if the extension is ok from a functional perspective, I will try to add the missing changes. |
76cbb98
to
1df616c
Compare
I see the need for removing a component. But I wonder if it needs to be a new command/api. Could this also be part of the |
From
When we use the PUT approach, we must do an extra remote GET call for retrieving all components that are part of the published repository. Because there is currently no way to get the resource representation of a single published repository, we must retrieve the whole list and find the published repository, or more precisely the components of the published repository. In addition, there is currently no What do you think? Is the extra GET call ok for you? In that case, we should add - in compliance with the cli - something like
which allows to get the resource representation of a single published repository and modify the Should we live with the limitation that components can only removed from published repositories, which are based on snapshots or should we add a new Maybe, it is possible to ensure backward compatibility in case of snapshots, so that both the deprecated attribute |
I would be great if we could come up with more solid API concept here ;-) just brainstorming.. maybe we can add a I don't think it's great to have an extra GET for the components to specify, except the one to be deleted... Another question: after deleting a component from a publish, would republishing the same snapshot not re-add said component ? |
The main problem with the DELETE is that it is a grey area, because it is unclear if a DELETE request can/should have a body: I try to avoid is whenever possible in order to minimize compatibility issues. I like resource identifiers coming from the domain. The only problem, we currently have with By making a component a first class resource entity we still have the problem, that the DELETE may have optional parameters like
In case of signing, we are getting into trouble, because everything must be put into the query. That does not scale well and makes enhancements more difficult. Another option would be to use PATCH for a partial resource update. But when we closely stick to the PATCH definition, we must use Json pointers in order to remove something from the
|
What do you think, if we extend the struct I think we should obey the following rules in the REST API - just a proposal:
I am not sure, if this API for a published repository will work in every case:
Optional:
The last three commands cover the following cases:
When operations may have optional flags like Optional: |
The question is, is there also a minimal-invasive way to extend the current API with full backward compatibility. Maybe this would be a compromise:
I am not sure, if we can risk to use another resource representation for the What do you think? That is the only way to get rid of the extra fetch request when modifying the sources resource via PATCH. Nevertheless, we must add |
Thanks a log for the analysis ! Concerning the potential slashes in the distribution field, there is already a convention in aptly to replace them with underscores, see https://github.com/aptly-dev/aptly/blob/master/api/publish.go#L47. It is used for prefix only I think, maybe it should be used for distribution fields too. This allows us to expand the api and be backward compatible.. I am not a fan of PATCH in general, as they require "operations"... but it does have a body, we could pass signing and other info ? I agree we should not add a body to DELETE, and I think i see the problem: to publish we need to pass signing information, which would require a body. So DELETE cannot be used to modify and resigns an existing publish ? Did I understand that right, the problem you wanna solve is to not republish big snapshots (or in worst case recreate them) but rather just change the components and/or sources ? Could you show a use case for better understanding ? |
Yes, I think that is a feasible solution 😃.
Well, the problem with PATCH is that we should follow the JSON patch specification and that limits our freedom in what we put into the message body: https://datatracker.ietf.org/doc/html/rfc6902. Everything must be modeled in an operational style and we can only transform attributes of the JSON representation of the resource. Currently, the
We can only use the operations
with the message body:
If we want to delete a published component, we must use the index of the right component tuple (Component, Name) in the
The problem is that the index is not known in advance and that we must ensure a stable order of the
Exactly, otherwise we have to add a message body to the DELETE request, which contains the signing information. The next problem with DELETE is that we can normally only delete a single resource/component, but the remove cli allows the deletion of multiple components in a single call, so that expensive operations are executed only once.
Yes, that’s right. I have "inherited" 😉 a pretty old self-built APT repo. The problem is that it only contains a single distribution, which contains nearly 100 components. Each component groups the packages that belong to a specific device version, so we have e.g. a component called |
I found that interesting: https://stackoverflow.com/a/21863914 (3. point) That is the reason, why I have decided to model a dedicated
|
Using PATCH would also mean to add a new go library to Aptly that does the resource transformation and in that case, we should use PATCH on other resources as well. However, that would nearly mean a complete redefinition of Aptly’s REST API. I think that is too much work for too little benefit and we will quickly loose backward compatibility. |
From my point of view, we should try to be pragmatic. It is not a one way at all. We can discuss,
Maybe this approach is not perfect, but we do not violate any RESTful principles and can provide an efficient REST API. |
1df616c
to
65d7367
Compare
Agree, let's be pragmatic. I just wanted to fully understand :) But I still have some questions...
this would remove a snapshot from a publish ? or a component ?
signing information is secret, we cannot add this to the database, if you want to publish/republish, signing info needs to be provided. the multidist could be remembered in the database, so it does not need to be specified.
Why this change? What is a Source, compared to Snapshot ? I rebased your branch on master, where we have swagger documentation now, so we can document the APIs inline. |
No problem, ask everything that is currently unclear.
The remove operation (API and CLI) drops a component from a published repository. It works on published repositories, which are based on snapshots, but also on those, which are based on local repositories. You are right; we must definitely unescape the prefix and the distribution (with parseEscapedPath) at the very beginning of the each API method.
Ok, when we are “not forced” to use PATCH, we do not have to store the signing information in the database. The user can pass them when calling a command that requires signing information. Having the
I am working on an additional pull request that will allow adding components to a published repository that is based on local repos. I kept the |
"github.com/smira/flag" | ||
) | ||
|
||
func aptlyPublishRemove(cmd *commander.Command, args []string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update man page?
This commit introduces the new 'remove' command for a published repository. It allows to remove one or multiple components from a published repository without needing to recreate it. Signed-off-by: Christoph Fiehe <[email protected]>
65d7367
to
e8adf4f
Compare
I was able to rebase on master and force push :-) the other branch I could not push, no permissions |
I pushed a commit with swagger documentation. Maybe you can improve the description and also update the others :-) |
b667374
to
a89d7db
Compare
a89d7db
to
c0b096e
Compare
fixed a typo in the doc and pushed |
shall we close this in favor of #1366 ? |
closing in favor of #1366 |
Fixes #1349
Description of the Change
This commit introduces the new
remove
command for a published repository. It allows to remove one or multiple components from a published repository without needing to recreate it.Checklist
AUTHORS