File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
csidrivercontrollerservicecontroller
csidrivernodeservicecontroller Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,25 @@ func WithCABundleDeploymentHook(
102102 }
103103}
104104
105+ // WithConfigMapHashAnnotationHook creates a deployment hook that annotates a Deployment with a config map's hash.
106+ func WithConfigMapHashAnnotationHook (
107+ namespace string ,
108+ configMapName string ,
109+ configMapInformer corev1.ConfigMapInformer ,
110+ ) dc.DeploymentHookFunc {
111+ return func (opSpec * opv1.OperatorSpec , deployment * appsv1.Deployment ) error {
112+ inputHashes , err := resourcehash .MultipleObjectHashStringMapForObjectReferenceFromLister (
113+ configMapInformer .Lister (),
114+ nil ,
115+ resourcehash .NewObjectRef ().ForConfigMap ().InNamespace (namespace ).Named (configMapName ),
116+ )
117+ if err != nil {
118+ return fmt .Errorf ("invalid dependency reference: %w" , err )
119+ }
120+ return addObjectHash (deployment , inputHashes )
121+ }
122+ }
123+
105124// WithSecretHashAnnotationHook creates a deployment hook that annotates a Deployment with a secret's hash.
106125func WithSecretHashAnnotationHook (
107126 namespace string ,
Original file line number Diff line number Diff line change @@ -74,6 +74,26 @@ func WithCABundleDaemonSetHook(
7474 }
7575}
7676
77+ // WithConfigMapHashAnnotationHook creates a DaemonSet hook that annotates a DaemonSet with a config map's hash.
78+ func WithConfigMapHashAnnotationHook (
79+ namespace string ,
80+ configMapName string ,
81+ configMapInformer corev1.ConfigMapInformer ,
82+ ) DaemonSetHookFunc {
83+ return func (_ * opv1.OperatorSpec , ds * appsv1.DaemonSet ) error {
84+ inputHashes , err := resourcehash .MultipleObjectHashStringMapForObjectReferenceFromLister (
85+ configMapInformer .Lister (),
86+ nil ,
87+ resourcehash .NewObjectRef ().ForConfigMap ().InNamespace (namespace ).Named (configMapName ),
88+ )
89+ if err != nil {
90+ return fmt .Errorf ("invalid dependency reference: %w" , err )
91+ }
92+
93+ return addObjectHash (ds , inputHashes )
94+ }
95+ }
96+
7797// WithSecretHashAnnotationHook creates a DaemonSet hook that annotates a DaemonSet with a secret's hash.
7898func WithSecretHashAnnotationHook (
7999 namespace string ,
You can’t perform that action at this time.
0 commit comments