Skip to content

Commit 29b8f4e

Browse files
committed
[TEST] adding print
1 parent c3480a9 commit 29b8f4e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

vault.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func addVault(pod *corev1.Pod, namespace string, databases []database) (patch []
2424
initContainers := []corev1.Container{}
2525
for _, databaseInfo := range databases {
2626

27+
//* These are fields from the CRD!
2728
database := databaseInfo.database
2829
role := databaseInfo.role
2930
serviceAccount := pod.Spec.ServiceAccountName
@@ -52,7 +53,7 @@ func addVault(pod *corev1.Pod, namespace string, databases []database) (patch []
5253

5354
vaultContainer := corev1.Container{
5455
Image: sidecarImage,
55-
ImagePullPolicy: "Always",
56+
ImagePullPolicy: "Always", // TODO: Change to IfNotPresent? https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy
5657
Resources: corev1.ResourceRequirements{
5758
Requests: requests,
5859
Limits: limits,
@@ -102,6 +103,7 @@ func addVault(pod *corev1.Pod, namespace string, databases []database) (patch []
102103
},
103104
}
104105

106+
// TODO: remember not to have preStop hook in the init container.
105107
initContainer := vaultContainer
106108

107109
jobLikeOwnerReferencesKinds := map[string]bool{"Job": true, "Workflow": true}

webhook.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func (srv webHookServer) serve(w http.ResponseWriter, r *http.Request) {
9999

100100
}
101101

102+
// This handles the admission review sent by k8s and mutates the pod
102103
func (srv webHookServer) mutate(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
103104
req := ar.Request
104105

@@ -121,7 +122,9 @@ func (srv webHookServer) mutate(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionR
121122
log.Infof("AdmissionReview for Kind=%v, Namespace=%v Name=%v UID=%v patchOperation=%v UserInfo=%v",
122123
ownerKind, req.Namespace, ownerName, req.UID, req.Operation, req.UserInfo)
123124

125+
// 'binds' is the list of database credential bindings
124126
binds, err := srv.bindings.List()
127+
log.Info(" -----> Database bindings: %+v", binds)
125128
if err != nil {
126129
return &v1beta1.AdmissionResponse{
127130
Result: &metav1.Status{
@@ -138,6 +141,7 @@ func (srv webHookServer) mutate(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionR
138141
}
139142
}
140143

144+
// TODO: This is were we build database bindings for the pod
141145
databases := matchBindings(filteredBindings, pod.Spec.ServiceAccountName)
142146
if len(databases) == 0 {
143147
log.Infof("Skipping mutation for %s/%s due to policy check", req.Namespace, ownerName)
@@ -176,6 +180,7 @@ func filterBindings(bindings []v1alpha1.DatabaseCredentialBinding, namespace str
176180
return filteredBindings
177181
}
178182

183+
// TODO: This is were we build database bindings for the pod
179184
func matchBindings(bindings []v1alpha1.DatabaseCredentialBinding, serviceAccount string) []database {
180185
matchedBindings := []database{}
181186
for _, binding := range bindings {

0 commit comments

Comments
 (0)