Skip to content
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

adding printing diff functionality in flux diff artifact #4138

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbdtu5498
Copy link

Fixes #3839
cc: @hiddeco @makkes @somtochiama
WIP. Please take a look. For the time being I have added a verbose flag for the functionallity to keep it backward compatible in terms of testing, but it can be removed as other diff commands also simply print the diff and thus it makes sense. I will be adding the test cases soon. Let me know what should be the case.

Comment on lines +167 to +181
tarReader := tar.NewReader(layerContent)
for {
_, err := tarReader.Next()
if err == io.EOF {
break
}
if err != nil {
return nil, fmt.Errorf("failed to read tar header: %w", err)
}

// Read the file contents and write them to the buffer
if _, err := io.Copy(&contentsBuffer, tarReader); err != nil {
return nil, fmt.Errorf("failed to read tar entry contents: %w", err)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this looking at just file contents, I think it would be much better if path data would be taken into account (which also can be done for local directories, as they are expected to have the same structure as a decompressed tar).

This way, not only differences in file content would be observed. But also things being moved (or swapped) from file A -> B, files changing from path, etc.

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.

Allow diffing of two OCI artifacts
2 participants