forked from Intersmash/intersmash
-
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.
- Loading branch information
1 parent
e201f43
commit 2525685
Showing
9 changed files
with
5,478 additions
and
0 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
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
40 changes: 40 additions & 0 deletions
40
.../org/jboss/intersmash/tools/application/openshift/KeycloakQuarkusOperatorApplication.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,40 @@ | ||
/** | ||
* Copyright (C) 2023 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.intersmash.tools.application.openshift; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.jboss.intersmash.tools.provision.openshift.KeycloakQuarkusOperatorProvisioner; | ||
import org.keycloak.k8s.v2alpha1.Keycloak; | ||
import org.keycloak.k8s.v2alpha1.KeycloakRealmImport; | ||
|
||
/** | ||
* End user Application interface which presents Keycloak operator application on OpenShift Container Platform. | ||
* | ||
* The application will be deployed by: | ||
* <ul> | ||
* <li>{@link KeycloakQuarkusOperatorProvisioner}</li> | ||
* </ul> | ||
*/ | ||
public interface KeycloakQuarkusOperatorApplication extends OperatorApplication { | ||
|
||
Keycloak getKeycloak(); | ||
|
||
default List<KeycloakRealmImport> getKeycloakRealmImports() { | ||
return Collections.emptyList(); | ||
} | ||
} |
141 changes: 141 additions & 0 deletions
141
...va/org/jboss/intersmash/tools/provision/openshift/KeycloakQuarkusOperatorProvisioner.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,141 @@ | ||
/** | ||
* Copyright (C) 2023 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.intersmash.tools.provision.openshift; | ||
|
||
import cz.xtf.core.event.helpers.EventHelper; | ||
import cz.xtf.core.waiting.failfast.FailFastCheck; | ||
import io.fabric8.kubernetes.api.model.KubernetesResourceList; | ||
import io.fabric8.kubernetes.api.model.Pod; | ||
import io.fabric8.kubernetes.client.DefaultKubernetesClient; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.dsl.MixedOperation; | ||
import io.fabric8.kubernetes.client.dsl.Resource; | ||
import lombok.NonNull; | ||
import org.assertj.core.util.Strings; | ||
import org.jboss.intersmash.tools.IntersmashConfig; | ||
import org.jboss.intersmash.tools.application.openshift.KeycloakQuarkusOperatorApplication; | ||
import org.jboss.intersmash.tools.provision.openshift.operator.OperatorProvisioner; | ||
import org.jboss.intersmash.tools.provision.openshift.operator.keycloak.realm.KeycloakRealm; | ||
import org.keycloak.k8s.v2alpha1.Keycloak; | ||
import org.keycloak.k8s.v2alpha1.KeycloakRealmImport; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Keycloak operator provisioner | ||
*/ | ||
public class KeycloakQuarkusOperatorProvisioner extends OperatorProvisioner<KeycloakQuarkusOperatorApplication> { | ||
|
||
private static final String OPERATOR_ID = IntersmashConfig.keycloakQuarkusOperatorPackageManifest(); | ||
protected FailFastCheck ffCheck = () -> false; | ||
|
||
public KeycloakQuarkusOperatorProvisioner(@NonNull KeycloakQuarkusOperatorApplication application) { | ||
super(application, OPERATOR_ID); | ||
} | ||
|
||
public static String getOperatorId() { | ||
return OPERATOR_ID; | ||
} | ||
|
||
@Override | ||
public void subscribe() { | ||
if (Strings.isNullOrEmpty(IntersmashConfig.keycloakImageURL())) { | ||
super.subscribe(); | ||
} else { | ||
// RELATED_IMAGE_RHSSO_OPENJ9 and RELATED_IMAGE_RHSSO_OPENJDK, determine the final value for RELATED_IMAGE_RHSSO | ||
subscribe( | ||
INSTALLPLAN_APPROVAL_MANUAL, | ||
Map.of( | ||
"RELATED_IMAGE_RHSSO", IntersmashConfig.keycloakImageURL(), | ||
"PROFILE", "RHSSO")); | ||
} | ||
} | ||
|
||
@Override | ||
public void deploy() { | ||
ffCheck = FailFastUtils.getFailFastCheck(EventHelper.timeOfLastEventBMOrTestNamespaceOrEpoch(), | ||
getApplication().getName()); | ||
// Keycloak Operator codebase contains the name of the Keycloak image to deploy: user can override Keycloak image to | ||
// deploy using environment variables in Keycloak Operator Subscription | ||
subscribe(); | ||
|
||
// create custom resources | ||
keycloakClient().createOrReplace(getApplication().getKeycloak()); | ||
if (getApplication().getKeycloakRealmImports().size() > 0) | ||
keycloakRealmImportClient().createOrReplace(getApplication().getKeycloakRealmImports().stream().toArray(KeycloakRealmImport[]::new)); | ||
} | ||
|
||
@Override | ||
public void undeploy() { | ||
|
||
} | ||
|
||
@Override | ||
public List<Pod> getPods() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void scale(int replicas, boolean wait) { | ||
|
||
} | ||
|
||
@Override | ||
protected String getOperatorCatalogSource() { | ||
return IntersmashConfig.keycloakQuarkusOperatorCatalogSource(); | ||
} | ||
|
||
@Override | ||
protected String getOperatorIndexImage() { | ||
return IntersmashConfig.keycloakQuarkusOperatorIndexImage(); | ||
} | ||
|
||
@Override | ||
protected String getOperatorChannel() { | ||
return IntersmashConfig.keycloakQuarkusOperatorChannel(); | ||
} | ||
|
||
public MixedOperation<Keycloak, KubernetesResourceList<Keycloak>, Resource<Keycloak>> keycloakClient() { | ||
try (KubernetesClient kubernetesClient = new DefaultKubernetesClient()) { | ||
MixedOperation<Keycloak, KubernetesResourceList<Keycloak>, Resource<Keycloak>> keycloakClient = kubernetesClient | ||
.resources(Keycloak.class); | ||
return keycloakClient; | ||
} | ||
} | ||
|
||
public MixedOperation<KeycloakRealmImport, KubernetesResourceList<KeycloakRealmImport>, Resource<KeycloakRealmImport>> keycloakRealmImportClient() { | ||
try (KubernetesClient kubernetesClient = new DefaultKubernetesClient()) { | ||
MixedOperation<KeycloakRealmImport, KubernetesResourceList<KeycloakRealmImport>, Resource<KeycloakRealmImport>> keycloakRealmImportClient = kubernetesClient | ||
.resources(KeycloakRealmImport.class); | ||
return keycloakRealmImportClient; | ||
} | ||
} | ||
|
||
|
||
/* | ||
try (KubernetesClient kubernetesClient = new DefaultKubernetesClient()) { | ||
OpenShiftClient oClient = kubernetesClient.adapt(OpenShiftClient.class); | ||
MixedOperation<Keycloak, KubernetesResourceList<Keycloak>, Resource<Keycloak>> keycloakClient = kubernetesClient | ||
.resources(Keycloak.class); | ||
keycloakClient.inNamespace(OpenShiftConfig.namespace()).list(); | ||
MixedOperation<KeycloakRealmImport, KubernetesResourceList<KeycloakRealmImport>, Resource<KeycloakRealmImport>> keycloakRealmImportClient = kubernetesClient | ||
.resources(KeycloakRealmImport.class); | ||
keycloakRealmImportClient.inNamespace(OpenShiftConfig.namespace()).list(); | ||
} | ||
*/ | ||
} |
33 changes: 33 additions & 0 deletions
33
...jboss/intersmash/tools/provision/openshift/KeycloakQuarkusOperatorProvisionerFactory.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,33 @@ | ||
/** | ||
* Copyright (C) 2023 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.intersmash.tools.provision.openshift; | ||
|
||
import org.jboss.intersmash.tools.application.Application; | ||
import org.jboss.intersmash.tools.application.openshift.KeycloakQuarkusOperatorApplication; | ||
import org.jboss.intersmash.tools.provision.ProvisionerFactory; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class KeycloakQuarkusOperatorProvisionerFactory implements ProvisionerFactory<KeycloakQuarkusOperatorProvisioner> { | ||
|
||
@Override | ||
public KeycloakQuarkusOperatorProvisioner getProvisioner(Application application) { | ||
if (KeycloakQuarkusOperatorApplication.class.isAssignableFrom(application.getClass())) | ||
return new KeycloakQuarkusOperatorProvisioner((KeycloakQuarkusOperatorApplication) application); | ||
return null; | ||
} | ||
} |
Oops, something went wrong.