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

feat: allow symlink #571

Closed
wants to merge 1 commit into from
Closed

feat: allow symlink #571

wants to merge 1 commit into from

Conversation

developer-guy
Copy link
Collaborator

Signed-off-by: Batuhan Apaydın [email protected]

Fixes #460

Is that what you thought? @imjasonh

@codecov-commenter
Copy link

codecov-commenter commented Jan 25, 2022

Codecov Report

Merging #571 (3843eab) into main (ea93812) will decrease coverage by 0.37%.
The diff coverage is 12.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #571      +/-   ##
==========================================
- Coverage   50.72%   50.34%   -0.38%     
==========================================
  Files          43       43              
  Lines        3316     3345      +29     
==========================================
+ Hits         1682     1684       +2     
- Misses       1424     1446      +22     
- Partials      210      215       +5     
Impacted Files Coverage Δ
pkg/commands/options/filestuff.go 0.00% <0.00%> (ø)
pkg/commands/resolver.go 27.95% <25.00%> (-0.58%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea93812...3843eab. Read the comment docs.

@imjasonh
Copy link
Member

I think the suggestion in #571 (comment) is still useful, we could add a symlink in the repo and exercise this new path in an e2e test

if fi.IsDir() {
if path != paths && !fo.Recursive {
return filepath.SkipDir
}
if watcher != nil {
watcher.Add(path)
watcher.Add(symlink)
Copy link
Member

Choose a reason for hiding this comment

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

Let's just remove any watcher interaction, we're going to delete it all soon anyway in #585

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OFC, thank you 🙋🏻‍♂️

Comment on lines 100 to 103
} else {
if symlink != "" {
files <- symlink
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} else {
if symlink != "" {
files <- symlink
}
} else if symlink != "" {
files <- symlink
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thank you 🙋🏻‍♂️

@@ -142,3 +155,10 @@ func EnumerateFiles(fo *FilenameOptions) chan string {
}()
return files
}

func ResolveSymlink(path string, fi os.FileInfo) (symlink string, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be replaced with https://pkg.go.dev/path/filepath#EvalSymlinks ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it didn't work when I switched to EvalSymlink, I don't know why 🤷🏻‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

I'd like to understand better why that's the case. This is getting fairly complicated, and I'd rather depend on stdlib methods as much as possible. If we still need to write significant code to handle symlinks, I'm a bit more inclined not to support symlinks for now.

@@ -0,0 +1 @@
test/test.yaml
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test that checks that this symlink is followed if you ko apply -f test/symlink.yaml ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried something to test this but couldn't make it work but anyways I wanted to share the code with you to see what I missed or did wrong 🙋🏻‍♂️ maybe you can help me to fix this 🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks a ton, @Dentrax, he helped me to fix this. ❤️

@Dentrax
Copy link

Dentrax commented Feb 28, 2022

NIT: One small concern here is that we do not support the case in which symlink points itself: too many levels of symbolic links

A workaround: https://github.com/fkautz/gitbom-go/pull/7/files (It would be overengineered to implement that in this project I think)

@developer-guy
Copy link
Collaborator Author

kindly ping 🙋🏻‍♂️

@github-actions
Copy link

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

Signed-off-by: Batuhan Apaydın <[email protected]>
@developer-guy developer-guy closed this by deleting the head repository Sep 12, 2022
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.

ko apply --recursive -f to follow symlinked directories
4 participants