1
1
package io .javaoperatorsdk .operator .processing .event ;
2
2
3
- import java .io .ByteArrayInputStream ;
4
- import java .io .IOException ;
5
- import java .nio .charset .StandardCharsets ;
6
-
7
3
import org .slf4j .Logger ;
8
4
import org .slf4j .LoggerFactory ;
9
5
14
10
import io .fabric8 .kubernetes .client .dsl .MixedOperation ;
15
11
import io .fabric8 .kubernetes .client .dsl .Resource ;
16
12
import io .fabric8 .kubernetes .client .dsl .internal .HasMetadataOperationsImpl ;
17
- import io .fabric8 .kubernetes .client .utils .Serialization ;
18
13
import io .javaoperatorsdk .operator .OperatorException ;
19
14
import io .javaoperatorsdk .operator .api .ObservedGenerationAware ;
20
15
import io .javaoperatorsdk .operator .api .config .ConfigurationServiceProvider ;
@@ -372,9 +367,9 @@ public R replaceResourceWithLock(R resource) {
372
367
resource .getMetadata ().getResourceVersion ());
373
368
return resourceOperation
374
369
.inNamespace (resource .getMetadata ().getNamespace ())
375
- .withName ( getName ( resource ) )
370
+ .resource ( resource )
376
371
.lockResourceVersion (resource .getMetadata ().getResourceVersion ())
377
- .replace (resource );
372
+ .replace ();
378
373
}
379
374
380
375
@ SuppressWarnings ({"rawtypes" , "unchecked" })
@@ -393,15 +388,11 @@ public R patchStatus(R resource, R originalResource) {
393
388
// don't do optimistic locking on patch
394
389
originalResource .getMetadata ().setResourceVersion (null );
395
390
resource .getMetadata ().setResourceVersion (null );
396
- try (var bis = new ByteArrayInputStream (
397
- Serialization .asJson (originalResource ).getBytes (StandardCharsets .UTF_8 ))) {
391
+ try {
398
392
return resourceOperation
399
393
.inNamespace (resource .getMetadata ().getNamespace ())
400
- // will be simplified in fabric8 v6
401
- .load (bis )
394
+ .resource (originalResource )
402
395
.editStatus (r -> resource );
403
- } catch (IOException e ) {
404
- throw new IllegalStateException (e );
405
396
} finally {
406
397
// restore initial resource version
407
398
originalResource .getMetadata ().setResourceVersion (resourceVersion );
0 commit comments