Concealing editors definitions

Learn how to conceal Che editor definitions. This is useful when you want to hide selected editors from the Dashboard UI, e.g. hide the IntelliJ IDEA Ultimate and have only Visual Studio Code - Open Source visible.

Prerequisites
Procedure
  1. Find out the namespace where the Che Operator is deployed:

    OPERATOR_NAMESPACE=$(kubectl get pods -l app.kubernetes.io/component=che-operator -o jsonpath={".items[0].metadata.namespace"} --all-namespaces)
  2. Find out the available editors definitions files:

    kubectl exec -n $OPERATOR_NAMESPACE deploy/che-operator -- ls /tmp/editors-definitions

    The output should look similar to the following example:

    che-code-insiders.yaml
    che-code-latest.yaml
    che-idea-latest.yaml
    che-idea-next.yaml
  3. Choose an editor definition to conceal. For example, to conceal the che-idea-next.yaml editor definition, set the editor definition file name:

    CHE_EDITOR_CONCEAL_FILE_NAME=che-idea-next.yaml
  4. Define the ConfigMap name for the concealed editor definition:

    CHE_EDITOR_CONCEAL_CONFIGMAP_NAME=che-conceal-$CHE_EDITOR_CONCEAL_FILE_NAME
  5. Create the ConfigMap:

    kubectl create configmap $CHE_EDITOR_CONCEAL_CONFIGMAP_NAME \
        --namespace $OPERATOR_NAMESPACE \
        --from-literal=$CHE_EDITOR_CONCEAL_FILE_NAME=""
  6. Find out the Operator subscription namespace (if it exists):

    SUBSCRIPTION_NAMESPACE=$(kubectl get subscription \
        --all-namespaces \
        --field-selector=metadata.name=eclipse-che \
        --output jsonpath='{.items[0].metadata.namespace}' 2>/dev/null
    )
  7. Patch the Kubernetes resource to mount the ConfigMap with the empty editor definition. The resource to patch depends on the existence of the Operator subscription. If the subscription exists, then the subscription should be patched. If not, patch the Operator deployment:

    if [[ -n $SUBSCRIPTION_NAMESPACE ]]; then
        if [[ $(kubectl get subscription eclipse-che --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config}') == "" ]]; then
            kubectl patch subscription eclipse-che \
              --namespace $SUBSCRIPTION_NAMESPACE \
              --type json \
              --patch '[{
                    "op":"add",
                    "path":"/spec/config",
                    "value": {}
                }]'
        fi
    
        if [[ $(kubectl get subscription eclipse-che --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumes}') == "" ]]; then
            kubectl patch subscription eclipse-che \
              --namespace $SUBSCRIPTION_NAMESPACE \
              --type json \
              --patch '[{
                    "op":"add",
                    "path":"/spec/config/volumes",
                    "value": []
                }]'
        fi
    
        if [[ $(kubectl get subscription eclipse-che --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumeMounts}') == "" ]]; then
            kubectl patch subscription eclipse-che \
              --namespace $SUBSCRIPTION_NAMESPACE \
              --type json \
              --patch '[{
                    "op":"add",
                    "path":"/spec/config/volumeMounts",
                    "value": []
                }]'
        fi
    
        kubectl patch subscription eclipse-che \
          --namespace $SUBSCRIPTION_NAMESPACE \
          --type json \
          --patch '[{
            "op":"add",
            "path":"/spec/config/volumes/-",
            "value": {
                "name":"'$(echo ${CHE_EDITOR_CONCEAL_FILE_NAME%.*})'",
                "configMap": {
                    "name": "'$CHE_EDITOR_CONCEAL_CONFIGMAP_NAME'"
                }
            }
          },
          {
            "op":"add",
            "path":"/spec/config/volumeMounts/-",
            "value":{
                "name": "'$(echo ${CHE_EDITOR_CONCEAL_FILE_NAME%.*})'",
                "subPath":"'$CHE_EDITOR_CONCEAL_FILE_NAME'",
                "mountPath": "/tmp/editors-definitions/'$CHE_EDITOR_CONCEAL_FILE_NAME'"
            }
          }]'
    else
        kubectl patch deployment che-operator \
          --namespace $OPERATOR_NAMESPACE \
          --type json \
          --patch '[{
            "op":"add",
            "path":"/spec/template/spec/volumes/-",
            "value": {
                "name":"'$(echo ${CHE_EDITOR_CONCEAL_FILE_NAME%.*})'",
                "configMap": {
                    "name": "'$CHE_EDITOR_CONCEAL_CONFIGMAP_NAME'"
                }
            }
        },
        {
            "op":"add",
            "path":"/spec/template/spec/containers/0/volumeMounts/-",
            "value":{
                "name": "'$(echo ${CHE_EDITOR_CONCEAL_FILE_NAME%.*})'",
                "subPath":"'$CHE_EDITOR_CONCEAL_FILE_NAME'",
                "mountPath": "/tmp/editors-definitions/'$CHE_EDITOR_CONCEAL_FILE_NAME'"
            }
        }
    ]'
    fi