diff --git a/assets/scripts/check-engine-deployment.sh b/assets/scripts/check-engine-deployment.sh index 36968919..a54fae2f 100644 --- a/assets/scripts/check-engine-deployment.sh +++ b/assets/scripts/check-engine-deployment.sh @@ -13,10 +13,16 @@ CLUSTER_ID=$4 CLUSTER_TYPE=$5 OPS_FOLDER=$6 TAG=$7 +RUN_IN_DEVELOPMENT=$8 #======================= # Verify Ethereal Engine #======================= + if [[ "$RUN_IN_DEVELOPMENT" == 'true' ]]; then + APP_ENV=development + else + APP_ENV=production + fi cd "$ENGINE_FOLDER" || exit @@ -68,7 +74,7 @@ export COMPOSE_DOCKER_CLI_BUILD=0 if [[ $CLUSTER_TYPE == 'microk8s' ]]; then set +e - bash ./scripts/build_microk8s.sh "$TAG" true + bash ./scripts/build_microk8s.sh "$TAG" true "$APP_ENV" exit_status=$? if [ "$exit_status" -ne 0 ]; then @@ -87,7 +93,7 @@ elif [[ $CLUSTER_TYPE == 'microk8sWindows' ]]; then while [ "$retry" -le 6 ]; do echo "Trying: $retry" - bash ./scripts/build_microk8s.sh "$TAG" true + bash ./scripts/build_microk8s.sh "$TAG" true "$APP_ENV" exit_status=$? if [ $exit_status -eq 0 ]; then diff --git a/assets/scripts/configure-microk8s-linux.sh b/assets/scripts/configure-microk8s-linux.sh index bd70ba5f..dcf2bca6 100755 --- a/assets/scripts/configure-microk8s-linux.sh +++ b/assets/scripts/configure-microk8s-linux.sh @@ -15,7 +15,7 @@ checkExitCode() { # Parameters #=========== -while getopts a:c:d:f:i:o:p:r: flag; do +while getopts a:c:d:f:i:o:p:r:u: flag; do case "${flag}" in a) ASSETS_FOLDER=${OPTARG} ;; c) CONFIGS_FOLDER=${OPTARG} ;; @@ -25,6 +25,7 @@ while getopts a:c:d:f:i:o:p:r: flag; do o) OPS_FOLDER=${OPTARG} ;; p) PASSWORD=${OPTARG} ;; r) ENABLE_RIPPLE_STACK=${OPTARG} ;; + u) RUN_IN_DEVELOPMENT=${OPTARG} ;; *) echo "Invalid argument passed" >&2 exit 1 @@ -32,7 +33,7 @@ while getopts a:c:d:f:i:o:p:r: flag; do esac done -if [[ -z $ASSETS_FOLDER || -z $CONFIGS_FOLDER || -z $FORCE_DB_REFRESH || -z $ENGINE_FOLDER || -z $CLUSTER_ID || -z $OPS_FOLDER || -z $ENABLE_RIPPLE_STACK ]]; then +if [[ -z $ASSETS_FOLDER || -z $CONFIGS_FOLDER || -z $FORCE_DB_REFRESH || -z $ENGINE_FOLDER || -z $CLUSTER_ID || -z $OPS_FOLDER || -z $ENABLE_RIPPLE_STACK || -z $RUN_IN_DEVELOPMENT ]]; then # Allow empty passwords echo "Missing arguments" exit 1 @@ -47,6 +48,7 @@ echo "Engine Folder: ${ENGINE_FOLDER}" echo "OPS Folder: ${OPS_FOLDER}" echo "Assets Folder: ${ASSETS_FOLDER}" echo "Configs Folder: ${CONFIGS_FOLDER}" +echo "Run In development: ${RUN_IN_DEVELOPMENT}" #================================ # Set script directory as current @@ -295,7 +297,7 @@ checkExitCode # Verify Ethereal Engine #======================= -bash "$SCRIPTS_FOLDER/check-engine-deployment.sh" "$ENGINE_FOLDER" "$FORCE_DB_REFRESH" "$CONFIGS_FOLDER" "$CLUSTER_ID" "microk8s" "$OPS_FOLDER" "$TAG" +bash "$SCRIPTS_FOLDER/check-engine-deployment.sh" "$ENGINE_FOLDER" "$FORCE_DB_REFRESH" "$CONFIGS_FOLDER" "$CLUSTER_ID" "microk8s" "$OPS_FOLDER" "$TAG" "$RUN_IN_DEVELOPMENT" checkExitCode diff --git a/assets/scripts/configure-microk8s-windows.ps1 b/assets/scripts/configure-microk8s-windows.ps1 index ef19cc3a..5ba2aa37 100644 --- a/assets/scripts/configure-microk8s-windows.ps1 +++ b/assets/scripts/configure-microk8s-windows.ps1 @@ -61,6 +61,9 @@ for ( $i = 0; $i -lt $args.count; $i += 2 ) { elseif ($args[$i] -eq "-r") { $ENABLE_RIPPLE_STACK = $args[$i + 1] } + elseif ($args[$i] -eq "-u") { + $RUN_IN_DEVELOPMENT = $args[$i + 1] + } else { throw "Invalid argument passed" exit 1 @@ -74,7 +77,8 @@ if ([string]::IsNullOrEmpty($ASSETS_FOLDER) -or [string]::IsNullOrEmpty($CLUSTER_ID) -or [string]::IsNullOrEmpty($OPS_FOLDER) -or [string]::IsNullOrEmpty($PASSWORD) -or - [string]::IsNullOrEmpty($ENABLE_RIPPLE_STACK)) { + [string]::IsNullOrEmpty($ENABLE_RIPPLE_STACK) -or + [string]::IsNullOrEmpty($RUN_IN_DEVELOPMENT)) { throw "Missing arguments" exit 1 } @@ -88,6 +92,7 @@ Write-Host "Engine Folder: $ENGINE_FOLDER"; Write-Host "OPS Folder: $OPS_FOLDER"; Write-Host "Configs Folder: $CONFIGS_FOLDER"; Write-Host "Assets Folder: $ASSETS_FOLDER"; +Write-Host "Force DB Refresh: $RUN_IN_DEVELOPMENT"; #============== # Prerequisites @@ -412,7 +417,7 @@ Write-Host "Tag is $TAG"; # Verify Ethereal Engine #======================= -wsl bash -ic "`"$SCRIPTS_FOLDER/check-engine-deployment.sh`" `"$ENGINE_FOLDER`" `"$FORCE_DB_REFRESH`" `"$CONFIGS_FOLDER`" `"$CLUSTER_ID`" `"microk8sWindows`" `"$OPS_FOLDER`" `"$TAG`""; +wsl bash -ic "`"$SCRIPTS_FOLDER/check-engine-deployment.sh`" `"$ENGINE_FOLDER`" `"$FORCE_DB_REFRESH`" `"$CONFIGS_FOLDER`" `"$CLUSTER_ID`" `"microk8sWindows`" `"$OPS_FOLDER`" `"$TAG`" `"$RUN_IN_DEVELOPMENT`""; checkExitCode; diff --git a/src/constants/Storage.ts b/src/constants/Storage.ts index db9baad2..76cc6683 100755 --- a/src/constants/Storage.ts +++ b/src/constants/Storage.ts @@ -23,6 +23,7 @@ export const generateUUID = () => { const Storage = { COLOR_MODE: 'COLOR_MODE', FORCE_DB_REFRESH: 'FORCE_DB_REFRESH', + RUN_IN_DEVELOPMENT: 'RUN_IN_DEVELOPMENT', AUTH_SECRET_KEY: 'AUTH_SECRET_UUID_OR_SIMILAR', SNS_TOPIC_NAME_KEY: 'SNS_TOPIC_NAME', AWS_ACCOUNT_ID_KEY: 'AWS_ACCOUNT_ID', diff --git a/src/main/Clusters/MicroK8s/MicroK8s.class.ts b/src/main/Clusters/MicroK8s/MicroK8s.class.ts index 16e4ded4..970de843 100644 --- a/src/main/Clusters/MicroK8s/MicroK8s.class.ts +++ b/src/main/Clusters/MicroK8s/MicroK8s.class.ts @@ -148,7 +148,8 @@ class MicroK8s { `-i "${cluster.id}"`, `-o "${cluster.configs[Storage.OPS_PATH]}"`, `-p "${password}"`, - `-r "${cluster.configs[Storage.ENABLE_RIPPLE_STACK]}"` + `-r "${cluster.configs[Storage.ENABLE_RIPPLE_STACK]}"`, + `-u "${flags[Storage.RUN_IN_DEVELOPMENT]}"` ], onConfigureStd, onConfigureStd diff --git a/src/renderer/components/Config/RunDevView.tsx b/src/renderer/components/Config/RunDevView.tsx new file mode 100644 index 00000000..cce0f377 --- /dev/null +++ b/src/renderer/components/Config/RunDevView.tsx @@ -0,0 +1,46 @@ +// RunInDevelopment.tsx +import { Box, FormControlLabel, Switch, SxProps, Theme, Typography } from '@mui/material'; +import InfoTooltip from '../../common/InfoTooltip'; +import Storage from 'constants/Storage'; + +interface Props { + // runDev: Record; + localFlags: Record; + onChange: (key: string, value: string) => void; + sx?: SxProps; +} + +const RunInDevelopment = ({ localFlags, onChange, sx }: Props) => { + return ( + + + {Storage.RUN_IN_DEVELOPMENT.replaceAll('_', ' ')} + + + } + sx={{ marginTop: 1, marginLeft: 0 }} + control={} + value={localFlags[Storage.RUN_IN_DEVELOPMENT] === 'true'} + // onChange={(_event, checked) => onChange(Storage.RUN_IN_DEVELOPMENT, checked ? 'true' : 'false')} + onChange={(_event, checked) => { + onChange(Storage.RUN_IN_DEVELOPMENT, checked ? 'true' : 'false') + if (checked) { + console.log(true) + console.log(Storage.RUN_IN_DEVELOPMENT) + console.log(localFlags[Storage.RUN_IN_DEVELOPMENT]) + } + else { + console.log(false) + console.log(Storage.RUN_IN_DEVELOPMENT) + console.log(localFlags[Storage.RUN_IN_DEVELOPMENT]) + } + }} + /> + + ); +}; + +export default RunInDevelopment; diff --git a/src/renderer/dialogs/ConfigurationDialog.tsx b/src/renderer/dialogs/ConfigurationDialog.tsx index 9d46b78c..26c6d0f7 100644 --- a/src/renderer/dialogs/ConfigurationDialog.tsx +++ b/src/renderer/dialogs/ConfigurationDialog.tsx @@ -36,6 +36,7 @@ import ConfigsView from '../components/Config/ConfigsView' import FlagsView from '../components/Config/FlagsView' import SummaryView from '../components/Config/SummaryView' import VarsView from '../components/Config/VarsView' +import RunDevView from 'renderer/components/Config/RunDevView' const ColorlibStepIcon = (props: StepIconProps) => { const { active, completed, className } = props @@ -76,7 +77,7 @@ const ConfigurationDialog = ({ onClose }: Props) => { }) const [tempConfigs, setTempConfigs] = useState({} as Record) const [tempVars, setTempVars] = useState({} as Record) - const [localFlags, setLocalFlags] = useState({ [Storage.FORCE_DB_REFRESH]: 'false' } as Record) + const [localFlags, setLocalFlags] = useState({ [Storage.FORCE_DB_REFRESH]: 'false', [Storage.RUN_IN_DEVELOPMENT]: 'false' } as Record) if (!selectedCluster) { enqueueSnackbar('Please select a cluster.', { variant: 'error' }) @@ -187,6 +188,7 @@ const ConfigurationDialog = ({ onClose }: Props) => { + ) }, diff --git a/src/renderer/dialogs/CreateClusterDialog.tsx b/src/renderer/dialogs/CreateClusterDialog.tsx index 72b55517..2fddae3c 100644 --- a/src/renderer/dialogs/CreateClusterDialog.tsx +++ b/src/renderer/dialogs/CreateClusterDialog.tsx @@ -43,6 +43,7 @@ import KubeconfigView from '../components/Config/KubeconfigView' import PrereqsView from '../components/Config/PrereqsView' import SummaryView from '../components/Config/SummaryView' import VarsView from '../components/Config/VarsView' +import RunDevView from 'renderer/components/Config/RunDevView' const ColorlibStepIcon = (props: StepIconProps) => { const { active, completed, className } = props @@ -115,7 +116,7 @@ const CreateClusterDialog = ({ onClose }: Props) => { setState((state) => ({ ...state, defaultConfigs: configs, - localFlags: { [Storage.FORCE_DB_REFRESH]: 'false' }, + localFlags: { [Storage.FORCE_DB_REFRESH]: 'false', [Storage.RUN_IN_DEVELOPMENT]: 'false' }, isLoading: false })) } @@ -276,6 +277,7 @@ const CreateClusterDialog = ({ onClose }: Props) => { + ) })