Hi guys,
I’m trying to use this API method:
curl --location 'https://api.qovery.com/application/:applicationId/environmentVariable' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Token TOKEN' \
--data '{
"key": "NGINX_CONFIG_FILE",
"value": "...",
"mount_path": "/etc/nginx/nginx.conf"
}'
to create an environment variable as file, but I’m struggling to load the file contents to the “value” property in the JSON body of the request.
I saw in the Qovery web console that the file contents get transformed to something like this:
"value": "user nginx;\nworker_processes auto;\n#pid /run/nginx.pid;\n\nevents {\n\t#worker_connections 4096;\n\tmulti_accept on;\n}\n\nhttp {\n\n\t##\n\t# Basic Settings\n\t##\n\n\tsendfile on;\n\ttcp_nopush on;\n\ttcp_nodelay on;\n\tkeepalive_timeout 90;\n\ttypes_hash_max_size 2048;\n\tserver_tokens off;\n\n client_max_body_size 5120M;\n\t# server_names_hash_bucket_size 64;\n\t# server_name_in_redirect off;\n\n\tinclude /etc/nginx/mime.types;\n\tdefault_type application/octet-stream;\n\n\t##\n\t# SSL Settings\n\t##\n\n\tssl_protocols TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE\n\tssl_prefer_server_ciphers on;\n\n\t##\n\t# Logging Settings\n\t##\n\n\tlog_format main '$remote_addr - $remote_user [$time_local] $status '\n '\"$request\" $body_bytes_sent \"$http_referer\" '\n '\"$http_user_agent\" \"$http_x_forwarded_for\" '\n\t '$connection_requests - $connection_time - $request_time';\n\n\taccess_log /var/log/nginx/access.log main;\n\terror_log /var/log/nginx/error.log;\n\n\t##\n\t# Gzip Settings\n\t##\n\n\tgzip on;\n\n\tgzip_vary on;\n\tgzip_proxied any;\n\tgzip_comp_level 6;\n\tgzip_buffers 16 8k;\n\tgzip_http_version 1.1;\n\tgzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;\n\n\t##\n\t# Virtual Host Configs\n\t##\n\tupstream app {\n\t\tserver localhost:8080;\n\t}\n\n\tupstream grpc {\n\t\tserver localhost:8081;\n\t}\n\n server {\n listen 80;\n\n server_name getduna.com;\n\n include /etc/nginx/common/cloudfront.conf ;\n\n location = /favicon.ico {\n return 204;\n access_log off;\n log_not_found off;\n }\n\n # grpc\n location /grpc/ {\n proxy_redirect off;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $http_x_forwarded_for;\n proxy_set_header X-Forwarded-Host $server_name;\n proxy_pass http://grpc/;\n }\n\n # go api\n location / {\n proxy_redirect off;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $http_x_forwarded_for;\n proxy_set_header X-Forwarded-Host $server_name;\n proxy_pass http://app;\n }\n }\n}"
I tried reading the file using cat
and transforming the output with awk
and sed
but sadly is not working.
Any advice on how to accomplish this would be really appreciated, preferable using bash.
Thanks for your help