@@ -6,23 +6,28 @@ use stackable_operator::{
66 } ,
77} ;
88
9- use crate :: data:: container ;
9+ use crate :: data:: containers ;
1010
1111/// Copies the resources of the container named "secret-operator-deployer" from `source`
12- /// to the container "secret-operator" in `target`.
13- /// Does nothing if there are no resources or if the `target` is not a DaemonSet.
12+ /// to *all* containers in `target`.
13+ /// Does nothing if there are no resources or if the `target` is not a DaemonSet or a Deployment.
14+ /// This function allows OLM Subscription objects to configure the resources
15+ /// of operator containers.
1416pub ( super ) fn maybe_copy_resources (
1517 source : & Deployment ,
1618 target : & mut DynamicObject ,
1719 target_gvk : & GroupVersionKind ,
1820) -> anyhow:: Result < ( ) > {
19- if target_gvk. kind == "DaemonSet" {
21+ let target_kind_set = [ "DaemonSet" , "Deployment" ] ;
22+ if target_kind_set. contains ( & target_gvk. kind . as_str ( ) ) {
2023 if let Some ( res) = deployment_resources ( source) {
21- match container ( target, "secret-operator" ) ? {
22- serde_json:: Value :: Object ( c) => {
23- c. insert ( "resources" . to_string ( ) , serde_json:: json!( res) ) ;
24+ for container in containers ( target) ? {
25+ match container {
26+ serde_json:: Value :: Object ( c) => {
27+ c. insert ( "resources" . to_string ( ) , serde_json:: json!( res) ) ;
28+ }
29+ _ => anyhow:: bail!( "no containers found in object {}" , target. name_any( ) ) ,
2430 }
25- _ => anyhow:: bail!( "no containers found in object {}" , target. name_any( ) ) ,
2631 }
2732 }
2833 }
@@ -150,7 +155,9 @@ spec:
150155 ..ResourceRequirements :: default ( )
151156 } ) ;
152157 assert_eq ! (
153- container( & mut daemonset, "secret-operator" ) ?
158+ containers( & mut daemonset) ?
159+ . first( )
160+ . expect( "daemonset has no containers" )
154161 . get( "resources" )
155162 . unwrap( ) ,
156163 & expected
0 commit comments