-
Notifications
You must be signed in to change notification settings - Fork 90
/
secrets_objects.go
137 lines (121 loc) · 3.11 KB
/
secrets_objects.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package kotsadm
import (
"fmt"
"github.com/google/uuid"
"github.com/replicatedhq/kots/pkg/kotsadm/types"
kotsadmversion "github.com/replicatedhq/kots/pkg/kotsadm/version"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func JwtSecret(namespace string, jwt string) *corev1.Secret {
if jwt == "" {
jwt = uuid.New().String()
}
secret := &corev1.Secret{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Secret",
},
ObjectMeta: metav1.ObjectMeta{
Name: "kotsadm-session",
Namespace: namespace,
Labels: types.GetKotsadmLabels(),
},
Data: map[string][]byte{
"key": []byte(jwt),
},
}
return secret
}
func PgSecret(namespace string, password string) *corev1.Secret {
if password == "" {
password = uuid.New().String()
}
secret := &corev1.Secret{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Secret",
},
ObjectMeta: metav1.ObjectMeta{
Name: "kotsadm-postgres",
Namespace: namespace,
Labels: types.GetKotsadmLabels(),
},
Data: map[string][]byte{
"uri": []byte(fmt.Sprintf("postgresql://kotsadm:%s@kotsadm-postgres/kotsadm?connect_timeout=10&sslmode=disable", password)),
"password": []byte(password),
},
}
return secret
}
func SharedPasswordSecret(namespace string, bcryptPassword string) *corev1.Secret {
secret := &corev1.Secret{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Secret",
},
ObjectMeta: metav1.ObjectMeta{
Name: "kotsadm-password",
Namespace: namespace,
Labels: types.GetKotsadmLabels(),
},
Data: map[string][]byte{
"passwordBcrypt": []byte(bcryptPassword),
},
}
return secret
}
func S3Secret(namespace string, accessKey string, secretKey string) *corev1.Secret {
secret := &corev1.Secret{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Secret",
},
ObjectMeta: metav1.ObjectMeta{
Name: "kotsadm-minio",
Namespace: namespace,
Labels: types.GetKotsadmLabels(),
},
Data: map[string][]byte{
"accesskey": []byte(accessKey),
"secretkey": []byte(secretKey),
},
}
return secret
}
func ApiEncryptionKeySecret(namespace string, key string) *corev1.Secret {
secret := &corev1.Secret{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Secret",
},
ObjectMeta: metav1.ObjectMeta{
Name: "kotsadm-encryption",
Namespace: namespace,
Labels: types.GetKotsadmLabels(),
},
Data: map[string][]byte{
"encryptionKey": []byte(key),
},
}
return secret
}
func ApiClusterTokenSecret(deployOptions types.DeployOptions) *corev1.Secret {
return &corev1.Secret{
TypeMeta: metav1.TypeMeta{
Kind: "Secret",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: deployOptions.Namespace,
Name: types.ClusterTokenSecret,
Labels: types.GetKotsadmLabels(),
},
StringData: map[string]string{
types.ClusterTokenSecret: deployOptions.AutoCreateClusterToken,
},
}
}
func PrivateKotsadmRegistrySecret(namespace string, kotsadmOptions types.KotsadmOptions) *corev1.Secret {
return kotsadmversion.KotsadmPullSecret(namespace, kotsadmOptions)
}