Skip to content

Commit

Permalink
fix: handle nil maps in flagd-standalone
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
  • Loading branch information
toddbaert committed Jul 17, 2024
1 parent c6ccfc1 commit 952e628
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions controllers/core/flagd/resources/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ func (r *FlagdDeployment) GetResource(ctx context.Context, flagd *api.Flagd) (cl
// override settings for the injected container for flagd standalone deployment mode
deployment.Spec.Template.Spec.ImagePullSecrets = imagePullSecrets
if len(r.FlagdConfig.Labels) > 0 {
if deployment.Spec.Template.ObjectMeta.Labels == nil {
deployment.Spec.Template.ObjectMeta.Labels = map[string]string{}
}
maps.Copy(deployment.Spec.Template.ObjectMeta.Labels, r.FlagdConfig.Labels)
}
if len(r.FlagdConfig.Annotations) > 0 {
if deployment.Spec.Template.ObjectMeta.Annotations == nil {
deployment.Spec.Template.ObjectMeta.Annotations = map[string]string{}
}
maps.Copy(deployment.Spec.Template.ObjectMeta.Annotations, r.FlagdConfig.Annotations)
}
deployment.Spec.Template.Spec.Containers[0].Image = fmt.Sprintf("%s:%s", r.FlagdConfig.Image, r.FlagdConfig.Tag)
Expand Down

0 comments on commit 952e628

Please sign in to comment.