-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from mkuznyetsov/newfields
Add & validate plugin meta for plugin viewer
- Loading branch information
Showing
19 changed files
with
215 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ sudo: required | |
services: docker | ||
|
||
script: | ||
- docker build . | ||
- docker build . --no-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |