-
Notifications
You must be signed in to change notification settings - Fork 36
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
Added event for default rule "Read SSH Information" #112
Conversation
Signed-off-by: GLVS Kiriti <[email protected]>
Signed-off-by: GLVS Kiriti <[email protected]>
Signed-off-by: GLVS Kiriti <[email protected]>
…logic Signed-off-by: GLVS Kiriti <[email protected]>
Signed-off-by: GLVS Kiriti <[email protected]>
Signed-off-by: GLVS Kiriti <[email protected]>
Signed-off-by: GLVS Kiriti <[email protected]>
Signed-off-by: GLVS Kiriti <[email protected]>
@FedeDP Kindly tell me if there are any changes! |
if err != nil { | ||
return err | ||
} | ||
sshDir := filepath.Join(tempDirectoryName, ".ssh") |
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 don't need this line right? Since createSshDirectoryUnderHome
already creates .ssh
folder inside the temp folder it can just return sshDir
!
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.
@FedeDP Yes we can do that! But before the function return we should also clean the temp folder created by createSshDirectoryUnderHome .
defer os.RemoveAll(tempDirectoryName)
So if we return sshDir instead of tempDir . How can we clean tempDir ?
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.
So if we return sshdir then one valid approach is trimming the last 5 characters in sshDir gives tempdir path. Is that ok?
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.
I got it, your are right! Nope, i'd leave another comment on the helper function!
events/syscall/utils_linux.go
Outdated
return "", err | ||
} | ||
|
||
return tempDirectoryName, nil |
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.
return tempDirectoryName, nil | |
return sshDir, nil |
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.
I got #112 (comment), what if this function also returns a cleanup
function?, like:
return sshDir, func() { _ = os.RemoveAll(tempDirectoryName) }, nil
then the caller will just defer cleanup()
after it captures the result, of course if cleanup != nil.
This is often used in go :)
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.
Yepp!! Awesome
Just did that and tested it its working absolutely fine 💯
Signed-off-by: GLVS Kiriti <[email protected]>
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.
/approve
I think in the future we might want to make createSshDirectoryUnderHome
more reusable (by eg: taking a new parameter fileName string
in order to allow it to be used to create any file in a temporary user folder directory).
For now, it LGTM!
LGTM label has been added. Git tree hash: 9dbddf5a266c60ade1af9fcf089d373a940f9ed7
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, GLVSKiriti 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 |
Yess certainly It would be very useful |
What type of PR is this?
/kind feature
Any specific area of the project related to this PR?
/area events
What this PR does / why we need it:
Added event for default rule "Read SSH Information"
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: