Skip to content

Commit 87fadaa

Browse files
committed
feat: make run-dev also installs ops in release.yaml
1 parent 3e6fe5a commit 87fadaa

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

template/Makefile.j2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ check-kubernetes:
189189
@kubectl cluster-info > /dev/null 2>&1 || (echo "Error: Kubernetes is not running or kubectl is not properly configured."; exit 1)
190190

191191
run-dev: check-nix check-kubernetes
192-
kubectl apply -f deploy/stackable-operators-ns.yaml
192+
# Install ops in release.yaml except the one that is installed by Tilt
193+
SHORT_OP_NAME=$$(echo ${OPERATOR_NAME} | sed 's/-operator//');\
194+
./scripts/run-tests --log-level debug --skip-tests --skip-operator ${SHORT_OP_NAME}
195+
# Build and install the operator
193196
nix run --extra-experimental-features "nix-command flakes" -f. tilt -- up --port {[5430 + operator_index}] --namespace stackable-operators
194197

195198
stop-dev: check-nix check-kubernetes

template/deploy/stackable-operators-ns.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

template/scripts/run-tests

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
100100
default=[],
101101
)
102102

103+
parser.add_argument(
104+
"--skip-operator",
105+
help="Skip given operator(s) when installing a release.",
106+
nargs="*",
107+
default=[],
108+
)
109+
103110
parser.add_argument(
104111
"--test",
105112
help="Kuttl test to run.",
@@ -180,6 +187,7 @@ def have_requirements() -> None:
180187
@contextlib.contextmanager
181188
def release_file(
182189
operators: list[tuple[str, str]] = [],
190+
skip_ops: list[str] = [],
183191
) -> collections.abc.Generator[str, None, None]:
184192
"""Patch release.yaml with operator versions if needed.
185193
@@ -209,7 +217,22 @@ def release_file(
209217
patch_version = version
210218
ops_copy.remove((op, version)) # found an operator to patch
211219
break
212-
patched_release.append(line)
220+
patched_release.append(line.rstrip('\n'))
221+
222+
# Filter out skip operators
223+
skipped_release = []
224+
for line in patched_release:
225+
skip = False
226+
if skip:
227+
skip = False
228+
else:
229+
if any((op in line for op in skip_ops)):
230+
skip = True
231+
break
232+
else:
233+
skipped_release.append(line)
234+
patched_release = skipped_release
235+
213236
if ops_copy:
214237
# Some --operator args were not found in the release file. This is
215238
# most likely a typo and CI pipelines should terminate early in such
@@ -223,7 +246,7 @@ def release_file(
223246
delete=False,
224247
prefix="patched",
225248
) as f:
226-
pcontents = "".join(patched_release)
249+
pcontents = "\n".join(patched_release)
227250
logging.debug(f"Writing patched release to {f.name}: {pcontents}\n")
228251
f.write(pcontents)
229252
return f.name
@@ -353,7 +376,7 @@ def main(argv) -> int:
353376
logging.basicConfig(encoding="utf-8", level=opts.log_level)
354377
have_requirements()
355378
gen_tests(opts.test_suite)
356-
with release_file(opts.operator) as f:
379+
with release_file(opts.operator, opts.skip_operator) as f:
357380
maybe_install_release(opts.skip_release, f)
358381
if opts.skip_tests:
359382
logging.info("Skip running tests.")

0 commit comments

Comments
 (0)