xorpaul / g10k

my r10k fork in Go
Apache License 2.0
125 stars 50 forks source link

fix: Fix logic of useSSHAgent and needSSHKey #178

Closed nudgegoonies closed 3 years ago

nudgegoonies commented 3 years ago

For us the fix in https://github.com/xorpaul/g10k/issues/171 did not work. g10k still asks for passwords with two different types of diaglogs. We fiddled around with the useSSHAgent and needSSHKey and this change works for us but i am not a go programmer and i don't know if it still works for the opposite usecase. Can you please take a lookg @xorpaul ?

xorpaul commented 3 years ago

Your change would cause g10k to try to load a ssh key even if there's no ssh key set in the g10k config.

Do you use a private github.com repository with a ssh key by any chance?

Otherwise g10k should skip any ssh-add command for your git module with use_ssh_agent set to true

Can you trigger the original g10k I release with the -debug option and check for the Executing ... git clone... lines?

nudgegoonies commented 3 years ago

Do you use a private github.com repository with a ssh key by any chance?

We use an inhouse repository and the key is already loaded.

Can you trigger the original g10k I release with the -debug option and check for the Executing ... git clone... lines?

This is from your latest master without my patch and an inhouse repo, key already loaded and use_ssh_agent set to true true:

[...]DEBUG executeCommand(): Executing ssh-agent bash -c 'ssh-add ; git --git-dir /tmp/g10k/[...]

When i understand your comments and the documentation right, the ssh-add here is wrong.

xorpaul commented 3 years ago

ah, needed to format your comment, which answers my question

xorpaul commented 3 years ago

I guess I found it, do you use the -puppetfile mode here?

xorpaul commented 3 years ago

Please try out https://github.com/xorpaul/g10k/releases/tag/v0.8.15

I've fixed the dedicated cache directories even in -puppetfile mode for modules and environments here: https://github.com/xorpaul/g10k/blob/master/g10k.go#L313-L315

Because I'm using that to detect if the git repository that is being updated is a control repository, where a SSH key will be used if it is set in the g10k config and that did cause the wrong behavior of using the ssh-add even when you specified a module with :useSSHAgent.

I've renamed the variable and fixed logic for using an SSH key working with git repositories here: https://github.com/xorpaul/g10k/blob/master/git.go#L102-L111

nudgegoonies commented 3 years ago

Thank you very much. That fixed it.