@@ -60,22 +60,28 @@ private static V1Service addHash(V1Service service) {
60
60
return service ;
61
61
}
62
62
63
+ static String getHash (V1Pod pod ) {
64
+ return getAnnotation (pod .getMetadata (), AnnotationHelper ::getSha256Annotation );
65
+ }
66
+
67
+ static String getHash (V1Service service ) {
68
+ return getAnnotation (service .getMetadata (), AnnotationHelper ::getSha256Annotation );
69
+ }
70
+
63
71
static String getDebugString (V1Pod pod ) {
64
- return pod .getMetadata (). getAnnotations (). get ( HASHED_STRING );
72
+ return getAnnotation ( pod .getMetadata (), AnnotationHelper :: getDebugHashAnnotation );
65
73
}
66
74
67
- static String getHash (V1Pod pod ) {
68
- return Optional .ofNullable (pod .getMetadata ())
75
+ private static String getAnnotation (
76
+ V1ObjectMeta metadata , Function <Map <String , String >, String > annotationGetter ) {
77
+ return Optional .ofNullable (metadata )
69
78
.map (V1ObjectMeta ::getAnnotations )
70
- .map (AnnotationHelper :: getSha256Annotation )
79
+ .map (annotationGetter )
71
80
.orElse ("" );
72
81
}
73
82
74
- static String getHash (V1Service service ) {
75
- return Optional .ofNullable (service .getMetadata ())
76
- .map (V1ObjectMeta ::getAnnotations )
77
- .map (AnnotationHelper ::getSha256Annotation )
78
- .orElse ("" );
83
+ private static String getDebugHashAnnotation (Map <String , String > annotations ) {
84
+ return annotations .get (HASHED_STRING );
79
85
}
80
86
81
87
private static String getSha256Annotation (Map <String , String > annotations ) {
0 commit comments