Skip to content

Commit 5a0439c

Browse files
committed
Temporary fix to #221
Attempt to detect class from Api version and kind alone if Api group not found when loading from Yaml. Fixes issue #221 temporarily until Api group-version prefixes are generated in class names properly.
1 parent dd93b9d commit 5a0439c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

util/src/main/java/io/kubernetes/client/util/Yaml.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ public static Object load(Reader reader) throws IOException {
168168
}
169169

170170
Class<?> clazz = (Class<?>) classes.get(apiVersion + "/" + kind);
171+
if (clazz == null) {
172+
// Attempt to detect class from version and kind alone
173+
if (apiVersion.contains("/")) {
174+
clazz = (Class<?>) classes.get(apiVersion.split("/")[1] + "/" + kind);
175+
}
176+
}
171177
if (clazz == null) {
172178
throw new IOException(
173179
"Unknown apiVersionKind: "

util/src/test/java/io/kubernetes/client/util/YamlTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public void testLoad() {
3636
String[] apiVersions =
3737
new String[] {
3838
"v1",
39-
"v2alpha1",
40-
"v2beta1",
41-
"v1alpha1",
42-
"v1beta2",
43-
"v1beta1",
39+
"batch/v2alpha1",
40+
"autoscaling/v2beta1",
41+
"rbac.authorization.k8s.io/v1alpha1",
42+
"apps/v1beta2",
43+
"apiregistration.k8s.io/v1beta1",
4444
"extensions/v1beta1",
4545
"apps/v1beta1"
4646
};

0 commit comments

Comments
 (0)