-
Notifications
You must be signed in to change notification settings - Fork 15
/
secrets.go
32 lines (27 loc) · 957 Bytes
/
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
package resource
import (
"github.com/dev4devs-com/postgresql-operator/pkg/apis/postgresql/v1alpha1"
"github.com/dev4devs-com/postgresql-operator/pkg/utils"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)
//Returns the buildDatabaseSecret object for the Database Backup
func NewBackupSecret(bkp *v1alpha1.Backup, prefix string, secretData map[string][]byte, secretStringData map[string]string, scheme *runtime.Scheme) *corev1.Secret {
ls := utils.GetLabels(bkp.Name)
secret := &corev1.Secret{
ObjectMeta: v1.ObjectMeta{
Name: prefix + bkp.Name,
Namespace: bkp.Namespace,
Labels: ls,
},
Data: secretData,
Type: "Opaque",
}
if secretStringData != nil && len(secretStringData) > 0 {
secret.StringData = secretStringData
}
controllerutil.SetControllerReference(bkp, secret, scheme)
return secret
}