-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplace.rb
93 lines (84 loc) · 4.04 KB
/
replace.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env ruby
# Define the hash for replacements
replacements = {
"S3_MINIO_HOST" => "BROWSERUP_S3_MINIO_HOST",
"S3_MINIO_HOST_PORT_1" => "BROWSERUP_S3_MINIO_HOST_PORT_1",
"S3_MINIO_PORT_1" => "BROWSERUP_S3_MINIO_PORT_1",
"S3_MINIO_PORT_2" => "BROWSERUP_S3_MINIO_PORT_2",
"S3_MINIO_ARTIFACTS_BUCKET" => "BROWSERUP_S3_MINIO_ARTIFACTS_BUCKET",
"S3_MINIO_ACCESS_KEY_ID" => "BROWSERUP_S3_MINIO_ACCESS_KEY_ID",
"S3_MINIO_ENDPOINT" => "BROWSERUP_S3_MINIO_ENDPOINT",
"S3_MINIO_SECRET_ACCESS_KEY" => "BROWSERUP_S3_MINIO_SECRET_ACCESS_KEY",
"RABBITMQ_HOST" => "BROWSERUP_RABBITMQ_HOST",
"RABBITMQ_PEER_DISCOVERY_PORT" => "BROWSERUP_RABBITMQ_PEER_DISCOVERY_PORT",
"RABBITMQ_QUEUE_PORT" => "BROWSERUP_RABBITMQ_QUEUE_PORT",
"RABBITMQ_MANAGEMENT_PORT" => "BROWSERUP_RABBITMQ_MANAGEMENT_PORT",
"RABBITMQ_DEFAULT_PASS" => "BROWSERUP_RABBITMQ_DEFAULT_PASS",
"ZOOKEEPER_HOST" => "BROWSERUP_ZOOKEEPER_HOST",
"ZOOKEEPER_CLIENT_PORT" => "BROWSERUP_ZOOKEEPER_CLIENT_PORT",
"ZOO_MAX_CLIENT_CNXNS" => "BROWSERUP_ZOO_MAX_CLIENT_CNXNS",
"REDIS_HOST" => "BROWSERUP_REDIS_HOST",
"REDIS_PORT" => "BROWSERUP_REDIS_PORT",
"MYSQL_HOST" => "BROWSERUP_MYSQL_HOST",
"MYSQL_PORT" => "BROWSERUP_MYSQL_PORT",
"MYSQL_PASSWORD" => "BROWSERUP_MYSQL_PASSWORD",
"MYSQL_USERNAME" => "BROWSERUP_MYSQL_USERNAME",
"WEBCONSOLE_HOST" => "BROWSERUP_WEBCONSOLE_HOST",
"WEBCONSOLE_PORT" => "BROWSERUP_WEBCONSOLE_PORT",
"WEBCONSOLE_PROTOCOL" => "BROWSERUP_WEBCONSOLE_PROTOCOL",
"RAILS_MASTER_KEY" => "BROWSERUP_RAILS_MASTER_KEY",
"LOCKBOX_MASTER_KEY" => "BROWSERUP_LOCKBOX_MASTER_KEY",
"GRID_JAVA_API_HOST" => "BROWSERUP_GRID_JAVA_API_HOST",
"GRID_JAVA_API_PORT" => "BROWSERUP_GRID_JAVA_API_PORT",
"CHRONOGRAF_HOST" => "BROWSERUP_CHRONOGRAF_HOST",
"CHRONOGRAF_PORT" => "BROWSERUP_CHRONOGRAF_PORT",
"CLUSTER_PUBLIC_IP" => "BROWSERUP_CLUSTER_PUBLIC_IP",
"IS_CLOUD" => "BROWSERUP_IS_CLOUD",
"INFLUX_DB_HOST" => "BROWSERUP_INFLUX_DB_HOST",
"INFLUX_DB_PORT" => "BROWSERUP_INFLUX_DB_PORT",
"INFLUX_DB_NAME" => "BROWSERUP_INFLUX_DB_NAME",
"INFLUX_DB_USER" => "BROWSERUP_INFLUX_DB_USER",
"INFLUX_TEST_DB_HOST" => "BROWSERUP_INFLUX_TEST_DB_HOST",
"INFLUX_TEST_DB_PORT" => "BROWSERUP_INFLUX_TEST_DB_PORT",
"INFLUX_DB_PASSWORD" => "BROWSERUP_INFLUX_DB_PASSWORD",
"GRAFANA_PORT" => "BROWSERUP_GRAFANA_PORT",
"GRAFANA_USERNAME" => "BROWSERUP_GRAFANA_USERNAME",
"GRAFANA_PASSWORD" => "BROWSERUP_GRAFANA_PASSWORD",
"PRIVATE_DNS_NAMESPACE_NAME" => "BROWSERUP_PRIVATE_DNS_NAMESPACE_NAME",
"STANDARD_IMAGE_VERSION_TAG_OVERRIDE" => "BROWSERUP_STANDARD_IMAGE_VERSION_TAG_OVERRIDE",
"RABBITMQ_DEFAULT_USER" => "BROWSERUP_RABBITMQ_DEFAULT_USER",
"MINION_VUS" => "BROWSERUP_MINION_VUS",
"MINION_LOG_MAX_SIZE" => "BROWSERUP_MINION_LOG_MAX_SIZE",
"MINION_LOG_MAX_NUMBER" => "BROWSERUP_MINION_LOG_MAX_NUMBER",
"USE_LOCAL_DOCKER_CACHED_IMAGE" => "BROWSERUP_USE_LOCAL_DOCKER_CACHED_IMAGE",
"USER_ARTIFACT_CACHE_PATH" => "BROWSERUP_USER_ARTIFACT_CACHE_PATH"
}
def walk(dir, &block)
$script_path ||= File.expand_path(__FILE__)
# Walk over all files and directories under the current directory
Dir.glob('**/*') do |name|
file_path = File.expand_path(name)
puts file_path
if file_path.match(/(node|assets|jvm|binary|build|cache)/) || file_path.match(/.(kotlin_module|kapt_metadata|gif|jpg|ico|br|iml|jpeg|gz|png|ttf|tab|bin|jar|dll|exe|class|values|at)$/)
puts "SKIPPING #{file_path}"
next
end
next if File.directory?(name) || file_path == $script_path
# Read the file content
yield name
# Write the new content back to the file
File.write(name, content)
end
end
walk('.') do |name|
content = File.read(name)
# Perform the replacements
replacements.each do |from, to|
# Only replace 'from' if it is not already prefixed with 'BROWSERUP_'
# srxp = "(?<!BROWSERUP_)#{from}"
srxp = "(?<!BROWSERUP_|-\s)#{from}(?!:)"
puts "using regexp #{srxp}"
content.gsub!(Regexp.new(srxp), to)
end
end
port_values = ["6790", "6791", "6769", "6772", "6767", "6781", "6892", "3306", "6730", "8080", "6788", "6786", "6786", "9000", "6799"]