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.
-
An active
kubectl
session with administrative permissions to the Kubernetes cluster. See Overview of kubectl. -
jq
. See Downloadingjq
.
-
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)
-
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
-
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
-
Define the ConfigMap name for the concealed editor definition:
CHE_EDITOR_CONCEAL_CONFIGMAP_NAME=che-conceal-$CHE_EDITOR_CONCEAL_FILE_NAME
-
Create the ConfigMap:
kubectl create configmap $CHE_EDITOR_CONCEAL_CONFIGMAP_NAME \ --namespace $OPERATOR_NAMESPACE \ --from-literal=$CHE_EDITOR_CONCEAL_FILE_NAME=""
-
Find out the Operator subscription name and namespace (if it exists):
SUBSCRIPTION=$(kubectl get subscriptions \ --all-namespaces \ --output json \ | jq -r '.items[] | select(.spec.name=="eclipse-che")') SUBSCRIPTION_NAMESPACE=$(echo $SUBSCRIPTION | jq -r '.metadata.namespace') SUBSCRIPTION_NAME=$(echo $SUBSCRIPTION | jq -r '.metadata.name')
-
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 $SUBSCRIPTION_NAME --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config}') == "" ]]; then kubectl patch subscription $SUBSCRIPTION_NAME \ --namespace $SUBSCRIPTION_NAMESPACE \ --type json \ --patch '[{ "op":"add", "path":"/spec/config", "value": {} }]' fi if [[ $(kubectl get subscription $SUBSCRIPTION_NAME --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumes}') == "" ]]; then kubectl patch subscription $SUBSCRIPTION_NAME \ --namespace $SUBSCRIPTION_NAMESPACE \ --type json \ --patch '[{ "op":"add", "path":"/spec/config/volumes", "value": [] }]' fi if [[ $(kubectl get subscription $SUBSCRIPTION_NAME --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumeMounts}') == "" ]]; then kubectl patch subscription $SUBSCRIPTION_NAME \ --namespace $SUBSCRIPTION_NAMESPACE \ --type json \ --patch '[{ "op":"add", "path":"/spec/config/volumeMounts", "value": [] }]' fi kubectl patch subscription $SUBSCRIPTION_NAME \ --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