Skip to content

Commit

Permalink
KOGITO-1606: Add install option in makefile (apache#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgitario authored and MarianMacik committed Oct 3, 2023
1 parent 0b828f4 commit 22e96a0
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 34 deletions.
48 changes: 48 additions & 0 deletions hack/crds-utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
# Copyright 2020 Red Hat, Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Script with utils for CRDs resources.

# Apply CRDs by replacing existing resources or applying if they didn't exist previously.
# Example: apply_crds my_path
function apply_crds(){
deploy_folder=${1}
files=($deploy_folder/crds/*_crd.yaml)
for file in ${files[@]}
do
echo "Replace crds file ${file}"
oc replace -f ${file}
if [ "$?" != 0 ]; then
echo "crd from file '${file}' may not exist yet in cluster, try to simply apply it"
oc apply -f ${file}
fi
done
}

# Download CRDs from a URL into a folder.
# Example: download_remote_crds my_path https://path/to/crds.
function download_remote_crds(){
deploy_folder=${1}
url=${2}
echo "Download crd files into '${deploy_folder}' from ${url}"

mkdir -p "${deploy_folder}/crds"
files=(deploy/crds/*_crd.yaml)
for file in ${files[@]}
do
filename=${file##*/}
curl -k -o "${deploy_folder}/crds/${filename}" "${url}/crds/${filename}"
done
}
49 changes: 49 additions & 0 deletions hack/deploy-operator-on-ocp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
# Copyright 2020 Red Hat, Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# build and deploy the operator into Openshift using our quay account
# 0. Deploy CRDs
# 1. Deploy Roles and Service Account
# 2. Deploy the operator on Openshift

SCRIPT_DIR=`dirname $0`
IMAGE=$1
OPERATOR_NAME=kogito-operator
TMP_FOLDER=tmp

mkdir -p $TMP_FOLDER
rm -rf $TMP_FOLDER/*

echo "Deploying Operator $OPERATOR_NAME"

# CRDs
source $SCRIPT_DIR/crds-utils.sh
apply_crds "deploy"

# Service Account
oc create -f deploy/service_account.yaml

# Roles
oc create -f deploy/role.yaml
oc create -f deploy/role_binding.yaml

# Operator
sed "s/name: kogito-operator/name: $OPERATOR_NAME/g" deploy/operator.yaml > $TMP_FOLDER/operator.yaml
sed "s|image: quay.io/kiegroup/.*|image: $IMAGE|g" $TMP_FOLDER/operator.yaml > $TMP_FOLDER/operator-tmp.yaml
oc create -f $TMP_FOLDER/operator-tmp.yaml

# Clean Up
rm -rf $TMP_FOLDER/*
35 changes: 1 addition & 34 deletions hack/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.


# runs all BDD tests for the operator
SCRIPT_NAME=`basename $0`
SCRIPT_DIR=`dirname $0`

MASTER_RAW_URL=https://raw.githubusercontent.com/kiegroup/kogito-cloud-operator/master/deploy
CRD_FILES_TO_IMPORT=(
"app.kiegroup.org_kogitoapps_crd.yaml"
"app.kiegroup.org_kogitodataindices_crd.yaml"
"app.kiegroup.org_kogitoinfras_crd.yaml"
"app.kiegroup.org_kogitojobsservices_crd.yaml"
"app.kiegroup.org_kogitomgmtconsoles_crd.yaml"
)

function usage(){
printf "Run BDD tests."
Expand Down Expand Up @@ -88,32 +80,6 @@ function usage(){
printf "\n"
}

function download_remote_crds(){
deploy_folder=${1}
url=${2}
echo "Download crd files into '${deploy_folder}' from ${url}"

mkdir -p "${deploy_folder}/crds"
for file in ${CRD_FILES_TO_IMPORT[*]}
do
curl -k -o "${deploy_folder}/crds/${file}" "${url}/crds/${file}"
done
}

function apply_crds(){
deploy_folder=${1}
for file in ${CRD_FILES_TO_IMPORT[*]}
do
crd_file="${deploy_folder}/crds/${file}"
echo "Replace crds file ${crd_file}"
oc replace -f ${crd_file}
if [ "$?" != 0 ]; then
echo "crd from file '${file}' may not exist yet in cluster, try to simply apply it"
oc apply -f ${crd_file}
fi
done
}

function addParam(){
PARAMS="${PARAMS} ${1}"
}
Expand Down Expand Up @@ -317,6 +283,7 @@ done

if ${CRDS_UPDATE}; then
echo "-------- Apply CRD files"
source $SCRIPT_DIR/crds-utils.sh

deploy_folder="${SCRIPT_DIR}/../deploy"
if [[ ! -z "${OPERATOR_DEPLOY_FOLDER}" ]]; then
Expand Down

0 comments on commit 22e96a0

Please sign in to comment.