@@ -28,6 +28,7 @@ type PodMutator struct {
2828
2929// PodMutator adds an annotation to every incoming pods.
3030func (m * PodMutator ) Handle (ctx context.Context , req admission.Request ) admission.Response {
31+
3132 pod := & corev1.Pod {}
3233 m .Log .V (2 ).Info ("Handling pod %s/%s" , req .Namespace , req .Name )
3334 err := m .decoder .Decode (req , pod )
@@ -60,6 +61,7 @@ func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admissio
6061 }
6162 }
6263
64+ // TODO: this should be a short sha to avoid collisions
6365 configName := fmt .Sprintf ("%s-%s-config" , pod .Name , pod .Namespace )
6466 // Create the agent configmap
6567 m .Client .Delete (context .TODO (), & corev1.ConfigMap {
@@ -68,7 +70,7 @@ func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admissio
6870 Namespace : req .Namespace ,
6971 },
7072 }) // Delete the configmap if it exists
71- m .Log .V (1 ).Info ("Creating configmap %s/%s" , pod .Namespace , configName )
73+ m .Log .V (1 ).Info (fmt . Sprintf ( "Creating configmap %s/%s" , pod .Namespace , configName ) )
7274 if err := m .Client .Create (ctx , & corev1.ConfigMap {
7375 ObjectMeta : metav1.ObjectMeta {
7476 Name : configName ,
@@ -79,11 +81,11 @@ func (m *PodMutator) Handle(ctx context.Context, req admission.Request) admissio
7981 "config.yaml" : featureFlagCustomResource .Spec .FeatureFlagSpec ,
8082 },
8183 }); err != nil {
82- fmt .Printf ("failed to create config map %s" , configName )
84+ fmt .Printf (fmt . Sprintf ( "failed to create config map %s" , configName ) )
8385 return admission .Errored (http .StatusInternalServerError , err )
8486 }
8587
86- m .Log .V (1 ).Info ("Creating sidecar for pod %s/%s" , pod .Namespace , pod .Name )
88+ m .Log .V (1 ).Info (fmt . Sprintf ( "Creating sidecar for pod %s/%s" , pod .Namespace , pod .Name ) )
8789 // Inject the agent
8890 pod .Spec .Volumes = append (pod .Spec .Volumes , corev1.Volume {
8991 Name : "flagd-config" ,
0 commit comments