File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
extended/src/main/java/io/kubernetes/client/extended/kubectl Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 19
19
import org .apache .commons .lang3 .StringUtils ;
20
20
21
21
public class KubectlDelete <ApiType extends KubernetesObject >
22
- extends Kubectl .ResourceBuilder <ApiType , KubectlDelete <ApiType >>
23
- implements Kubectl .Executable <ApiType > {
22
+ extends Kubectl .ResourceBuilder <ApiType , KubectlDelete <ApiType >>
23
+ implements Kubectl .Executable <ApiType > {
24
+
25
+ private boolean ignoreNotFound = false ;
24
26
25
27
KubectlDelete (Class <ApiType > apiTypeClass ) {
26
28
super (apiTypeClass );
27
29
}
28
30
31
+ public KubectlDelete <ApiType > ignoreNotFound (boolean ignore ) {
32
+ this .ignoreNotFound = ignore ;
33
+ return this ;
34
+ }
35
+
29
36
@ Override
30
37
public ApiType execute () throws KubectlException {
31
38
verifyArguments ();
@@ -35,13 +42,21 @@ public ApiType execute() throws KubectlException {
35
42
try {
36
43
return getGenericApi ().delete (namespace , name ).throwsApiException ().getObject ();
37
44
} catch (ApiException e ) {
38
- throw new KubectlException (e );
45
+ if (ignoreNotFound && e .getCode () == 404 ) {
46
+ return null ;
47
+ } else {
48
+ throw new KubectlException (e );
49
+ }
39
50
}
40
51
} else {
41
52
try {
42
53
return getGenericApi ().delete (name ).throwsApiException ().getObject ();
43
54
} catch (ApiException e ) {
44
- throw new KubectlException (e );
55
+ if (ignoreNotFound && e .getCode () == 404 ) {
56
+ return null ;
57
+ } else {
58
+ throw new KubectlException (e );
59
+ }
45
60
}
46
61
}
47
62
}
You can’t perform that action at this time.
0 commit comments