-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Added dockerization for the Trino Gateway
- Loading branch information
Showing
6 changed files
with
87 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
function get_2nd_level_yaml_key() { | ||
local parent_key=$1 | ||
local target_key=$2 | ||
local yaml_file_path=$3 | ||
|
||
# In order to get the nested key we will leverage awk to do some parsing | ||
awk -v parent_key=${parent_key} \ | ||
-v target_key=${target_key} \ | ||
' | ||
function count_indentation(line) { | ||
match(line, /^[[:space:]]*/); | ||
return RLENGTH; | ||
} | ||
# First we search for the parent_key, once we find it we set in_block to true | ||
match($0, "^" parent_key ":") { | ||
in_block=1; | ||
parent_indent_level = count_indentation($0); | ||
next; | ||
} \ | ||
in_block { | ||
# All lines we deem to be a comment will be skipped. | ||
if (match($0, "^[[:space:]]*#")) { next; } | ||
# If we determine that we have left the parent_key block we will exit. | ||
if ($0 ~ /^[^\t #]/) { exit; } | ||
current_indent_level = count_indentation($0); | ||
# Next, because we dont know the indentation levels being provided, we will attempt | ||
# to find the indentation level of the 2nd level keys. | ||
if ( !first_level_indentation \ | ||
&& match($0, "^[[:space:]]+.*:") \ | ||
&& current_indent_level > parent_indent_level) { | ||
first_level_indentation = current_indent_level; | ||
} | ||
# Then we will attempt to find the 2nd level target key based on: | ||
# 1. Theres only spaces before the target_key | ||
# 2. The indentation level is equal to the found 2nd level indentation | ||
if (match($0, "^[[:space:]]+" target_key ":") \ | ||
&& current_indent_level == first_level_indentation) { | ||
# If we decide that the key matches our expectations, we will print the matched value | ||
sub(/:/, "", $2); | ||
print $2; | ||
} | ||
} | ||
' \ | ||
${yaml_file_path} | ||
} | ||
|
||
config=/opt/trino/gateway-ha-config.yml | ||
scheme=http | ||
port=8080 | ||
|
||
# prefer to use http even if https is enabled | ||
if [ "$(get_2nd_level_yaml_key 'requestRouter' 'ssl' "$config")" == "true" ]; then | ||
scheme=https | ||
fi | ||
|
||
potential_port=$(get_2nd_level_yaml_key 'requestRouter' 'port' "$config") | ||
if [ "${potential_port}" != "" ]; then | ||
port=${potential_port} | ||
fi | ||
|
||
endpoint="${scheme}://localhost:${port}/api/public/backends" | ||
|
||
# add --insecure to disable certificate verification in curl, in case a self-signed certificate is being used | ||
if ! info=$(curl --fail --silent --show-error --insecure "$endpoint"); then | ||
echo >&2 "Server is not responding to requests" | ||
exit 1 | ||
fi |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters