Skip to content

Conversation

@nghialv
Copy link
Member

@nghialv nghialv commented Jul 12, 2021

What this PR does / why we need it:

Currently, we are writing an SSH config file to use the given SSH key file directly.
In that way, ssh-agent will consider the directory which contains the given SSH key file as a dedicated directory to deal with key/cert files.

In some cases, users are expecting that the Piped should use the given SSH key file and do nothing with its directory.
So this PR copies the given key into ssh config directory with a random name to use.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.04%. This pull request decreases coverage by -0.02%.

File Function Base Head Diff
pkg/git/ssh_config.go AddSSHConfig 0.00% 0.00% +0.00%

@nakabonne
Copy link
Member

Cool
/lgtm

Comment on lines +68 to +71
f, err := os.CreateTemp(sshDir, "piped-ssh-key-*")
if err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

Across the docs looks like we should close/remove the opened temp file by ourselves 👀 Should we?

It is the caller's responsibility to remove the file when it is no longer needed.

ref: docs

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. Let me add a TODO to remove the added file.

Copy link
Member

Choose a reason for hiding this comment

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

🙆‍♀️

Copy link
Member Author

Choose a reason for hiding this comment

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

@khanhtc1202 Added.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.04%. This pull request decreases coverage by -0.02%.

File Function Base Head Diff
pkg/git/ssh_config.go AddSSHConfig 0.00% 0.00% +0.00%

@pipecd-bot pipecd-bot removed the lgtm label Jul 12, 2021
@pipecd-bot
Copy link
Collaborator

TODO

The following ISSUES will be created once got merged. If you want me to skip creating the issue, you can use /todo skip command.

Details

1. Remove this key file when Piped terminating.

https://github.com/pipe-cd/pipe/blob/3ab99b8cf5056061a90f5e4759b4f46eb38c5184/pkg/git/ssh_config.go#L76-L79

This was created by todo plugin since "TODO:" was found in 3ab99b8 when #2214 was merged. cc: @nghialv.

@khanhtc1202
Copy link
Member

Thx 🚀
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by khanhtc1202.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.04%. This pull request decreases coverage by -0.02%.

File Function Base Head Diff
pkg/git/ssh_config.go AddSSHConfig 0.00% 0.00% +0.00%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants