refactor: rename HOST_* env vars to SLHAF_HUB_* across CLI/TUI, security, docs, and compose
This commit is contained in:
@@ -37,15 +37,15 @@ cd slhaf-hub
|
||||
docker build -t slhaf-hub:latest .
|
||||
docker run --rm -p 8080:8080 \
|
||||
-v "$(pwd)/scripts:/app/scripts" \
|
||||
-e HOST_API_TOKEN=your-token \
|
||||
-e SLHAF_HUB_TOKEN=your-token \
|
||||
-e MAX_RUN_CONCURRENCY=8 \
|
||||
slhaf-hub:latest
|
||||
```
|
||||
|
||||
#### 3) Run with Docker Compose
|
||||
```bash
|
||||
# optional: export HOST_API_TOKEN=your-token
|
||||
# optional: export HOST_PORT=8080
|
||||
# optional: export SLHAF_HUB_TOKEN=your-token
|
||||
# optional: export SLHAF_HUB_PORT=8080
|
||||
# optional: export MAX_RUN_CONCURRENCY=8
|
||||
docker compose up -d --build
|
||||
```
|
||||
@@ -79,7 +79,7 @@ Auth headers:
|
||||
- `X-Host-Token: <token>`
|
||||
|
||||
Token source priority:
|
||||
1. `HOST_API_TOKEN` env var
|
||||
1. `SLHAF_HUB_TOKEN` env var
|
||||
2. `scripts/.host-api-token`
|
||||
3. Auto-generated token saved to `scripts/.host-api-token`
|
||||
|
||||
|
||||
@@ -37,15 +37,15 @@ cd slhaf-hub
|
||||
docker build -t slhaf-hub:latest .
|
||||
docker run --rm -p 8080:8080 \
|
||||
-v "$(pwd)/scripts:/app/scripts" \
|
||||
-e HOST_API_TOKEN=your-token \
|
||||
-e SLHAF_HUB_TOKEN=your-token \
|
||||
-e MAX_RUN_CONCURRENCY=8 \
|
||||
slhaf-hub:latest
|
||||
```
|
||||
|
||||
#### 3) Docker Compose 启动
|
||||
```bash
|
||||
# 可选:export HOST_API_TOKEN=your-token
|
||||
# 可选:export HOST_PORT=8080
|
||||
# 可选:export SLHAF_HUB_TOKEN=your-token
|
||||
# 可选:export SLHAF_HUB_PORT=8080
|
||||
# 可选:export MAX_RUN_CONCURRENCY=8
|
||||
docker compose up -d --build
|
||||
```
|
||||
@@ -79,7 +79,7 @@ CLI/TUI 环境变量:
|
||||
- `X-Host-Token: <token>`
|
||||
|
||||
Token 来源优先级:
|
||||
1. 环境变量 `HOST_API_TOKEN`
|
||||
1. 环境变量 `SLHAF_HUB_TOKEN`
|
||||
2. `scripts/.host-api-token`
|
||||
3. 自动生成并写入 `scripts/.host-api-token`
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ services:
|
||||
container_name: slhaf-hub
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${HOST_PORT:-8080}:8080"
|
||||
- "${SLHAF_HUB_PORT:-8080}:8080"
|
||||
environment:
|
||||
HOST_API_TOKEN: ${HOST_API_TOKEN:-}
|
||||
SLHAF_HUB_TOKEN: ${SLHAF_HUB_TOKEN:-}
|
||||
MAX_RUN_CONCURRENCY: ${MAX_RUN_CONCURRENCY:-}
|
||||
volumes:
|
||||
- ./scripts:/app/scripts
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.ktor.server.response.respondText
|
||||
import java.io.File
|
||||
import java.security.SecureRandom
|
||||
|
||||
private const val ENV_API_TOKEN = "HOST_API_TOKEN"
|
||||
private const val ENV_API_TOKEN = "SLHAF_HUB_TOKEN"
|
||||
private const val TOKEN_FILE_NAME = ".host-api-token"
|
||||
private const val SUBTOKEN_FILE_NAME = ".host-subtokens.db"
|
||||
private const val ALT_TOKEN_HEADER = "X-Host-Token"
|
||||
|
||||
@@ -9,8 +9,8 @@ import java.net.http.HttpResponse
|
||||
import java.nio.charset.StandardCharsets
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
val ENV_API_BASE_URL = "HOST_API_BASE_URL"
|
||||
val ENV_API_TOKEN = "HOST_API_TOKEN"
|
||||
val ENV_API_BASE_URL = "SLHAF_HUB_BASE_URL"
|
||||
val ENV_API_TOKEN = "SLHAF_HUB_TOKEN"
|
||||
|
||||
data class GlobalOptions(
|
||||
val baseUrl: String,
|
||||
@@ -30,9 +30,9 @@ Usage:
|
||||
kotlin slhaf-hub-cli.kts [global options] <command> [command options]
|
||||
|
||||
Global options:
|
||||
--base-url=<url> Default: HOST_API_BASE_URL or http://127.0.0.1:8080
|
||||
--base-url=<url> Default: SLHAF_HUB_BASE_URL or http://127.0.0.1:8080
|
||||
--token=<token> Authorization token
|
||||
--token-file=<path> Load token from file (fallback: HOST_API_TOKEN env)
|
||||
--token-file=<path> Load token from file (fallback: SLHAF_HUB_TOKEN env)
|
||||
|
||||
Commands:
|
||||
health
|
||||
|
||||
@@ -54,8 +54,8 @@ private val YELLOW = "\u001b[33m"
|
||||
private val RED = "\u001b[31m"
|
||||
private val BG_BLUE = "\u001b[44m"
|
||||
private val FG_BLACK = "\u001b[30m"
|
||||
val ENV_API_BASE_URL = "HOST_API_BASE_URL"
|
||||
val ENV_API_TOKEN = "HOST_API_TOKEN"
|
||||
val ENV_API_BASE_URL = "SLHAF_HUB_BASE_URL"
|
||||
val ENV_API_TOKEN = "SLHAF_HUB_TOKEN"
|
||||
|
||||
private fun ok(text: String) = "$GREEN$text$RESET"
|
||||
private fun warn(text: String) = "$YELLOW$text$RESET"
|
||||
@@ -81,8 +81,8 @@ Keys:
|
||||
q Quit
|
||||
|
||||
Env fallback:
|
||||
HOST_API_BASE_URL
|
||||
HOST_API_TOKEN
|
||||
SLHAF_HUB_BASE_URL
|
||||
SLHAF_HUB_TOKEN
|
||||
""".trimIndent()
|
||||
|
||||
fun parseOptions(args: List<String>): Options {
|
||||
@@ -113,7 +113,7 @@ fun readToken(options: Options): String {
|
||||
return file.readText().trim()
|
||||
}
|
||||
return System.getenv(ENV_API_TOKEN)?.trim()
|
||||
?: error("Missing token. Use --token or --token-file or HOST_API_TOKEN")
|
||||
?: error("Missing token. Use --token or --token-file or SLHAF_HUB_TOKEN")
|
||||
}
|
||||
|
||||
fun encode(value: String): String = URLEncoder.encode(value, StandardCharsets.UTF_8)
|
||||
|
||||
Reference in New Issue
Block a user