@@ -62,6 +62,8 @@ struct OlmDeployerRun {
6262 help = "Name of ClusterServiceVersion object that owns this Deployment."
6363 ) ]
6464 csv : String ,
65+ #[ arg( long, short, help = "Name of deployment object that owns this Pod." ) ]
66+ deployer : String ,
6567 #[ arg( long, short, help = "Namespace of the ClusterServiceVersion object." ) ]
6668 namespace : String ,
6769 #[ arg( long, short, help = "Directory with manifests to patch and apply." ) ]
@@ -79,6 +81,7 @@ async fn main() -> Result<()> {
7981 if let Command :: Run ( OlmDeployerRun {
8082 keep_alive,
8183 csv,
84+ deployer,
8285 namespace,
8386 dir,
8487 tracing_target,
@@ -98,7 +101,7 @@ async fn main() -> Result<()> {
98101 let client =
99102 client:: initialize_operator ( Some ( APP_NAME . to_string ( ) ) , & cluster_info_opts) . await ?;
100103
101- let deployment = get_deployment ( & csv, & namespace, & client) . await ?;
104+ let deployment = get_deployment ( & csv, & deployer , & namespace, & client) . await ?;
102105 let cluster_role = get_cluster_role ( & csv, & client) . await ?;
103106
104107 let kube_client = client. as_kube_client ( ) ;
@@ -204,7 +207,12 @@ async fn get_cluster_role(csv: &str, client: &client::Client) -> Result<ClusterR
204207 }
205208}
206209
207- async fn get_deployment ( csv : & str , namespace : & str , client : & client:: Client ) -> Result < Deployment > {
210+ async fn get_deployment (
211+ csv : & str ,
212+ deployer : & str ,
213+ namespace : & str ,
214+ client : & client:: Client ,
215+ ) -> Result < Deployment > {
208216 let labels = format ! ( "olm.owner={csv},olm.owner.kind=ClusterServiceVersion" ) ;
209217 let lp = ListParams {
210218 label_selector : Some ( labels. clone ( ) ) ,
@@ -216,7 +224,9 @@ async fn get_deployment(csv: &str, namespace: &str, client: &client::Client) ->
216224
217225 match result. len ( ) {
218226 0 => bail ! ( "no deployment owned by the csv {csv} found in namespace {namespace}" ) ,
219- 1 => Ok ( result. first ( ) . unwrap ( ) . clone ( ) ) ,
220- _ => bail ! ( "multiple deployments owned by the csv {csv} found but only one was expected" ) ,
227+ _ => Ok ( result
228+ . into_iter ( )
229+ . find ( |d| d. name_any ( ) == deployer)
230+ . context ( format ! ( "no deployment named {deployer} found" ) ) ?) ,
221231 }
222232}
0 commit comments