Skip to content

Commit

Permalink
Merge pull request #79 from mkuznyetsov/newfields
Browse files Browse the repository at this point in the history
Add & validate plugin meta for plugin viewer
  • Loading branch information
mkuznyetsov authored Feb 12, 2019
2 parents 33bd7b5 + b59a745 commit 1fe841b
Show file tree
Hide file tree
Showing 19 changed files with 215 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ sudo: required
services: docker

script:
- docker build .
- docker build . --no-cache
23 changes: 15 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
FROM mikefarah/yq
#
# Copyright (c) 2018-2019 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
#
FROM mikefarah/yq as builder
RUN apk add --no-cache bash
COPY /plugins /test/plugins
COPY check_plugins_location.sh /test/check_plugins_location.sh
COPY check_plugins_images.sh /test/check_plugins_images.sh
RUN cd /test/ && ./check_plugins_location.sh && ./check_plugins_images.sh
COPY .htaccess README.md /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/

FROM registry.centos.org/centos/httpd-24-centos7
RUN mkdir /var/www/html/plugins
COPY /plugins /var/www/html/plugins
COPY index.sh .htaccess README.md /var/www/html/
RUN cd /var/www/html/ && ./index.sh > plugins/index.json && rm index.sh
COPY --from=builder /build/ /var/www/html/
USER 0
RUN chmod -R g+rwX /var/www/html/plugins
20 changes: 17 additions & 3 deletions Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# Copyright (c) 2018-2019 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
#
FROM mikefarah/yq as builder
RUN apk add --no-cache bash
COPY .htaccess README.md /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/

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

RUN sed -i -e "s,Listen 80,Listen 8080," /etc/httpd/conf/httpd.conf
Expand All @@ -12,9 +28,7 @@ RUN chmod a+rwX /etc/httpd/conf
RUN chmod a+rwX /run/httpd

RUN mkdir /var/www/html/plugins
COPY /plugins /var/www/html/plugins
COPY index.sh .htaccess README.md /var/www/html/
RUN cd /var/www/html/ && ./index.sh > plugins/index.json && rm index.sh
COPY --from=builder /build/ /var/www/html/

STOPSIGNAL SIGWINCH

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ 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.
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

## OpenShift
Expand Down
85 changes: 85 additions & 0 deletions check_plugins_viewer_mandatory_fields.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash
#
# Copyright (c) 2018-2019 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

FIELDS=("title" "publisher" "category" "icon" "description" "repository" "firstPublicationDate" "latestUpdateDate")
CATEGORIES=("Editor" "Debugger" "Formatter" "Language" "Linter" "Snippet" "Theme" "Other")

# check that field value, given in the parameter, is not null or empty
function check_field() {
if [[ $1 == "null" || $1 = "\'\'" ]];then
return 1;
fi
return 0
}

# validate category value, given in the parameter,
function check_category() {
# If category is absent, replace is with "Other" and consider it valid
if [[ $1 == "null" || $1 = "\'\'" ]];then
yq w meta.yaml category "Other" -i
return 0;
fi
for CATEGORY in "${CATEGORIES[@]}"
do
if [[ ${CATEGORY} == "$1" ]];then
return 0
fi
done
return 1
}


cd plugins
echo "start"
for d in */ ; do
ID_DIR_NAME=${d%/}
cd "$d"

for VERSION_DIR_NAME in */ ; do
# Remove trailing slash
VERSION_DIR_NAME=${VERSION_DIR_NAME%/}
cd "${VERSION_DIR_NAME}"

echo "Checking plugin '${ID_DIR_NAME}/${VERSION_DIR_NAME}'"

unset NULL_OR_EMPTY_FIELDS

for FIELD in "${FIELDS[@]}"
do
VALUE=$(yq r meta.yaml "$FIELD")
if [[ "${FIELD}" == "category" ]];then
if ! check_category "${VALUE}";then
echo "!!! Invalid category in '${ID_DIR_NAME}/${VERSION_DIR_NAME}': $VALUE"
INVALID_FIELDS=true;
fi
continue
fi

if ! check_field "${VALUE}";then
NULL_OR_EMPTY_FIELDS+="$FIELD "
fi
done

if [[ -n "${NULL_OR_EMPTY_FIELDS}" ]];then
echo "!!! Null or empty mandatory fields in '${ID_DIR_NAME}/${VERSION_DIR_NAME}': $NULL_OR_EMPTY_FIELDS"
INVALID_FIELDS=true
fi

cd ..
done

cd ..
done

if [[ -n "${INVALID_FIELDS}" ]];then
exit 1
fi

5 changes: 3 additions & 2 deletions cico_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ function install_deps() {
/usr/sbin/setenforce 0 || true

# Get all the deps in
yum -y install \
docker \
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce \
git

service docker start
Expand Down
2 changes: 1 addition & 1 deletion index.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Copyright (c) 2012-2018 Red Hat, Inc.
# This program and the accompanying materials are made
Expand Down
4 changes: 4 additions & 0 deletions plugins/che-dummy-plugin/0.0.1/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ title: Che Samples Hello World Plugin
description: A hello world theia plug-in wrapped into a Che Plug-in
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
url: https://github.com/ws-skeleton/che-dummy-plugin/releases/download/untagged-8f3e198285a2f3b6b2db/che-dummy-plugin.tar.gz
publisher: Red Hat, Inc.
repository: https://github.com/ws-skeleton/che-dummy-plugin/
category: Other
firstPublicationDate: "2019-02-05"
7 changes: 6 additions & 1 deletion plugins/che-machine-exec-plugin/0.0.1/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ version: 0.0.1
type: Che Plugin
name: Che machine-exec Service
title: Che machine-exec Service Plugin
description: Che Plug-in with che-machine-exec service to provide creation terminal or tasks for Eclipse CHE workspace machines.
description: Che Plug-in with che-machine-exec service to provide creation terminal
or tasks for Eclipse CHE workspace machines.
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
url: https://github.com/eclipse/che-machine-exec/releases/download/0.0.2/che-service-plugin.tar.gz
publisher: Red Hat, Inc.
repository: https://github.com/eclipse/che-machine-exec/
firstPublicationDate: "2019-02-05"
category: Other
4 changes: 4 additions & 0 deletions plugins/che-service-plugin/0.0.1/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ title: Che Samples REST API Sidecar Plugin
description: Che Plug-in with Theia plug-in and container definition providing a service
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
url: https://github.com/ws-skeleton/che-service-plugin/releases/download/untagged-5c4c888ff2de8ae7a5e2/che-service-plugin.tar.gz
publisher: Red Hat, Inc.
repository: https://github.com/ws-skeleton/che-service-plugin/
category: Other
firstPublicationDate: "2019-02-05"
4 changes: 4 additions & 0 deletions plugins/org.eclipse.che.editor.dirigible/1.0.0/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ title: Eclipse Dirigible for Eclipse Che
description: Eclipse Dirigible as App Development Platform for Eclipse Che
icon: https://www.dirigible.io/img/dirigible.svg
url: https://raw.githubusercontent.com/dirigiblelabs/dirigible-che-editor-plugin/817f57ddd61cc4f5f0f99a18dc95b7507a31ab4d/etc/che-plugin.yaml
publisher: Red Hat, Inc.
category: Editor
repository: https://github.com/dirigiblelabs/dirigible-che-editor-plugin/
firstPublicationDate: "2019-02-05"
4 changes: 4 additions & 0 deletions plugins/org.eclipse.che.editor.eclipseide/0.0.1/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ title: Eclipse IDE (in browser using Broadway) as editor for Eclipse Che
description: Eclipse IDE
icon: https://cdn.freebiesupply.com/logos/large/2x/eclipse-11-logo-svg-vector.svg
url: https://github.com/ws-skeleton/che-editor-eclipseide/releases/download/0.0.2/che-editor-plugin.tar.gz
publisher: Red Hat, Inc.
category: Editor
repository: https://github.com/ws-skeleton/che-editor-eclipseide/
firstPublicationDate: "2019-02-05"
4 changes: 4 additions & 0 deletions plugins/org.eclipse.che.editor.gwt/1.0.0/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ title: Eclipse GWT IDE for Eclipse Che
description: Eclipse GWT IDE
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
url: https://github.com/eclipse/che-editor-gwt-ide/releases/download/che-editor-gwt-ide-2019-01-31_1036-02/che-editor-plugin.tar.gz
publisher: Red Hat, Inc.
category: Editor
repository: https://github.com/eclipse/che-editor-gwt-ide/
firstPublicationDate: "2019-02-05"
4 changes: 4 additions & 0 deletions plugins/org.eclipse.che.editor.jupyter/1.0.0/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ title: Jupyter Notebook as Editor for Eclipse Che
description: Jupyter Notebook as Editor for Eclipse Che
icon: https://jupyter.org/assets/main-logo.svg
url: https://github.com/ws-skeleton/che-editor-jupyter/releases/download/untagged-561b57d97aea19f373ee/che-editor-plugin.tar.gz
publisher: Red Hat, Inc.
category: Editor
repository: https://github.com/ws-skeleton/che-editor-jupyter/
firstPublicationDate: "2019-02-05"
5 changes: 5 additions & 0 deletions plugins/org.eclipse.che.editor.theia/1.0.0/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ title: Eclipse Theia for Eclipse Che
description: Eclipse Theia
icon: https://raw.githubusercontent.com/theia-ide/theia/master/logo/theia-logo-no-text-black.svg?sanitize=true
url: https://github.com/eclipse/che-theia/releases/download/v0.3.19/che-editor-plugin.tar.gz
publisher: Red Hat, Inc.
category: Editor
repository: https://github.com/eclipse/che-theia
firstPublicationDate: "2019-02-05"

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ version: 0.0.1
type: Theia plugin
name: Che-Samples-Fortune
title: Che Samples Container Fortune Plugin
description: Fortune plug-in running in its own container that provides the fortune tool
description: Fortune plug-in running in its own container that provides the fortune
tool
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
url: https://github.com/ws-skeleton/che-fortune-plugin/releases/download/untagged-bbffe2843692982f673b/che_fortune_plugin.theia
publisher: Red Hat, Inc.
repository: https://github.com/ws-skeleton/che-fortune-plugin/
firstPublicationDate: "2019-02-05"
category: Other
4 changes: 4 additions & 0 deletions plugins/org.eclipse.che.theia.dev/0.0.1/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ title: Che Theia Dev Plugin
description: Che Theia Dev Plugin
icon: https://www.eclipse.org/che/images/logo-eclipseche.svg
url: https://github.com/che-incubator/che-theia-dev-plugin/releases/download/0.0.2/che-theia-dev-plugin.tar.gz
publisher: Red Hat, Inc.
repository: https://github.com/che-incubator/che-theia-dev-plugin/
firstPublicationDate: "2019-02-05"
category: Other
4 changes: 4 additions & 0 deletions plugins/org.eclipse.che.vscode-sonarlint/0.0.1/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ attributes:
extension: "vscode:extension/SonarSource.sonarlint-vscode"
container-image: "garagatyi/remotetheia:java"
containerImage: "garagatyi/remotetheia:java"
firstPublicationDate: "2019-02-05"
category: Linter
publisher: SonarSource
repository: https://www.sonarlint.org/
41 changes: 41 additions & 0 deletions set_plugin_dates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
#
# Copyright (c) 2019 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

is_first_publication_date_present() {
# check that first publication date is present in yaml,
# and is not an null or empty value
VALUE=$(yq r meta.yaml firstPublicationDate)
if [[ $VALUE == "null" || $VALUE = "\'\'" ]];then
return 1
fi
return 0;
}

cd plugins
for d in */ ; do
cd "$d"

for VERSION_DIR_NAME in */ ; do
# Remove trailing slash
VERSION_DIR_NAME=${VERSION_DIR_NAME%/}
cd "${VERSION_DIR_NAME}"

DATE=$(date -I)
if ! is_first_publication_date_present; then
yq w meta.yaml firstPublicationDate "${DATE}" -i
fi

yq w meta.yaml latestUpdateDate "${DATE}" -i
cd ..
done

cd ..
done

0 comments on commit 1fe841b

Please sign in to comment.