forked from fabric8io/kubernetes-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix fabric8io#887: adding visiting logic for walking api resources
- Loading branch information
Showing
8 changed files
with
230 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/ApiVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package io.fabric8.kubernetes.client; | ||
|
||
import io.fabric8.kubernetes.api.model.APIResource; | ||
import io.fabric8.kubernetes.api.model.GenericKubernetesResource; | ||
import io.fabric8.kubernetes.api.model.GenericKubernetesResourceList; | ||
import io.fabric8.kubernetes.client.dsl.MixedOperation; | ||
import io.fabric8.kubernetes.client.dsl.Resource; | ||
import io.fabric8.kubernetes.client.utils.ApiVersionUtil; | ||
|
||
/** | ||
* Used to perform operations across all resources known to the api server. | ||
*/ | ||
public interface ApiVisitor { | ||
|
||
public enum ApiVisitResult { | ||
/** | ||
* If returned, stop the visiting process immediately | ||
*/ | ||
TERMINATE, | ||
/** | ||
* Continue visiting | ||
*/ | ||
CONTINUE, | ||
/** | ||
* Skip any visiting that would occur under this point | ||
*/ | ||
SKIP | ||
} | ||
|
||
/** | ||
* Visit the api. The core/legacy group will be an empty string. | ||
* | ||
* @param api the group name | ||
* @return the result to control future actions. {@link ApiVisitResult#SKIP} will skip visiting all versions of this api. | ||
*/ | ||
default ApiVisitResult visitApi(String api) { | ||
return ApiVisitResult.CONTINUE; | ||
} | ||
|
||
/** | ||
* Visit the apiVersion, which will be in the form of api/version or just v1 for the core. | ||
* Use {@link ApiVersionUtil} to separate components if needed. | ||
* | ||
* @return the result to control future actions. {@link ApiVisitResult#SKIP} will skip visiting all resources under this | ||
* apiVersion. | ||
*/ | ||
default ApiVisitResult visitApiVersion(String apiVersion) { | ||
return ApiVisitResult.CONTINUE; | ||
} | ||
|
||
/** | ||
* Visit the resource. | ||
* | ||
* @param apiVersion in the form of api/version or just v1 for the core | ||
* @param apiResource can be used to look at applicable verbs and other resource information | ||
* @param operation the {@link GenericKubernetesResource} operation for the current resource. Will be in the namespace of the | ||
* client by default. | ||
* @return {@link ApiVisitResult#TERMINATE} to terminate. SKIP and CONTINUE will both continue visiting. | ||
*/ | ||
ApiVisitResult visitResources(String apiVersion, APIResource apiResource, | ||
MixedOperation<GenericKubernetesResource, GenericKubernetesResourceList, Resource<GenericKubernetesResource>> operation); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters