use env vars for secrets (ETHICA_TOKEN/HOME/INTERVAL override config)
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
# Copy to .env and fill in your values.
|
||||||
|
# Get your token: admin panel → Company → API tab → Company token
|
||||||
|
|
||||||
|
ETHICA_TOKEN=paste-your-company-token-here
|
||||||
|
ETHICA_HOME=https://ethica.no
|
||||||
|
# ETHICA_INTERVAL=60
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
ethica-agent.yml
|
ethica-agent.yml
|
||||||
|
.env
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ services:
|
|||||||
image: ethica-agent:latest
|
image: ethica-agent:latest
|
||||||
build: .
|
build: .
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
env_file: .env # ETHICA_TOKEN, ETHICA_HOME, ETHICA_INTERVAL
|
||||||
volumes:
|
volumes:
|
||||||
- ./ethica-agent.yml:/config/ethica-agent.yml:ro
|
- ./ethica-agent.yml:/config/ethica-agent.yml:ro
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
# Ethica Agent configuration
|
# Ethica Agent configuration
|
||||||
# Get your token from the admin panel: Company → API tab → Company token
|
#
|
||||||
|
# Token (required): set via ETHICA_TOKEN env var (recommended) or here.
|
||||||
|
# Get it from: admin panel → Company → API tab → Company token
|
||||||
|
#
|
||||||
|
# token: REPLACE_ME ← or set ETHICA_TOKEN in .env / environment
|
||||||
|
# home: https://ethica.no ← or set ETHICA_HOME (default: https://ethica.no)
|
||||||
|
# interval: 60 ← or set ETHICA_INTERVAL (seconds, default: 60)
|
||||||
|
|
||||||
token: REPLACE_ME
|
interval: 60
|
||||||
home: https://ethica.no
|
|
||||||
interval: 60 # seconds between collection runs
|
|
||||||
|
|
||||||
widgets:
|
widgets:
|
||||||
|
|
||||||
|
|||||||
+9
-5
@@ -309,14 +309,18 @@ def main():
|
|||||||
print(f"Config not found: {args.config}", file=sys.stderr)
|
print(f"Config not found: {args.config}", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
token = cfg.get("token", "")
|
# Env vars override config file — keeps secrets out of the yml.
|
||||||
home = cfg.get("home", "https://ethica.no")
|
# ETHICA_TOKEN : company API token (required)
|
||||||
interval = int(cfg.get("interval", 60))
|
# ETHICA_HOME : home URL (optional, default https://ethica.no)
|
||||||
|
# ETHICA_INTERVAL: collection interval in seconds (optional)
|
||||||
|
token = os.environ.get("ETHICA_TOKEN") or cfg.get("token", "")
|
||||||
|
home = os.environ.get("ETHICA_HOME") or cfg.get("home", "https://ethica.no")
|
||||||
|
interval = int(os.environ.get("ETHICA_INTERVAL") or cfg.get("interval", 60))
|
||||||
widgets = cfg.get("widgets", [])
|
widgets = cfg.get("widgets", [])
|
||||||
|
|
||||||
if not token or token == "REPLACE_ME":
|
if not token or token == "REPLACE_ME":
|
||||||
print("Set 'token' in your config (Company → API in the admin panel).",
|
print("Set ETHICA_TOKEN env var or 'token' in config "
|
||||||
file=sys.stderr)
|
"(Company → API tab in the admin panel).", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if not widgets:
|
if not widgets:
|
||||||
print("No widgets configured — nothing to do.", file=sys.stderr)
|
print("No widgets configured — nothing to do.", file=sys.stderr)
|
||||||
|
|||||||
Reference in New Issue
Block a user