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

feat: Connect to git with InsecureIgnoreHostKey. Closes #841 #842

Merged
merged 2 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 0 additions & 9 deletions examples/sensors/trigger-source-git.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,11 @@ spec:
name: argoproj
- mountPath: /git/argoproj1
name: argoproj1
- mountPath: /etc/ssh
name: known-hosts
volumes:
- name: argoproj
emptyDir: {}
- name: argoproj1
emptyDir: {}
# The name of the key in the secret must be "ssh_known_hosts"
# Make sure you have your git provider added in the known hosts
# e.g. create the secret by running, kubectl -n argo-events create secret generic git-known-hosts --from-file=ssh_known_hosts=.ssh/known_hosts
- name: known-hosts
secret:
secretName: git-known-hosts
serviceAccountName: argo-events-sa
dependencies:
- name: test-dep
Expand Down Expand Up @@ -63,6 +55,5 @@ spec:
sshKeySecret:
name: git-ssh
key: key
namespace: argo-events
filePath: "examples/hello-world.yaml"
branch: "master"
4 changes: 2 additions & 2 deletions store/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (g *GitArtifactReader) getRemote() string {
}

func getSSHKeyAuth(sshKeyFile string) (transport.AuthMethod, error) {
var auth transport.AuthMethod
sshKey, err := ioutil.ReadFile(sshKeyFile)
if err != nil {
return nil, fmt.Errorf("failed to read ssh key file. err: %+v", err)
Expand All @@ -73,7 +72,8 @@ func getSSHKeyAuth(sshKeyFile string) (transport.AuthMethod, error) {
if err != nil {
return nil, fmt.Errorf("failed to parse ssh key. err: %+v", err)
}
auth = &go_git_ssh.PublicKeys{User: "git", Signer: signer}
auth := &go_git_ssh.PublicKeys{User: "git", Signer: signer}
auth.HostKeyCallback = ssh.InsecureIgnoreHostKey()
return auth, nil
}

Expand Down
5 changes: 3 additions & 2 deletions store/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package store

import (
"crypto/tls"
"errors"
"io/ioutil"
"net/http"

"github.com/pkg/errors"

"github.com/argoproj/argo-events/common/logging"
"github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1"
)
Expand Down Expand Up @@ -41,7 +42,7 @@ func (reader *URLReader) Read() ([]byte, error) {

if resp.StatusCode != http.StatusOK {
log.Warnf("failed to read %s. status code: %d", reader.urlArtifact.Path, resp.StatusCode)
return nil, errors.New("status code " + string(resp.StatusCode))
return nil, errors.Errorf("status code %v", resp.StatusCode)
}

content, err := ioutil.ReadAll(resp.Body)
Expand Down