Skip to content

Commit 9e0b3b8

Browse files
committed
Swap order of Api version detection to fix bug
1 parent c7087e4 commit 9e0b3b8

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ public class Yaml {
3131
static final Logger logger = LoggerFactory.getLogger(Yaml.class);
3232

3333
public static String getApiGroupVersion(String name) {
34-
if (name.startsWith("AppsV1")) {
35-
return "apps/v1";
34+
if (name.startsWith("AppsV1beta2")) {
35+
return "apps/v1beta2";
3636
}
3737
if (name.startsWith("AppsV1beta1")) {
3838
return "apps/v1beta1";
3939
}
40+
if (name.startsWith("AppsV1")) {
41+
return "apps/v1";
42+
}
4043
if (name.startsWith("ExtensionsV1beta1")) {
4144
return "extensions/v1beta1";
4245
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@
2222
public class YamlTest {
2323
@Test
2424
public void testLoad() {
25-
String[] kinds = new String[] {"Pod", "Deployment", "ClusterRole", "APIService", "Scale"};
25+
String[] kinds = new String[] {"Pod", "CronJob", "HorizontalPodAutoscaler", "ClusterRole", "Deployment", "APIService", "Scale", "Deployment"};
2626
String[] apiVersions =
27-
new String[] {"v1", "v1beta2", "v1alpha1", "v1beta1", "extensions/v1beta1"};
27+
new String[] {"v1", "v2alpha1", "v2beta1", "v1alpha1", "v1beta2", "v1beta1", "extensions/v1beta1", "apps/v1beta1"};
2828
String[] classNames =
2929
new String[] {
3030
"V1Pod",
31-
"V1beta2Deployment",
31+
"V2alpha1CronJob",
32+
"V2beta1HorizontalPodAutoscaler",
3233
"V1alpha1ClusterRole",
34+
"V1beta2Deployment",
3335
"V1beta1APIService",
34-
"ExtensionsV1beta1Scale"
36+
"ExtensionsV1beta1Scale",
37+
"AppsV1beta1Deployment"
3538
};
3639
for (int i = 0; i < kinds.length; i++) {
3740
String kind = kinds[i];

0 commit comments

Comments
 (0)