Skip to content

Commit ad080a6

Browse files
shawkinsmanusa
authored andcommittedJul 14, 2021
chore: minimizing methods in handler templates
1 parent 400da28 commit ad080a6

File tree

18 files changed

+117
-632
lines changed

18 files changed

+117
-632
lines changed
 

‎extensions/camel-k/client/src/main/resources/resource-handler.vm

+3-52
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,15 @@
2929

3030
package io.fabric8.camelk.client.handlers.$apiVersion;
3131

32-
import java.util.function.Predicate;
33-
3432
import io.fabric8.kubernetes.client.Config;
3533
import io.fabric8.kubernetes.client.ResourceHandler;
36-
import io.fabric8.kubernetes.client.Watch;
37-
import io.fabric8.kubernetes.client.Watcher;
3834
import io.fabric8.camelk.client.internal.$apiVersion.${model.name}OperationsImpl;
39-
40-
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
35+
import io.fabric8.kubernetes.client.dsl.Resource;
4136
import okhttp3.OkHttpClient;
4237

43-
import io.fabric8.kubernetes.api.model.DeletionPropagation;
44-
import io.fabric8.kubernetes.api.model.ListOptions;
4538
import ${model.fullyQualifiedName};
4639
import ${model.fullyQualifiedName}Builder;
4740

48-
import java.util.TreeMap;
49-
import java.util.concurrent.TimeUnit;
50-
5141
public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
5242

5343
@Override
@@ -64,53 +54,14 @@ public class ${model.name}Handler implements ResourceHandler<${model.name}, ${mo
6454
#end
6555
}
6656

67-
@Override
68-
public ${model.name} create(OkHttpClient client, Config config, String namespace, ${model.name} item, boolean dryRun) {
69-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).dryRun(dryRun).create();
70-
}
71-
72-
@Override
73-
public ${model.name} replace(OkHttpClient client, Config config, String namespace, ${model.name} item, boolean dryRun) {
74-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).dryRun(dryRun).replace(item);
75-
}
76-
77-
@Override
78-
public ${model.name} reload(OkHttpClient client, Config config, String namespace, ${model.name} item) {
79-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).fromServer().get();
80-
}
81-
8257
@Override
8358
public ${model.name}Builder edit(${model.name} item) {
8459
return new ${model.name}Builder(item);
8560
}
8661

8762
@Override
88-
public Boolean delete(OkHttpClient client, Config config, String namespace, DeletionPropagation propagationPolicy, long gracePeriodSeconds, ${model.name} item, boolean dryRun) {
89-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).dryRun(dryRun).withPropagationPolicy(propagationPolicy).withGracePeriod(gracePeriodSeconds).delete();
90-
}
91-
92-
@Override
93-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, Watcher<${model.name}> watcher) {
94-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(watcher);
63+
public Resource<${model.name}> resource(OkHttpClient client, Config config, String namespace, ${model.name} item) {
64+
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName());
9565
}
9666

97-
@Override
98-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, String resourceVersion, Watcher<${model.name}> watcher) {
99-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(resourceVersion, watcher);
100-
}
101-
102-
@Override
103-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, ListOptions listOptions, Watcher<${model.name}> watcher) {
104-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(listOptions, watcher);
105-
}
106-
107-
@Override
108-
public ${model.name} waitUntilReady(OkHttpClient client, Config config, String namespace, ${model.name} item, long amount, TimeUnit timeUnit) throws InterruptedException {
109-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).waitUntilReady(amount, timeUnit);
110-
}
111-
112-
@Override
113-
public ${model.name} waitUntilCondition(OkHttpClient client, Config config, String namespace, ${model.name} item, Predicate<${model.name}> condition, long amount, TimeUnit timeUnit) throws InterruptedException {
114-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).waitUntilCondition(condition, amount, timeUnit);
115-
}
11667
}

‎extensions/certmanager/client/src/main/resources/resource-handler.vm

+3-52
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,15 @@
3030

3131
package io.fabric8.certmanager.${group}.${apiVersion}.handlers;
3232

33-
import java.util.function.Predicate;
34-
3533
import io.fabric8.kubernetes.client.Config;
3634
import io.fabric8.kubernetes.client.ResourceHandler;
37-
import io.fabric8.kubernetes.client.Watch;
38-
import io.fabric8.kubernetes.client.Watcher;
3935
import io.fabric8.certmanager.client.${group}.${apiVersion}.internal.${model.name}OperationsImpl;
40-
41-
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
36+
import io.fabric8.kubernetes.client.dsl.Resource;
4237
import okhttp3.OkHttpClient;
4338

44-
import io.fabric8.kubernetes.api.model.DeletionPropagation;
45-
import io.fabric8.kubernetes.api.model.ListOptions;
4639
import ${model.fullyQualifiedName};
4740
import ${model.fullyQualifiedName}Builder;
4841

49-
import java.util.TreeMap;
50-
import java.util.concurrent.TimeUnit;
51-
5242
public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
5343

5444
@Override
@@ -65,53 +55,14 @@ public class ${model.name}Handler implements ResourceHandler<${model.name}, ${mo
6555
#end
6656
}
6757

68-
@Override
69-
public ${model.name} create(OkHttpClient client, Config config, String namespace, ${model.name} item, boolean dryRun) {
70-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).dryRun(dryRun).create();
71-
}
72-
73-
@Override
74-
public ${model.name} replace(OkHttpClient client, Config config, String namespace, ${model.name} item, boolean dryRun) {
75-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).dryRun(dryRun).replace(item);
76-
}
77-
78-
@Override
79-
public ${model.name} reload(OkHttpClient client, Config config, String namespace, ${model.name} item) {
80-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).fromServer().get();
81-
}
82-
8358
@Override
8459
public ${model.name}Builder edit(${model.name} item) {
8560
return new ${model.name}Builder(item);
8661
}
8762

8863
@Override
89-
public Boolean delete(OkHttpClient client, Config config, String namespace, DeletionPropagation propagationPolicy, long gracePeriodSeconds, ${model.name} item, boolean dryRun) {
90-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).dryRun(dryRun).withPropagationPolicy(propagationPolicy).withGracePeriod(gracePeriodSeconds).delete();
91-
}
92-
93-
@Override
94-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, Watcher<${model.name}> watcher) {
95-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(watcher);
64+
public Resource<${model.name}> resource(OkHttpClient client, Config config, String namespace, ${model.name} item) {
65+
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName());
9666
}
9767

98-
@Override
99-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, String resourceVersion, Watcher<${model.name}> watcher) {
100-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(resourceVersion, watcher);
101-
}
102-
103-
@Override
104-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, ListOptions listOptions, Watcher<${model.name}> watcher) {
105-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(listOptions, watcher);
106-
}
107-
108-
@Override
109-
public ${model.name} waitUntilReady(OkHttpClient client, Config config, String namespace, ${model.name} item, long amount, TimeUnit timeUnit) throws InterruptedException {
110-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).waitUntilReady(amount, timeUnit);
111-
}
112-
113-
@Override
114-
public ${model.name} waitUntilCondition(OkHttpClient client, Config config, String namespace, ${model.name} item, Predicate<${model.name}> condition, long amount, TimeUnit timeUnit) throws InterruptedException {
115-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).waitUntilCondition(condition, amount, timeUnit);
116-
}
11768
}

‎extensions/chaosmesh/client/src/main/resources/resource-handler.vm

+3-52
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,15 @@
2929

3030
package io.fabric8.chaosmesh.client.handlers;
3131

32-
import java.util.function.Predicate;
33-
3432
import io.fabric8.kubernetes.client.Config;
3533
import io.fabric8.kubernetes.client.ResourceHandler;
36-
import io.fabric8.kubernetes.client.Watch;
37-
import io.fabric8.kubernetes.client.Watcher;
3834
import io.fabric8.chaosmesh.client.internal.${model.name}OperationsImpl;
39-
40-
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
35+
import io.fabric8.kubernetes.client.dsl.Resource;
4136
import okhttp3.OkHttpClient;
4237

43-
import io.fabric8.kubernetes.api.model.DeletionPropagation;
44-
import io.fabric8.kubernetes.api.model.ListOptions;
4538
import ${model.fullyQualifiedName};
4639
import ${model.fullyQualifiedName}Builder;
4740

48-
import java.util.TreeMap;
49-
import java.util.concurrent.TimeUnit;
50-
5141
public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
5242

5343
@Override
@@ -64,53 +54,14 @@ public class ${model.name}Handler implements ResourceHandler<${model.name}, ${mo
6454
#end
6555
}
6656

67-
@Override
68-
public ${model.name} create(OkHttpClient client, Config config, String namespace, ${model.name} item, boolean dryRun) {
69-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).dryRun(dryRun).create();
70-
}
71-
72-
@Override
73-
public ${model.name} replace(OkHttpClient client, Config config, String namespace, ${model.name} item, boolean dryRun) {
74-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).dryRun(dryRun).replace(item);
75-
}
76-
77-
@Override
78-
public ${model.name} reload(OkHttpClient client, Config config, String namespace, ${model.name} item) {
79-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).fromServer().get();
80-
}
81-
8257
@Override
8358
public ${model.name}Builder edit(${model.name} item) {
8459
return new ${model.name}Builder(item);
8560
}
8661

8762
@Override
88-
public Boolean delete(OkHttpClient client, Config config, String namespace, DeletionPropagation propagationPolicy, long gracePeriodSeconds, ${model.name} item, boolean dryRun) {
89-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).dryRun(dryRun).withPropagationPolicy(propagationPolicy).withGracePeriod(gracePeriodSeconds).delete();
90-
}
91-
92-
@Override
93-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, Watcher<${model.name}> watcher) {
94-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(watcher);
63+
public Resource<${model.name}> resource(OkHttpClient client, Config config, String namespace, ${model.name} item) {
64+
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName());
9565
}
9666

97-
@Override
98-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, String resourceVersion, Watcher<${model.name}> watcher) {
99-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(resourceVersion, watcher);
100-
}
101-
102-
@Override
103-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, ListOptions listOptions, Watcher<${model.name}> watcher) {
104-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(listOptions, watcher);
105-
}
106-
107-
@Override
108-
public ${model.name} waitUntilReady(OkHttpClient client, Config config, String namespace, ${model.name} item, long amount, TimeUnit timeUnit) throws InterruptedException {
109-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).waitUntilReady(amount, timeUnit);
110-
}
111-
112-
@Override
113-
public ${model.name} waitUntilCondition(OkHttpClient client, Config config, String namespace, ${model.name} item, Predicate<${model.name}> condition, long amount, TimeUnit timeUnit) throws InterruptedException {
114-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).waitUntilCondition(condition, amount, timeUnit);
115-
}
11667
}

‎extensions/knative/client/src/main/resources/resource-handler.vm

+4-52
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,16 @@
3030

3131
package io.fabric8.knative.client.${group}.${apiVersion}.handlers;
3232

33-
import java.util.function.Predicate;
34-
3533
import io.fabric8.kubernetes.client.Config;
3634
import io.fabric8.kubernetes.client.ResourceHandler;
37-
import io.fabric8.kubernetes.client.Watch;
38-
import io.fabric8.kubernetes.client.Watcher;
35+
import io.fabric8.kubernetes.client.dsl.Resource;
3936
import io.fabric8.knative.client.${group}.${apiVersion}.internal.${model.name}OperationsImpl;
4037

41-
import io.fabric8.kubernetes.client.dsl.base.OperationContext;
4238
import okhttp3.OkHttpClient;
4339

44-
import io.fabric8.kubernetes.api.model.DeletionPropagation;
45-
import io.fabric8.kubernetes.api.model.ListOptions;
4640
import ${model.fullyQualifiedName};
4741
import ${model.fullyQualifiedName}Builder;
4842

49-
import java.util.TreeMap;
50-
import java.util.concurrent.TimeUnit;
51-
5243
public class ${model.name}Handler implements ResourceHandler<${model.name}, ${model.name}Builder> {
5344

5445
@Override
@@ -65,53 +56,14 @@ public class ${model.name}Handler implements ResourceHandler<${model.name}, ${mo
6556
#end
6657
}
6758

68-
@Override
69-
public ${model.name} create(OkHttpClient client, Config config, String namespace, ${model.name} item, boolean dryRun) {
70-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).dryRun(dryRun).create();
71-
}
72-
73-
@Override
74-
public ${model.name} replace(OkHttpClient client, Config config, String namespace, ${model.name} item, boolean dryRun) {
75-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).dryRun(dryRun).replace(item);
76-
}
77-
78-
@Override
79-
public ${model.name} reload(OkHttpClient client, Config config, String namespace, ${model.name} item) {
80-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).fromServer().get();
81-
}
82-
8359
@Override
8460
public ${model.name}Builder edit(${model.name} item) {
8561
return new ${model.name}Builder(item);
8662
}
87-
88-
@Override
89-
public Boolean delete(OkHttpClient client, Config config, String namespace, DeletionPropagation propagationPolicy, long gracePeriodSeconds, ${model.name} item, boolean dryRun) {
90-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).dryRun(dryRun).withPropagationPolicy(propagationPolicy).withGracePeriod(gracePeriodSeconds).delete();
91-
}
92-
63+
9364
@Override
94-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, Watcher<${model.name}> watcher) {
95-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(watcher);
65+
public Resource<${model.name}> resource(OkHttpClient client, Config config, String namespace, ${model.name} item) {
66+
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName());
9667
}
9768

98-
@Override
99-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, String resourceVersion, Watcher<${model.name}> watcher) {
100-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(resourceVersion, watcher);
101-
}
102-
103-
@Override
104-
public Watch watch(OkHttpClient client, Config config, String namespace, ${model.name} item, ListOptions listOptions, Watcher<${model.name}> watcher) {
105-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).watch(listOptions, watcher);
106-
}
107-
108-
@Override
109-
public ${model.name} waitUntilReady(OkHttpClient client, Config config, String namespace, ${model.name} item, long amount, TimeUnit timeUnit) throws InterruptedException {
110-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).waitUntilReady(amount, timeUnit);
111-
}
112-
113-
@Override
114-
public ${model.name} waitUntilCondition(OkHttpClient client, Config config, String namespace, ${model.name} item, Predicate<${model.name}> condition, long amount, TimeUnit timeUnit) throws InterruptedException {
115-
return new ${model.name}OperationsImpl(client, config).withItem(item).inNamespace(namespace).withName(item.getMetadata().getName()).waitUntilCondition(condition, amount, timeUnit);
116-
}
11769
}

0 commit comments

Comments
 (0)
Please sign in to comment.