Skip to content

Commit 6467dcb

Browse files
authored
Merge pull request #173 from apache/partial-deploy
Partial deploy
2 parents 6e657d6 + 415e2c9 commit 6467dcb

4 files changed

Lines changed: 60 additions & 35 deletions

File tree

ide/docopts.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ OpenServerless Ide Development Utilities.
2626
Usage:
2727
ide login [<username>] [<apihost>]
2828
ide devel [--fast] [--dry-run]
29-
ide deploy [<action>] [--dry-run]
29+
ide deploy [<action>|--packages|--web] [--dry-run]
3030
ide undeploy [<action>] [--dry-run]
3131
ide clean
3232
ide setup
@@ -60,6 +60,8 @@ Usage:
6060
## Options
6161

6262
```
63-
--fast Skip the initial deployment step and go in incremental update mode
6463
--dry-run Simulates the execution without making any actual changes
64+
--packages Only deploy packages, skip web upload
65+
--web Only deploy web folder, skip packages
66+
--fast Skip the initial deployment step and go in incremental update mode
6567
```

ide/opsfile.yml

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ vars:
2222
API_HOST:
2323
sh: |
2424
echo "http://localhost:80"
25-
25+
2626
DEPLOY_CURRENT_HASH:
2727
sh: |
2828
if test -e "$OPS_ROOT/ide/deploy/bun.lockb"
@@ -36,12 +36,12 @@ vars:
3636
then cat "$OPS_ROOT/ide/deploy/hash.lock"
3737
else echo "0"
3838
fi
39-
39+
4040
tasks:
4141

4242
prereq:
4343
silent: true
44-
vars:
44+
vars:
4545
MSG: |
4646
This command must be run inside a devcontainer.
4747
Please use 'ops ide devcontainer' to create a configuration and enter in a devcontainer.
@@ -59,31 +59,31 @@ tasks:
5959
- test "$(ops -wsk property get --namespace | awk '{ print $3 }')" = "$OPSDEV_USERNAME" || die "Repeat the login"
6060
- |
6161
if ! test -d "$OPS_ROOT/ide/deploy/node_modules" || [ "{{.DEPLOY_CURRENT_HASH}}" != "{{.DEPLOY_PREVIOUS_HASH}}" ]
62-
then
62+
then
6363
cd $OPS_ROOT/ide/deploy && bun install && rm -f $OPS_ROOT/ide/deploy/hash.lock && bun $OPS_ROOT/ide/deploy/bun.lockb --hash > $OPS_ROOT/ide/deploy/hash.lock
6464
fi
6565
- |
6666
if test -e "$OPS_PWD/package.json"
6767
then if ! test -d "$OPS_PWD/node_modules"
6868
then cd $OPS_PWD ; bun install
6969
fi
70-
fi
70+
fi
7171
- task: kill
72-
72+
7373
devcontainer:
7474
silent: true
7575
desc: add a devcontainer to your project
7676
cmds:
7777
- |
7878
if test -e "$OPS_PWD/.devcontainer/devcontainer.json"
7979
then echo "a .devcontainer already exists"
80-
else
80+
else
8181
mkdir -p "$OPS_PWD/.devcontainer"
8282
cp devcontainer.json "$OPS_PWD/.devcontainer/"
8383
echo "devcontainer created in .devcontainer - please use VSCode and the command 'Reopen in Container'"
8484
fi
8585
- |
86-
if echo "$OPS_PWD/" | rg ' '
86+
if echo "$OPS_PWD/" | rg ' '
8787
then die "please place your workspace in a folder WITHOUT SPACES IN THE FOLDER NAME!!!!"
8888
fi
8989
- bun x @devcontainers/cli up --workspace-folder "$OPS_PWD"
@@ -98,22 +98,22 @@ tasks:
9898
PIDFILE=$(ops -opspath ~/.ops/tmp/deploy.pid)
9999
echo $PIDFILE
100100
if test -e $PIDFILE
101-
then
101+
then
102102
PID=$(cat $PIDFILE)
103103
104104
if [ ! -z "$PID" ]; then
105105
if ps -p "$PID" > /dev/null;
106106
then
107107
echo "Found previous deploy pid: $PID"
108108
kill "$PID"
109-
# PGRP=$(ps -o 'pgid=' -p $PID | xargs)
109+
# PGRP=$(ps -o 'pgid=' -p $PID | xargs)
110110
# if [ ! -z "$PGRP" ];
111-
# then
111+
# then
112112
# echo "Terminating deploy process group $PGRP"
113113
# kill "$PGRP"
114114
# else
115115
# echo "Terminating deploy process $PID"
116-
# kill "$PID"
116+
# kill "$PID"
117117
# fi
118118
fi
119119
fi
@@ -153,7 +153,7 @@ tasks:
153153
fi
154154
echo "*** Configuring Access to OpenServerless ***"
155155
if test -z "{{._apihost_}}"
156-
then
156+
then
157157
if test -z "$OPS_APIHOST"
158158
then
159159
echo -n "Enter Apihost: "
@@ -188,11 +188,11 @@ tasks:
188188
config OPSDEV_USERNAME="$OPSDEV_USERNAME"
189189
config OPSDEV_HOST="$OPSDEV_HOST_PROT://$OPSDEV_USERNAME.$OPSDEV_HOST_URL"
190190
source ~/.wskprops
191-
else
191+
else
192192
false
193193
fi
194-
195-
194+
195+
196196
197197
poll:
198198
silent: true
@@ -225,23 +225,41 @@ tasks:
225225
then source $OPS_PWD/packages/.env
226226
fi
227227
if test -n "$AUTH_CHECK"
228-
then if test "$AUTH_CHECK" != "$AUTH"
229-
then echo "WARNING: wrong deploy! You are logged in a different user than your configured AUTH_CHECK" ; exit 1
228+
then if test "$AUTH_CHECK" != "$AUTH"
229+
then echo "WARNING: wrong deploy! You are logged in a different user than your pinned one and configured in .env as AUTH_CHECK" ; exit 1
230230
fi
231231
fi
232+
232233
if {{.__dry_run}}
233234
then DRY="--dry-run" ; ECHO='echo'
234235
else DRY="" ; ECHO=""
235236
fi
236-
if test -z "{{._action_}}"
237+
238+
if {{.__web}}
239+
then deploy_packages=""
240+
else deploy_packages="1"
241+
fi
242+
243+
if {{.__packages}}
244+
then deploy_web=""
245+
else deploy_web="1"
246+
fi
247+
248+
if test -n "{{._action_}}"
237249
then
238-
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -d $DRY
239-
OPS_UPLOAD_FOLDER=`bun {{.TASKFILE_DIR}}/deploy/info.js upload web`
240-
echo "UPLOAD ASSETS FROM ${OPS_UPLOAD_FOLDER}"
241-
$ECHO $OPS util upload ${OPS_UPLOAD_FOLDER:-web}
242-
echo "URL: $OPSDEV_HOST"
250+
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -s "{{._action_}}" $DRY
243251
else
244-
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -s "{{._action_}}" $DRY
252+
if [ -n "$deploy_packages" ]
253+
then
254+
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -d $DRY
255+
fi
256+
if [ -n "$deploy_web" ]
257+
then
258+
OPS_UPLOAD_FOLDER=`bun {{.TASKFILE_DIR}}/deploy/info.js upload web`
259+
echo "UPLOAD ASSETS FROM ${OPS_UPLOAD_FOLDER}"
260+
$ECHO $OPS util upload ${OPS_UPLOAD_FOLDER:-web}
261+
echo "URL: $OPSDEV_HOST"
262+
fi
245263
fi
246264
247265
undeploy:
@@ -254,7 +272,6 @@ tasks:
254272
then DRY="--dry-run"
255273
else DRY=""
256274
fi
257-
258275
# Check if an action argument is provided
259276
if test -n "{{._action_}}"
260277
then
@@ -270,25 +287,24 @@ tasks:
270287
then echo '$' $OPS util clean
271288
else $OPS util clean
272289
fi
273-
290+
274291
275292
clean:
276293
silent: true
277294
cmds:
278295
- task: kill
279296
- |
280-
if test -d "$OPS_PWD/packages"
281-
then
297+
if test -d "$OPS_PWD/packages"
298+
then
282299
echo "*** removing virtualenv"
283300
/bin/rm -rvf "$OPS_PWD"/packages/*/*/virtualenv/
284301
echo "*** removing node_modules"
285302
/bin/rm -rvf "$OPS_PWD"/packages/*/*/node_modules/
286303
echo "*** removing .zip"
287-
/bin/rm -vf "$OPS_PWD"/packages/*/*.zip
304+
/bin/rm -vf "$OPS_PWD"/packages/*/*.zip
288305
else die "no packages in current directory"
289306
fi
290307
291-
292308
devel:
293309
interactive: true
294310
silent: true
@@ -304,7 +320,7 @@ tasks:
304320
then source $OPS_PWD/packages/.env
305321
fi
306322
if test -n "$AUTH_CHECK"
307-
then if test "$AUTH_CHECK" != "$AUTH"
323+
then if test "$AUTH_CHECK" != "$AUTH"
308324
then echo "WARNING: wrong deploy! You are logged in a different user than your configured AUTH_CHECK" ; exit 1
309325
fi
310326
fi
@@ -333,7 +349,6 @@ tasks:
333349
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -w $FAST $DRY
334350
true
335351
336-
337352
shell:
338353
desc: open a bash shell with the current environment
339354
interactive: true

util/docopts.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ OpenServerless Utilities
2424

2525
```text
2626
Usage:
27+
util apihost
2728
util system
2829
util update-cli
2930
util check-operator-version <version>
@@ -48,6 +49,7 @@ Usage:
4849
## Commands
4950

5051
```
52+
- apihost current apihost
5153
- system system info (<os>-<arch> in Go format)
5254
- update-cli update the cli downloading the binary
5355
- check-operator-version check if you need to update the operator

util/opsfile.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ tasks:
4747
cmds:
4848
- echo "{{OS}}-{{ARCH}}"
4949

50+
apihost:
51+
desc: current apihost``
52+
silent: true
53+
cmds:
54+
- ops -wsk property get | awk '/whisk API host/{print $4}'
55+
5056
update-cli:
5157
desc: update CLI
5258
silent: true

0 commit comments

Comments
 (0)