Skip to content

feat: add SSH repository URL support#118

Merged
creydr merged 10 commits intofunctions-dev:mainfrom
creydr:add-git-ssh-support
Apr 30, 2026
Merged

feat: add SSH repository URL support#118
creydr merged 10 commits intofunctions-dev:mainfrom
creydr:add-git-ssh-support

Conversation

@creydr
Copy link
Copy Markdown
Collaborator

@creydr creydr commented Apr 30, 2026

Summary

  • Support SSH repository URLs in Function CRs, both SCP-style (git@host:path) and standard (ssh://git@host/path)
  • SSH private key authentication via sshPrivateKey secret field, with optional sshPrivateKeyPassword and known_hosts for host key verification
  • Public repositories accessible over SSH work without a secret when the server allows anonymous SSH access

creydr added 10 commits April 29, 2026 17:28
Switch URL parsing to go-git's transport.ParseURL() which handles
SCP-style (git@host:path), ssh://, http://, and https:// URLs.
Add SSH auth support with private key, optional passphrase, and
optional known_hosts verification. Simplify temp directory naming.
Add CreateSSHKey and SSHRepoURL to RepositoryProvider interface.
Add WithSSHKey option for InitializeRepoWithFunction to push via SSH.
Read SSH endpoint from gitea-endpoint ConfigMap during client init.
Add tests for public SSH repos, private SSH repos with key auth,
and private SSH repos without auth (expected failure). Extend
auth error matcher with SSH-specific error patterns.
Document SSH key authentication secret format with sshPrivateKey,
sshPrivateKeyPassword, and known_hosts fields. Add Function CR
examples for both private and public SSH repos. Update API
reference table with supported URL formats.
Check error return from tmpFile.Close() and extract repeated "ssh"
string literal into constant.
ssh.PublicKeys with a nil Signer panics when go-git calls
ClientConfig(). Use ssh.Password with empty password instead,
which creates a valid SSH config for public repo access.
go-git's SSH transport falls back to loading known_hosts when
HostKeyAlgorithms is empty, even if HostKeyCallback is set. Build
the gossh.ClientConfig directly instead of using ssh.Password or
ssh.PublicKeys, setting both HostKeyCallback and HostKeyAlgorithms
to prevent the known_hosts fallback in the operator container.
Gitea requires SSH key authentication for all SSH connections, even
to public repos. The public SSH test now generates a keypair and
provides it via authSecretRef. Also extracts a helper to deduplicate
the SSH Function creation logic across test contexts.
go-git's SSH transport tries to load known_hosts for HostKeyAlgorithms
even when HostKeyCallback is already set, which fails in containers.
Document why we build gossh.ClientConfig directly instead of using
go-git's built-in SSH auth types.
…g builder

Create an empty ~/.ssh/known_hosts in NewManager() so go-git's SSH
transport can resolve host key algorithms without error. This lets us
use gitssh.Password and gitssh.NewPublicKeys directly, removing the
custom sshAuthFunc type and defaultHostKeyAlgorithms list.
@creydr creydr enabled auto-merge April 30, 2026 07:18
@creydr creydr added this pull request to the merge queue Apr 30, 2026
Merged via the queue into functions-dev:main with commit c389e1f Apr 30, 2026
11 checks passed
@creydr creydr deleted the add-git-ssh-support branch April 30, 2026 08:43
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.

1 participant