THIS IS ONLY A TEST INSTANCE. DON'T DO IMPORTANT WORK HERE!

Commit 431809f9 authored by Tom George's avatar Tom George Committed by David Festal
Browse files

Update custom resource doc, and make it available in OpenApi spec (#94)



* Add openapi gen flags
* Get code to compile with new OpenApi field names
Signed-off-by: default avatarTom George <tg82490@gmail.com>

* Complete the doc & fix optional management
* Rename the CRD to the initial name.
* Correctly update the CRD file
* remove unused and error-prone CRD file
* Update OLM packages with new OpenApi defs
Signed-off-by: default avatarDavid Festal <dfestal@redhat.com>
parent 202b3e25
This diff is collapsed.
......@@ -41,7 +41,6 @@ func main() {
}
logrus.Info("CRD successfully added to schema")
logrus.Infof("Creating a new namespace: %s", namespace)
ns := newNamespace()
if err := createNamespace(ns); err != nil {
......@@ -96,7 +95,6 @@ func main() {
logrus.Info("Installation succeeded")
}
// reconfigure CR to enable TLS support
logrus.Info("Patching CR with TLS enabled. This should cause a new Che deployment")
patchPath := "/spec/server/tlsSupport"
......@@ -158,7 +156,7 @@ func main() {
if err != nil {
logrus.Fatalf("Failed to get CR: %s", err)
}
oAuthClientName := cr.Spec.Auth.OauthClientName
oAuthClientName := cr.Spec.Auth.OAuthClientName
_, err = getOauthClient(oAuthClientName)
if err != nil {
logrus.Fatalf("oAuthclient %s not found", oAuthClientName)
......
--- /home/dfestal/go/src/github.com/eclipse/che-operator/olm/eclipse-che-preview-kubernetes/deploy/olm-catalog/eclipse-che-preview-kubernetes/9.9.9-nightly.1567522875/eclipse-che-preview-kubernetes.v9.9.9-nightly.1567522875.clusterserviceversion.yaml 2019-09-17 16:37:37.000000000 +0200
+++ /home/dfestal/go/src/github.com/eclipse/che-operator/olm/eclipse-che-preview-kubernetes/deploy/olm-catalog/eclipse-che-preview-kubernetes/9.9.9-nightly.1571049441/eclipse-che-preview-kubernetes.v9.9.9-nightly.1571049441.clusterserviceversion.yaml 2019-10-14 12:37:21.000000000 +0200
@@ -49,12 +49,12 @@
categories: Developer Tools
certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly
- createdAt: "2019-09-03T15:01:15Z"
+ createdAt: "2019-10-14T10:37:21Z"
description: A Kube-native development solution that delivers portable and collaborative
developer workspaces.
repository: https://github.com/eclipse/che-operator
support: Eclipse Foundation
- name: eclipse-che-preview-kubernetes.v9.9.9-nightly.1567522875
+ name: eclipse-che-preview-kubernetes.v9.9.9-nightly.1571049441
namespace: placeholder
spec:
apiservicedefinitions: {}
@@ -350,5 +350,5 @@
maturity: stable
provider:
name: Eclipse Foundation
- replaces: eclipse-che-preview-kubernetes.v9.9.9-nightly.1567514659
- version: 9.9.9-nightly.1567522875
+ replaces: eclipse-che-preview-kubernetes.v9.9.9-nightly.1567522875
+ version: 9.9.9-nightly.1571049441
channels:
- currentCSV: eclipse-che-preview-kubernetes.v9.9.9-nightly.1567522875
- currentCSV: eclipse-che-preview-kubernetes.v9.9.9-nightly.1571049441
name: nightly
- currentCSV: eclipse-che-preview-kubernetes.v7.2.0
name: stable
......
--- /home/dfestal/go/src/github.com/eclipse/che-operator/olm/eclipse-che-preview-openshift/deploy/olm-catalog/eclipse-che-preview-openshift/9.9.9-nightly.1567522875/eclipse-che-preview-openshift.v9.9.9-nightly.1567522875.clusterserviceversion.yaml 2019-09-17 16:37:37.000000000 +0200
+++ /home/dfestal/go/src/github.com/eclipse/che-operator/olm/eclipse-che-preview-openshift/deploy/olm-catalog/eclipse-che-preview-openshift/9.9.9-nightly.1571049441/eclipse-che-preview-openshift.v9.9.9-nightly.1571049441.clusterserviceversion.yaml 2019-10-14 12:37:21.000000000 +0200
@@ -46,12 +46,12 @@
categories: Developer Tools, OpenShift Optional
certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly
- createdAt: "2019-09-03T15:01:15Z"
+ createdAt: "2019-10-14T10:37:21Z"
description: A Kube-native development solution that delivers portable and collaborative
developer workspaces in OpenShift.
repository: https://github.com/eclipse/che-operator
support: Eclipse Foundation
- name: eclipse-che-preview-openshift.v9.9.9-nightly.1567522875
+ name: eclipse-che-preview-openshift.v9.9.9-nightly.1571049441
namespace: placeholder
spec:
apiservicedefinitions: {}
@@ -395,5 +395,5 @@
maturity: stable
provider:
name: Eclipse Foundation
- replaces: eclipse-che-preview-openshift.v9.9.9-nightly.1567514660
- version: 9.9.9-nightly.1567522875
+ replaces: eclipse-che-preview-openshift.v9.9.9-nightly.1567522875
+ version: 9.9.9-nightly.1571049441
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: checlusters.org.eclipse.che
spec:
group: org.eclipse.che
names:
kind: CheCluster
listKind: CheClusterList
plural: checlusters
singular: checluster
scope: Namespaced
version: v1
subresources:
status: {}
channels:
- currentCSV: eclipse-che-preview-openshift.v9.9.9-nightly.1567522875
- currentCSV: eclipse-che-preview-openshift.v9.9.9-nightly.1571049441
name: nightly
- currentCSV: eclipse-che-preview-openshift.v7.2.0
name: stable
......
......@@ -46,7 +46,10 @@ do
mv "${packageFolderPath}/${newNightlyPackageVersion}/${packageName}.v${newNightlyPackageVersion}.clusterserviceversion.yaml.new" \
"${packageFolderPath}/${newNightlyPackageVersion}/${packageName}.v${newNightlyPackageVersion}.clusterserviceversion.yaml"
echo " - Copying the CRD file"
cp "${packageFolderPath}/${lastPackageVersion}/eclipse-che-preview-${platform}.crd.yaml" "${packageFolderPath}/${newNightlyPackageVersion}/eclipse-che-preview-${platform}.crd.yaml"
cp "${BASE_DIR}/../deploy/crds/org_v1_che_crd.yaml" "${packageFolderPath}/${newNightlyPackageVersion}/eclipse-che-preview-${platform}.crd.yaml"
diff -u "${packageFolderPath}/${lastPackageVersion}/eclipse-che-preview-${platform}.crd.yaml" \
"${packageFolderPath}/${newNightlyPackageVersion}/eclipse-che-preview-${platform}.crd.yaml" \
> "${packageFolderPath}/${newNightlyPackageVersion}/eclipse-che-preview-${platform}.crd.yaml.diff" || true
echo " - Updating the 'nightly' channel with new version in the package descriptor: ${packageFilePath}"
sed -e "s/${lastPackageVersion}/${newNightlyPackageVersion}/" "${packageFilePath}" > "${packageFilePath}.new"
mv "${packageFilePath}.new" "${packageFilePath}"
......
This diff is collapsed.
// +build !ignore_autogenerated
/*
Copyright The Kubernetes Authors.
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.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
// Code generated by operator-sdk. DO NOT EDIT.
package v1
......@@ -92,7 +76,7 @@ func (in *CheClusterSpec) DeepCopyInto(out *CheClusterSpec) {
out.Database = in.Database
out.Auth = in.Auth
out.Storage = in.Storage
out.K8SOnly = in.K8SOnly
out.K8s = in.K8s
return
}
......
This diff is collapsed.
......@@ -246,7 +246,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
if isOpenShift {
// delete oAuthClient before CR is deleted
doInstallOpenShiftoAuthProvider := instance.Spec.Auth.OpenShiftOauth
doInstallOpenShiftoAuthProvider := instance.Spec.Auth.OpenShiftoAuth
if doInstallOpenShiftoAuthProvider {
if err := r.ReconcileFinalizer(instance); err != nil {
return reconcile.Result{}, err
......@@ -287,7 +287,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
// To use Openshift v4 OAuth, the OAuth endpoints are served from a namespace
// and NOT from the Openshift API Master URL (as in v3)
// So we also need the self-signed certificate to access them (same as the Che server)
(isOpenShift4 && instance.Spec.Auth.OpenShiftOauth && !instance.Spec.Server.TlsSupport) {
(isOpenShift4 && instance.Spec.Auth.OpenShiftoAuth && !instance.Spec.Server.TlsSupport) {
if err := r.CreateTLSSecret(instance, "", "self-signed-certificate"); err != nil {
return reconcile.Result{}, err
}
......@@ -308,7 +308,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
}
}
if instance.Spec.Auth.OpenShiftOauth {
if instance.Spec.Auth.OpenShiftoAuth {
users := &userv1.UserList{}
listOptions := &client.ListOptions{}
if err := r.nonCachedClient.List(context.TODO(), listOptions, users); err != nil {
......@@ -392,13 +392,13 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 1}, err
}
chePostgresPassword := instance.Spec.Database.ChePostgresPassword
keycloakPostgresPassword := instance.Spec.Auth.KeycloakPostgresPassword
keycloakAdminPassword := instance.Spec.Auth.KeycloakAdminPassword
keycloakPostgresPassword := instance.Spec.Auth.IdentityProviderPostgresPassword
keycloakAdminPassword := instance.Spec.Auth.IdentityProviderPassword
cheFlavor := util.GetValue(instance.Spec.Server.CheFlavor, deploy.DefaultCheFlavor)
// Create Postgres resources and provisioning unless an external DB is used
externalDB := instance.Spec.Database.ExternalDB
externalDB := instance.Spec.Database.ExternalDb
if !externalDB {
// Create a new postgres service
postgresLabels := deploy.GetLabels(instance, "postgres")
......@@ -485,8 +485,8 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
}
}
ingressStrategy := util.GetValue(instance.Spec.K8SOnly.IngressStrategy, deploy.DefaultIngressStrategy)
ingressDomain := instance.Spec.K8SOnly.IngressDomain
ingressStrategy := util.GetValue(instance.Spec.K8s.IngressStrategy, deploy.DefaultIngressStrategy)
ingressDomain := instance.Spec.K8s.IngressDomain
tlsSupport := instance.Spec.Server.TlsSupport
protocol := "http"
if tlsSupport {
......@@ -538,7 +538,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
}
// create and provision Keycloak related objects
ExternalKeycloak := instance.Spec.Auth.ExternalKeycloak
ExternalKeycloak := instance.Spec.Auth.ExternalIdentityProvider
if !ExternalKeycloak {
keycloakLabels := deploy.GetLabels(instance, "keycloak")
......@@ -556,9 +556,9 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
if ingressStrategy == "multi-host" {
keycloakURL = protocol + "://keycloak-" + instance.Namespace + "." + ingressDomain
}
if len(instance.Spec.Auth.KeycloakURL) == 0 {
instance.Spec.Auth.KeycloakURL = keycloakURL
if err := r.UpdateCheCRSpec(instance, "Keycloak URL", instance.Spec.Auth.KeycloakURL); err != nil {
if len(instance.Spec.Auth.IdentityProviderURL) == 0 {
instance.Spec.Auth.IdentityProviderURL = keycloakURL
if err := r.UpdateCheCRSpec(instance, "Keycloak URL", instance.Spec.Auth.IdentityProviderURL); err != nil {
instance, _ = r.GetCR(request)
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 1}, err
}
......@@ -573,17 +573,17 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
return reconcile.Result{}, err
}
keycloakURL := keycloakRoute.Spec.Host
if len(instance.Spec.Auth.KeycloakURL) == 0 {
instance.Spec.Auth.KeycloakURL = protocol + "://" + keycloakURL
if len(instance.Spec.Auth.IdentityProviderURL) == 0 {
instance.Spec.Auth.IdentityProviderURL = protocol + "://" + keycloakURL
if len(keycloakURL) < 1 {
keycloakURL := r.GetEffectiveRoute(instance, keycloakRoute.Name).Spec.Host
instance.Spec.Auth.KeycloakURL = protocol + "://" + keycloakURL
instance.Spec.Auth.IdentityProviderURL = protocol + "://" + keycloakURL
}
if err := r.UpdateCheCRSpec(instance, "Keycloak URL", instance.Spec.Auth.KeycloakURL); err != nil {
if err := r.UpdateCheCRSpec(instance, "Keycloak URL", instance.Spec.Auth.IdentityProviderURL); err != nil {
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 1}, err
}
instance.Status.KeycloakURL = protocol + "://" + keycloakURL
if err := r.UpdateCheCRStatus(instance, "status: Keycloak URL", instance.Spec.Auth.KeycloakURL); err != nil {
if err := r.UpdateCheCRStatus(instance, "status: Keycloak URL", instance.Spec.Auth.IdentityProviderURL); err != nil {
instance, _ = r.GetCR(request)
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 1}, err
}
......@@ -614,9 +614,9 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
k8sclient.GetDeploymentRollingUpdateStatus("keycloak", instance.Namespace)
}
desiredImage := util.GetValue(instance.Spec.Auth.KeycloakImage, deploy.DefaultKeycloakImage(instance, cheFlavor))
desiredImage := util.GetValue(instance.Spec.Auth.IdentityProviderImage, deploy.DefaultKeycloakImage(instance, cheFlavor))
effectiveImage := effectiveKeycloakDeployment.Spec.Template.Spec.Containers[0].Image
desiredImagePullPolicy := util.GetValue(string(instance.Spec.Auth.KeycloakImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(desiredImage))
desiredImagePullPolicy := util.GetValue(string(instance.Spec.Auth.IdentityProviderImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(desiredImage))
effectiveImagePullPolicy := string(effectiveKeycloakDeployment.Spec.Template.Spec.Containers[0].ImagePullPolicy)
cheCertSecretVersion := r.GetEffectiveSecretResourceVersion(instance, "self-signed-certificate")
storedCheCertSecretVersion := effectiveKeycloakDeployment.Annotations["che.self-signed-certificate.version"]
......@@ -654,7 +654,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
}
if isOpenShift {
doInstallOpenShiftoAuthProvider := instance.Spec.Auth.OpenShiftOauth
doInstallOpenShiftoAuthProvider := instance.Spec.Auth.OpenShiftoAuth
if doInstallOpenShiftoAuthProvider {
openShiftIdentityProviderStatus := instance.Status.OpenShiftoAuthProvisioned
if !openShiftIdentityProviderStatus {
......@@ -808,7 +808,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
result, err := addRegistryDeployment(
"devfile",
devfileRegistryImage,
corev1.PullPolicy(util.GetValue(string(instance.Spec.Server.PluginRegistryImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(devfileRegistryImage))),
corev1.PullPolicy(util.GetValue(string(instance.Spec.Server.PluginRegistryPullPolicy), deploy.DefaultPullPolicyFromDockerImage(devfileRegistryImage))),
util.GetValue(string(instance.Spec.Server.DevfileRegistryMemoryLimit), deploy.DefaultDevfileRegistryMemoryLimit),
util.GetValue(string(instance.Spec.Server.DevfileRegistryMemoryRequest), deploy.DefaultDevfileRegistryMemoryRequest),
"/devfiles/",
......@@ -844,7 +844,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
result, err := addRegistryDeployment(
"plugin",
pluginRegistryImage,
corev1.PullPolicy(util.GetValue(string(instance.Spec.Server.PluginRegistryImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(pluginRegistryImage))),
corev1.PullPolicy(util.GetValue(string(instance.Spec.Server.PluginRegistryPullPolicy), deploy.DefaultPullPolicyFromDockerImage(pluginRegistryImage))),
util.GetValue(string(instance.Spec.Server.PluginRegistryMemoryLimit), deploy.DefaultPluginRegistryMemoryLimit),
util.GetValue(string(instance.Spec.Server.PluginRegistryMemoryRequest), deploy.DefaultPluginRegistryMemoryRequest),
"/v3/plugins/",
......@@ -1008,8 +1008,8 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
break
}
for {
instance.Spec.Auth.OauthSecret = ""
instance.Spec.Auth.OauthClientName = ""
instance.Spec.Auth.OAuthSecret = ""
instance.Spec.Auth.OAuthClientName = ""
if err := r.UpdateCheCRSpec(instance, "clean oAuth secret name and client name", ""); err != nil &&
errors.IsConflict(err) {
instance, _ = r.GetCR(request)
......
......@@ -184,7 +184,7 @@ func TestCheController(t *testing.T) {
}
// update CR and make sure Che configmap has been updated
cheCR.Spec.Auth.OpenShiftOauth = true
cheCR.Spec.Auth.OpenShiftoAuth = true
if err := cl.Update(context.TODO(), cheCR); err != nil {
t.Error("Failed to update CheCluster custom resource")
}
......@@ -217,8 +217,8 @@ func TestCheController(t *testing.T) {
err = r.client.Get(context.TODO(), types.NamespacedName{Name: cheCR.Name, Namespace: cheCR.Namespace}, cheCR)
err = r.CreateIdentityProviderItems(cheCR, req, "che", "keycloak", false)
oAuthClientName := cheCR.Spec.Auth.OauthClientName
oauthSecret := cheCR.Spec.Auth.OauthSecret
oAuthClientName := cheCR.Spec.Auth.OAuthClientName
oauthSecret := cheCR.Spec.Auth.OAuthSecret
if err = r.client.Get(context.TODO(), types.NamespacedName{Name: oAuthClientName, Namespace: ""}, oAuthClient); err != nil {
t.Errorf("Failed to Get oAuthClient %s: %s", oAuthClient.Name, err)
}
......@@ -227,7 +227,7 @@ func TestCheController(t *testing.T) {
}
// check if a new Postgres deployment is not created when spec.Database.ExternalDB is true
cheCR.Spec.Database.ExternalDB = true
cheCR.Spec.Database.ExternalDb = true
if err := cl.Update(context.TODO(), cheCR); err != nil {
t.Error("Failed to update CheCluster custom resource")
}
......@@ -246,7 +246,7 @@ func TestCheController(t *testing.T) {
// check of storageClassName ends up in pvc spec
fakeStorageClassName := "fake-storage-class-name"
cheCR.Spec.Storage.PostgresPVCStorageClassName = fakeStorageClassName
cheCR.Spec.Database.ExternalDB = false
cheCR.Spec.Database.ExternalDb = false
if err := r.client.Update(context.TODO(), cheCR); err != nil {
t.Fatalf("Failed to update %s CR: %s", cheCR.Name, err)
}
......@@ -281,7 +281,7 @@ func TestCheController(t *testing.T) {
if err := r.ReconcileFinalizer(cheCR); err != nil {
t.Fatal("Failed to reconcile oAuthClient")
}
oauthClientName := cheCR.Spec.Auth.OauthClientName
oauthClientName := cheCR.Spec.Auth.OAuthClientName
_, err = r.GetOAuthClient(oauthClientName)
if err == nil {
t.Fatalf("OauthClient %s has not been deleted", oauthClientName)
......
......@@ -271,25 +271,25 @@ func (r *ReconcileChe) CreateNewRoleBinding(instance *orgv1.CheCluster, roleBind
func (r *ReconcileChe) CreateIdentityProviderItems(instance *orgv1.CheCluster, request reconcile.Request, cheFlavor string, keycloakDeploymentName string, isOpenShift4 bool) (err error) {
tests := r.tests
keycloakAdminPassword := instance.Spec.Auth.KeycloakAdminPassword
oAuthClientName := instance.Spec.Auth.OauthClientName
keycloakAdminPassword := instance.Spec.Auth.IdentityProviderPassword
oAuthClientName := instance.Spec.Auth.OAuthClientName
if len(oAuthClientName) < 1 {
oAuthClientName = instance.Name + "-openshift-identity-provider-" + strings.ToLower(util.GeneratePasswd(6))
instance.Spec.Auth.OauthClientName = oAuthClientName
instance.Spec.Auth.OAuthClientName = oAuthClientName
if err := r.UpdateCheCRSpec(instance, "oAuthClient name", oAuthClientName); err != nil {
return err
}
}
oauthSecret := instance.Spec.Auth.OauthSecret
oauthSecret := instance.Spec.Auth.OAuthSecret
if len(oauthSecret) < 1 {
oauthSecret = util.GeneratePasswd(12)
instance.Spec.Auth.OauthSecret = oauthSecret
instance.Spec.Auth.OAuthSecret = oauthSecret
if err := r.UpdateCheCRSpec(instance, "oAuthC secret name", oauthSecret); err != nil {
return err
}
}
keycloakURL := instance.Spec.Auth.KeycloakURL
keycloakRealm := util.GetValue(instance.Spec.Auth.KeycloakRealm, cheFlavor)
keycloakURL := instance.Spec.Auth.IdentityProviderURL
keycloakRealm := util.GetValue(instance.Spec.Auth.IdentityProviderRealm, cheFlavor)
oAuthClient := deploy.NewOAuthClient(oAuthClientName, oauthSecret, keycloakURL, keycloakRealm, isOpenShift4)
if err := r.CreateNewOauthClient(instance, oAuthClient); err != nil {
return err
......@@ -311,7 +311,7 @@ func (r *ReconcileChe) CreateIdentityProviderItems(instance *orgv1.CheCluster, r
for {
instance.Status.OpenShiftoAuthProvisioned = true
if err := r.UpdateCheCRStatus(instance, "status: provisioned with OpenShift identity provider", "true"); err != nil &&
errors.IsConflict(err) {
errors.IsConflict(err) {
instance, _ = r.GetCR(request)
continue
}
......@@ -354,9 +354,9 @@ func (r *ReconcileChe) GenerateAndSaveFields(instance *orgv1.CheCluster, request
}
}
keycloakPostgresPassword := util.GetValue(instance.Spec.Auth.KeycloakPostgresPassword, util.GeneratePasswd(12))
if len(instance.Spec.Auth.KeycloakPostgresPassword) < 1 {
instance.Spec.Auth.KeycloakPostgresPassword = keycloakPostgresPassword
keycloakPostgresPassword := util.GetValue(instance.Spec.Auth.IdentityProviderPostgresPassword, util.GeneratePasswd(12))
if len(instance.Spec.Auth.IdentityProviderPostgresPassword) < 1 {
instance.Spec.Auth.IdentityProviderPostgresPassword = keycloakPostgresPassword
keycloakDeployment, err := r.GetEffectiveDeployment(instance, "keycloak")
if err != nil {
logrus.Info("Disregard the error. No existing Identity provider deployment found. Generating passwd")
......@@ -367,28 +367,28 @@ func (r *ReconcileChe) GenerateAndSaveFields(instance *orgv1.CheCluster, request
return err
}
}
if len(instance.Spec.Auth.KeycloakAdminPassword) < 1 {
keycloakAdminPassword := util.GetValue(instance.Spec.Auth.KeycloakAdminPassword, util.GeneratePasswd(12))
if len(instance.Spec.Auth.IdentityProviderPassword) < 1 {
keycloakAdminPassword := util.GetValue(instance.Spec.Auth.IdentityProviderPassword, util.GeneratePasswd(12))
keycloakDeployment, err := r.GetEffectiveDeployment(instance, "keycloak")
if err != nil {
logrus.Info("Disregard the error. No existing Identity provider deployment found. Generating passwd")
} else {
keycloakAdminPassword = r.GetDeploymentEnv(keycloakDeployment, "SSO_ADMIN_PASSWORD")
}
instance.Spec.Auth.KeycloakAdminPassword = keycloakAdminPassword
instance.Spec.Auth.IdentityProviderPassword = keycloakAdminPassword
if err := r.UpdateCheCRSpec(instance, "Keycloak admin password", "password hidden"); err != nil {
return err
}
}
if len(instance.Spec.Auth.KeycloakAdminUserName) < 1 {
keycloakAdminUserName := util.GetValue(instance.Spec.Auth.KeycloakAdminUserName, "admin")
if len(instance.Spec.Auth.IdentityProviderAdminUserName) < 1 {
keycloakAdminUserName := util.GetValue(instance.Spec.Auth.IdentityProviderAdminUserName, "admin")
keycloakDeployment, err := r.GetEffectiveDeployment(instance, "keycloak")
if err != nil {
logrus.Info("Disregard the error. No existing Identity provider deployment found. Generating admin username")
} else {
keycloakAdminUserName = r.GetDeploymentEnv(keycloakDeployment, "SSO_ADMIN_USERNAME")
}
instance.Spec.Auth.KeycloakAdminUserName = keycloakAdminUserName
instance.Spec.Auth.IdentityProviderAdminUserName = keycloakAdminUserName
if err := r.UpdateCheCRSpec(instance, "Keycloak admin username", keycloakAdminUserName); err != nil {
return err
}
......@@ -407,9 +407,9 @@ func (r *ReconcileChe) GenerateAndSaveFields(instance *orgv1.CheCluster, request
return err
}
}
chePostgresHostName := util.GetValue(instance.Spec.Database.ChePostgresDBHostname, deploy.DefaultChePostgresHostName)
if len(instance.Spec.Database.ChePostgresDBHostname) < 1 {
instance.Spec.Database.ChePostgresDBHostname = chePostgresHostName
chePostgresHostName := util.GetValue(instance.Spec.Database.ChePostgresHostName, deploy.DefaultChePostgresHostName)
if len(instance.Spec.Database.ChePostgresHostName) < 1 {
instance.Spec.Database.ChePostgresHostName = chePostgresHostName
if err := r.UpdateCheCRSpec(instance, "Postgres hostname", chePostgresHostName); err != nil {
return err
}
......@@ -428,16 +428,16 @@ func (r *ReconcileChe) GenerateAndSaveFields(instance *orgv1.CheCluster, request
return err
}
}
keycloakRealm := util.GetValue(instance.Spec.Auth.KeycloakRealm, cheFlavor)
if len(instance.Spec.Auth.KeycloakRealm) < 1 {
instance.Spec.Auth.KeycloakRealm = keycloakRealm
keycloakRealm := util.GetValue(instance.Spec.Auth.IdentityProviderRealm, cheFlavor)
if len(instance.Spec.Auth.IdentityProviderRealm) < 1 {
instance.Spec.Auth.IdentityProviderRealm = keycloakRealm
if err := r.UpdateCheCRSpec(instance, "Keycloak realm", keycloakRealm); err != nil {
return err
}
}
keycloakClientId := util.GetValue(instance.Spec.Auth.KeycloakClientId, cheFlavor+"-public")
if len(instance.Spec.Auth.KeycloakClientId) < 1 {
instance.Spec.Auth.KeycloakClientId = keycloakClientId
keycloakClientId := util.GetValue(instance.Spec.Auth.IdentityProviderClientId, cheFlavor+"-public")
if len(instance.Spec.Auth.IdentityProviderClientId) < 1 {
instance.Spec.Auth.IdentityProviderClientId = keycloakClientId
if err := r.UpdateCheCRSpec(instance, "Keycloak client ID", keycloakClientId); err != nil {
return err
......@@ -491,9 +491,9 @@ func (r *ReconcileChe) GenerateAndSaveFields(instance *orgv1.CheCluster, request
}
}
if instance.Spec.Auth.KeycloakImage == deploy.OldDefaultKeycloakUpstreamImageToDetect {
instance.Spec.Auth.KeycloakImage = ""
if err := r.UpdateCheCRSpec(instance, "keycloak image", instance.Spec.Auth.KeycloakImage); err != nil {
if instance.Spec.Auth.IdentityProviderImage == deploy.OldDefaultKeycloakUpstreamImageToDetect {
instance.Spec.Auth.IdentityProviderImage = ""
if err := r.UpdateCheCRSpec(instance, "keycloak image", instance.Spec.Auth.IdentityProviderImage); err != nil {
return err
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment