feat: Allow token via environment variables
This commit is contained in:
parent
181ac45bbf
commit
0fca58810a
@ -3,7 +3,7 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
|
import os
|
||||||
import toml
|
import toml
|
||||||
|
|
||||||
from mastodon_blocklist_deploy.models import Instance
|
from mastodon_blocklist_deploy.models import Instance
|
||||||
@ -76,12 +76,19 @@ def cli():
|
|||||||
else:
|
else:
|
||||||
logging.basicConfig(level=logging.WARN)
|
logging.basicConfig(level=logging.WARN)
|
||||||
|
|
||||||
|
if args.token:
|
||||||
|
token = args.token
|
||||||
|
else:
|
||||||
|
token = os.getenv('MBD_TOKEN')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""if there is a remote blocklist provided load this instead of fetching it from a server (for debugging reasons)"""
|
"""if there is a remote blocklist provided load this instead of fetching it from a server (for debugging reasons)"""
|
||||||
if args.remote_blocklist:
|
if args.remote_blocklist:
|
||||||
with open(args.remote_blocklist) as f:
|
with open(args.remote_blocklist) as f:
|
||||||
remote_blocklist = blocklist_json_to_instances(json.load(f))
|
remote_blocklist = blocklist_json_to_instances(json.load(f))
|
||||||
else:
|
else:
|
||||||
remote_blocklist = load_blocklist_from_instance(server=args.server, token=args.token)
|
remote_blocklist = load_blocklist_from_instance(server=args.server, token=token)
|
||||||
|
|
||||||
"""Load local blocklist only when needed"""
|
"""Load local blocklist only when needed"""
|
||||||
if args.action in ["diff", "deploy"]:
|
if args.action in ["diff", "deploy"]:
|
||||||
@ -95,7 +102,7 @@ def cli():
|
|||||||
Instance.show_diffs(local_blocklist, remote_blocklist)
|
Instance.show_diffs(local_blocklist, remote_blocklist)
|
||||||
elif args.action == "deploy":
|
elif args.action == "deploy":
|
||||||
diffs = Instance.list_diffs(local_blocklist, remote_blocklist)
|
diffs = Instance.list_diffs(local_blocklist, remote_blocklist)
|
||||||
Instance.apply_blocks_from_diff(diffs, args.server, args.token, args.no_delete)
|
Instance.apply_blocks_from_diff(diffs, args.server, token, args.no_delete)
|
||||||
elif args.action == "export":
|
elif args.action == "export":
|
||||||
if not args.output:
|
if not args.output:
|
||||||
print("Export currently requires to pass --output as well")
|
print("Export currently requires to pass --output as well")
|
||||||
|
Loading…
Reference in New Issue
Block a user