Skip to content

Commit c7bb200

Browse files
committed
Add iriscli and ipm container utility scripts
1 parent 329ccfd commit c7bb200

5 files changed

Lines changed: 127 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- #992: Implement automatic history purge logic
1212
- #973: Enables CORS and JWT configuration for WebApplications in module.xml
13+
- #1110: Add `iriscli` and `ipm` container utility scripts
1314

1415
### Fixed
1516
- #1001: The `unmap` and `enable` commands will now only activate CPF merge once after all namespaces have been configured instead after every namespace

CONTRIBUTING.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,49 @@ From time to time, you may also want to remove unused Docker data to save disk s
9292
docker system prune -a
9393
```
9494

95+
#### Convenience Scripts: `ipm` and `iriscli`
96+
97+
The repo ships two bash scripts that wrap common IRIS interactions so you don't have to type `iris session iris` boilerplate every time. They are copied into `/home/irisowner/bin/` during the container build and are available by name in any running container.
98+
99+
**`ipm`** — runs a single IPM/ZPM command non-interactively and exits:
100+
```bash
101+
# List installed packages
102+
docker exec -it <container-name, e.g. ipm-iris-1> ipm list
103+
104+
# Install a package
105+
docker exec -it <container-name, e.g. ipm-iris-1> ipm install zpm-registry
106+
107+
# Run tests for a module
108+
docker exec -it <container-name, e.g. ipm-iris-1> ipm test mymodule -only
109+
110+
# Using docker compose exec (works for any container defined in docker-compose.yml)
111+
# Note: must be run from the directory containing docker-compose.yml
112+
docker compose exec iris ipm list
113+
```
114+
115+
**`iriscli`** — opens an interactive IRIS terminal session:
116+
```bash
117+
# Either this command
118+
docker exec -it <container-name, e.g. ipm-iris-1> iriscli
119+
120+
# Or this equivalent command (must be run from the directory containing docker-compose.yml)
121+
docker compose exec -it iris iriscli
122+
```
123+
124+
`iriscli` also accepts an ObjectScript script file, executing each line and then halting:
125+
```bash
126+
docker compose exec -it iris iriscli /path/to/demo.script
127+
```
128+
129+
A sample `demo.script`:
130+
```objectscript
131+
zn "USER"
132+
write $zversion,!
133+
zpm "list"
134+
```
135+
136+
> **Namespace:** Both scripts respect the `IRIS_NAMESPACE` environment variable, or accept `-U <namespace>` as the first argument. For example: `docker exec -it <container-name> ipm -U %SYS list`.
137+
95138

96139
### Developing IPM in an Existing IRIS Instance
97140
If you already have an IRIS instance running and you want to test IPM in this instance, run the following command:

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ FROM ${BASE}
44

55
ARG REGISTRY=https://pm.community.intersystems.com
66

7+
# --- Create dirs and place tools (use --chown to avoid extra chown layers) ---
8+
COPY --chown=irisowner:irisowner iriscli /home/irisowner/bin/iriscli
9+
COPY --chown=irisowner:irisowner ipm /home/irisowner/bin/ipm
10+
RUN chmod +x /home/irisowner/bin/iriscli /home/irisowner/bin/ipm
11+
712
RUN --mount=type=bind,src=.,dst=/home/irisowner/zpm/ \
813
iris start iris && \
914
iris session IRIS < /home/irisowner/zpm/iris.script && \

ipm

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# ipm: convenience wrapper to run a ZPM command in an IRIS session
4+
# Usage examples:
5+
# ipm isc.genai test -only
6+
# ipm -U PLAZA isc.genai test -only
7+
8+
ARGS=()
9+
CMD=()
10+
11+
# Allow namespace via env like iriscli
12+
if [ -n "$IRIS_NAMESPACE" ]; then
13+
ARGS+=( -U "$IRIS_NAMESPACE" )
14+
elif [ -n "$IRISNAMESPACE" ]; then
15+
ARGS+=( -U "$IRISNAMESPACE" )
16+
fi
17+
18+
# Optional leading -U <ns>
19+
if [ "$1" = "-U" ] && [ -n "$2" ]; then
20+
ARGS+=( -U "$2" )
21+
shift 2
22+
fi
23+
24+
# Remaining args compose the ZPM command string
25+
while [[ $# -gt 0 ]]; do
26+
CMD+=( "$1" )
27+
shift
28+
done
29+
30+
if [ ${#CMD[@]} -eq 0 ]; then
31+
echo "Usage: ipm [ -U <NAMESPACE> ] <zpm command and args...>" >&2
32+
exit 1
33+
fi
34+
35+
# Join CMD array into a single string
36+
CMDSTR="${CMD[*]}"
37+
# Escape quotes for ObjectScript string literal
38+
CMDSTR_ESC=${CMDSTR//\"/\"\"}
39+
40+
# Build an OS snippet and feed to iris session
41+
(
42+
echo "zpm \"${CMDSTR_ESC}\":1:1"
43+
echo "halt"
44+
) | iris session ${ISC_PACKAGE_INSTANCENAME:-iris} "${ARGS[@]}"

iriscli

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
ARGS=()
4+
PARAMS=()
5+
file=
6+
7+
if [ -n "$IRIS_NAMESPACE" ]; then
8+
ARGS+=( -U $IRIS_NAMESPACE )
9+
elif [ -n "$IRISNAMESPACE" ]; then
10+
ARGS+=( -U $IRISNAMESPACE )
11+
fi
12+
13+
while [[ $# -gt 0 ]]; do
14+
if [ -x $1 ]; then
15+
file=$1
16+
elif [ -z "$file" ]; then
17+
ARGS+=("$1")
18+
else
19+
PARAMS+=("$1")
20+
fi
21+
shift
22+
done
23+
24+
if [ -n "$file" ]; then
25+
(
26+
for param in ${PARAMS[@]}; do
27+
echo "Set params(\$i(params)) = \"${param//\"/\"\"}\""
28+
done
29+
egrep -v '^(;|#|//)|^$' $file;
30+
echo halt
31+
) | iris session $ISC_PACKAGE_INSTANCENAME "${ARGS[@]}"
32+
else
33+
iris session iris "${ARGS[@]}"
34+
fi

0 commit comments

Comments
 (0)