Skip to content

Commit

Permalink
#55: Naming convention changes (#111)
Browse files Browse the repository at this point in the history
Copy plugins into 'v2/publisher' folders.
Rename field name to displayName.
Rename field id to name.
Remove /meta.yaml from plugin links in index.
Add deprecate section to old plugins.
Rework scripts.
Add migrate section to registry index.
Add old notation plugins to v2 not to break exisiting workspaces.
Adapt Readme.md.
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
  • Loading branch information
Oleksandr Garagatyi authored Apr 24, 2019
1 parent 3e95e4d commit 1003e15
Show file tree
Hide file tree
Showing 40 changed files with 775 additions and 168 deletions.
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
#
FROM mikefarah/yq as builder
RUN apk add --no-cache bash
COPY .htaccess README.md /build/
COPY .htaccess README.md *.sh /build/
COPY /plugins /build/plugins
COPY check_plugins_location.sh check_plugins_images.sh check_plugins_viewer_mandatory_fields.sh index.sh set_plugin_dates.sh /build/
RUN cd /build/ && ./check_plugins_location.sh && ./check_plugins_images.sh && ./set_plugin_dates.sh && ./check_plugins_viewer_mandatory_fields.sh && ./index.sh > /build/plugins/index.json
COPY .htaccess README.md /build/
COPY /v2 /build/v2
WORKDIR /build/
RUN ./check_plugins_location_v1.sh
RUN ./check_plugins_location_v2.sh
RUN ./check_plugins_images.sh
RUN ./set_plugin_dates.sh
RUN ./check_plugins_viewer_mandatory_fields_v1.sh
RUN ./check_plugins_viewer_mandatory_fields_v2.sh
RUN ./index.sh > /build/plugins/index.json
RUN ./index_v2.sh > /build/v2/plugins/index.json

FROM registry.centos.org/centos/httpd-24-centos7
RUN mkdir /var/www/html/plugins
Expand Down
15 changes: 11 additions & 4 deletions Dockerfile.rhel
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
#
FROM mikefarah/yq as builder
RUN apk add --no-cache bash
COPY .htaccess README.md /build/
COPY .htaccess README.md *.sh /build/
COPY /plugins /build/plugins
COPY check_plugins_location.sh check_plugins_images.sh check_plugins_viewer_mandatory_fields.sh index.sh set_plugin_dates.sh /build/
RUN cd /build/ && ./check_plugins_location.sh && ./check_plugins_images.sh && ./set_plugin_dates.sh && ./check_plugins_viewer_mandatory_fields.sh && ./index.sh > /build/plugins/index.json
COPY .htaccess README.md /build/
COPY /v2 /build/v2
WORKDIR /build/
RUN cd plugins && ./check_plugins_location_v1.sh
RUN cd v2/plugins && ./check_plugins_location_v2.sh
RUN ./check_plugins_images.sh
RUN ./set_plugin_dates.sh
RUN ./check_plugins_viewer_mandatory_fields_v1.sh
RUN ./check_plugins_viewer_mandatory_fields_v2.sh
RUN ./index.sh > /build/plugins/index.json
RUN ./index_v2.sh > /build/v2/plugins/index.json

FROM quay.io/openshiftio/rhel-base-httpd:latest

Expand Down
89 changes: 68 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Useful when you change plugin metadata files and rebuild the image.

## https://hub.docker.com/

Note that the Dockerfiles feature multi-stage build, so it requires Docker of version 17.05 and higher.
Note that the Dockerfiles feature multi-stage build, so it requires Docker of version 17.05 and higher.
Though you may also just provide the image to the older versions of Docker (ex. on Minishift) by having it build on newer version, and pushing and pulling it from Docker Hub.

```eclipse/che-plugin-registry:latest``` image would be rebuilt after each commit in master
Expand Down Expand Up @@ -60,84 +60,131 @@ Here is an overview of all fields that can be present in plugin meta YAML files

|field name in YAML | description | mandatory |
|-------|-------|-------|
| id | plugin ID | yes |
| publisher | publisher name | yes |
| name | plugin name | yes |
| version | plugin version | yes |
| deprecate.migrateTo | which plugin should be used instead when plugin is deprecated. Format: publisher/name/version | no |
| deprecate.autoMigrate | if deprecated plugin should be automatically replaced by another plugin specified in deprecate.migrateTo | no |
| type | plugin type | yes|
| name | plugin name | yes|
| displayName | plugin name | yes|
| title| plugin title | yes |
| description| plugin description | yes |
| icon| URL to plugin icon (must be in SVG format) | yes |
| url| an URL to the plugin source | yes |
| publisher| name of plugin publisher | yes |
| repository | URL to repository of the plugin | yes |
| category| plugin category | yes<sup>1</sup> |
| category| plugin category | yes<sup>1</sup> |
| firstPublicationDate | date of publishing the plugin (in ISO 8601) | no<sup>2</sup> |
| latestUpdateDate | date of latest plugin update (in ISO 8601) | no<sup>3</sup> |
| preview | a URL to devfile, to preview this plugin | no |
| tags | a list of tags, related to this plugin | no|
| tags | a list of tags, related to this plugin | no|
| mediaImage | links for images showcasing the plugin | no |
| mediaVideo | links for video showcasing the plugin| no |
| attributes | a map of special attributes, can be used for instance, imported plugins from VS Code | no |

1 - Category must be equal to one of the following: "Editor", "Debugger", "Formatter", "Language", "Linter", "Snippet", "Theme", "Other"

2 - firstPublicationDate is not required to be present in YAML, as if not present, it will be generated during Plugin Registry dockerimage build

3 - latestUpdateDate is not required to be present in YAML, as it will be generated during Plugin Registry dockerimage build

At the moment, some of these fields (that are related to plugin viewer) are validated during the Plugin Registry dockerimage build.
3 - latestUpdateDate is not required to be present in YAML, as it will be generated during Plugin Registry dockerimage build

At the moment, some of these fields (that are related to plugin viewer) are validated during the Plugin Registry dockerimage build.

## Get index list of all plugins
Example:
```
curl "http://localhost:8080/plugins/index.json"
curl "http://localhost:8080/v2/plugins/index.json"
```
or
```
curl "http://localhost:8080/v2/plugins/"
```
Response:
```javascript
[
{
"id": "org.eclipse.che.editor.theia",
"publisher": "che-incubator",
"name": "theia",
"version": "1.0.0",
"id": "che-incubator/theia/1.0.0",
"type": "Che Editor",
"displayName": "Eclipse Theia",
"description": "Eclipse Theia",
"links": {
"self": "/plugins/che-incubator/theia/1.0.0"
}
},
{
"publisher": "che-incubator",
"name": "theia",
"version": "next",
"id": "che-incubator/theia/next",
"type": "Che Editor",
"name": "theia-ide",
"displayName": "Eclipse Theia",
"description": "Eclipse Theia",
"links": {
"self": "/plugins/org.eclipse.che.editor.theia/1.0.0/meta.yaml"
"self": "/plugins/che-incubator/theia/next"
}
},
{
"id": "che-service-plugin",
"publisher": "ws-skeleton",
"name": "che-service-plugin",
"version": "0.0.1",
"id": "ws-skeleton/che-service-plugin/0.0.1",
"type": "Che Plugin",
"name": "Che Service",
"displayName": "Che Service",
"description": "Che Plug-in with Theia plug-in and container definition providing a service",
"links": {
"self": "/plugins/che-service-plugin/0.0.1/meta.yaml"
"self": "/plugins/ws-skeleton/che-service-plugin/0.0.1"
}
},
{
"id": "che-dummy-plugin",
"publisher": "",
"name": "che-dummy-plugin",
"version": "0.0.1",
"deprecate": {
"migrateTo": "ws-skeleton/che-dummy-plugin/0.0.1",
"autoMigrate": true
},
"id": "che-dummy-plugin/0.0.1",
"type": "Che Plugin",
"name": "Che dummy plugin",
"displayName": "Che dummy plugin",
"description": "A hello world theia plug-in wrapped into a Che Plug-in",
"links": {
"self": "/plugins/che-dummy-plugin/0.0.1/meta.yaml"
"self": "/plugins/che-dummy-plugin/0.0.1"
}
},
{
"publisher": "ws-skeleton",
"name": "che-dummy-plugin",
"version": "0.0.1",
"id": "ws-skeleton/che-dummy-plugin/0.0.1",
"type": "Che Plugin",
"displayName": "Che dummy plugin",
"description": "A hello world theia plug-in wrapped into a Che Plug-in",
"links": {
"self": "/plugins/ws-skeleton/che-dummy-plugin/0.0.1"
}
}
]
```
## Get meta.yaml of a plugin
Example:
```
curl "http://localhost:8080/plugins/org.eclipse.che.editor.theia/1.0.0/meta.yaml"
curl "http://localhost:8080/v2/plugins/che-incubator/theia/1.0.0"
```
or
```
curl "http://localhost:8080/v2/plugins/che-incubator/theia/1.0.0/meta.yaml"
```
Response:
```yaml
id: org.eclipse.che.editor.theia
publisher: che-incubator
name: theia
version: 1.0.0
id: che-incubator/theia/1.0.0
type: Che Editor
name: theia-ide
displayName: Eclipse Theia
title: Eclipse Theia for Eclipse Che
description: Eclipse Theia
icon: https://pbs.twimg.com/profile_images/929088242456190976/xjkS2L-0_400x400.jpg
Expand Down
29 changes: 12 additions & 17 deletions check_plugins_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,24 @@
# SPDX-License-Identifier: EPL-2.0
#

## browse all plugin directories which names and
## check that icon tags in meta.yaml files points to the .svg images
cd plugins
for d in */ ; do
ID_DIR_NAME=${d%/}
cd $d
set -e

for VERSION_DIR_NAME in */ ; do
# Remove trailing slash
VERSION_DIR_NAME=${VERSION_DIR_NAME%/}
cd $VERSION_DIR_NAME
source ./util.sh

ICON=$(yq r meta.yaml icon | sed 's/^"\(.*\)"$/\1/')
## check that icon tags in meta.yaml files points to the .svg images
declare -a arr=(`find . -name "meta.yaml"`)
for i in "${arr[@]}"
do
ICON=$(yq r $i icon | sed 's/^"\(.*\)"$/\1/')
# Regex: contains .svg and not contains dots after it (to avoid xxx.svg.jpg hacks)
if [[ ! $ICON =~ (\.svg)+[^\.]*$ ]];then
echo "!!! Wrong icon type found in '${ID_DIR_NAME}/${VERSION_DIR_NAME}':"
if [[ ! $ICON =~ (\.svg)+[^\.]*$ ]]; then
plugin_id=$(evaluate_plugin_id $i)
plugin_version=$(yq r "$i" version | sed 's/^"\(.*\)"$/\1/')
plugin_publisher=$(yq r "$i" publisher | sed 's/^"\(.*\)"$/\1/')
echo "!!! Wrong icon type found in '${plugin_id}' of publisher '${plugin_publisher}' with version '${plugin_version}':"
echo "!!! '${ICON}' Make sure it is pointing to .svg image."
FOUND=true
fi
cd ..
done

cd ..
done

if [[ $FOUND ]];then
Expand Down
48 changes: 0 additions & 48 deletions check_plugins_location.sh

This file was deleted.

32 changes: 32 additions & 0 deletions check_plugins_location_v1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
#
# Copyright (c) 2012-2018 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#

set -e

source ./util.sh

declare -a arr=(`find plugins -name "meta.yaml"`)
for i in "${arr[@]}"
do
id=$(yq r "$i" id | sed 's/^"\(.*\)"$/\1/')
version=$(yq r "$i" version | sed 's/^"\(.*\)"$/\1/')

expected_path="plugins/${id}/${version}/meta.yaml"
if [[ "${expected_path}" != "$i" ]];then
echo "!!! Location mismatch in plugin '${id}:${version}':"
echo "!!! Expected location: '${expected_path}'"
echo "!!! Actual location: '${i}' "
FOUND=true
fi
done

if [[ $FOUND ]];then
exit 1
fi
31 changes: 31 additions & 0 deletions check_plugins_location_v2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
#
# Copyright (c) 2012-2018 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#

set -e

source ./util.sh

declare -a arr=(`find v2 -name "meta.yaml"`)
for i in "${arr[@]}"
do
plugin_id=$(evaluate_plugin_id $i)

expected_path="v2/plugins/${plugin_id}/meta.yaml"
if [[ "${expected_path}" != "$i" ]]; then
echo "!!! Location mismatch in plugin '${plugin_id}':"
echo "!!! Expected location: '${expected_path}'"
echo "!!! Actual location: '${i}' "
FOUND=true
fi
done

if [[ $FOUND ]];then
exit 1
fi
Loading

0 comments on commit 1003e15

Please sign in to comment.