File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed
rust/stackable-cockpit/src/utils/k8s Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -151,30 +151,30 @@ impl Client {
151151 {
152152 object. metadata . resource_version = existing_object. resource_version ( ) ;
153153
154- match api
154+ api
155155 . patch (
156156 & object. name_any ( ) ,
157157 & PatchParams :: apply ( "stackablectl" ) ,
158158 & Patch :: Merge ( object. clone ( ) ) ,
159159 )
160160 . await
161- {
162- Ok ( result) => result,
163- Err ( e) => {
161+ . or_else ( |e| {
164162 // If re-applying a Job fails due to immutability, print out the failed manifests instead of erroring out,
165163 // so the user can decide if the existing Job needs a deletion and recreation
166- if resource. kind == * "Job" && e. to_string ( ) . contains ( "field is immutable" ) {
167- indicatif_eprintln ! (
168- "Deploying {kind}/{object_name} manifest failed due to immutability" ,
169- kind = resource. kind,
170- object_name = object. name_any( ) . clone( )
171- ) ;
172- object
173- } else {
174- return Err ( e) . context ( KubeClientPatchSnafu ) ;
164+ match ( resource. kind . as_ref ( ) , e) {
165+ ( "Job" , kube:: Error :: Api ( e) ) if e. message . contains ( "field is immutable" ) => {
166+ indicatif_eprintln ! (
167+ "Deploying {kind}/{object_name} manifest failed due to immutability" ,
168+ kind = resource. kind,
169+ object_name = object. name_any( ) . clone( )
170+ ) ;
171+ Ok ( object)
172+ }
173+ ( _, e) => {
174+ Err ( e) . context ( KubeClientPatchSnafu )
175+ }
175176 }
176- }
177- } ;
177+ } ) ?;
178178 } else {
179179 api. patch (
180180 & object. name_any ( ) ,
You can’t perform that action at this time.
0 commit comments