Skip to content

Commit

Permalink
Fixing start script to work on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
metalice committed Jan 30, 2025
1 parent e763870 commit ed26661
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
31 changes: 21 additions & 10 deletions ci/start-console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,32 @@ source ${script_dir}/configure/openshift.sh
CONSOLE_CONTAINER_NAME=okd-console
FORKLIFT_NAMESPACE=konveyor-forklift

PLUGIN_NAME="forklift-console-plugin"
PLUGIN_URL=${PLUGIN_URL:-"http://localhost:9001"}
BASE_HOST_URL=${BASE_HOST_URL:-"https://localhost"}
CONTAINER_NETWORK_TYPE=${CONTAINER_NETWORK_TYPE:-"host"}
CONTAINER_NETWORK=${CONTAINER_NETWORK:-"--network=${CONTAINER_NETWORK_TYPE}"}

PLUGIN_NAME="forklift-console-plugin"
CONSOLE_IMAGE=${CONSOLE_IMAGE:-"quay.io/openshift/origin-console:latest"}
CONSOLE_PORT=${CONSOLE_PORT:-9000}

if [[ $(uname) = "Darwin" ]]; then
# On macOS
BASE_HOST_URL="http://host.containers.internal"
CONTAINER_NETWORK=""

fi
PLUGIN_URL="$BASE_HOST_URL:9001"

# Look for forklift routes
if oc_available_loggedin; then
routes=$(oc get routes -A -o template --template='{{range .items}}{{.spec.host}}{{"\n"}}{{end}}' 2>/dev/null || true)
INVENTORY_SERVER_HOST=${INVENTORY_SERVER_HOST:-$(echo "$routes" | grep forklift-inventory || true)}
SERVICES_API_SERVER_HOST=${SERVICES_API_SERVER_HOST:-$(echo "$routes" | grep forklift-services || true)}
INVENTORY_SERVER_HOST="https://$(echo "$routes" | grep forklift-inventory)"
SERVICES_API_SERVER_HOST="https://$(echo "$routes" | grep forklift-services)"
fi

# Default to localhost if no route found
INVENTORY_SERVER_HOST=${INVENTORY_SERVER_HOST:-"https://localhost:30444"}
SERVICES_API_SERVER_HOST=${SERVICES_API_SERVER_HOST:-"https://localhost:30446"}
INVENTORY_SERVER_HOST=${INVENTORY_SERVER_HOST:-"$BASE_HOST_URL:30444"}
SERVICES_API_SERVER_HOST=${SERVICES_API_SERVER_HOST:-"$BASE_HOST_URL:30446"}

if [[ ${CONSOLE_IMAGE} =~ ^localhost/ ]]; then
PULL_POLICY="never"
Expand All @@ -32,8 +42,8 @@ fi

# Test if console is already running
if podman container exists ${CONSOLE_CONTAINER_NAME}; then
echo "container named ${CONSOLE_CONTAINER_NAME} is running, exit."
exit 1
echo "container named ${CONSOLE_CONTAINER_NAME} is running, exit."
exit 1
fi

# Base setup for the bridge
Expand All @@ -49,7 +59,8 @@ fi
#
# NOTE: When running KinD we should use host network type because KinD only listen on localhost.
BRIDGE_PLUGINS="${PLUGIN_NAME}=${PLUGIN_URL}"
BRIDGE_PLUGIN_PROXY=$(cat << END | jq -c .
BRIDGE_PLUGIN_PROXY=$(
cat <<END | jq -c .
{"services":[
{
"consoleAPIPath":"/api/proxy/plugin/${PLUGIN_NAME}/forklift-inventory/",
Expand Down Expand Up @@ -95,7 +106,7 @@ podman run \
--pull=${PULL_POLICY} \
--rm \
${mount_tmp_dir_flag} \
--network=${CONTAINER_NETWORK_TYPE} \
${CONTAINER_NETWORK} \
--publish=${CONSOLE_PORT}:${CONSOLE_PORT} \
--name=${CONSOLE_CONTAINER_NAME} \
--env "BRIDGE_*" \
Expand Down
2 changes: 1 addition & 1 deletion packages/forklift-console-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"clean:all": "yarn clean ./node_modules ./.rollup.cache",
"i18n": "i18next \"./src/**/*.{js,jsx,ts,tsx}\" [-oc] -c ./i18next-parser.config.js",
"build": "NODE_ENV=production webpack",
"start": "NODE_ENV=development webpack serve",
"start": "NODE_ENV=development webpack serve --progress",
"buildlib": "rollup -c --bundleConfigAsCjs",
"lint": "eslint . && stylelint \"src/**/*.css\" --allow-empty-input",
"lint:fix": "eslint . --fix && stylelint \"src/**/*.css\" --allow-empty-input --fix",
Expand Down
4 changes: 2 additions & 2 deletions packages/forklift-console-plugin/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ const config: Configuration = {
},
devServer: {
static: ['./dist'],
host: 'localhost',
hot: false,
allowedHosts: 'all',
hot: true,
port: 9001,
headers: {
'Access-Control-Allow-Origin': '*',
Expand Down

0 comments on commit ed26661

Please sign in to comment.