Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Added run-in-development toggle for local development #164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions assets/scripts/check-engine-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions assets/scripts/configure-microk8s-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} ;;
Expand All @@ -25,14 +25,15 @@ 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
;;
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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions assets/scripts/configure-microk8s-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/constants/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion src/main/Clusters/MicroK8s/MicroK8s.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions src/renderer/components/Config/RunDevView.tsx
Original file line number Diff line number Diff line change
@@ -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<string, string>;
localFlags: Record<string, string>;
onChange: (key: string, value: string) => void;
sx?: SxProps<Theme>;
}

const RunInDevelopment = ({ localFlags, onChange, sx }: Props) => {
return (
<Box sx={sx}>
<FormControlLabel
labelPlacement="start"
label={
<Box sx={{ display: 'flex', alignItems: 'top', flexDirection: 'row' }}>
<Typography variant="body2">{Storage.RUN_IN_DEVELOPMENT.replaceAll('_', ' ')}</Typography>
<InfoTooltip message="Toggle to run in development mode." />
</Box>
}
sx={{ marginTop: 1, marginLeft: 0 }}
control={<Switch checked={localFlags[Storage.RUN_IN_DEVELOPMENT] === 'true'} sx={{ marginLeft: 4 }} />}
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])
}
}}
/>
</Box>
);
};

export default RunInDevelopment;
4 changes: 3 additions & 1 deletion src/renderer/dialogs/ConfigurationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,7 +77,7 @@ const ConfigurationDialog = ({ onClose }: Props) => {
})
const [tempConfigs, setTempConfigs] = useState({} as Record<string, string>)
const [tempVars, setTempVars] = useState({} as Record<string, string>)
const [localFlags, setLocalFlags] = useState({ [Storage.FORCE_DB_REFRESH]: 'false' } as Record<string, string>)
const [localFlags, setLocalFlags] = useState({ [Storage.FORCE_DB_REFRESH]: 'false', [Storage.RUN_IN_DEVELOPMENT]: 'false' } as Record<string, string>)

if (!selectedCluster) {
enqueueSnackbar('Please select a cluster.', { variant: 'error' })
Expand Down Expand Up @@ -187,6 +188,7 @@ const ConfigurationDialog = ({ onClose }: Props) => {
<Box sx={{ marginLeft: 2, marginRight: 2 }}>
<ConfigsView localConfigs={localConfigs} onChange={onChangeConfig} />
<FlagsView localFlags={localFlags} onChange={onChangeFlag} />
<RunDevView localFlags={localFlags} onChange={onChangeFlag}/>
</Box>
)
},
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/dialogs/CreateClusterDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}))
}
Expand Down Expand Up @@ -276,6 +277,7 @@ const CreateClusterDialog = ({ onClose }: Props) => {
<Box sx={{ marginLeft: 2, marginRight: 2 }}>
<ConfigsView localConfigs={localConfigs} onChange={onChangeConfig} />
<FlagsView localFlags={localFlags} onChange={onChangeFlag} />
<RunDevView localFlags={localFlags} onChange={onChangeFlag}/>
</Box>
)
})
Expand Down
Loading