diff --git a/cmd/argocd/commands/repo.go b/cmd/argocd/commands/repo.go index 1b11625524b5d..c2653927a8aa6 100644 --- a/cmd/argocd/commands/repo.go +++ b/cmd/argocd/commands/repo.go @@ -4,6 +4,7 @@ import ( "bufio" "context" "fmt" + "io/ioutil" "os" "syscall" "text/tabwriter" @@ -39,7 +40,8 @@ func NewRepoCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command { // NewRepoAddCommand returns a new instance of an `argocd repo add` command func NewRepoAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command { var ( - repo appsv1.Repository + repo appsv1.Repository + sshPrivateKeyPath string ) var command = &cobra.Command{ Use: "add", @@ -50,15 +52,22 @@ func NewRepoAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command { os.Exit(1) } repo.Repo = args[0] - err := git.TestRepo(repo.Repo, repo.Username, repo.Password) + if sshPrivateKeyPath != "" { + keyData, err := ioutil.ReadFile(sshPrivateKeyPath) + if err != nil { + log.Fatal(err) + } + repo.SSHPrivateKey = string(keyData) + } + err := git.TestRepo(repo.Repo, repo.Username, repo.Password, repo.SSHPrivateKey) if err != nil { - if repo.Username != "" && repo.Password != "" { - // if everything was supplied, one of the inputs was definitely bad + if repo.Username != "" && repo.Password != "" || git.IsSshURL(repo.Repo) { + // if everything was supplied or repo URL is SSH url, one of the inputs was definitely bad log.Fatal(err) } // If we can't test the repo, it's probably private. Prompt for credentials and try again. promptCredentials(&repo) - err = git.TestRepo(repo.Repo, repo.Username, repo.Password) + err = git.TestRepo(repo.Repo, repo.Username, repo.Password, repo.SSHPrivateKey) } errors.CheckError(err) conn, repoIf := argocdclient.NewClientOrDie(clientOpts).NewRepoClientOrDie() @@ -70,6 +79,7 @@ func NewRepoAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command { } command.Flags().StringVar(&repo.Username, "username", "", "username to the repository") command.Flags().StringVar(&repo.Password, "password", "", "password to the repository") + command.Flags().StringVar(&sshPrivateKeyPath, "sshPrivateKeyPath", "", "path to the private ssh key (e.g. ~/.ssh/id_rsa)") return command } diff --git a/pkg/apis/application/v1alpha1/generated.pb.go b/pkg/apis/application/v1alpha1/generated.pb.go index 20acaf4cf489e..cdb14120f840f 100644 --- a/pkg/apis/application/v1alpha1/generated.pb.go +++ b/pkg/apis/application/v1alpha1/generated.pb.go @@ -556,6 +556,10 @@ func (m *Repository) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Password))) i += copy(dAtA[i:], m.Password) + dAtA[i] = 0x22 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.SSHPrivateKey))) + i += copy(dAtA[i:], m.SSHPrivateKey) return i, nil } @@ -837,6 +841,8 @@ func (m *Repository) Size() (n int) { n += 1 + l + sovGenerated(uint64(l)) l = len(m.Password) n += 1 + l + sovGenerated(uint64(l)) + l = len(m.SSHPrivateKey) + n += 1 + l + sovGenerated(uint64(l)) return n } @@ -1039,6 +1045,7 @@ func (this *Repository) String() string { `Repo:` + fmt.Sprintf("%v", this.Repo) + `,`, `Username:` + fmt.Sprintf("%v", this.Username) + `,`, `Password:` + fmt.Sprintf("%v", this.Password) + `,`, + `SSHPrivateKey:` + fmt.Sprintf("%v", this.SSHPrivateKey) + `,`, `}`, }, "") return s @@ -2704,6 +2711,35 @@ func (m *Repository) Unmarshal(dAtA []byte) error { } m.Password = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SSHPrivateKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SSHPrivateKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenerated(dAtA[iNdEx:]) @@ -3275,82 +3311,84 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 1230 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0x3a, 0x8e, 0x63, 0x8f, 0x9b, 0x3f, 0x1d, 0x44, 0xb1, 0x72, 0x70, 0xa2, 0x45, 0x40, - 0x40, 0x74, 0x4d, 0xc2, 0x7f, 0x0e, 0x48, 0x59, 0x37, 0x88, 0x90, 0x50, 0xca, 0xc4, 0x15, 0x12, - 0x42, 0xc0, 0x64, 0x3d, 0xb5, 0x37, 0xb6, 0x77, 0x96, 0x99, 0xb1, 0x2b, 0x1f, 0x90, 0x7a, 0xe0, - 0x84, 0x04, 0x82, 0x4f, 0x81, 0xc4, 0x11, 0x3e, 0x03, 0x52, 0x8e, 0x95, 0x40, 0xa2, 0x42, 0x28, - 0x22, 0xee, 0x85, 0xcf, 0xd0, 0x13, 0x9a, 0xd9, 0xd9, 0xdd, 0xf1, 0x5a, 0x51, 0x52, 0x6c, 0xf5, - 0xb6, 0xf3, 0xde, 0x6f, 0x7e, 0xef, 0xed, 0xfb, 0x37, 0x0f, 0xec, 0xb5, 0x7c, 0xd1, 0xee, 0x1f, - 0x39, 0x1e, 0xed, 0xd5, 0x30, 0x6b, 0xd1, 0x90, 0xd1, 0x63, 0xf5, 0x71, 0xdd, 0x6b, 0xd6, 0xc2, - 0x4e, 0xab, 0x86, 0x43, 0x9f, 0xd7, 0x70, 0x18, 0x76, 0x7d, 0x0f, 0x0b, 0x9f, 0x06, 0xb5, 0xc1, - 0x16, 0xee, 0x86, 0x6d, 0xbc, 0x55, 0x6b, 0x91, 0x80, 0x30, 0x2c, 0x48, 0xd3, 0x09, 0x19,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88, 0x38, 0xb2, - 0xeb, 0xf3, 0x41, 0xac, 0x40, 0x29, 0xc6, 0xa8, 0xdf, 0xf9, 0xc7, 0xad, 0x5f, 0xfb, 0x5f, 0x0b, - 0x64, 0x07, 0xa9, 0x4c, 0xaa, 0x1f, 0x70, 0xe2, 0xf5, 0x59, 0xe4, 0x74, 0x31, 0x8d, 0xf1, 0x9e, - 0x96, 0xa3, 0x04, 0x01, 0xb7, 0x01, 0x88, 0x1a, 0xef, 0x66, 0x5a, 0x32, 0x49, 0x2b, 0x1f, 0x26, - 0x1a, 0x64, 0xa0, 0xe0, 0x26, 0x28, 0x7a, 0x84, 0x89, 0x1b, 0x32, 0xeb, 0xd2, 0xe7, 0x2b, 0xee, - 0x15, 0xc9, 0x5e, 0xd7, 0x32, 0x94, 0x68, 0xe1, 0x73, 0x60, 0xb1, 0x43, 0x86, 0x0a, 0x98, 0x57, - 0xc0, 0xb2, 0xdc, 0x90, 0xf7, 0x23, 0x11, 0x8a, 0x75, 0xd0, 0x06, 0x05, 0x0f, 0x2b, 0xd4, 0x82, - 0x42, 0x01, 0xf5, 0x86, 0xee, 0x28, 0x90, 0xd6, 0xb8, 0xce, 0xc9, 0x59, 0x75, 0xee, 0xfe, 0x59, - 0x75, 0xee, 0xc1, 0x59, 0x75, 0xee, 0xde, 0xa8, 0x6a, 0x9d, 0x8c, 0xaa, 0xd6, 0xfd, 0x51, 0xd5, - 0x7a, 0x30, 0xaa, 0x5a, 0xff, 0x8c, 0xaa, 0xd6, 0x0f, 0x0f, 0xab, 0x73, 0x9f, 0x16, 0xe3, 0x8c, - 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, 0xf2, 0x3a, 0xcb, 0xfe, 0xe8, 0x0f, 0x00, 0x00, + // 1257 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x5d, 0x6f, 0x1b, 0x45, + 0x17, 0xce, 0x3a, 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0x8c, 0x4f, 0x61, 0x59, 0x11, + 0xd4, 0xe7, 0xc4, 0xeb, 0xb1, 0xc8, 0xe9, 0x7c, 0x1a, 0xe3, 0x3d, 0x2d, 0x47, 0x09, 0x02, 0x6e, + 0x03, 0x10, 0x75, 0xed, 0xed, 0xb4, 0xde, 0x92, 0x39, 0x50, 0x4b, 0x34, 0xc8, 0x40, 0xc1, 0x4d, + 0x90, 0xf7, 0x08, 0x13, 0x37, 0x65, 0xd6, 0xa5, 0xcf, 0x57, 0xdc, 0x2b, 0x92, 0xbd, 0xaa, 0x65, + 0x28, 0xd1, 0xc2, 0x67, 0xc1, 0x62, 0x9b, 0x0c, 0x14, 0x30, 0xab, 0x80, 0x45, 0xb9, 0x5e, 0xef, + 0x47, 0x22, 0x14, 0xeb, 0xa0, 0x0d, 0x72, 0x1e, 0x56, 0xa8, 0x05, 0x85, 0x02, 0xea, 0x01, 0xde, + 0x51, 0x20, 0xad, 0x71, 0x9d, 0x93, 0xb3, 0xf2, 0xdc, 0x83, 0xb3, 0xf2, 0xdc, 0xc3, 0xb3, 0xf2, + 0xdc, 0xfd, 0x61, 0xd9, 0x3a, 0x19, 0x96, 0xad, 0x07, 0xc3, 0xb2, 0xf5, 0x70, 0x58, 0xb6, 0xfe, + 0x1e, 0x96, 0xad, 0xef, 0x1e, 0x95, 0xe7, 0x3e, 0xc9, 0xc7, 0x19, 0xff, 0x37, 0x00, 0x00, 0xff, + 0xff, 0xc8, 0x01, 0xc1, 0x64, 0x25, 0x10, 0x00, 0x00, } diff --git a/pkg/apis/application/v1alpha1/generated.proto b/pkg/apis/application/v1alpha1/generated.proto index ee38c1e2be8e7..db702c4d89474 100644 --- a/pkg/apis/application/v1alpha1/generated.proto +++ b/pkg/apis/application/v1alpha1/generated.proto @@ -145,6 +145,8 @@ message Repository { optional string username = 2; optional string password = 3; + + optional string sshPrivateKey = 4; } // RepositoryList is a collection of Repositories. diff --git a/pkg/apis/application/v1alpha1/types.go b/pkg/apis/application/v1alpha1/types.go index c0467fa67f1e3..20b7915a223ce 100644 --- a/pkg/apis/application/v1alpha1/types.go +++ b/pkg/apis/application/v1alpha1/types.go @@ -162,9 +162,10 @@ type TLSClientConfig struct { // Repository is a Git repository holding application configurations type Repository struct { - Repo string `json:"repo" protobuf:"bytes,1,opt,name=repo"` - Username string `json:"username" protobuf:"bytes,2,opt,name=username"` - Password string `json:"password" protobuf:"bytes,3,opt,name=password"` + Repo string `json:"repo" protobuf:"bytes,1,opt,name=repo"` + Username string `json:"username" protobuf:"bytes,2,opt,name=username"` + Password string `json:"password" protobuf:"bytes,3,opt,name=password"` + SSHPrivateKey string `json:"sshPrivateKey" protobuf:"bytes,4,opt,name=sshPrivateKey"` } // RepositoryList is a collection of Repositories. diff --git a/reposerver/repository/repository.go b/reposerver/repository/repository.go index aa5f9a7192bea..95a9bbb97a94e 100644 --- a/reposerver/repository/repository.go +++ b/reposerver/repository/repository.go @@ -39,7 +39,7 @@ func (s *Service) GenerateManifest(c context.Context, q *ManifestRequest) (*Mani s.repoLock.Lock(appRepoPath) defer s.repoLock.Unlock(appRepoPath) - err := s.gitClient.CloneOrFetch(q.Repo.Repo, q.Repo.Username, q.Repo.Password, appRepoPath) + err := s.gitClient.CloneOrFetch(q.Repo.Repo, q.Repo.Username, q.Repo.Password, q.Repo.SSHPrivateKey, appRepoPath) if err != nil { return nil, err } diff --git a/server/repository/repository.go b/server/repository/repository.go index 0ea628399a5e0..c28fb9e4ee15b 100644 --- a/server/repository/repository.go +++ b/server/repository/repository.go @@ -64,7 +64,7 @@ func (s *Server) Create(ctx context.Context, r *appsv1.Repository) (*appsv1.Repo shallowCopy := *r r = &shallowCopy r.Repo = git.NormalizeGitURL(r.Repo) - err := git.TestRepo(r.Repo, r.Username, r.Password) + err := git.TestRepo(r.Repo, r.Username, r.Password, r.SSHPrivateKey) if err != nil { return nil, err } @@ -111,7 +111,7 @@ func (s *Server) Get(ctx context.Context, q *RepoQuery) (*appsv1.Repository, err // Update updates a repository func (s *Server) Update(ctx context.Context, r *appsv1.Repository) (*appsv1.Repository, error) { - err := git.TestRepo(r.Repo, r.Username, r.Password) + err := git.TestRepo(r.Repo, r.Username, r.Password, r.SSHPrivateKey) if err != nil { return nil, err } @@ -152,17 +152,19 @@ func repoURLToSecretName(repo string) string { // repoToStringData converts a repository object to string data for serialization to a secret func repoToStringData(r *appsv1.Repository) map[string]string { return map[string]string{ - "repository": r.Repo, - "username": r.Username, - "password": r.Password, + "repository": r.Repo, + "username": r.Username, + "password": r.Password, + "sshPrivateKey": r.SSHPrivateKey, } } // secretToRepo converts a secret into a repository object func secretToRepo(s *apiv1.Secret) *appsv1.Repository { return &appsv1.Repository{ - Repo: string(s.Data["repository"]), - Username: string(s.Data["username"]), - Password: string(s.Data["password"]), + Repo: string(s.Data["repository"]), + Username: string(s.Data["username"]), + Password: string(s.Data["password"]), + SSHPrivateKey: string(s.Data["sshPrivateKey"]), } } diff --git a/test/e2e/fixture.go b/test/e2e/fixture.go index 0497655363a40..0eb447fb1f8e0 100644 --- a/test/e2e/fixture.go +++ b/test/e2e/fixture.go @@ -185,7 +185,7 @@ func PollUntil(t *testing.T, condition wait.ConditionFunc) { type FakeGitClient struct { } -func (c *FakeGitClient) CloneOrFetch(repo string, username string, password string, repoPath string) error { +func (c *FakeGitClient) CloneOrFetch(repo string, username string, password string, sshPrivateKey string, repoPath string) error { _, err := exec.Command("rm", "-rf", repoPath).Output() if err != nil { return err diff --git a/util/git/client.go b/util/git/client.go index 12b23e23401e6..a8ee5fdcbbd50 100644 --- a/util/git/client.go +++ b/util/git/client.go @@ -3,7 +3,6 @@ package git import ( "fmt" "io/ioutil" - "net/url" "os" "os/exec" @@ -12,7 +11,7 @@ import ( // Client is a generic git client interface type Client interface { - CloneOrFetch(url string, username string, password string, repoPath string) error + CloneOrFetch(url string, username string, password string, sshPrivateKey string, repoPath string) error Checkout(repoPath string, sha string) error } @@ -22,7 +21,7 @@ type NativeGitClient struct { } // CloneOrFetch either clone or fetch repository into specified directory path. -func (m *NativeGitClient) CloneOrFetch(repo string, username string, password string, repoPath string) error { +func (m *NativeGitClient) CloneOrFetch(repo string, username string, password string, sshPrivateKey string, repoPath string) error { var needClone bool if _, err := os.Stat(repoPath); os.IsNotExist(err) { needClone = true @@ -32,22 +31,24 @@ func (m *NativeGitClient) CloneOrFetch(repo string, username string, password st _, err = cmd.Output() needClone = err != nil } + if needClone { _, err := exec.Command("rm", "-rf", repoPath).Output() if err != nil { return fmt.Errorf("unable to clean repo cache at %s: %v", repoPath, err) } - repoURL, err := url.ParseRequestURI(repo) + repoURL, env, err := GetGitCommandEnvAndURL(repo, username, password, sshPrivateKey) if err != nil { return err } - repoURLNoPassword := repoURL.String() - log.Infof("Cloning %s to %s", repoURLNoPassword, repoPath) - repoURL.User = url.UserPassword(username, password) - _, err = exec.Command("git", "clone", repoURL.String(), repoPath).Output() + + log.Infof("Cloning %s to %s", repo, repoPath) + cmd := exec.Command("git", "clone", repoURL, repoPath) + cmd.Env = env + _, err = cmd.Output() if err != nil { - return fmt.Errorf("unable to clone repository %s: %v", repoURLNoPassword, err) + return fmt.Errorf("unable to clone repository %s: %v", repo, err) } } else { log.Infof("Fetching %s", repo) diff --git a/util/git/git.go b/util/git/git.go index caa51d39acbea..4e59e7942aad9 100644 --- a/util/git/git.go +++ b/util/git/git.go @@ -2,6 +2,7 @@ package git import ( "fmt" + "io/ioutil" "net/url" "os" "os/exec" @@ -11,20 +12,59 @@ import ( // NormalizeGitURL normalizes a git URL for lookup and storage func NormalizeGitURL(repo string) string { - repoURL, _ := url.Parse(repo) + repoURL, err := url.Parse(repo) + if err != nil { + return strings.ToLower(repo) + } return repoURL.String() } +// IsSshURL returns true is supplied URL is SSH URL +func IsSshURL(url string) bool { + return strings.Index(url, "git@") == 0 +} + +// GetGitCommandOptions returns URL and env options for git operation +func GetGitCommandEnvAndURL(repo, username, password string, sshPrivateKey string) (string, []string, error) { + cmdURL := repo + env := os.Environ() + if IsSshURL(repo) { + if sshPrivateKey != "" { + sshFile, err := ioutil.TempFile("", "") + if err != nil { + return "", nil, err + } + _, err = sshFile.WriteString(sshPrivateKey) + if err != nil { + return "", nil, err + } + err = sshFile.Close() + if err != nil { + return "", nil, err + } + env = append(env, fmt.Sprintf("GIT_SSH_COMMAND=ssh -i %s", sshFile.Name())) + } + } else { + env = append(env, "GIT_ASKPASS=") + repoURL, err := url.ParseRequestURI(repo) + if err != nil { + return "", nil, err + } + + repoURL.User = url.UserPassword(username, password) + cmdURL = repoURL.String() + } + return cmdURL, env, nil +} + // TestRepo tests if a repo exists and is accessible with the given credentials -func TestRepo(repo, username, password string) error { - repoURL, err := url.ParseRequestURI(repo) +func TestRepo(repo, username, password string, sshPrivateKey string) error { + repo, env, err := GetGitCommandEnvAndURL(repo, username, password, sshPrivateKey) if err != nil { return err } - repoURL.User = url.UserPassword(username, password) - cmd := exec.Command("git", "ls-remote", repoURL.String(), "HEAD") - env := os.Environ() - env = append(env, "GIT_ASKPASS=") + cmd := exec.Command("git", "ls-remote", repo, "HEAD") + cmd.Env = env _, err = cmd.Output() if err != nil { diff --git a/util/git/git_test.go b/util/git/git_test.go new file mode 100644 index 0000000000000..bc68fdca1ac07 --- /dev/null +++ b/util/git/git_test.go @@ -0,0 +1,19 @@ +package git + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestReturnsTrueForSSHUrl(t *testing.T) { + assert.True(t, IsSshURL("git@github.com:test.git")) +} + +func TestReturnsFalseForNonSSHUrl(t *testing.T) { + assert.False(t, IsSshURL("https://github.com/test.git")) +} + +func TestNormalizeUrl(t *testing.T) { + assert.Equal(t, NormalizeGitURL("git@GITHUB.com:test.git"), "git@github.com:test.git") +} diff --git a/util/git/mocks/Client.go b/util/git/mocks/Client.go index aa103b612b122..b3c3eacc1f5e7 100644 --- a/util/git/mocks/Client.go +++ b/util/git/mocks/Client.go @@ -22,13 +22,13 @@ func (_m *Client) Checkout(repoPath string, sha string) error { return r0 } -// CloneOrFetch provides a mock function with given fields: url, username, password, repoPath -func (_m *Client) CloneOrFetch(url string, username string, password string, repoPath string) error { - ret := _m.Called(url, username, password, repoPath) +// CloneOrFetch provides a mock function with given fields: url, username, password, sshPrivateKey, repoPath +func (_m *Client) CloneOrFetch(url string, username string, password string, sshPrivateKey string, repoPath string) error { + ret := _m.Called(url, username, password, sshPrivateKey, repoPath) var r0 error - if rf, ok := ret.Get(0).(func(string, string, string, string) error); ok { - r0 = rf(url, username, password, repoPath) + if rf, ok := ret.Get(0).(func(string, string, string, string, string) error); ok { + r0 = rf(url, username, password, sshPrivateKey, repoPath) } else { r0 = ret.Error(0) }