Skip to content

Commit

Permalink
Fix fabric8io#1172 : Use v1beta1 for CronJob
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanKanojia committed Aug 9, 2018
1 parent 3bf0cc7 commit de6dcff
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

* Fix #1165 : Null parameter values when processing a template are now handled properly

* Fix #1172 : Use v1beta1 for CronJob

Improvements

* Added Kubernetes/Openshift examples for client.getVersion()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

public class CronJobOperationsImpl extends HasMetadataOperation<CronJob, CronJobList, DoneableCronJob, Resource<CronJob, DoneableCronJob>> {
public CronJobOperationsImpl(OkHttpClient client, Config config, String namespace) {
this(client, config, "v2alpha1", namespace, null, true, null, null, false, -1, new TreeMap<String, String>(), new TreeMap<String, String>(), new TreeMap<String, String[]>(), new TreeMap<String, String[]>(), new TreeMap<String, String>());
this(client, config, "v1beta1", namespace, null, true, null, null, false, -1, new TreeMap<String, String>(), new TreeMap<String, String>(), new TreeMap<String, String[]>(), new TreeMap<String, String[]>(), new TreeMap<String, String>());
}

public CronJobOperationsImpl(OkHttpClient client, Config config, String apiVersion, String namespace, String name, Boolean cascading, CronJob item, String resourceVersion, Boolean reloadingFromServer, long gracePeriodSeconds, Map<String, String> labels, Map<String, String> labelsNot, Map<String, String[]> labelsIn, Map<String, String[]> labelsNotIn, Map<String, String> fields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public int hashCode() {
notFoundTransformations.put(new ResourceKey("Role", "roles", "rbac.authorization.k8s.io", "v1"), new ResourceKey("Role", "roles", "rbac.authorization.k8s.io", "v1beta1"));
notFoundTransformations.put(new ResourceKey("ClusterRoleBinding", "clusterrolebindings", "rbac.authorization.k8s.io", "v1"), new ResourceKey("ClusterRoleBinding", "clusterrolebindings", "rbac.authorization.k8s.io", "v1beta1"));
notFoundTransformations.put(new ResourceKey("ClusterRole", "clusterroles", "rbac.authorization.k8s.io", "v1"), new ResourceKey("ClusterRole", "clusterroles", "rbac.authorization.k8s.io", "v1beta1"));
notFoundTransformations.put(new ResourceKey("CronJob", "cronjobs", "batch", "v1beta1"), new ResourceKey("CronJob", "cronjob", "batch", "v2alpha1"));

badRequestTransformations.put(new ResourceKey("Deployment", "deployments", "apps", "v1beta1"), new ResourceKey("Deployment", "deployments", "extensions", "v1beta1"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static void main(String args[]) throws InterruptedException {
final String namespace = client.getNamespace();

CronJob cronJob1 = new CronJobBuilder()
.withApiVersion("batch/v1beta1")
.withNewMetadata()
.withName("hello")
.withLabels(Collections.singletonMap("foo", "bar"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class CronJobIT {
@Before
public void init() {
currentNamespace = session.getNamespace();
cronJob1 = new CronJobBuilder().withNewMetadata()
cronJob1 = new CronJobBuilder().withApiVersion("batch/v1beta1").withNewMetadata()
.withName("cronjob1")
.endMetadata()
.withNewSpec()
Expand All @@ -74,7 +74,7 @@ public void init() {
.endJobTemplate()
.endSpec()
.build();
cronJob2 = new CronJobBuilder().withNewMetadata()
cronJob2 = new CronJobBuilder().withApiVersion("batch/v1beta1").withNewMetadata()
.withName("cronjob2")
.endMetadata()
.withNewSpec()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public class CronJobTest {

@Test
public void testList() {
server.expect().withPath("/apis/batch/v2alpha1/namespaces/test/cronjobs").andReturn(200, new CronJobListBuilder().build()).once();
server.expect().withPath("/apis/batch/v2alpha1/namespaces/ns1/cronjobs").andReturn(200, new CronJobListBuilder()
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs").andReturn(200, new CronJobListBuilder().build()).once();
server.expect().withPath("/apis/batch/v1beta1/namespaces/ns1/cronjobs").andReturn(200, new CronJobListBuilder()
.addNewItem().and()
.addNewItem().and().build()).once();

server.expect().withPath("/apis/batch/v2alpha1/cronjobs").andReturn(200, new CronJobListBuilder()
server.expect().withPath("/apis/batch/v1beta1/cronjobs").andReturn(200, new CronJobListBuilder()
.addNewItem().and()
.addNewItem().and()
.addNewItem()
Expand All @@ -59,8 +59,8 @@ public void testList() {

@Test
public void testListWithLables() {
server.expect().withPath("/apis/batch/v2alpha1/namespaces/test/cronjobs?labelSelector=" + toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new CronJobListBuilder().build()).always();
server.expect().withPath("/apis/batch/v2alpha1/namespaces/test/cronjobs?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new CronJobListBuilder()
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs?labelSelector=" + toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new CronJobListBuilder().build()).always();
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs?labelSelector=" + toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new CronJobListBuilder()
.addNewItem().and()
.addNewItem().and()
.addNewItem().and()
Expand All @@ -87,8 +87,8 @@ public void testListWithLables() {
}
@Test
public void testGet() {
server.expect().withPath("/apis/batch/v2alpha1/namespaces/test/cronjobs/cronjob1").andReturn(200, new CronJobBuilder().build()).once();
server.expect().withPath("/apis/batch/v2alpha1/namespaces/ns1/cronjobs/cronjob2").andReturn(200, new CronJobBuilder().build()).once();
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs/cronjob1").andReturn(200, new CronJobBuilder().build()).once();
server.expect().withPath("/apis/batch/v1beta1/namespaces/ns1/cronjobs/cronjob2").andReturn(200, new CronJobBuilder().build()).once();

KubernetesClient client = server.getClient();

Expand All @@ -104,7 +104,7 @@ public void testGet() {

@Test
public void testDelete() {
server.expect().withPath("/apis/batch/v2alpha1/namespaces/test/cronjobs/cronJob1").andReturn(200, new CronJobBuilder().withNewMetadata()
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs/cronJob1").andReturn(200, new CronJobBuilder().withNewMetadata()
.withName("cronJob1")
.withResourceVersion("1")
.endMetadata()
Expand Down Expand Up @@ -137,7 +137,7 @@ public void testDelete() {
.endSpec()
.build()).once();

server.expect().withPath("/apis/batch/v2alpha1/namespaces/test/cronjobs/cronJob2").andReturn(200, new CronJobBuilder().withNewMetadata()
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs/cronJob2").andReturn(200, new CronJobBuilder().withNewMetadata()
.withName("cronJob2")
.withResourceVersion("1")
.endMetadata()
Expand Down Expand Up @@ -201,11 +201,11 @@ public void testDeleteMulti() {
.build();
CronJob cronjob3 = new CronJobBuilder().withNewMetadata().withName("cronjob3").withNamespace("any").and().build();

server.expect().withPath("/apis/batch/v2alpha1/namespaces/test/cronjobs/cronjob1").andReturn(200, cronjob1).once();
server.expect().withPath("/apis/batch/v2alpha1/namespaces/test/cronjobs/cronjob1").andReturn(200, new CronJobBuilder(cronjob1)
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs/cronjob1").andReturn(200, cronjob1).once();
server.expect().withPath("/apis/batch/v1beta1/namespaces/test/cronjobs/cronjob1").andReturn(200, new CronJobBuilder(cronjob1)
.editStatus().endStatus().build()).times(5);
server.expect().withPath("/apis/batch/v2alpha1/namespaces/ns1/cronjobs/cronjob2").andReturn(200, cronjob2).once();
server.expect().withPath("/apis/batch/v2alpha1/namespaces/ns1/cronjobs/cronjob2").andReturn(200, new CronJobBuilder(cronjob2)
server.expect().withPath("/apis/batch/v1beta1/namespaces/ns1/cronjobs/cronjob2").andReturn(200, cronjob2).once();
server.expect().withPath("/apis/batch/v1beta1/namespaces/ns1/cronjobs/cronjob2").andReturn(200, new CronJobBuilder(cronjob2)
.editStatus().endStatus().build()).times(5);

KubernetesClient client = server.getClient();
Expand Down

0 comments on commit de6dcff

Please sign in to comment.