Skip to content

Commit 18eb63d

Browse files
committed
Add job to update faf featured mod files with the existing files to launch games
Fix faf_data_dir being None
1 parent 9ff350e commit 18eb63d

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Tiltfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ config.define_string("windows-bash-path", args=False, usage="Path to bash.exe fo
44
config.define_string("default-pull-policy", args=False, usage="Pull policy to use for containers")
55
config.define_string("host-ip", args=False, usage="IP Address of the host to enable redirection to local services")
66
config.define_string("hostname", args=False, usage="Accessible name of the host to enable redirection to local services")
7+
config.define_string("faf-data-dir", args=False, usage="Directory where the FAF Data lives normally C:/ProgramData/FAForever on Windows")
78
config.define_string_list("local-services", args=False, usage="Names of services that you intend to run locally")
89
cfg = config.parse()
910
windows_bash_path = cfg.get("windows-bash-path", "C:\\Program Files\\Git\\bin\\bash.exe")
@@ -12,6 +13,7 @@ local_services = cfg.get("local-services", [])
1213

1314
data_relative_path = ".local-data"
1415
if os.name == "nt":
16+
faf_data_dir = cfg.get("faf-data-dir", "C:/ProgramData/FAForever")
1517
if not os.path.exists(windows_bash_path):
1618
fail("Windows users need to supply a valid path to a bash executable")
1719

@@ -28,6 +30,7 @@ if os.name == "nt":
2830
fail("Cannot determine how to mount for windows host")
2931

3032
else:
33+
faf_data_dir = cfg.get("faf-data-dir", "")
3134
hostname = cfg.get("hostname", "")
3235
data_absolute_path = os.path.join(os.getcwd(), data_relative_path)
3336
use_named_volumes = []
@@ -180,6 +183,8 @@ def proxy_local_service_if_set(service_name, service_chart, service_namespace, a
180183
service_config_yaml, service_yaml = filter_yaml(service_yaml, kind="ConfigMap|Secret")
181184
service_config_yaml = patch_config(yaml=service_config_yaml, config_name=service_name, config=config_patch)
182185
if (service_config_yaml):
186+
if service_name == "faf-lobby-server":
187+
service_config_yaml = no_policy_server(service_config_yaml)
183188
k8s_yaml(service_config_yaml)
184189
config_objects = []
185190
for object in decode_yaml_stream(service_config_yaml):
@@ -205,8 +210,6 @@ def proxy_local_service_if_set(service_name, service_chart, service_namespace, a
205210
service_objects.append(object["metadata"]["name"] + ":" + object["kind"].lower())
206211
k8s_resource(new_name=service_name, objects=service_objects, resource_deps=all_service_deps, labels=user_service_labels, links=user_service_links, pod_readiness="ignore")
207212
else:
208-
if service_name == "faf-lobby-server":
209-
service_yaml = no_policy_server(service_yaml)
210213
if service_name == "faf-icebreaker":
211214
service_yaml = remove_init_container(service_yaml)
212215

@@ -223,6 +226,7 @@ def extract_ingress_details(yaml):
223226
return ["port=" + str(service["port"]), "name=" + service["name"]]
224227

225228
agnostic_local_resource("create-hosts-file-content", cmd=["./tilt/scripts/print-hosts.sh"], labels=["core"], auto_init=False, trigger_mode=TRIGGER_MODE_MANUAL, allow_parallel=True)
229+
agnostic_local_resource("populate-featured-mod-files", cmd=["./tilt/scripts/update-faf-featured-mod.sh", faf_data_dir], labels=["database"], resource_deps=["faf-db-migrations"], auto_init=False, trigger_mode=TRIGGER_MODE_MANUAL, allow_parallel=True)
226230

227231
k8s_yaml("cluster/namespaces.yaml")
228232
k8s_yaml(helm_with_build_cache("infra/clusterroles", namespace="faf-infra", values=["config/local.yaml"]))
@@ -351,12 +355,12 @@ k8s_resource(new_name="faf-policy-server-config", objects=["faf-policy-server:co
351355
user_service_deps = ["faf-db-migrations", "ory-hydra"]
352356
user_service_labels = ["user"]
353357
user_service_links = [link("http://user.localhost/register", "User Service Registration")]
354-
proxy_local_service_if_set(service_name="faf-user-service", service_chart="apps/faf-user-service", service_namespace="faf-apps", service_deps=user_service_deps, service_labels=user_service_labels, service_links=user_service_links, config_patch={"HYDRA_TOKEN_ISSUER": "http://ory-hydra:4444", "HYDRA_JWKS_URL": "http://ory-hydra:4444/.well-known/jwks.json", "LOBBY_URL":"ws://localhost:8003", "REPLAY_URL":"ws://localhost:15001"})
358+
proxy_local_service_if_set(service_name="faf-user-service", service_chart="apps/faf-user-service", service_namespace="faf-apps", service_deps=user_service_deps, service_labels=user_service_labels, service_links=user_service_links, config_patch={"HYDRA_TOKEN_ISSUER": "http://ory-hydra:4444", "HYDRA_JWKS_URL": "http://ory-hydra:4444/.well-known/jwks.json", "LOBBY_URL":"ws://ws.localhost", "REPLAY_URL":"ws://replay-ws.localhost"})
355359

356360
website_deps = ["wordpress"]
357361
website_labels = ["website"]
358362
website_links = [link("http://www.localhost", "FAForever Website")]
359-
proxy_local_service_if_set(service_name="faf-website", service_chart="apps/faf-website", service_namespace="faf-apps", service_deps=website_deps, service_labels=website_labels, service_links=website_links, additional_values=["apps/faf-website/values-prod.yaml"], config_patch={"OAUTH_URL": "http://ory-hydra:4444", "OAUTH_PUBLIC_URL": "http://hydra.localhost:4444", "API_URL": "http://faf-api:8010", "WP_URL": "http://wordpress:80"})
363+
proxy_local_service_if_set(service_name="faf-website", service_chart="apps/faf-website", service_namespace="faf-apps", service_deps=website_deps, service_labels=website_labels, service_links=website_links, additional_values=["apps/faf-website/values-prod.yaml"], config_patch={"OAUTH_URL": "http://ory-hydra:4444", "OAUTH_PUBLIC_URL": "http://hydra.localhost", "API_URL": "http://faf-api:8010", "WP_URL": "http://wordpress:80"})
360364

361365
api_deps=["faf-db-migrations", "ory-hydra"] + rabbitmq_setup_resources
362366
api_labels=["api"]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
faf_data_dir=$1
4+
init_file="$faf_data_dir/bin/init_faf.lua"
5+
init_file_md5sum=($(md5sum $init_file))
6+
7+
mariadb_exec() {
8+
kubectl exec --namespace=faf-infra statefulset/mariadb -- mariadb --host=mariadb --user=root --password="banana" faf_lobby "$@"
9+
}
10+
11+
mariadb_exec -e "TRUNCATE updates_faf_files;"
12+
mariadb_exec -e "TRUNCATE updates_faf;"
13+
mariadb_exec -e "INSERT INTO updates_faf (id, filename, path) values (1, \"init_faf.lua\", \"bin\");"
14+
mariadb_exec -e "INSERT INTO updates_faf_files (fileId, version, name, md5) values (1, 1, \"init_faf_1.lua\", \"$init_file_md5sum\");"

0 commit comments

Comments
 (0)