Skip to content

Commit

Permalink
Merge pull request eclipse-che#132 from garagatyi/fixScripts
Browse files Browse the repository at this point in the history
Fix bash usage by scripts
  • Loading branch information
Oleksandr Garagatyi authored May 7, 2019
2 parents e66c286 + 01da8d4 commit bec007a
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 36 deletions.
6 changes: 3 additions & 3 deletions check_plugins_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ set -e
source ./util.sh

## check that icon tags in meta.yaml files points to the .svg images
declare -a arr=(`find . -name "meta.yaml"`)
readarray -d '' arr < <(find . -name 'meta.yaml' -print0)
for i in "${arr[@]}"
do
ICON=$(yq r $i icon | sed 's/^"\(.*\)"$/\1/')
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
plugin_id=$(evaluate_plugin_id $i)
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}':"
Expand Down
2 changes: 1 addition & 1 deletion check_plugins_location_v1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -e

source ./util.sh

declare -a arr=(`find plugins -name "meta.yaml"`)
readarray -d '' arr < <(find plugins -name 'meta.yaml' -print0)
for i in "${arr[@]}"
do
id=$(yq r "$i" id | sed 's/^"\(.*\)"$/\1/')
Expand Down
4 changes: 2 additions & 2 deletions check_plugins_location_v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ set -e

source ./util.sh

declare -a arr=(`find "$1" -name "meta.yaml"`)
readarray -d '' arr < <(find "$1" -name 'meta.yaml' -print0)
for i in "${arr[@]}"
do
plugin_id=$(evaluate_plugin_id $i)
plugin_id=$(evaluate_plugin_id "$i")

expected_path="$1/plugins/${plugin_id}/meta.yaml"
if [[ "${expected_path}" != "$i" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions check_plugins_viewer_mandatory_fields_v1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function check_category() {
return 1
}

declare -a arr=(`find plugins -name "meta.yaml"`)
readarray -d '' arr < <(find plugins -name 'meta.yaml' -print0)
for i in "${arr[@]}"
do
id=$(yq r "$i" id | sed 's/^"\(.*\)"$/\1/')
Expand All @@ -55,7 +55,7 @@ do

for FIELD in "${FIELDS[@]}"
do
VALUE=$(yq r $i "$FIELD")
VALUE=$(yq r "$i" "$FIELD")
if [[ "${FIELD}" == "category" ]];then
if ! check_category "$i" "${VALUE}";then
echo "!!! Invalid category in '${full_id}': $VALUE"
Expand Down
6 changes: 3 additions & 3 deletions check_plugins_viewer_mandatory_fields_v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ function check_category() {
return 1
}

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

echo "Checking plugin '${plugin_id}'"

unset NULL_OR_EMPTY_FIELDS

for FIELD in "${FIELDS[@]}"
do
VALUE=$(yq r $i "$FIELD")
VALUE=$(yq r "$i" "$FIELD")
if [[ "${FIELD}" == "category" ]];then
if ! check_category "$i" "${VALUE}";then
echo "!!! Invalid category in '${plugin_id}': $VALUE"
Expand Down
6 changes: 3 additions & 3 deletions check_plugins_viewer_mandatory_fields_v3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ function check_category() {
return 1
}

declare -a arr=(`find v3 -name "meta.yaml"`)
readarray -d '' arr < <(find v3 -name 'meta.yaml' -print0)
for i in "${arr[@]}"
do
plugin_id=$(evaluate_plugin_id $i)
plugin_id=$(evaluate_plugin_id "$i")

echo "Checking plugin '${plugin_id}'"

unset NULL_OR_EMPTY_FIELDS

for FIELD in "${FIELDS[@]}"
do
VALUE=$(yq r $i "$FIELD")
VALUE=$(yq r "$i" "$FIELD")
if [[ "${FIELD}" == "category" ]];then
if ! check_category "$i" "${VALUE}";then
echo "!!! Invalid category in '${plugin_id}': $VALUE"
Expand Down
16 changes: 8 additions & 8 deletions cico_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,35 @@ function install_deps() {

function tag_push() {
local TARGET=$1
docker tag ${IMAGE} $TARGET
docker push $TARGET
docker tag "${IMAGE}" "$TARGET"
docker push "$TARGET"
}

function deploy() {
TARGET=${TARGET:-"centos"}
REGISTRY="quay.io"

if [ $TARGET == "rhel" ]; then
if [ "$TARGET" == "rhel" ]; then
DOCKERFILE="Dockerfile.rhel"
IMAGE="rhel-che-plugin-registry"
else
DOCKERFILE="Dockerfile"
IMAGE="che-plugin-registry"
fi

if [ -n "${QUAY_USERNAME}" -a -n "${QUAY_PASSWORD}" ]; then
docker login -u ${QUAY_USERNAME} -p ${QUAY_PASSWORD} ${REGISTRY}
if [ -n "${QUAY_USERNAME}" ] && [ -n "${QUAY_PASSWORD}" ]; then
docker login -u "${QUAY_USERNAME}" -p "${QUAY_PASSWORD}" "${REGISTRY}"
else
echo "Could not login, missing credentials for the registry"
fi

# Let's deploy
docker build -t ${IMAGE} -f ${DOCKERFILE} .

TAG=$(echo $GIT_COMMIT | cut -c1-${DEVSHIFT_TAG_LEN})
TAG=$(echo "$GIT_COMMIT" | cut -c1-"${DEVSHIFT_TAG_LEN}")

tag_push ${REGISTRY}/openshiftio/$IMAGE:$TAG
tag_push ${REGISTRY}/openshiftio/$IMAGE:latest
tag_push "${REGISTRY}/openshiftio/$IMAGE:$TAG"
tag_push "${REGISTRY}/openshiftio/$IMAGE:latest"
echo 'CICO: Image pushed, ready to update deployed app'
}

Expand Down
11 changes: 6 additions & 5 deletions index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getId() {
function buildIndex() {
fields=('displayName' 'version' 'type' 'name' 'description' 'publisher')
## search for all editors and plugins
declare -a arr=(`find "$1" -name "meta.yaml"`)
readarray -d '' arr < <(find "$1" -name 'meta.yaml' -print0)
FIRST_LINE=true
echo "["
## now loop through meta files
Expand All @@ -39,12 +39,13 @@ function buildIndex() {
echo ",{"
fi

plugin_id=$(getId $i)
plugin_id=$(getId "$i")
echo " \"id\": \"$plugin_id\","

for field in ${fields[@]}
for field in "${fields[@]}"
do
echo " \"$field\":\""$(yq r "$i" "$field" | sed 's/^"\(.*\)"$/\1/')"\","
value="$(yq r "$i" "$field" | sed 's/^"\(.*\)"$/\1/')"
echo " \"$field\":\"$value\","
done

# Add deprecate section
Expand All @@ -60,7 +61,7 @@ function buildIndex() {
echo " },"
fi

echo " \"links\": {\"self\":\"/$(echo $i)\" }"
echo " \"links\": {\"self\":\"/$i\" }"
echo "}"
done
echo "]"
Expand Down
14 changes: 8 additions & 6 deletions index_v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ source ./util.sh
# Arguments:
# 1 - meta.yaml location
function getId() {
evaluate_plugin_id $1
evaluate_plugin_id "$1"
}

# getId function MUST be defined to use this function
Expand All @@ -29,7 +29,7 @@ function getId() {
function buildIndex() {
fields=('displayName' 'version' 'type' 'name' 'description' 'publisher')
## search for all editors and plugins
declare -a arr=(`find "$1" -name "meta.yaml"`)
readarray -d '' arr < <(find "$1" -name 'meta.yaml' -print0)
FIRST_LINE=true
echo "["
## now loop through meta files
Expand All @@ -42,12 +42,13 @@ function buildIndex() {
echo ",{"
fi

plugin_id=$(getId $i)
plugin_id=$(getId "$i")
echo " \"id\": \"$plugin_id\","

for field in ${fields[@]}
for field in "${fields[@]}"
do
echo " \"$field\":\""$(yq r "$i" "$field" | sed 's/^"\(.*\)"$/\1/')"\","
value="$(yq r "$i" "$field" | sed 's/^"\(.*\)"$/\1/')"
echo " \"$field\":\"$value\","
done

# Add deprecate section
Expand All @@ -63,7 +64,8 @@ function buildIndex() {
echo " },"
fi

echo " \"links\": {\"self\":\"/$(echo $i|sed 's/\/meta.yaml$//g')\" }"
path=$(echo "$i" | sed 's/\/meta.yaml$//g')
echo " \"links\": {\"self\":\"/$path\" }"
echo "}"
done
echo "]"
Expand Down
5 changes: 2 additions & 3 deletions set_plugin_dates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ 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 "$1" firstPublicationDate)
if [ $? -ne 0 ]; then
if ! VALUE=$(yq r "$1" firstPublicationDate); then
exit 1
fi

Expand All @@ -24,7 +23,7 @@ is_first_publication_date_present() {
return 0;
}

declare -a arr=(`find . -name "meta.yaml"`)
readarray -d '' arr < <(find . -name 'meta.yaml' -print0)
for i in "${arr[@]}"
do
DATE=$(date -I)
Expand Down

0 comments on commit bec007a

Please sign in to comment.