Editing a devfile and plug-in at runtime

An alternative to building a custom registry image is to:

  1. Start a registry

  2. 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

Procedure

To add a plug-in:

  1. Check out the plugin registry sources.

    $ git clone https://github.com/eclipse/che-plugin-registry; \
      cd che-plugin-registry
  2. Create a meta.yaml in some local folder. This can be done from scratch or by copying from an existing plug-in’s meta.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
  3. 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 unique title, displayName and description. Update the firstPublicationDate to today’s date.

  4. These fields in meta.yaml must match the path defined in PLUGIN above.

    publisher: new-org
    name: new-plugin
    version: 0.0.1
  5. 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)
  6. 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
  7. Copy the new index.json and meta.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
  8. 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

Procedure

To add a devfile:

  1. Check out the devfile registry sources.

    $ git clone https://github.com/eclipse/che-devfile-registry; \
      cd che-devfile-registry
  2. Create a devfile.yaml and meta.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}/
  3. If copying from an existing devfile, make changes to the devfile to suit your needs. Make sure the new devfile has a unique displayName and description.

  4. 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)
  5. 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
  6. Copy the new index.json, devfile.yaml and meta.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
  7. 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.