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

Quadlet - add full support for Symlinks #24018

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

Conversation

ygalblum
Copy link
Collaborator

Does this PR introduce a user-facing change?

Yes

Quadlet now support symbolic links also inside the search path

Resolves: #23755

Copy link
Contributor

openshift-ci bot commented Sep 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ygalblum

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 19, 2024
@ygalblum ygalblum force-pushed the allow-symlinks branch 2 times, most recently from 02f21f9 to 0cdab9f Compare September 19, 2024 19:22
Comment on lines 114 to 116
varExist, dirs := getDirsFromEnv(dirs)
if !varExist {
resolvedUnitDirAdminUser := resolveUnitDirAdminUser()
Copy link
Member

Choose a reason for hiding this comment

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

I this is would be cleaner written as if varExist {return dirs} so you do not have to indent the other logic

Copy link
Member

Choose a reason for hiding this comment

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

early return ++

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, fixed. With the addition of not returning dirs the if statement become even simpler

}

func getDirsFromEnv() (bool, []string) {
func getDirsFromEnv(dirs map[string]struct{}) (bool, map[string]struct{}) {
Copy link
Member

Choose a reason for hiding this comment

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

Unlike other types, maps are behind a shred pointer and modified in place when passed around. As such it is not needed to return the same map back to the caller unless I am missing something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you are correct. Leftover from the previous implementation. Fixed

nonNumericFilter := getNonNumericFilter(resolvedUnitDirAdminUser, systemUserDirLevel)
dirs = getRootlessDirs(dirs, nonNumericFilter, userLevelFilter)
} else {
dirs = getRootDirs(dirs, userLevelFilter)
Copy link
Member

Choose a reason for hiding this comment

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

same idea could be used here i think? early return.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. But, I have to say in the previous implementation the return inside the rootless statement kinda confused me. So, I rather have a single return when it's not really an early return but rather a different path

@baude
Copy link
Member

baude commented Sep 20, 2024

couple of changes most of which @Luap99 points out; else LGTM

Use os.ReadDir recursively instead of filepath.WalkDir
Use map instead of list to easily find looped Symlinks
Update existing tests and add a more elaborate one
Update the man page

Signed-off-by: Ygal Blum <[email protected]>
@mheon
Copy link
Member

mheon commented Sep 20, 2024

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quadlet support symlinked subdirectory
4 participants