summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-runner/src/cli/kotlin
diff options
context:
space:
mode:
authorvincent van beek <vincent@vlogic.nl>2026-03-27 16:49:40 +0100
committerGitHub <noreply@github.com>2026-03-27 15:49:40 +0000
commit048bf777997bdbf599240645fc66612c98abf3c2 (patch)
treec04e999cb981c98ae9dc0fd83ea70aec9eaa419c /opendc-web/opendc-web-runner/src/cli/kotlin
parent235057cd170f1583db14bf93ea7d2de39e492356 (diff)
Add import topology (#393)
* add a the posibility to import and export topogies in JSON format * fix web-runner integration, there were several bugs and mismatches between new implementations in OpenDC and the UI
Diffstat (limited to 'opendc-web/opendc-web-runner/src/cli/kotlin')
-rw-r--r--opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt43
1 files changed, 36 insertions, 7 deletions
diff --git a/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt b/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt
index 5d35fd98..6583810c 100644
--- a/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt
+++ b/opendc-web/opendc-web-runner/src/cli/kotlin/org/opendc/web/runner/Main.kt
@@ -26,8 +26,8 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.convert
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.defaultLazy
+import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
-import com.github.ajalt.clikt.parameters.options.required
import com.github.ajalt.clikt.parameters.types.file
import com.github.ajalt.clikt.parameters.types.int
import mu.KotlinLogging
@@ -54,6 +54,15 @@ class RunnerCli : CliktCommand(name = "opendc-runner") {
.default(URI("https://api.opendc.org/v2"))
/**
+ * Flag to disable authentication (for local development).
+ */
+ private val noAuth by option(
+ "--no-auth",
+ help = "disable authentication (for local development)",
+ )
+ .flag()
+
+ /**
* The auth domain to use.
*/
private val authDomain by option(
@@ -61,17 +70,15 @@ class RunnerCli : CliktCommand(name = "opendc-runner") {
help = "auth domain of the OpenDC API",
envvar = "AUTH0_DOMAIN",
)
- .required()
/**
- * The auth domain to use.
+ * The auth audience to use.
*/
private val authAudience by option(
"--auth-audience",
help = "auth audience of the OpenDC API",
envvar = "AUTH0_AUDIENCE",
)
- .required()
/**
* The auth client ID to use.
@@ -81,7 +88,6 @@ class RunnerCli : CliktCommand(name = "opendc-runner") {
help = "auth client id of the OpenDC API",
envvar = "AUTH0_CLIENT_ID",
)
- .required()
/**
* The auth client secret to use.
@@ -91,7 +97,6 @@ class RunnerCli : CliktCommand(name = "opendc-runner") {
help = "auth client secret of the OpenDC API",
envvar = "AUTH0_CLIENT_SECRET",
)
- .required()
/**
* The path to the traces directory.
@@ -117,7 +122,31 @@ class RunnerCli : CliktCommand(name = "opendc-runner") {
override fun run() {
logger.info { "Starting OpenDC web runner" }
- val client = OpenDCRunnerClient(baseUrl = apiUrl, OpenIdAuthController(authDomain, authClientId, authClientSecret, authAudience))
+ // Validate auth parameters if authentication is enabled
+ if (!noAuth) {
+ require(
+ authDomain != null,
+ ) { "Auth domain is required when authentication is enabled. Use --no-auth to disable authentication." }
+ require(
+ authAudience != null,
+ ) { "Auth audience is required when authentication is enabled. Use --no-auth to disable authentication." }
+ require(
+ authClientId != null,
+ ) { "Auth client ID is required when authentication is enabled. Use --no-auth to disable authentication." }
+ require(authClientSecret != null) {
+ "Auth client secret is required when authentication is enabled. Use --no-auth to disable authentication."
+ }
+ }
+
+ val authController =
+ if (noAuth) {
+ logger.info { "Running without authentication" }
+ null
+ } else {
+ OpenIdAuthController(authDomain!!, authClientId!!, authClientSecret!!, authAudience!!)
+ }
+
+ val client = OpenDCRunnerClient(baseUrl = apiUrl, authController)
val manager = JobManager(client)
val runner = OpenDCRunner(manager, tracePath, parallelism = parallelism)