-
Notifications
You must be signed in to change notification settings - Fork 786
/
secrets.go
38 lines (35 loc) · 1.24 KB
/
secrets.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
package testkube
import (
"github.com/jenkins-x/jx/v2/pkg/gits"
"github.com/jenkins-x/jx/v2/pkg/kube"
"github.com/jenkins-x/jx/v2/pkg/kube/naming"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// CreateTestPipelineGitSecret creates a test git pipeline credential secret
func CreateTestPipelineGitSecret(gitServiceKind string, name string, gitUrl string, username string, password string) corev1.Secret {
return corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: naming.ToValidName(name),
Namespace: "jx",
Annotations: map[string]string{
kube.AnnotationURL: gitUrl,
kube.AnnotationName: name,
},
Labels: map[string]string{
kube.LabelKind: kube.ValueKindGit,
kube.LabelCredentialsType: kube.ValueCredentialTypeUsernamePassword,
kube.LabelServiceKind: gitServiceKind,
},
},
Data: map[string][]byte{
kube.SecretDataUsername: []byte(username),
kube.SecretDataPassword: []byte(password),
},
}
}
// CreateFakeGitSecret creates a Secret for connecting to the fake git provider
func CreateFakeGitSecret() *corev1.Secret {
secret := CreateTestPipelineGitSecret(gits.KindGitFake, "jx-pipeline-git-fake", gits.FakeGitURL, "fakeuser", "fakepwd")
return &secret
}