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

fix: Fix logic of useSSHAgent and needSSHKey #178

Closed
wants to merge 1 commit into from

Conversation

nudgegoonies
Copy link

  • Fix logic of useSSHAgent and needSSHKey

For us the fix in #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 ?

* Fix logic of useSSHAgent and needSSHKey
@xorpaul xorpaul self-assigned this Apr 9, 2021
@xorpaul
Copy link
Owner

xorpaul commented Apr 9, 2021

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?

needSSHKey = false
} else {
Copy link
Owner

Choose a reason for hiding this comment

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

I admit the the variable name needSSHKey can be misleading. I renamed it to explicitlyLoadSSHKey in the next version. Hopefully this helps understanding the logic.

@nudgegoonies
Copy link
Author

nudgegoonies commented Apr 14, 2021

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
Copy link
Owner

xorpaul commented Apr 19, 2021

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

@xorpaul
Copy link
Owner

xorpaul commented Apr 19, 2021

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

@xorpaul
Copy link
Owner

xorpaul commented Apr 20, 2021

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

@xorpaul xorpaul closed this Apr 20, 2021
@nudgegoonies
Copy link
Author

Thank you very much. That fixed it.

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.

2 participants