envparsing.sh (9427B)
1 #!/bin/sh 2 3 set -eu 4 5 EXPECT=$(cat <<"EOF" 6 { 7 "account-domain": "peepee", 8 "accounts-allow-custom-css": true, 9 "accounts-approval-required": false, 10 "accounts-custom-css-length": 5000, 11 "accounts-reason-required": false, 12 "accounts-registration-open": true, 13 "advanced-cookies-samesite": "strict", 14 "advanced-rate-limit-requests": 6969, 15 "advanced-sender-multiplier": -1, 16 "advanced-throttling-multiplier": -1, 17 "advanced-throttling-retry-after": 10000000000, 18 "application-name": "gts", 19 "bind-address": "127.0.0.1", 20 "cache": { 21 "gts": { 22 "account-max-size": 99, 23 "account-sweep-freq": 1000000000, 24 "account-ttl": 10800000000000, 25 "block-max-size": 1000, 26 "block-sweep-freq": 60000000000, 27 "block-ttl": 1800000000000, 28 "domain-block-max-size": 2000, 29 "domain-block-sweep-freq": 60000000000, 30 "domain-block-ttl": 86400000000000, 31 "emoji-category-max-size": 100, 32 "emoji-category-sweep-freq": 60000000000, 33 "emoji-category-ttl": 1800000000000, 34 "emoji-max-size": 2000, 35 "emoji-sweep-freq": 60000000000, 36 "emoji-ttl": 1800000000000, 37 "follow-max-size": 2000, 38 "follow-request-max-size": 2000, 39 "follow-request-sweep-freq": 60000000000, 40 "follow-request-ttl": 1800000000000, 41 "follow-sweep-freq": 60000000000, 42 "follow-ttl": 1800000000000, 43 "list-entry-max-size": 2000, 44 "list-entry-sweep-freq": 60000000000, 45 "list-entry-ttl": 1800000000000, 46 "list-max-size": 2000, 47 "list-sweep-freq": 60000000000, 48 "list-ttl": 1800000000000, 49 "media-max-size": 1000, 50 "media-sweep-freq": 60000000000, 51 "media-ttl": 1800000000000, 52 "mention-max-size": 2000, 53 "mention-sweep-freq": 60000000000, 54 "mention-ttl": 1800000000000, 55 "notification-max-size": 1000, 56 "notification-sweep-freq": 60000000000, 57 "notification-ttl": 1800000000000, 58 "report-max-size": 100, 59 "report-sweep-freq": 60000000000, 60 "report-ttl": 1800000000000, 61 "status-fave-max-size": 2000, 62 "status-fave-sweep-freq": 60000000000, 63 "status-fave-ttl": 1800000000000, 64 "status-max-size": 2000, 65 "status-sweep-freq": 60000000000, 66 "status-ttl": 1800000000000, 67 "tombstone-max-size": 500, 68 "tombstone-sweep-freq": 60000000000, 69 "tombstone-ttl": 1800000000000, 70 "user-max-size": 500, 71 "user-sweep-freq": 60000000000, 72 "user-ttl": 1800000000000, 73 "webfinger-max-size": 250, 74 "webfinger-sweep-freq": 900000000000, 75 "webfinger-ttl": 86400000000000 76 }, 77 "visibility-max-size": 2000, 78 "visibility-sweep-freq": 60000000000, 79 "visibility-ttl": 1800000000000 80 }, 81 "config-path": "internal/config/testdata/test.yaml", 82 "db-address": ":memory:", 83 "db-database": "gotosocial_prod", 84 "db-max-open-conns-multiplier": 3, 85 "db-password": "hunter2", 86 "db-port": 6969, 87 "db-sqlite-busy-timeout": 1000000000, 88 "db-sqlite-cache-size": 0, 89 "db-sqlite-journal-mode": "DELETE", 90 "db-sqlite-synchronous": "FULL", 91 "db-tls-ca-cert": "", 92 "db-tls-mode": "disable", 93 "db-type": "sqlite", 94 "db-user": "sex-haver", 95 "dry-run": true, 96 "email": "", 97 "host": "example.com", 98 "instance-deliver-to-shared-inboxes": false, 99 "instance-expose-peers": true, 100 "instance-expose-public-timeline": true, 101 "instance-expose-suspended": true, 102 "instance-expose-suspended-web": true, 103 "landing-page-user": "admin", 104 "letsencrypt-cert-dir": "/gotosocial/storage/certs", 105 "letsencrypt-email-address": "", 106 "letsencrypt-enabled": true, 107 "letsencrypt-port": 80, 108 "log-client-ip": false, 109 "log-db-queries": true, 110 "log-level": "info", 111 "media-description-max-chars": 5000, 112 "media-description-min-chars": 69, 113 "media-emoji-local-max-size": 420, 114 "media-emoji-remote-max-size": 420, 115 "media-image-max-size": 420, 116 "media-remote-cache-days": 30, 117 "media-video-max-size": 420, 118 "oidc-admin-groups": [ 119 "steamy" 120 ], 121 "oidc-client-id": "1234", 122 "oidc-client-secret": "shhhh its a secret", 123 "oidc-enabled": true, 124 "oidc-idp-name": "sex-haver", 125 "oidc-issuer": "whoknows", 126 "oidc-link-existing": true, 127 "oidc-scopes": [ 128 "read", 129 "write" 130 ], 131 "oidc-skip-verification": true, 132 "password": "", 133 "path": "", 134 "port": 6969, 135 "protocol": "http", 136 "request-id-header": "X-Trace-Id", 137 "smtp-disclose-recipients": true, 138 "smtp-from": "queen.rip.in.piss@terfisland.org", 139 "smtp-host": "example.com", 140 "smtp-password": "hunter2", 141 "smtp-port": 4269, 142 "smtp-username": "sex-haver", 143 "software-version": "", 144 "statuses-cw-max-chars": 420, 145 "statuses-max-chars": 69, 146 "statuses-media-max-files": 1, 147 "statuses-poll-max-options": 1, 148 "statuses-poll-option-max-chars": 50, 149 "storage-backend": "local", 150 "storage-local-base-path": "/root/store", 151 "storage-s3-access-key": "minio", 152 "storage-s3-bucket": "gts", 153 "storage-s3-endpoint": "localhost:9000", 154 "storage-s3-proxy": true, 155 "storage-s3-secret-key": "miniostorage", 156 "storage-s3-use-ssl": false, 157 "syslog-address": "127.0.0.1:6969", 158 "syslog-enabled": true, 159 "syslog-protocol": "udp", 160 "tls-certificate-chain": "", 161 "tls-certificate-key": "", 162 "tracing-enabled": false, 163 "tracing-endpoint": "localhost:4317", 164 "tracing-insecure": false, 165 "tracing-transport": "grpc", 166 "trusted-proxies": [ 167 "127.0.0.1/32", 168 "docker.host.local" 169 ], 170 "username": "", 171 "web-asset-base-dir": "/root", 172 "web-template-base-dir": "/root" 173 } 174 EOF 175 ) 176 177 # Set all the environment variables to 178 # ensure that these are parsed without panic 179 OUTPUT=$(GTS_LOG_LEVEL='info' \ 180 GTS_LOG_DB_QUERIES=true \ 181 GTS_LOG_CLIENT_IP=false \ 182 GTS_APPLICATION_NAME=gts \ 183 GTS_LANDING_PAGE_USER=admin \ 184 GTS_HOST=example.com \ 185 GTS_ACCOUNT_DOMAIN='peepee' \ 186 GTS_PROTOCOL=http \ 187 GTS_BIND_ADDRESS='127.0.0.1' \ 188 GTS_PORT=6969 \ 189 GTS_TRUSTED_PROXIES='127.0.0.1/32,docker.host.local' \ 190 GTS_DB_TYPE='sqlite' \ 191 GTS_DB_ADDRESS=':memory:' \ 192 GTS_DB_PORT=6969 \ 193 GTS_DB_USER='sex-haver' \ 194 GTS_DB_PASSWORD='hunter2' \ 195 GTS_DB_DATABASE='gotosocial_prod' \ 196 GTS_DB_MAX_OPEN_CONNS_MULTIPLIER=3 \ 197 GTS_DB_SQLITE_JOURNAL_MODE='DELETE' \ 198 GTS_DB_SQLITE_SYNCHRONOUS='FULL' \ 199 GTS_DB_SQLITE_CACHE_SIZE=0 \ 200 GTS_DB_SQLITE_BUSY_TIMEOUT='1s' \ 201 GTS_TLS_MODE='' \ 202 GTS_DB_TLS_CA_CERT='' \ 203 GTS_WEB_TEMPLATE_BASE_DIR='/root' \ 204 GTS_WEB_ASSET_BASE_DIR='/root' \ 205 GTS_INSTANCE_EXPOSE_PEERS=true \ 206 GTS_INSTANCE_EXPOSE_SUSPENDED=true \ 207 GTS_INSTANCE_EXPOSE_SUSPENDED_WEB=true \ 208 GTS_INSTANCE_EXPOSE_PUBLIC_TIMELINE=true \ 209 GTS_INSTANCE_DELIVER_TO_SHARED_INBOXES=false \ 210 GTS_ACCOUNTS_ALLOW_CUSTOM_CSS=true \ 211 GTS_ACCOUNTS_CUSTOM_CSS_LENGTH=5000 \ 212 GTS_ACCOUNTS_REGISTRATION_OPEN=true \ 213 GTS_ACCOUNTS_APPROVAL_REQUIRED=false \ 214 GTS_ACCOUNTS_REASON_REQUIRED=false \ 215 GTS_MEDIA_IMAGE_MAX_SIZE=420 \ 216 GTS_MEDIA_VIDEO_MAX_SIZE=420 \ 217 GTS_MEDIA_DESCRIPTION_MIN_CHARS=69 \ 218 GTS_MEDIA_DESCRIPTION_MAX_CHARS=5000 \ 219 GTS_MEDIA_REMOTE_CACHE_DAYS=30 \ 220 GTS_MEDIA_EMOJI_LOCAL_MAX_SIZE=420 \ 221 GTS_MEDIA_EMOJI_REMOTE_MAX_SIZE=420 \ 222 GTS_STORAGE_BACKEND='local' \ 223 GTS_STORAGE_LOCAL_BASE_PATH='/root/store' \ 224 GTS_STORAGE_S3_ACCESS_KEY='minio' \ 225 GTS_STORAGE_S3_SECRET_KEY='miniostorage' \ 226 GTS_STORAGE_S3_ENDPOINT='localhost:9000' \ 227 GTS_STORAGE_S3_USE_SSL='false' \ 228 GTS_STORAGE_S3_PROXY='true' \ 229 GTS_STORAGE_S3_BUCKET='gts' \ 230 GTS_STATUSES_MAX_CHARS=69 \ 231 GTS_STATUSES_CW_MAX_CHARS=420 \ 232 GTS_STATUSES_POLL_MAX_OPTIONS=1 \ 233 GTS_STATUSES_POLL_OPTIONS_MAX_CHARS=69 \ 234 GTS_STATUSES_MEDIA_MAX_FILES=1 \ 235 GTS_LETS_ENCRYPT_ENABLED=false \ 236 GTS_LETS_ENCRYPT_PORT=8080 \ 237 GTS_LETS_ENCRYPT_CERT_DIR='/root/certs' \ 238 GTS_LETS_ENCRYPT_EMAIL_ADDRESS='le@example.com' \ 239 GTS_OIDC_ENABLED=true \ 240 GTS_OIDC_IDP_NAME='sex-haver' \ 241 GTS_OIDC_SKIP_VERIFICATION=true \ 242 GTS_OIDC_ISSUER='whoknows' \ 243 GTS_OIDC_CLIENT_ID='1234' \ 244 GTS_OIDC_CLIENT_SECRET='shhhh its a secret' \ 245 GTS_OIDC_SCOPES='read,write' \ 246 GTS_OIDC_LINK_EXISTING=true \ 247 GTS_OIDC_ADMIN_GROUPS='steamy' \ 248 GTS_SMTP_HOST='example.com' \ 249 GTS_SMTP_PORT=4269 \ 250 GTS_SMTP_USERNAME='sex-haver' \ 251 GTS_SMTP_PASSWORD='hunter2' \ 252 GTS_SMTP_FROM='queen.rip.in.piss@terfisland.org' \ 253 GTS_SMTP_DISCLOSE_RECIPIENTS=true \ 254 GTS_SYSLOG_ENABLED=true \ 255 GTS_SYSLOG_PROTOCOL='udp' \ 256 GTS_SYSLOG_ADDRESS='127.0.0.1:6969' \ 257 GTS_TRACING_ENDPOINT='localhost:4317' \ 258 GTS_ADVANCED_COOKIES_SAMESITE='strict' \ 259 GTS_ADVANCED_RATE_LIMIT_REQUESTS=6969 \ 260 GTS_ADVANCED_SENDER_MULTIPLIER=-1 \ 261 GTS_ADVANCED_THROTTLING_MULTIPLIER=-1 \ 262 GTS_ADVANCED_THROTTLING_RETRY_AFTER='10s' \ 263 GTS_REQUEST_ID_HEADER='X-Trace-Id' \ 264 go run ./cmd/gotosocial/... --config-path internal/config/testdata/test.yaml debug config) 265 266 OUTPUT_OUT=$(mktemp) 267 echo "$OUTPUT" > "$OUTPUT_OUT" 268 269 EXPECT_OUT=$(mktemp) 270 echo "$EXPECT" > "$EXPECT_OUT" 271 272 DIFFCMD=$(command -v diff 2>&1) 273 if command -v jd >/dev/null 2>&1; then 274 DIFFCMD=$(command -v jd 2>&1) 275 fi 276 277 if ! DIFF=$("$DIFFCMD" "$OUTPUT_OUT" "$EXPECT_OUT"); then 278 echo "OUTPUT not equal EXPECTED" 279 echo "$DIFF" 280 exit 1 281 else 282 echo "OK" 283 exit 0 284 fi