-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
podman Image diff between two images #10667
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: infiniteregrets The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I am unable to get
Any ideas on where I could be going wrong? |
I am not sure why The JSON change must be made in https://github.com/containers/common. You cannot edit files under the vendor directory directly. Also please squash your commits into one. |
Okay so looks like I might have messed up a bit. When I was rebasing to squash commits, I probably added a commit made by rhatdan previously and now it is here and it is co-authored? I am not sure how to fix it... |
Use |
Thanks! But I think I made another mistake. When I was rebasing I wrote drop on that commit instead of removing it. I am not sure if that is what you meant |
Yeah I meant drop so its correct. You need to add a test to |
I added some tests, but some CI tests are failing idk why Nvm! i figured out where I went wrong, I will fix it soon Edit: |
pkg/domain/infra/tunnel/images.go
Outdated
options := new(images.DiffOptions) | ||
changes, err := images.Diff(ir.ClientCtx, nameOrID, options) | ||
changes, err := images.Diff(ir.ClientCtx, options, nameOrID, otherNameOrID) |
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.
Why not pass down the diff options from the caller?
Thanks @infiniteregrets Then do a diff between the newly created image and the from image, and make sure that the new files are in the diff. |
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.
The remote client does not work. I left some comments what you have to do on the client side. On the server side you have to parse the new option. You have to do this here https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/changes.go. Take a look at https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_logs.go for an example how to parse options on the server.
pkg/bindings/images/diff.go
Outdated
@@ -9,7 +9,7 @@ import ( | |||
) | |||
|
|||
// Diff provides the changes between two container layers | |||
func Diff(ctx context.Context, nameOrID string, options *DiffOptions) ([]archive.Change, error) { | |||
func Diff(ctx context.Context, options *DiffOptions, nameOrID string, otherNameOrID string) ([]archive.Change, 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.
We cannot change the function parameters here. This package is meant for external use and we cannot do breaking changes. You have to add the second image name to the options struct here
podman/pkg/bindings/images/types.go
Line 18 in e3dd12a
type DiffOptions struct { |
make generate-bindings
.
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.
No, you just cannot break the http api bindings. Just add the second image to the options for the bindings and api. For the cli it is fine to use two arguments.
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.
Okay so is having a flag that would override the comparison between the parent layer and the given image a good idea?
For example:podman image diff --format json --compare-with alpine:3 alpine:latest
On it, was going to make a separate comment down regarding the same so I deleted it from here
pkg/bindings/images/diff.go
Outdated
@@ -19,7 +19,7 @@ func Diff(ctx context.Context, nameOrID string, options *DiffOptions) ([]archive | |||
return nil, err | |||
} | |||
|
|||
response, err := conn.DoRequest(nil, http.MethodGet, "/images/%s/changes", nil, nil, nameOrID) | |||
response, err := conn.DoRequest(nil, http.MethodGet, "/images/%s/changes", nil, nil, nameOrID, otherNameOrID) |
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.
This does not work, when you add the the second image to the options struct as described above. You have to add
params, err := options.ToParams()
if err != nil {
return nil, err
}
response, err := conn.DoRequest(nil, http.MethodGet, "/images/%s/changes", params, nil, nameOrID)
Thanks for the review @Luap99. I will try again and also add the tests as mentioned by rhatdan |
@Luap99 I tried to work on this, but I don't think I completely understand how everything works. I really want to do all of it myself but before that I think it would be really helpful if you could give me a brief overview of how everything is laid out When you say the remote client, are you referring to the client used for mac os? And what do you mean by client side and server side. I do understand that there are functions to interact with Podman's REST API but I am not quite sure what Sorry if this is a bit naive, but I hope I can understand everything and make better future contributions. |
So you can use podman in two ways, via cli and rest api. The podman remote client called podman-remote talks to the podman api endpoint. Unlike podman, podman-remote can be used on macOS, windows and linux since it just needs to talk to a podman service on linux. The On the server side You already have the local podman working but you have to add this to the http api so that podman-remote can also use it. To test this run |
@Luap99 Nice write up on the design. We should add this comment to the contributors page or somewhere to help explain the design of the podman command. |
Thanks @Luap99! This was really helpful. Line 24 in b3f61ec
So is it okay to do so? |
Fixes: #10649 |
Signed-off-by: Mehul Arora <[email protected]>
Hi @Luap99, will you be able to take this over from here by any chance? I am still not completely sure about a few things.
I really appreciate the help! Thanks! |
Sure, I'll take it. |
Thanks! I've set this PR to be editable by maintainers if that is what's required |
@Luap99 did you get time to work on this? |
@infiniteregrets I am working on this now |
Thanks! |
This adds image diff functionality as mentioned in #10649. This was my first time writing go, so if I made any mistakes or if something is not idiomatic then please let me know and I will fix it. I couldn't find a way to accept optional arguments in go so I just added if else blocks to check for length of args.
If no image is given then the following error would occur:
If a single image is given then it is compared to the parent layer, retaining the functionality from before.
If two images are given then they are compared.
JSON/json
output is now indented.Thanks!
Signed-off-by: Mehul Arora [email protected]