-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
613f988
commit bbe3e25
Showing
4 changed files
with
210 additions
and
2 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
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
86 changes: 86 additions & 0 deletions
86
junit5/src/main/java/cz/xtf/junit5/extensions/helpers/CustomResourceHelper.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,86 @@ | ||
package cz.xtf.junit5.extensions.helpers; | ||
|
||
import cz.xtf.core.openshift.OpenShifts; | ||
import io.fabric8.kubernetes.client.dsl.MixedOperation; | ||
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; | ||
import io.fabric8.kubernetes.client.dsl.Resource; | ||
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext; | ||
import io.fabric8.openshift.api.model.operatorhub.v1.DoneableOperatorGroup; | ||
import io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup; | ||
import io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupList; | ||
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion; | ||
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersionList; | ||
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.DoneableClusterServiceVersion; | ||
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.DoneableInstallPlan; | ||
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.DoneableSubscription; | ||
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.InstallPlan; | ||
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.InstallPlanList; | ||
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription; | ||
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionList; | ||
|
||
/** | ||
* <p>This class provides the clients used to interact with some of the APIs of the Operator Lifecycle Manager (OLM)</p> | ||
* <p>For example it provides the client to ineract with <code>ClusterServiceVersion</code></p> | ||
*/ | ||
public class CustomResourceHelper { | ||
|
||
public static final String OPERATORS_COREOS_COM = "operators.coreos.com"; | ||
|
||
public NonNamespaceOperation<ClusterServiceVersion, ClusterServiceVersionList, DoneableClusterServiceVersion, Resource<ClusterServiceVersion, DoneableClusterServiceVersion>> getClusterServiceVersionClient() { | ||
CustomResourceDefinitionContext clusterserviceversionsContext = new CustomResourceDefinitionContext.Builder() | ||
.withGroup(OPERATORS_COREOS_COM).withVersion("v1alpha1").withScope("Namespaced") | ||
.withName("clusterserviceversions.operators.coreos.com").withPlural("clusterserviceversions") | ||
.withKind("ClusterServiceVersion").build(); | ||
|
||
NonNamespaceOperation<ClusterServiceVersion, ClusterServiceVersionList, DoneableClusterServiceVersion, Resource<ClusterServiceVersion, DoneableClusterServiceVersion>> client = OpenShifts | ||
.admin().customResources(clusterserviceversionsContext, ClusterServiceVersion.class, | ||
ClusterServiceVersionList.class, DoneableClusterServiceVersion.class); | ||
client = ((MixedOperation<ClusterServiceVersion, ClusterServiceVersionList, DoneableClusterServiceVersion, Resource<ClusterServiceVersion, DoneableClusterServiceVersion>>) client) | ||
.inNamespace(OpenShifts.master().getNamespace()); | ||
return client; | ||
} | ||
|
||
public NonNamespaceOperation<InstallPlan, InstallPlanList, DoneableInstallPlan, Resource<InstallPlan, DoneableInstallPlan>> getInstallPlanClient() { | ||
CustomResourceDefinitionContext installplansContext = new CustomResourceDefinitionContext.Builder() | ||
.withGroup(OPERATORS_COREOS_COM).withVersion("v1alpha1").withScope("Namespaced") | ||
.withName("installplans.operators.coreos.com").withPlural("installplans").withKind("InstallPlan") | ||
.build(); | ||
|
||
NonNamespaceOperation<InstallPlan, InstallPlanList, DoneableInstallPlan, Resource<InstallPlan, DoneableInstallPlan>> client = OpenShifts | ||
.admin().customResources(installplansContext, InstallPlan.class, InstallPlanList.class, | ||
DoneableInstallPlan.class); | ||
client = ((MixedOperation<InstallPlan, InstallPlanList, DoneableInstallPlan, Resource<InstallPlan, DoneableInstallPlan>>) client) | ||
.inNamespace(OpenShifts.master().getNamespace()); | ||
|
||
return client; | ||
} | ||
|
||
public NonNamespaceOperation<OperatorGroup, OperatorGroupList, DoneableOperatorGroup, Resource<OperatorGroup, DoneableOperatorGroup>> getOperatorGroupClient() { | ||
CustomResourceDefinitionContext operatorgroupsContext = new CustomResourceDefinitionContext.Builder() | ||
.withGroup(OPERATORS_COREOS_COM).withVersion("v1").withScope("Namespaced") | ||
.withName("operatorgroups.operators.coreos.com").withPlural("operatorgroups").withKind("OperatorGroup") | ||
.build(); | ||
|
||
NonNamespaceOperation<OperatorGroup, OperatorGroupList, DoneableOperatorGroup, Resource<OperatorGroup, DoneableOperatorGroup>> client = OpenShifts | ||
.admin().customResources(operatorgroupsContext, OperatorGroup.class, OperatorGroupList.class, | ||
DoneableOperatorGroup.class); | ||
client = ((MixedOperation<OperatorGroup, OperatorGroupList, DoneableOperatorGroup, Resource<OperatorGroup, DoneableOperatorGroup>>) client) | ||
.inNamespace(OpenShifts.master().getNamespace()); | ||
|
||
return client; | ||
} | ||
|
||
public NonNamespaceOperation<Subscription, SubscriptionList, DoneableSubscription, Resource<Subscription, DoneableSubscription>> getSubscriptionClient() { | ||
CustomResourceDefinitionContext subscriptionsContext = new CustomResourceDefinitionContext.Builder() | ||
.withGroup(OPERATORS_COREOS_COM).withVersion("v1alpha1").withScope("Namespaced") | ||
.withName("subscriptions.operators.coreos.com").withPlural("subscriptions").withKind("Subscription") | ||
.build(); | ||
|
||
NonNamespaceOperation<Subscription, SubscriptionList, DoneableSubscription, Resource<Subscription, DoneableSubscription>> client = OpenShifts | ||
.admin().customResources(subscriptionsContext, Subscription.class, SubscriptionList.class, | ||
DoneableSubscription.class); | ||
client = ((MixedOperation<Subscription, SubscriptionList, DoneableSubscription, Resource<Subscription, DoneableSubscription>>) client) | ||
.inNamespace(OpenShifts.master().getNamespace()); | ||
return client; | ||
} | ||
} |
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