@@ -10,7 +10,7 @@ import (
1010 api "github.com/open-feature/open-feature-operator/apis/core/v1beta1"
1111 "github.com/open-feature/open-feature-operator/internal/common"
1212 "github.com/open-feature/open-feature-operator/internal/common/flagdinjector"
13- "github.com/open-feature/open-feature-operator/internal/controller/core/flagd/common"
13+ resources "github.com/open-feature/open-feature-operator/internal/controller/core/flagd/common"
1414 "golang.org/x/exp/maps"
1515 appsv1 "k8s.io/api/apps/v1"
1616 corev1 "k8s.io/api/core/v1"
@@ -37,24 +37,49 @@ func (r *FlagdDeployment) AreObjectsEqual(o1 client.Object, o2 client.Object) bo
3737 return false
3838 }
3939
40- return reflect .DeepEqual (oldDeployment .Spec , newDeployment .Spec )
40+ return reflect .DeepEqual (oldDeployment .Spec , newDeployment .Spec ) && reflect . DeepEqual ( oldDeployment . ObjectMeta . Annotations , newDeployment . ObjectMeta . Annotations ) && reflect . DeepEqual ( oldDeployment . ObjectMeta . Labels , newDeployment . ObjectMeta . Labels )
4141}
4242
43- func (r * FlagdDeployment ) GetResource (ctx context.Context , flagd * api.Flagd ) (client.Object , error ) {
44- labels := map [string ]string {
43+ func (r * FlagdDeployment ) getLabels (flagd * api.Flagd ) map [string ]string {
44+ labels := map [string ]string {}
45+
46+ // FlagdConfig has lowest priority
47+ if len (r .FlagdConfig .Labels ) > 0 {
48+ maps .Copy (labels , r .FlagdConfig .Labels )
49+ }
50+
51+ // PodLabels have higher priority than FlagdConfig
52+ maps .Copy (labels , flagd .Spec .PodLabels )
53+
54+ // Default labels highest priority
55+ maps .Copy (labels , map [string ]string {
4556 "app" : flagd .Name ,
4657 "app.kubernetes.io/name" : flagd .Name ,
4758 "app.kubernetes.io/managed-by" : common .ManagedByAnnotationValue ,
4859 "app.kubernetes.io/version" : r .FlagdConfig .Tag ,
49- }
50- if len (r .FlagdConfig .Labels ) > 0 {
51- maps .Copy (labels , r .FlagdConfig .Labels )
52- }
53- // No "built-in" annotations to merge at this time. If adding them follow the same pattern as labels.
60+ })
61+
62+ return labels
63+ }
64+
65+ func (r * FlagdDeployment ) getAnnotations (flagd * api.Flagd ) map [string ]string {
5466 annotations := map [string ]string {}
67+
68+ // FlagdConfig has lowest priority
5569 if len (r .FlagdConfig .Annotations ) > 0 {
5670 maps .Copy (annotations , r .FlagdConfig .Annotations )
5771 }
72+
73+ // PodAnnotations have higher priority than FlagdConfig
74+ maps .Copy (annotations , flagd .Spec .PodAnnotations )
75+
76+ return annotations
77+ }
78+
79+ func (r * FlagdDeployment ) GetResource (ctx context.Context , flagd * api.Flagd ) (client.Object , error ) {
80+ labels := r .getLabels (flagd )
81+ annotations := r .getAnnotations (flagd )
82+
5883 deployment := & appsv1.Deployment {
5984 ObjectMeta : metav1.ObjectMeta {
6085 Name : flagd .Name ,
0 commit comments