Skip to content

Commit a9c0d13

Browse files
WIP
Signed-off-by: James Milligan <[email protected]>
1 parent 3b956ea commit a9c0d13

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ package main
1818

1919
import (
2020
"flag"
21+
"os"
22+
2123
corev1 "k8s.io/api/core/v1"
2224
"k8s.io/apimachinery/pkg/api/resource"
23-
"os"
2425

2526
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
2627
// to ensure that exec-entrypoint and run can make use of them.
@@ -166,7 +167,7 @@ func main() {
166167

167168
//+kubebuilder:scaffold:builder
168169
hookServer := mgr.GetWebhookServer()
169-
hookServer.Register("/mutate-v1-pod", &webhook.Admission{Handler: &webhooks.PodMutator{
170+
podMutator := &webhooks.PodMutator{
170171
FlagDResourceRequirements: corev1.ResourceRequirements{
171172
Limits: map[corev1.ResourceName]resource.Quantity{
172173
corev1.ResourceCPU: flagDCpuLimitResource,
@@ -179,7 +180,11 @@ func main() {
179180
},
180181
Client: mgr.GetClient(),
181182
Log: ctrl.Log.WithName("mutating-pod-webhook"),
182-
}})
183+
}
184+
podMutator.BackfillPermissions()
185+
hookServer.Register("/mutate-v1-pod", &webhook.Admission{
186+
Handler: podMutator,
187+
})
183188
hookServer.Register("/validate-v1alpha1-featureflagconfiguration", &webhook.Admission{Handler: &webhooks.FeatureFlagConfigurationValidator{
184189
Client: mgr.GetClient(),
185190
Log: ctrl.Log.WithName("validating-featureflagconfiguration-webhook"),

webhooks/pod_webhook.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ type PodMutator struct {
4242
Log logr.Logger
4343
}
4444

45+
func (m *PodMutator) BackfillPermissions() {
46+
podList := &corev1.PodList{}
47+
err := m.Client.List(context.Background(), podList, client.MatchingLabels{"somelabel": "someval"})
48+
}
49+
4550
// Handle injects the flagd sidecar (if the prerequisites are all met)
4651
func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admission.Response {
4752
defer func() {

0 commit comments

Comments
 (0)