Skip to content

Commit 4e028e7

Browse files
committed
porting missing class from master branch
Signed-off-by: Min Jin <[email protected]>
1 parent d164c3e commit 4e028e7

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

kubernetes/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@
184184
<groupId>com.fasterxml.jackson.core</groupId>
185185
<artifactId>jackson-databind</artifactId>
186186
</dependency>
187+
<dependency>
188+
<groupId>com.fasterxml.jackson.core</groupId>
189+
<artifactId>jackson-core</artifactId>
190+
</dependency>
187191

188192
<!-- test dependencies -->
189193
<dependency>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package io.kubernetes.client.custom;
14+
15+
import java.util.Arrays;
16+
import java.util.Map;
17+
18+
public class MapUtils {
19+
public static boolean equals(Map<String, byte[]> map1, Map<String, byte[]> map2) {
20+
if (map1 == map2) {
21+
return true; // Both pointing to the same instance
22+
}
23+
if (map1 == null || map2 == null || map1.size() != map2.size()) {
24+
return false; // One is null or their sizes are different
25+
}
26+
for (String key : map1.keySet()) {
27+
if (!map2.containsKey(key) || !Arrays.equals(map1.get(key), map2.get(key))) {
28+
// Key doesn't exist in map2 or the byte arrays are not equal
29+
return false;
30+
}
31+
}
32+
// All keys matched and their corresponding byte arrays are equal
33+
return true;
34+
}
35+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package io.kubernetes.client.gson;
14+
15+
import com.google.gson.ExclusionStrategy;
16+
import com.google.gson.FieldAttributes;
17+
import io.kubernetes.client.openapi.models.V1ObjectMeta;
18+
19+
public class V1MetadataExclusionStrategy implements com.google.gson.ExclusionStrategy {
20+
public boolean shouldSkipField(FieldAttributes f) {
21+
// Don't serialize the 'managedFields' field.
22+
return (f.getDeclaringClass().equals(V1ObjectMeta.class) && f.getName().equalsIgnoreCase("managedFields"));
23+
}
24+
25+
public boolean shouldSkipClass(Class<?> clazz) {
26+
return false;
27+
}
28+
}

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@
272272
<artifactId>jackson-databind</artifactId>
273273
<version>${jackson.version}</version>
274274
</dependency>
275+
<dependency>
276+
<groupId>com.fasterxml.jackson.core</groupId>
277+
<artifactId>jackson-core</artifactId>
278+
<version>${jackson.version}</version>
279+
</dependency>
275280

276281
<!-- tests -->
277282
<dependency>

0 commit comments

Comments
 (0)