-
Notifications
You must be signed in to change notification settings - Fork 5k
/
repos.go
73 lines (65 loc) · 2.08 KB
/
repos.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package repos
import (
"path/filepath"
"github.com/argoproj/argo-cd/errors"
"github.com/argoproj/argo-cd/test/e2e/fixture"
)
var (
CertPath = mustToAbsPath("../fixture/certs/argocd-test-client.crt")
CertKeyPath = mustToAbsPath("../fixture/certs/argocd-test-client.key")
)
func mustToAbsPath(relativePath string) string {
res, err := filepath.Abs(relativePath)
errors.CheckError(err)
return res
}
// sets the current repo as the default SSH test repo
func AddSSHRepo(insecure bool) {
keyPath, err := filepath.Abs("../fixture/testrepos/id_rsa")
errors.CheckError(err)
args := []string{"repo", "add", fixture.RepoURL(fixture.RepoURLTypeSSH), "--ssh-private-key-path", keyPath}
if insecure {
args = append(args, "--insecure-ignore-host-key")
}
errors.FailOnErr(fixture.RunCli(args...))
}
// sets the current repo as the default HTTPS test repo
func AddHTTPSRepo(insecure bool) {
// This construct is somewhat necessary to satisfy the compiler
var repoURLType fixture.RepoURLType = fixture.RepoURLTypeHTTPS
args := []string{"repo", "add", fixture.RepoURL(repoURLType), "--username", fixture.GitUsername, "--password", fixture.GitPassword}
if insecure {
args = append(args, "--insecure-skip-server-verification")
}
errors.FailOnErr(fixture.RunCli(args...))
}
// sets a HTTPS repo using TLS client certificate authentication
func AddHTTPSRepoClientCert(insecure bool) {
args := []string{
"repo",
"add",
fixture.RepoURL(fixture.RepoURLTypeHTTPSClientCert),
"--username", fixture.GitUsername,
"--password", fixture.GitPassword,
"--tls-client-cert-path", CertPath,
"--tls-client-cert-key-path", CertKeyPath,
}
if insecure {
args = append(args, "--insecure-skip-server-verification")
}
errors.FailOnErr(fixture.RunCli(args...))
}
func AddHelmRepo(name string) {
args := []string{
"repo",
"add",
fixture.RepoURL(fixture.RepoURLTypeHelm),
"--username", fixture.GitUsername,
"--password", fixture.GitPassword,
"--tls-client-cert-path", CertPath,
"--tls-client-cert-key-path", CertKeyPath,
"--type", "helm",
"--name", name,
}
errors.FailOnErr(fixture.RunCli(args...))
}