diff --git a/.gitignore b/.gitignore index 19bde6a..9462c35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ venv **secret** +!/bin/secret-push !/conf/mock/.secret-mock.toml dexorder.toml logging.toml diff --git a/bin/config-push b/bin/config-push new file mode 100755 index 0000000..8850519 --- /dev/null +++ b/bin/config-push @@ -0,0 +1,48 @@ +#!/bin/bash + +if [ "$1" == "" ]; then + echo 'usage: config-push {config_name} [secret_name]' + exit 1 +fi + +CONFIG=$1 +shift + +if [ "$1" != "" ]; then + KEY=backend-$1 +else + KEY=backend +fi + +DEXO="conf/dexorder-$CONFIG.toml" +if [ ! -f "$DEXO" ]; then + DEXO="conf/$CONFIG/dexorder-$CONFIG.toml" +fi +if [ ! -f "$DEXO" ]; then + DEXO= +else + DEXO="--from-file dexorder.toml=$DEXO" +fi + +LOG="conf/logging-$CONFIG.toml" +if [ ! -f "$LOG" ]; then + LOG="conf/$CONFIG/logging-$CONFIG.toml" +fi +if [ ! -f "$LOG" ]; then + LOG= +else + LOG="--from-file logging.toml=$LOG" +fi + +META="conf/metadata-$CONFIG.json" +if [ ! -f "$META" ]; then + META="conf/$CONFIG/metadata-$CONFIG.json" +fi +if [ ! -f "$META" ]; then + META= +else + META="--from-file metadata.json=$META" +fi + +# shellcheck disable=SC2086 +kubectl create configmap "$KEY" $DEXO $LOG $META --dry-run=client -o yaml | kubectl apply -f - diff --git a/bin/secret-push b/bin/secret-push new file mode 100755 index 0000000..18f3a30 --- /dev/null +++ b/bin/secret-push @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ "$1" == "" ]; then + echo 'usage: secret-push {config_name} [secret_name]' + exit 1 +fi + +CONFIG=$1 +shift + +if [ "$1" != "" ]; then + KEY=backend-$1 +else + KEY=backend +fi + +FILE="conf/dexorder-$CONFIG.toml" + +if [ ! -f "$FILE" ]; then + FILE="conf/$CONFIG/dexorder-$CONFIG.toml" +fi +if [ ! -f "$FILE" ]; then + echo Could not find config file for $1 + exit 1; +fi + +kubectl create secret generic "$KEY" --from-file ".secret.toml=$FILE" --dry-run=client -o yaml | kubectl apply -f - diff --git a/conf/finaldata/dexorder-finaldata.toml b/conf/finaldata/dexorder-finaldata.toml new file mode 100644 index 0000000..92439f3 --- /dev/null +++ b/conf/finaldata/dexorder-finaldata.toml @@ -0,0 +1,6 @@ +metadata='metadata.json' # mounted from a ConfigMap in the k8s yaml +rpc_url = '${rpc_urls.finaldata}' +account = '' +ws_url = '' +redis_url = '' +ohlc_dir = '/ohlc' \ No newline at end of file diff --git a/conf/finaldata/logging-finaldata.toml b/conf/finaldata/logging-finaldata.toml new file mode 100644 index 0000000..376ed2b --- /dev/null +++ b/conf/finaldata/logging-finaldata.toml @@ -0,0 +1,20 @@ +# https://docs.python.org/3/library/logging.config.html#logging-config-dictschema +version=1 + +[loggers.''] +level='INFO' +handlers=['console',] + +[loggers.dexorder] +level='DEBUG' + +[handlers.console] +class='logging.StreamHandler' +formatter='notime' +stream='ext://sys.stdout' + +[formatters.notime] +# https://docs.python.org/3/library/logging.html#logrecord-attributes +format='%(levelname)s %(name)s %(message)s' +# https://docs.python.org/3/library/time.html#time.strftime +datefmt='%Y-%m-%d %H:%M:%S' diff --git a/conf/finaldata/metadata-finaldata.json b/conf/finaldata/metadata-finaldata.json new file mode 100644 index 0000000..1dbbacf --- /dev/null +++ b/conf/finaldata/metadata-finaldata.json @@ -0,0 +1,28 @@ +{ + "42161": { + "t": [ + { + "a": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", + "n": "Wrapped Ether", + "s": "WETH", + "d": 18 + }, + { + "a": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", + "n": "USD Coin (Arbitrum Native)", + "s": "USDC", + "d": 6 + } + ], + "p": [ + { + "a": "0xC6962004f452bE9203591991D15f6b388e09E8D0", + "b": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", + "q": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", + "f": 500, + "e": 1, + "d": 12 + } + ] + } +}