Editing a devfile and plug-in at runtime
An alternative to building a custom registry image is to:
-
Start a registry
-
Modify its content at runtime
This approach is simpler and faster. But the modifications are lost as soon as the container is deleted.
Adding a plug-in at runtime
To add a plug-in:
-
Check out the plugin registry sources.
$ git clone https://github.com/eclipse/che-plugin-registry; \ cd che-plugin-registry
-
Create a
meta.yaml
in some local folder. This can be done from scratch or by copying from an existing plug-in’smeta.yaml
file.$ PLUGIN="v3/plugins/new-org/new-plugin/0.0.1"; \ mkdir -p ${PLUGIN}; cp v3/plugins/che-incubator/cpptools/0.1/* ${PLUGIN}/ echo "${PLUGIN##*/}" > ${PLUGIN}/../latest.txt
-
If copying from an existing plug-in, make changes to the
meta.yaml
file to suit your needs. Make sure the new plug-in has a uniquetitle
,displayName
anddescription
. Update thefirstPublicationDate
to today’s date. -
These fields in
meta.yaml
must match the path defined inPLUGIN
above.publisher: new-org name: new-plugin version: 0.0.1
-
Get the name of the Pod that hosts the plug-in registry container. To do this, filter the
component=plugin-registry
label:$ PLUGIN_REG_POD=$(kubectl get -o custom-columns=NAME:.metadata.name \ --no-headers pod -l component=plugin-registry)
-
Regenerate the registry’s
index.json
file to include the new plug-in.$ cd che-plugin-registry; \ "$(pwd)/build/scripts/generate_latest_metas.sh" v3 && \ "$(pwd)/build/scripts/check_plugins_location.sh" v3 && \ "$(pwd)/build/scripts/set_plugin_dates.sh" v3 && \ "$(pwd)/build/scripts/check_plugins_viewer_mandatory_fields.sh" v3 && \ "$(pwd)/build/scripts/index.sh" v3 > v3/plugins/index.json
-
Copy the new
index.json
andmeta.yaml
files from the new local plug-in folder to the container.$ cd che-plugin-registry; \ LOCAL_FILES="$(pwd)/${PLUGIN}/meta.yaml $(pwd)/v3/plugins/index.json"; \ kubectl exec ${PLUGIN_REG_POD} -i -t -- mkdir -p /var/www/html/$/{PLUGIN}; \ for f in $LOCAL_FILES; do e=${f/$(pwd)\//}; echo "Upload ${f} -> /var/www/html/${e}"; \ kubectl cp "${f}" ${PLUGIN_REG_POD}:/var/www/html/${e}; done
-
The new plug-in can now be used from the existing Che instance of the plug-in registry. To discover it, go to the Che dashboard, then click the Workspaces link. From there, click the gear icon to configure one of your workspaces. Select the Plugins tab to see the updated list of available plug-ins.
Adding a devfile at runtime
To add a devfile:
-
Check out the devfile registry sources.
$ git clone https://github.com/eclipse/che-devfile-registry; \ cd che-devfile-registry
-
Create a
devfile.yaml
andmeta.yaml
in some local folder. This can be done from scratch or by copying from an existing devfile.$ STACK="new-stack"; \ mkdir -p devfiles/${STACK}; cp devfiles/nodejs/* devfiles/${STACK}/
-
If copying from an existing devfile, make changes to the devfile to suit your needs. Make sure the new devfile has a unique
displayName
anddescription
. -
Get the name of the Pod that hosts the devfile registry container. To do this, filter the
component=devfile-registry
label:$ DEVFILE_REG_POD=$(kubectl get -o custom-columns=NAME:.metadata.name \ --no-headers pod -l component=devfile-registry)
-
Regenerate the registry’s
index.json
file to include the new devfile.$ cd che-devfile-registry; \ "$(pwd)/build/scripts/check_mandatory_fields.sh" devfiles; \ "$(pwd)/build/scripts/index.sh" > index.json
-
Copy the new
index.json
,devfile.yaml
andmeta.yaml
files from the new local devfile folder to the container.$ cd che-devfile-registry; \ kubectl exec ${DEVFILE_REG_POD} -i -t -- mkdir -p /var/www/html/devfiles/${STACK}; \ kubectl cp $(pwd)/devfiles/${STACK}/meta.yaml ${DEVFILE_REG_POD}:/var/www/html/devfiles/${STACK}/meta.yaml; \ kubectl cp $(pwd)/devfiles/${STACK}/devfile.yaml ${DEVFILE_REG_POD}:/var/www/html/devfiles/${STACK}/devfile.yaml; \ kubectl cp $(pwd)/index.json ${DEVFILE_REG_POD}:/var/www/html/devfiles/index.json
-
The new devfile can now be used from the existing Che instance of the devfile registry. To discover it, go to the Che dashboard, then click the Workspaces link. From there, click Add Workspace to see the updated list of available devfiles.