Skip to content

Commit

Permalink
feat(instances): Add support of multiple instances
Browse files Browse the repository at this point in the history
You can specify multiple instances in config file, as it help
to do development and test on various destinations.

Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
  • Loading branch information
nuclearcat committed Sep 11, 2024
1 parent 47fe4bd commit bd0a9b3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
10 changes: 9 additions & 1 deletion .kci-dev.toml.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[connection]
[local]
host="https://127.0.0.1"
token="example"

[staging]
host="https://staging.kernelci.org:9100/"
token="example"

[production]
host="https://kernelci-pipeline.westus3.cloudapp.azure.com/"
token="example"
9 changes: 8 additions & 1 deletion kci-dev/kci-dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@
)
@click.version_option("0.0.1", prog_name="kci-dev")
@click.option("--settings", default=".kci-dev.toml", help="path of toml setting file")
@click.option(
"--instance",
help="KernelCI instance",
default="local",
show_default=True,
)
@click.pass_context
def cli(ctx, settings):
def cli(ctx, settings, instance):
cfg = load_toml(settings)
ctx.ensure_object(dict)
ctx.obj["CFG"] = cfg
ctx.obj["INSTANCE"] = instance
pass


Expand Down
5 changes: 3 additions & 2 deletions kci-dev/subcommands/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ def send_build(url, patch, branch, treeurl, token):
@click.pass_context
def commit(ctx, repository, branch, private, path):
cfg = ctx.obj.get("CFG")
url = api_connection(cfg["connection"]["host"])
instance = ctx.obj.get("INSTANCE")
url = api_connection(cfg[instance]["host"])
diff = find_diff(path, branch, repository)
send_build(url, diff, branch, repository, cfg["connection"]["token"])
send_build(url, diff, branch, repository, cfg[instance]["token"])


if __name__ == "__main__":
Expand Down
5 changes: 3 additions & 2 deletions kci-dev/subcommands/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ def send_build(url, patch, branch, treeurl, token):
@click.pass_context
def patch(ctx, repository, branch, private, patch):
cfg = ctx.obj.get("CFG")
url = api_connection(cfg["connection"]["host"])
instance = ctx.obj.get("INSTANCE")
url = api_connection(cfg[instance]["host"])
patch = open(patch, "rb")
send_build(url, patch, branch, repository, cfg["connection"]["token"])
send_build(url, patch, branch, repository, cfg[instance]["token"])


if __name__ == "__main__":
Expand Down

0 comments on commit bd0a9b3

Please sign in to comment.